/* ExecFlow App Styles — Modern dark blue aesthetic */

:root {
  --bg-dark: #0d1117;
  --bg-card: #161b22;
  --bg-elevated: #21262d;
  --accent: #2563eb;
  --accent-dim: #1d4ed8;
  --accent-light: #3b82f6;
  --accent-glow: rgba(37, 99, 235, 0.15);
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-dim: #484f58;
  --border: #30363d;
  --danger: #f85149;
  --danger-dim: #da3633;
  --success: #3fb950;
  --warning: #d29922;
  --terminal-blue: #3b82f6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.6;
  min-height: 100vh;
}

.mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.mono-sm { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 13px; color: var(--text-secondary); }

/* ── App Shell ──────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-dark);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 40px;
}

.nav-logo {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  letter-spacing: -0.5px;
}

.logo-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 12px var(--accent); }
  50% { opacity: 0.6; box-shadow: 0 0 4px var(--accent); }
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-link.active {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-user {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-main {
  flex: 1;
  padding: 40px 32px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ── Auth Pages ─────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(0,255,136,0.04) 0%, transparent 60%),
    var(--bg-dark);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.auth-logo {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  letter-spacing: -0.5px;
}

.auth-card h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.auth-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.auth-footer {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 24px;
}

/* ── Forms ──────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.input-field {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  transition: border-color 0.15s;
  outline: none;
}

.form-group input:focus,
.input-field:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder,
.input-field::placeholder {
  color: var(--text-dim);
}

.select-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

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

.form-error {
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 16px;
  min-height: 20px;
}

.form-msg {
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

.form-success {
  color: var(--success);
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.form-row .input-field {
  flex: 1;
}

.form-row .select-field {
  width: 140px;
  flex: none;
}

.invite-form {
  margin-top: 16px;
}

/* ── Buttons ────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--accent);
  color: #0a0a0f;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover {
  background: var(--accent-dim);
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.2);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  width: auto;
  padding: 10px 20px;
  white-space: nowrap;
}

.btn-ghost {
  padding: 8px 14px;
  font-size: 13px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-dim);
  background: var(--bg-elevated);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
}

.text-danger { color: var(--danger) !important; border-color: rgba(255, 77, 77, 0.3) !important; }
.text-danger:hover { background: rgba(255, 77, 77, 0.08) !important; }
.text-success { color: var(--success) !important; }
.success-text { color: var(--success); }

/* ── Page Header ────────────────────────────────── */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-sub {
  font-size: 15px;
  color: var(--text-secondary);
}

/* ── Stats Grid ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: border-color 0.15s;
}

.stat-card:hover {
  border-color: var(--text-dim);
}

.stat-icon {
  font-size: 20px;
  margin-bottom: 12px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}

.card h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* ── Tables ─────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid rgba(34, 34, 51, 0.5);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(26, 26, 36, 0.5);
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-weight: 500;
}

.user-email {
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.action-btns {
  display: flex;
  gap: 8px;
}

/* ── Badges ─────────────────────────────────────── */
.role-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
}

.role-admin {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.role-operator {
  color: var(--text-secondary);
  background: rgba(136, 136, 160, 0.1);
  border: 1px solid rgba(136, 136, 160, 0.2);
}

.status-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
}

.status-active {
  color: var(--success);
  background: rgba(37, 99, 235, 0.08);
}

.status-inactive {
  color: var(--danger);
  background: rgba(255, 77, 77, 0.08);
}

/* ── Terminal ───────────────────────────────────── */
.terminal-preview {
  margin-top: 8px;
}

.terminal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.terminal-dot:nth-child(1) { background: #ff5f57; }
.terminal-dot:nth-child(2) { background: #ffbd2e; }
.terminal-dot:nth-child(3) { background: #28ca42; }

.terminal-title {
  flex: 1;
  text-align: center;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.terminal-body {
  padding: 24px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 14px;
  line-height: 2;
}

.terminal-line { margin-bottom: 4px; }
.prompt { color: var(--accent); }
.cmd { color: var(--text-primary); }

.cursor-blink {
  color: var(--accent);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Loading ────────────────────────────────────── */
.loading {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  padding: 60px 0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Clickable Card ────────────────────────────── */
.stat-card.clickable {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.stat-card.clickable:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

/* ── Empty State ───────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}
.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 360px;
  margin: 0 auto;
}

/* ── Server Cards Grid ─────────────────────────── */
.servers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.server-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.server-card:hover {
  border-color: var(--text-dim);
}
.server-card.testing {
  border-color: var(--accent-dim);
  animation: card-pulse 1.5s ease-in-out infinite;
}
@keyframes card-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(37, 99, 235, 0); }
  50% { box-shadow: 0 0 20px rgba(37, 99, 235, 0.15); }
}

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

.server-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}

.server-card-actions {
  display: flex;
  gap: 4px;
}

.server-card-body {
  padding: 16px 20px;
}

.server-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.server-detail:not(:last-child) {
  border-bottom: 1px solid rgba(34, 34, 51, 0.3);
}
.server-detail-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.server-detail-value {
  font-size: 13px;
}

.server-name {
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* ── Server Status ─────────────────────────────── */
.server-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

.status-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: capitalize;
}
.status-label.status-online { color: var(--success); }
.status-label.status-unreachable { color: var(--danger); }
.status-label.status-unknown { color: var(--warning); }

/* ── Auth Badges ───────────────────────────────── */
.auth-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.auth-password {
  color: var(--warning);
  background: rgba(255, 189, 46, 0.1);
  border: 1px solid rgba(255, 189, 46, 0.2);
}
.auth-ssh_key {
  color: #7c8aff;
  background: rgba(124, 138, 255, 0.1);
  border: 1px solid rgba(124, 138, 255, 0.2);
}

/* ── Auth Toggle ───────────────────────────────── */
.auth-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-dark);
}
.auth-toggle-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-toggle-btn.active {
  background: var(--accent);
  color: #0a0a0f;
  font-weight: 600;
}
.auth-toggle-btn:not(.active):hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ── Icon Button ───────────────────────────────── */
.btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--border);
}
.btn-icon.text-danger:hover {
  color: var(--danger);
  background: rgba(255, 77, 77, 0.08);
  border-color: rgba(255, 77, 77, 0.2);
}

/* ── Modal ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: modal-fade 0.15s ease;
}
@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
  animation: modal-slide 0.2s ease;
}
@keyframes modal-slide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Textarea ──────────────────────────────────── */
textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 13px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}
textarea:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
textarea::placeholder {
  color: var(--text-dim);
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  .app-nav {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .nav-left { gap: 20px; }
  .nav-right { gap: 8px; }
  .nav-user { display: none; }
  .app-main { padding: 24px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .servers-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 24px; }
  .modal-card { padding: 24px 20px; }
  .form-row { flex-direction: column; }
  .form-row .select-field { width: 100%; }
  .form-row .form-group { flex: auto !important; }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 10px 8px; }
  .action-btns { flex-direction: column; gap: 4px; }
  .page-header { flex-direction: column !important; align-items: flex-start !important; gap: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════
   CONSOLE TERMINAL INTERFACE
   ══════════════════════════════════════════════════════ */

.console-page {
  height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}

.console-terminal {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-height: calc(100vh - 120px);
}

/* Terminal Header */
.console-terminal .terminal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.terminal-dots {
  display: flex;
  gap: 8px;
}

.terminal-server-select {
  margin-left: auto;
}

.server-dropdown {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: var(--bg-dark);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  outline: none;
  max-width: 280px;
}
.server-dropdown:focus {
  border-color: var(--accent-dim);
}
.server-dropdown option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Terminal Body */
.console-terminal .terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.8;
  scroll-behavior: smooth;
}

.terminal-welcome .terminal-line {
  margin-bottom: 2px;
}

.accent-text {
  color: var(--accent);
  font-weight: 500;
}

.output {
  color: var(--text-secondary);
}

/* Console Output Lines */
.output-prompt span { font-weight: 600; }
.output-status span { font-style: italic; }

/* Input Bar */
.console-input-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.input-mode-toggle {
  display: flex;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.mode-btn {
  padding: 16px 14px;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-weight: 500;
  background: transparent;
  color: var(--text-dim);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.mode-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-dark);
}

.mode-btn.active {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.06);
}

.mode-icon {
  font-size: 14px;
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
}

.input-prompt {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

#console-input {
  flex: 1;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 14px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  padding: 16px 0;
}

#console-input::placeholder {
  color: var(--text-dim);
}

#console-input:disabled {
  opacity: 0.5;
}

.send-btn {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.send-btn:hover {
  background: rgba(37, 99, 235, 0.06);
}

.send-btn:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
}

/* ── Plan Card ──────────────────────────────────── */

.plan-card {
  background: var(--bg-dark);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 10px;
  margin-top: 16px;
  overflow: hidden;
}

.plan-card.plan-risky {
  border-color: rgba(255, 189, 46, 0.3);
}

.plan-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.plan-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.plan-icon {
  font-size: 16px;
}

.plan-summary {
  font-size: 12px;
  color: var(--text-secondary);
}

.plan-steps {
  padding: 12px 0;
}

.plan-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 20px;
  transition: background 0.1s;
}

.plan-step:hover {
  background: rgba(255, 255, 255, 0.02);
}

.plan-step.step-risky {
  background: rgba(255, 189, 46, 0.04);
}

.step-number {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--accent-dim);
  background: rgba(37, 99, 235, 0.08);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-content {
  flex: 1;
  min-width: 0;
}

.step-command {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  word-break: break-all;
}

.step-desc {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.step-warning {
  display: block;
  font-size: 11px;
  color: var(--warning);
  margin-top: 4px;
  font-weight: 500;
}

.plan-warnings {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.plan-warning {
  font-size: 12px;
  color: var(--warning);
  margin-bottom: 4px;
}

.plan-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.btn-approve {
  flex: 1;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--accent);
  color: #0a0a0f;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-approve:hover {
  background: var(--accent-dim);
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.2);
}

.btn-reject {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-reject:hover {
  color: var(--danger);
  border-color: rgba(255, 77, 77, 0.3);
  background: rgba(255, 77, 77, 0.06);
}

/* ── History Page ───────────────────────────────── */

.history-row {
  cursor: pointer;
}
.history-row:hover td {
  background: var(--bg-elevated) !important;
}

.instruction-cell {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exec-status {
  font-size: 16px;
  font-weight: 700;
}
.exec-completed { color: var(--success); }
.exec-failed { color: var(--danger); }
.exec-running { color: var(--accent); animation: pulse 1.5s infinite; }
.exec-pending { color: var(--warning); }
.exec-rejected { color: var(--text-dim); }

.mode-badge {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}
.mode-natural {
  color: #7c8aff;
  background: rgba(124, 138, 255, 0.1);
  border: 1px solid rgba(124, 138, 255, 0.2);
}
.mode-direct {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.status-label.status-pending_approval { color: var(--warning); }
.status-label.status-running { color: var(--accent); }
.status-label.status-completed { color: var(--success); }
.status-label.status-failed { color: var(--danger); }
.status-label.status-rejected { color: var(--text-dim); }
.status-label.status-planning { color: var(--text-secondary); }

.table-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

/* ── Execution Detail ───────────────────────────── */

.exec-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.exec-meta-label {
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 8px;
}

.plan-steps-compact {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-dark);
  border-radius: 6px;
}

.step-num {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--accent-dim);
  background: rgba(37, 99, 235, 0.08);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
}

.step-compact code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--text-primary);
}

.output-block {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-dark);
  padding: 16px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text-secondary);
}

.error-block {
  color: var(--danger);
}

/* ── Console Responsive ─────────────────────────── */
@media (max-width: 768px) {
  .console-page { height: calc(100vh - 60px); }
  .console-terminal { max-height: calc(100vh - 80px); }
  .console-terminal .terminal-body { padding: 12px 16px; font-size: 12px; }
  .server-dropdown { max-width: 160px; font-size: 11px; }
  .terminal-title { display: none; }
  .console-input-bar { flex-wrap: nowrap; }
  .input-mode-toggle { border-right: 1px solid var(--border); }
  .mode-btn { padding: 14px 10px; font-size: 11px; }
  .input-wrapper { padding: 0 10px; }
  #console-input { font-size: 13px; }
  .plan-step { padding: 8px 14px; }
  .step-command { font-size: 12px; }
  .instruction-cell { max-width: 180px; }
}

/* ══════════════════════════════════════════════════════
   SERVER INVENTORY DASHBOARD
   ══════════════════════════════════════════════════════ */

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.inventory-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Inventory header ──────────────────────────── */
.inventory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}

.inventory-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Stats Row ─────────────────────────────────── */
.inventory-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  transition: border-color 0.15s, background 0.15s;
}

.stat-card:hover {
  border-color: rgba(37, 99, 235, 0.25);
  background: var(--bg-elevated);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.stat-value.accent-green { color: var(--accent); }
.stat-value.accent-red   { color: var(--danger); }
.stat-value.accent-warn  { color: var(--warning); }

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Search + Filter Controls ──────────────────── */
.inventory-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px 10px 40px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.search-input::placeholder { color: var(--text-dim); }
.search-input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.filter-btn:hover {
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--text-primary);
}

.filter-btn.active {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--accent-dim);
  color: var(--accent);
}

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

.filter-dot.online     { background: var(--success); box-shadow: 0 0 6px var(--success); }
.filter-dot.unreachable { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.filter-dot.unknown    { background: var(--warning); box-shadow: 0 0 6px var(--warning); }

/* ── Inventory Card (enhanced server card) ─────── */
.inventory-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.inventory-card:hover {
  border-color: rgba(37, 99, 235, 0.2);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.server-host {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}

/* ── Badges row ────────────────────────────────── */
.server-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Server details mini-grid ──────────────────── */
.server-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

/* ── Live Metrics Section ──────────────────────── */
.server-metrics {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 52px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 20px;
}

.metric-item {}

.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.metric-value {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.metrics-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

@keyframes metrics-spin {
  to { transform: rotate(360deg); }
}

.metrics-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: metrics-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.metrics-hint {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

.metrics-error {
  font-size: 12px;
  color: var(--warning);
}

/* ── Quick action footer ───────────────────────── */
.server-quick-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: auto;
}

.btn-connect {
  flex: 1;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-connect:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.2);
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.2);
}

.btn-connect:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-fetch-info {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.btn-fetch-info:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--text-primary);
}

.btn-fetch-info:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Inventory footer ──────────────────────────── */
.inventory-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  padding: 16px 0 8px;
}

/* ── Responsive inventory ──────────────────────── */
@media (max-width: 900px) {
  .inventory-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .inventory-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .inventory-controls { flex-direction: column; align-items: stretch; }
  .search-wrap { min-width: unset; }
  .inventory-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .server-details-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .inventory-stats { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 24px; }
}

/* ══════════════════════════════════════════════════
   PLAYBOOKS PAGE
   ══════════════════════════════════════════════════ */

.playbooks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.playbook-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.playbook-card:hover {
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 4px 24px rgba(37, 99, 235, 0.05);
}

.pb-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pb-icon {
  font-size: 28px;
  line-height: 1;
}

.pb-category {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pb-name {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.3px;
}

.pb-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.pb-meta {
  display: flex;
  gap: 16px;
}

.pb-time, .pb-params {
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.pb-run-btn {
  margin-top: 4px;
  align-self: flex-start;
}

/* ── Playbook Runner ──────────────────────────────── */
.pb-runner-card {
  background: var(--bg-card);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 12px;
  padding: 28px;
  margin-top: 8px;
}

.pb-runner-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.pb-runner-form {
  max-width: 640px;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.pb-terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-radius: 8px 8px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
}

.pb-terminal-title {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--accent);
}

.pb-terminal-body {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════════
   AGENT INSTALL MODAL
   ══════════════════════════════════════════════════ */

.code-block-wrap {
  position: relative;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 48px 14px 16px;
}

.code-block {
  display: block;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.5;
}

.btn-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-copy:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.agent-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.agent-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.step-dot {
  width: 22px;
  height: 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.agent-wait-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Responsive playbooks ─────────────────────────── */
@media (max-width: 768px) {
  .playbooks-grid { grid-template-columns: 1fr; }
  .pb-runner-header { flex-direction: column; }
}
