/* ==========================================================================
   PuTTY Web Pro - Modern Design System & Stylesheet
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-main: #0a0d12;
  --bg-surface: #121820;
  --bg-surface-elevated: #1a222d;
  --bg-card: #151d27;
  --border-subtle: #243040;
  --border-focus: #3b82f6;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #10b981;       /* PuTTY Emerald */
  --accent-primary-hover: #059669;
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-amber: #f59e0b;
  --accent-danger: #ef4444;
  --accent-purple: #8b5cf6;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Layout Dimensions */
  --header-height: 52px;
  --tabs-height: 38px;
  --statusbar-height: 28px;
  --drawer-width: 440px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -1px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 15px rgba(16, 185, 129, 0.25);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Global Utilities */
.hidden {
  display: none !important;
}

/* Layout Container */
.app-layout {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Header & Quick Connect Bar
   ========================================================================== */

.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 16px;
  z-index: 20;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.brand-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Quick Connect Form */
.quick-connect-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-main);
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  flex: 1;
  max-width: 740px;
}

.input-group {
  display: flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  padding: 0 8px;
  height: 30px;
  transition: border-color var(--transition-fast);
}

.input-group:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.input-icon {
  font-size: 12px;
  margin-right: 4px;
  opacity: 0.8;
}

.qc-select, .qc-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 12px;
  color: var(--text-primary);
  width: 100%;
}

.qc-select {
  cursor: pointer;
  padding-right: 4px;
}

.qc-select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.host-group {
  flex: 3;
}

.port-group {
  flex: 1;
  max-width: 70px;
}

.user-group {
  flex: 1.5;
  max-width: 110px;
}

.qc-btn {
  height: 30px;
  padding: 0 14px;
  white-space: nowrap;
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Button Component System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  outline: none;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: #047857;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.45);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: #222d3b;
  border-color: #3b4d63;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  background: var(--accent-danger);
  color: #ffffff;
}

.btn-success {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
}

.btn-success:hover {
  background: var(--accent-primary);
  color: #ffffff;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-icon-only:hover {
  background: #243040;
  border-color: #3b4d63;
}

/* Dropdown Menu */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 210px;
  padding: 6px;
  display: none;
  z-index: 100;
}

.dropdown.active .dropdown-menu {
  display: block;
}

.dropdown-header {
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: #2b394a;
}

.theme-preview {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

/* ==========================================================================
   Tabs Strip
   ========================================================================== */

.tabs-strip {
  height: var(--tabs-height);
  background: #0d1117;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
  overflow-x: auto;
  user-select: none;
  scrollbar-width: thin;
}

.tabs-list {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.tab-item {
  height: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  white-space: nowrap;
  max-width: 200px;
}

.tab-item:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.tab-item.active {
  background: var(--bg-card);
  color: #ffffff;
  border-color: #3b4d63;
  border-bottom: 2px solid var(--accent-primary);
  font-weight: 600;
}

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}

.tab-dot.connected {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.tab-dot.connecting {
  background: #f59e0b;
  animation: pulse 1.2s infinite;
}

.tab-dot.disconnected {
  background: #ef4444;
}

.tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-close {
  font-size: 13px;
  padding: 0 3px;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
}

.tab-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.btn-add-tab {
  height: 24px;
  padding: 0 8px;
  background: transparent;
  border: 1px dashed var(--border-subtle);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  transition: all var(--transition-fast);
}

.btn-add-tab:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.08);
}

/* ==========================================================================
   Terminal Workspace & In-terminal Overlays
   ========================================================================== */

.terminal-workspace {
  flex: 1;
  position: relative;
  background: #000000;
  overflow: hidden;
}

.terminals-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.terminal-tab-view {
  width: 100%;
  height: 100%;
  padding: 6px;
  display: none;
  background: transparent;
}

.terminal-tab-view.active {
  display: block;
}

/* Empty State / No Sessions Placeholder */
.no-sessions-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 50%, #111827 0%, #030712 100%);
  color: var(--text-primary);
  text-align: center;
  padding: 24px;
}

.placeholder-card {
  max-width: 480px;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 36px 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.placeholder-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.2);
}

.placeholder-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.placeholder-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.placeholder-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.xterm {
  height: 100%;
  padding: 4px;
}

/* Floating Terminal Search Bar */
.search-floating-bar {
  position: absolute;
  top: 12px;
  right: 24px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 50;
  animation: slideDown 150ms ease-out;
}

.search-floating-bar input {
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  color: #ffffff;
  outline: none;
  width: 180px;
}

.search-floating-bar input:focus {
  border-color: var(--accent-blue);
}

.btn-search-nav {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.btn-search-nav:hover {
  background: #2a3749;
}

.search-option-label {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

.btn-search-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
}

.btn-search-close:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   SFTP File Drawer
   ========================================================================== */

.sftp-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--drawer-width);
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform var(--transition-normal);
}

.sftp-drawer.hidden {
  display: none;
}

.sftp-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sftp-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
}

.drawer-close-btn:hover {
  color: #ffffff;
}

.sftp-nav-bar {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

.sftp-path-box {
  flex: 1;
}

.sftp-path-box input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #38bdf8;
  outline: none;
}

.sftp-actions-bar {
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

.sftp-table-container {
  flex: 1;
  overflow-y: auto;
}

.sftp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.sftp-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-main);
  color: var(--text-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border-subtle);
}

.sftp-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(36, 48, 64, 0.4);
}

.sftp-table tr:hover td {
  background: var(--bg-card);
}

.sftp-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.sftp-item-name.is-dir {
  color: #38bdf8;
  font-weight: 600;
}

.sftp-item-name:hover {
  text-decoration: underline;
}

.sftp-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

/* ==========================================================================
   Command Snippets Drawer
   ========================================================================== */

.snippets-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 380px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.snippets-drawer.hidden {
  display: none;
}

.snippets-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.snippets-title {
  font-weight: 600;
  font-size: 14px;
}

.snippets-search-box {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.snippets-search-box input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 6px 10px;
  color: #ffffff;
  outline: none;
}

.snippets-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.snippet-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px;
  transition: all var(--transition-fast);
}

.snippet-card:hover {
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-sm);
}

.snippet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.snippet-name {
  font-weight: 600;
  color: #ffffff;
}

.snippet-category {
  font-size: 10px;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  padding: 1px 6px;
  border-radius: 3px;
}

.snippet-cmd {
  background: #06090e;
  padding: 6px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #a7f3d0;
  word-break: break-all;
  margin-bottom: 8px;
}

.snippet-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* ==========================================================================
   CmdPad Multi-Tab Command Editor & Session Runner
   ========================================================================== */

.btn-cmdpad-glow {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.25)) !important;
  border-color: rgba(16, 185, 129, 0.4) !important;
  color: #34d399 !important;
  font-weight: 600;
}

.btn-cmdpad-glow:hover, .btn-cmdpad-glow.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(5, 150, 105, 0.45)) !important;
  border-color: #10b981 !important;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

.terminal-workspace.cmdpad-docked-open .terminals-wrapper {
  margin-right: var(--cmdpad-current-width, 480px);
  transition: margin-right 0.12s ease-out;
}

.cmdpad-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 480px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 45;
  user-select: text;
}

.cmdpad-drawer.cmdpad-floating {
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.65);
}

.cmdpad-drawer.cmdpad-docked {
  box-shadow: -3px 0 12px rgba(0, 0, 0, 0.3);
}

.cmdpad-drawer.hidden {
  display: none !important;
}

body.cmdpad-resizing {
  cursor: ew-resize !important;
  user-select: none !important;
}

.cmdpad-resizer {
  position: absolute;
  top: 0;
  left: -4px;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  z-index: 50;
  transition: background 0.15s;
}

.cmdpad-resizer:hover, body.cmdpad-resizing .cmdpad-resizer {
  background: rgba(16, 185, 129, 0.5);
}

/* Header */
.cmdpad-header {
  padding: 8px 12px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cmdpad-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cmdpad-badge-icon {
  width: 24px;
  height: 24px;
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cmdpad-title {
  font-weight: 700;
  font-size: 13px;
  color: #ffffff;
  letter-spacing: 0.3px;
}

.cmdpad-subbadge {
  font-size: 9px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 1px 5px;
  border-radius: 4px;
}

.cmdpad-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmdpad-session-target {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 2px 6px;
}

.session-target-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
  box-shadow: 0 0 5px currentColor;
}

.cmdpad-session-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 11px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  max-width: 140px;
}

.cmdpad-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cmdpad-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.cmdpad-icon-btn.active {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
}

/* Tabs Bar */
.cmdpad-tabs-bar {
  display: flex;
  align-items: center;
  background: #090d12;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 4px;
  height: 32px;
  overflow-x: auto;
  scrollbar-width: none;
}

.cmdpad-tabs-bar::-webkit-scrollbar {
  display: none;
}

.cmdpad-tabs-list {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
}

.cmdpad-tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  background: #151b23;
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all var(--transition-fast);
}

.cmdpad-tab-item:hover {
  background: #1f2937;
  color: #ffffff;
}

.cmdpad-tab-item.active {
  background: var(--bg-surface);
  color: #34d399;
  border-color: var(--border-subtle);
  border-top: 2px solid #10b981;
  font-weight: 600;
}

.cmdpad-tab-icon {
  font-size: 11px;
}

.cmdpad-tab-dirty {
  color: #f59e0b;
  font-size: 8px;
}

.cmdpad-tab-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  border-radius: 3px;
}

.cmdpad-tab-close:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ef4444;
}

.cmdpad-new-tab-btn {
  background: transparent;
  border: 1px dashed var(--border-subtle);
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  margin-left: 4px;
  transition: all var(--transition-fast);
}

.cmdpad-new-tab-btn:hover {
  background: #1f2937;
  color: #ffffff;
  border-color: #10b981;
}

/* Toolbar */
.cmdpad-toolbar {
  padding: 6px 10px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.cmdpad-toolbar-left, .cmdpad-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmdpad-run-btn {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  border-color: #059669 !important;
  color: #ffffff !important;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.cmdpad-run-btn:hover {
  background: linear-gradient(135deg, #059669, #047857) !important;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4);
}

.cmdpad-snippets-dropdown {
  position: relative;
}

/* Editor Body (Gutter + Textarea) */
.cmdpad-editor-wrap {
  flex: 1;
  display: flex;
  background: #090d10;
  overflow: hidden;
  position: relative;
}

.cmdpad-gutter {
  width: 44px;
  background: #0d1217;
  border-right: 1px solid var(--border-subtle);
  overflow-y: hidden;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 20px;
  padding: 6px 0;
  flex-shrink: 0;
}

.cmdpad-gutter-line {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  color: #4b5563;
  transition: background 0.15s, color 0.15s;
}

.cmdpad-gutter-line:hover {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.cmdpad-gutter-num {
  font-size: 11px;
  pointer-events: none;
}

.cmdpad-play-btn {
  position: absolute;
  right: 4px;
  width: 16px;
  height: 16px;
  background: #10b981;
  color: #061e0e;
  border: none;
  border-radius: 3px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s, background 0.1s;
}

.cmdpad-play-btn:hover {
  background: #34d399;
  transform: scale(1.15);
}

.cmdpad-gutter-line:hover .cmdpad-gutter-num {
  display: none;
}

.cmdpad-gutter-line:hover .cmdpad-play-btn {
  display: flex;
}

.cmdpad-gutter-line.line-executed {
  background: rgba(16, 185, 129, 0.35) !important;
  color: #ffffff !important;
}

.cmdpad-gutter-line.line-failed {
  background: rgba(239, 68, 68, 0.35) !important;
  color: #ffffff !important;
}

.cmdpad-textarea-wrap {
  flex: 1;
  position: relative;
  height: 100%;
}

.cmdpad-textarea-wrap textarea {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: #e5e7eb;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 20px;
  padding: 6px 12px;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
}

/* Footer / Status bar */
.cmdpad-footer {
  height: 26px;
  padding: 0 10px;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.cmdpad-footer-left, .cmdpad-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cmdpad-footer-sep {
  opacity: 0.4;
}

.cmdpad-save-tag {
  color: #10b981;
  font-size: 10px;
}

.cmdpad-save-tag.saved-pulse {
  animation: pulse-saved 0.6s ease-in-out;
}

@keyframes pulse-saved {
  0% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; color: #34d399; }
  100% { transform: scale(1); opacity: 1; }
}

.cmdpad-tip {
  font-size: 10px;
  color: #94a3b8;
}

/* Toast notifications */
.cmdpad-toast {
  position: fixed;
  bottom: 35px;
  right: 25px;
  padding: 8px 14px;
  background: #1f2937;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: #ffffff;
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmdpad-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.cmdpad-toast.success {
  border-color: #10b981;
  background: #062b1b;
  color: #6ee7b7;
}

.cmdpad-toast.warning {
  border-color: #f59e0b;
  background: #2e1d05;
  color: #fcd34d;
}

.cmdpad-toast.info {
  border-color: #3b82f6;
  background: #0f1d38;
  color: #93c5fd;
}

/* ==========================================================================
   Bottom Status Bar
   ========================================================================== */

.app-statusbar {
  height: var(--statusbar-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-secondary);
  user-select: none;
  z-index: 20;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-dot.connected {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.7);
}

.status-dot.connecting {
  background: #f59e0b;
  animation: pulse 1.2s infinite;
}

.status-dot.disconnected {
  background: #ef4444;
}

.status-divider {
  width: 1px;
  height: 14px;
  background: var(--border-subtle);
}

.status-item {
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ==========================================================================
   Classic PuTTY Configuration Modal
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 150ms ease-out;
}

.modal-backdrop.hidden {
  display: none !important;
}

.putty-dialog {
  width: 680px;
  max-width: 95vw;
  height: 520px;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dialog-header {
  padding: 10px 16px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-title-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: #ffffff;
}

.dialog-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

.dialog-close-btn:hover {
  color: #ffffff;
}

.dialog-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Classic PuTTY Left Sidebar Tree */
.dialog-sidebar {
  width: 190px;
  background: #0c1017;
  border-right: 1px solid var(--border-subtle);
  padding: 12px 8px;
  overflow-y: auto;
  user-select: none;
}

.sidebar-title {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 6px;
  font-weight: 600;
}

.category-tree {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.category-item, .category-sub-item {
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.category-sub-item {
  padding-left: 20px;
  font-size: 11px;
}

.category-item:hover, .category-sub-item:hover {
  background: #182230;
  color: #ffffff;
}

.category-item.active, .category-sub-item.active {
  background: #1e293b;
  color: var(--accent-primary);
  font-weight: 600;
}

.tree-bullet {
  font-size: 10px;
  color: var(--text-muted);
}

/* Right Dynamic Configuration Content */
.dialog-content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  background: var(--bg-surface);
}

.category-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.category-panel.active {
  display: flex;
}

.panel-section {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  background: var(--bg-card);
  position: relative;
}

.section-title {
  position: absolute;
  top: -9px;
  left: 12px;
  background: var(--bg-card);
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }

label {
  font-size: 11px;
  color: var(--text-secondary);
}

.form-input, .form-textarea {
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition-fast);
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.form-textarea {
  font-family: var(--font-mono);
  font-size: 11px;
  resize: vertical;
}

.radio-group {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.radio-group.vertical {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.radio-label, .checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Saved Sessions Listbox */
.saved-sessions-wrapper {
  align-items: stretch;
}

.sessions-listbox {
  flex: 1;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 6px;
  color: #ffffff;
  outline: none;
}

.sessions-listbox option {
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.sessions-listbox option:hover {
  background: #1e293b;
}

.sessions-listbox option:checked {
  background: #0284c7;
  color: #ffffff;
}

.session-btn-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 80px;
}

/* Dialog Footer */
.dialog-footer {
  padding: 10px 16px;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* File Preview Modal */
.preview-dialog {
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-body {
  flex: 1;
  padding: 16px;
  overflow: auto;
  background: #000000;
}

.preview-body pre {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #38bdf8;
  white-space: pre-wrap;
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 200px;
  z-index: 2000;
}

.context-menu.hidden {
  display: none;
}

.context-item {
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--transition-fast);
}

.context-item:hover {
  background: #253346;
}

.ctx-shortcut {
  font-size: 10px;
  color: var(--text-muted);
}

.context-separator {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* Theme Swatches */
.theme-palette-preview {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.theme-swatch {
  flex: 1;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Retro CRT Phosphor Monitor Overlay
   ========================================================================== */

.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.25) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.03),
    rgba(0, 255, 0, 0.01),
    rgba(0, 0, 255, 0.03)
  );
  background-size: 100% 3px, 6px 100%;
  opacity: 0.85;
}

.crt-overlay.hidden {
  display: none;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .qc-input { width: 100%; }
  .user-group { display: none; }
  .sftp-drawer { width: 100%; }
}

/* ==========================================================================
   PuTTY Web 2FA / OTP Security System
   ========================================================================== */

/* Security Gate Dialog */
.otp-dialog {
  width: 440px;
  max-width: 92vw;
  background: #111722;
  border: 1px solid #1e293b;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.75), 0 0 20px rgba(16, 185, 129, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.otp-header {
  padding: 24px 24px 16px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.15) 0%, transparent 70%);
}

.otp-shield-glow {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}

.otp-dialog-title {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.otp-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.otp-body {
  padding: 20px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.otp-alert {
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 12px;
  animation: shake 250ms ease-in-out;
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  padding-right: 36px;
}

.btn-toggle-pwd {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
}

.btn-toggle-pwd:hover {
  opacity: 1;
}

.otp-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.otp-timer {
  font-size: 11px;
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-weight: 600;
}

.otp-code-input {
  font-family: var(--font-mono) !important;
  font-size: 22px !important;
  letter-spacing: 8px;
  text-align: center;
  height: 48px;
  font-weight: 700;
  color: #38bdf8 !important;
  background: #080d14 !important;
  border-color: #243040 !important;
}

.otp-code-input:focus {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25) !important;
}

.otp-timer-progress {
  width: 100%;
  height: 3px;
  background: #1e293b;
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.otp-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981 0%, #38bdf8 100%);
  transition: width 1s linear;
}

/* Demo Helper Card */
.otp-demo-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px dashed rgba(56, 189, 248, 0.3);
  border-radius: 6px;
  margin-top: -4px;
}

.demo-card-content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.demo-badge {
  font-family: var(--font-mono);
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  letter-spacing: 1px;
}

.btn-block {
  width: 100%;
  height: 38px;
  font-size: 13px;
  font-weight: 600;
}

/* Gate QR Preview */
.gate-qr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #080d14;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  animation: fadeIn 200ms ease-out;
}

.gate-qr-box {
  background: #ffffff;
  padding: 6px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.gate-qr-image {
  width: 150px;
  height: 150px;
  display: block;
}

.gate-qr-info {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  text-align: left;
  width: 100%;
}

.gate-qr-info strong {
  color: #38bdf8;
}

/* OTP Setup Dialog */
#otp-setup-modal {
  z-index: 1200;
}

.otp-setup-dialog {
  width: 780px;
  height: 600px;
}

.otp-setup-body {
  padding: 20px;
  overflow-y: auto;
}

.otp-setup-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}

.otp-setup-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-right: 18px;
  border-right: 1px solid var(--border-subtle);
}

.qr-container {
  padding: 8px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  margin: 14px 0;
}

.qr-code-img {
  width: 180px;
  height: 180px;
  display: block;
}

.secret-box {
  width: 100%;
  text-align: left;
}

.secret-copy-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.secret-text {
  flex: 1;
  background: var(--bg-main);
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  color: #38bdf8;
  word-break: break-all;
}

.otp-setup-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.backup-codes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.backup-code-item {
  background: var(--bg-main);
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #a7f3d0;
  text-align: center;
  letter-spacing: 1px;
}

.backup-actions {
  display: flex;
  gap: 8px;
}

.security-toggle-section, .password-change-section {
  padding: 12px;
}

.mt-8 {
  margin-top: 8px;
}

.btn-otp-status {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
}

.btn-otp-status:hover {
  background: rgba(16, 185, 129, 0.2);
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}
