/* ===== AGENTFARM DESIGN SYSTEM — BINANCE-INSPIRED ===== */

:root {
  /* Primary */
  --yellow: #F0B90B;
  --gold: #FFD000;
  --light-gold: #F8D12F;
  --active-yellow: #D0980B;
  --focus-blue: #1EAEDB;

  /* Surfaces */
  --white: #FFFFFF;
  --snow: #F5F5F5;
  --dark: #222126;
  --dark-card: #2B2F36;
  --ink: #1E2026;

  /* Text */
  --text-primary: #1E2026;
  --text-secondary: #32313A;
  --text-slate: #848E9C;
  --text-steel: #686A6C;
  --text-muted: #777E90;
  --text-hover: #1A1A1A;

  /* Semantic */
  --green: #0ECB81;
  --red: #F6465D;
  --border: #E6E8EA;
  --border-gold: #FFD000;

  /* Status */
  --status-ready: #0ECB81;
  --status-connecting: #F0B90B;
  --status-disconnected: #F6465D;
  --status-unknown: #848E9C;

  /* Log levels */
  --log-debug: #848E9C;
  --log-info: #1EAEDB;
  --log-warning: #F0B90B;
  --log-error: #F6465D;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 50px;

  /* Transitions */
  --transition: 200ms ease;

  /* Shadows */
  --shadow-card: rgba(32, 32, 37, 0.05) 0px 3px 5px 0px;
  --shadow-card-hover: rgba(8, 8, 8, 0.05) 0px 3px 5px 5px;
  --shadow-pill: rgba(153, 153, 153, 0.15) 0px 2px 10px -3px;
  --shadow-modal: rgba(0, 0, 0, 0.08) 0px 32px 37px 0px;
}

/* ===== DARK THEME OVERRIDES ===== */
[data-theme="dark"] {
  --snow: #0a0e1a;
  --white: #141824;
  --border: rgba(100, 120, 180, 0.12);
  --border-gold: rgba(240, 185, 11, 0.25);

  --text-primary: #e8eaf6;
  --text-secondary: #94a3b8;
  --text-slate: #64748b;
  --text-steel: #5a6070;
  --text-muted: #505868;
  --text-hover: #f1f5f9;

  --ink: #0a0e1a;
  --dark: #080b14;

  --shadow-card: rgba(0, 0, 0, 0.3) 0px 3px 5px 0px;
  --shadow-card-hover: rgba(0, 0, 0, 0.4) 0px 3px 5px 5px;
  --shadow-pill: rgba(0, 0, 0, 0.4) 0px 2px 10px -3px;
  --shadow-modal: rgba(0, 0, 0, 0.5) 0px 32px 37px 0px;
}

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

body {
  background: var(--snow);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text-primary); }

/* ===== NAVIGATION ===== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
}

.topnav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.topnav-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.5px;
}

.topnav-brand:hover { color: var(--text-primary); }

.topnav-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.topnav-brand-icon svg {
  width: 18px;
  height: 18px;
}

.topnav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  background: var(--snow);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
  margin-left: 8px;
  color: var(--text-secondary);
}

.theme-toggle:hover {
  border-color: var(--yellow);
  color: var(--yellow);
  background: rgba(240, 185, 11, 0.06);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }

[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(100, 120, 180, 0.15);
  color: var(--text-slate);
}

[data-theme="dark"] .theme-toggle:hover {
  color: var(--yellow);
  border-color: var(--yellow);
  background: rgba(240, 185, 11, 0.08);
}

.topnav-links a {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.topnav-links a:hover {
  color: var(--text-hover);
  background: var(--snow);
}

.topnav-links a.active {
  color: var(--yellow);
  background: rgba(240, 185, 11, 0.06);
}

/* ===== MAIN CONTAINER ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 48px;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.page-header h2 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== AGENT GRID (Dashboard) ===== */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

/* ===== CARDS ===== */
.agent-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: box-shadow var(--transition);
}

.agent-card:hover {
  box-shadow: var(--shadow-card-hover);
}

.agent-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.agent-card .agent-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== STATUS PILL ===== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--snow);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-slate);
}

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

.status-pill.ready .status-dot {
  background: var(--green);
  box-shadow: 0 0 6px rgba(14, 203, 129, 0.4);
}

.status-pill.ready { color: var(--green); }

.status-pill.connecting .status-dot,
.status-pill.initializing .status-dot {
  background: var(--yellow);
  box-shadow: 0 0 6px rgba(240, 185, 11, 0.4);
  animation: statusPulse 2s ease-in-out infinite;
}

.status-pill.connecting,
.status-pill.initializing { color: #b8860b; }

.status-pill.disconnected .status-dot {
  background: var(--red);
  box-shadow: 0 0 6px rgba(246, 70, 93, 0.4);
}

.status-pill.disconnected { color: var(--red); }

.status-pill.unknown .status-dot {
  background: var(--status-unknown);
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 13px;
}

.card-row .label {
  color: var(--text-slate);
  font-size: 12px;
}

.card-row .value {
  color: var(--text-primary);
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 32px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  position: relative;
}

.btn-primary {
  background: var(--yellow);
  color: var(--ink);
}

.btn-primary:hover {
  background: var(--focus-blue);
  color: var(--white);
}

.btn-primary:active {
  background: var(--active-yellow);
}

.btn-primary:focus-visible {
  background: var(--focus-blue);
  color: var(--white);
  outline: 2px solid #000;
  outline-offset: 1px;
}

.btn-ghost {
  background: var(--white);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--text-slate);
  color: var(--text-hover);
}

.btn-danger {
  background: var(--white);
  color: var(--red);
  border: 1px solid rgba(246, 70, 93, 0.25);
}

.btn-danger:hover {
  background: rgba(246, 70, 93, 0.06);
  border-color: var(--red);
}

.btn-sm {
  padding: 5px 14px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Pill buttons (CTAs) */
.btn-pill {
  border-radius: var(--radius-pill);
  padding: 10px 24px;
  box-shadow: var(--shadow-pill);
}

.reconnect-btn {
  margin-top: 0;
  flex: 1;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}

.reconnect-btn:hover:not(:disabled) {
  border-color: var(--yellow);
  color: var(--ink);
}

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

.manage-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  padding: 8px 16px;
  background: var(--yellow);
  border: none;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.manage-link:hover {
  background: var(--focus-blue);
  color: var(--white);
}

/* ===== LOG PANEL ===== */
.log-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.log-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}

.log-panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: 0;
}

.load-more {
  font-size: 12px;
  font-weight: 600;
  color: var(--yellow);
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  transition: all var(--transition);
}

.load-more:hover {
  background: rgba(240, 185, 11, 0.06);
  border-color: var(--yellow);
}

.log-stream {
  max-height: 55vh;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  background: var(--ink);
}

.log-stream::-webkit-scrollbar { width: 6px; }
.log-stream::-webkit-scrollbar-track { background: transparent; }
.log-stream::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 24px;
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.7);
  transition: background var(--transition);
}

.log-entry:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-time {
  color: rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  min-width: 60px;
  font-size: 10.5px;
}

.log-level {
  flex-shrink: 0;
  min-width: 44px;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.log-level.debug { color: #64748b; background: rgba(100, 116, 139, 0.15); }
.log-level.info { color: #22d3ee; background: rgba(34, 211, 238, 0.12); }
.log-level.warning { color: #fbbf24; background: rgba(251, 191, 36, 0.12); }
.log-level.error { color: #f87171; background: rgba(248, 113, 113, 0.12); }

.log-module {
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
  min-width: 120px;
  font-size: 10.5px;
}

.log-message {
  color: rgba(255, 255, 255, 0.85);
  word-break: break-word;
}

.empty-logs {
  padding: 48px 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
  background: var(--ink);
}

/* ===== TABLES ===== */
.agent-table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: var(--shadow-card);
}

.agent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.agent-table th {
  text-align: left;
  padding: 14px 20px;
  font-weight: 600;
  color: var(--text-slate);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  background: var(--snow);
}

.agent-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-secondary);
}

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

.agent-table tr:hover td {
  background: rgba(240, 185, 11, 0.02);
}

.table-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition);
}

.table-link:hover {
  color: var(--yellow);
}

.row-actions {
  display: flex;
  gap: 6px;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: rgba(14, 203, 129, 0.08);
  color: var(--green);
}

.badge-muted {
  background: var(--snow);
  color: var(--text-slate);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 64px 24px;
  text-align: center;
  color: var(--text-slate);
  font-size: 14px;
}

.empty-state a {
  color: var(--yellow);
  text-decoration: none;
  font-weight: 600;
}

.empty-state a:hover {
  text-decoration: underline;
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 200ms ease-out;
}

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

.modal {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 92%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: modalSlideIn 200ms ease-out;
}

.modal-wide {
  max-width: 920px;
}

.modal-logs {
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-logs-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-logs .modal-close {
  padding: 12px 0;
  width: auto;
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-slate);
  cursor: pointer;
  font-size: 22px;
  padding: 16px 20px 4px;
  display: flex;
  justify-content: flex-end;
  width: 100%;
  transition: color var(--transition);
}

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

.modal-content {
  padding: 4px 28px 28px;
}

.modal-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-primary);
}

/* ===== FORMS ===== */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-field input,
.form-field select {
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.form-field input:focus,
.form-field select:focus {
  border-color: #000;
}

.form-field input::placeholder {
  color: var(--text-slate);
}

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

.form-error {
  display: block;
  color: var(--red);
  font-size: 12px;
  margin-top: 4px;
}

.field-error {
  display: block;
  font-size: 11px;
  color: var(--red);
  margin-top: 4px;
}

.form-field input.input-error,
.form-field select.input-error {
  border-color: var(--red);
}

.field-hint {
  font-size: 11px;
  color: var(--text-slate);
  margin-top: 2px;
}

.mono {
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== SHOW PAGE CARDS ===== */
.agent-show-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

@media (min-width: 768px) {
  .agent-show-grid {
    grid-template-columns: 1fr 1fr;
  }
  .tasks-card {
    grid-column: 1 / -1;
  }
}

.show-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.show-card h3 {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-slate);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.show-card h4 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-slate);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.show-header {
  margin-bottom: 20px;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 4px 0;
}

.detail-label {
  color: var(--text-slate);
  font-size: 12px;
}

.detail-value {
  color: var(--text-primary);
}

.detail-value.mono {
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12px;
}

.show-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.registration-ok {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.registration-pending {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.muted {
  color: var(--text-slate);
  font-size: 13px;
}

/* ===== TASKS ===== */
.tasks-section {
  margin-bottom: 24px;
}

.tasks-section:last-child {
  margin-bottom: 0;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--snow);
  border-radius: var(--radius-md);
  font-size: 13px;
  border-left: 3px solid var(--text-slate);
  transition: all var(--transition);
}

.task-item:hover {
  background: var(--border);
}

.task-item.running {
  border-left-color: var(--yellow);
  background: rgba(240, 185, 11, 0.04);
}

.task-item.completed {
  border-left-color: var(--green);
  background: rgba(14, 203, 129, 0.04);
}

.task-item.failed {
  border-left-color: var(--red);
  background: rgba(246, 70, 93, 0.04);
}

.task-id {
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-primary);
  min-width: 100px;
  font-weight: 500;
}

.task-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  background: var(--white);
  color: var(--text-secondary);
}

.task-time {
  margin-left: auto;
  color: var(--text-slate);
  font-size: 11px;
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ===== PROVIDER PAGE ===== */
.page-desc {
  color: var(--text-slate);
  font-size: 14px;
  margin-bottom: 28px;
  line-height: 1.6;
}

.warning-banner {
  background: rgba(240, 185, 11, 0.06);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(240, 185, 11, 0.15);
}

.warning-banner p {
  color: #b8860b;
  font-size: 13px;
  margin: 0;
}

.warning-banner a {
  color: var(--yellow);
  font-weight: 600;
}

/* ===== FLASH NOTICES ===== */
.flash {
  position: fixed;
  top: 76px;
  right: 32px;
  z-index: 300;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  animation: flashIn 250ms ease-out;
  cursor: pointer;
  max-width: 360px;
}

.flash-info {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow-card-hover);
}

.flash-error {
  background: var(--white);
  border: 1px solid rgba(246, 70, 93, 0.25);
  color: var(--red);
  box-shadow: var(--shadow-card-hover);
}

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

/* ===== MARKDOWN EDITOR ===== */
.md-preset-toggle {
  display: flex;
  gap: 6px;
}

.md-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--white);
}

.md-editor-pane textarea {
  width: 100%;
  min-height: 260px;
  padding: 14px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-primary);
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}

.md-editor-pane textarea::placeholder {
  color: var(--text-slate);
}

.md-editor-preview {
  padding: 14px;
  background: var(--snow);
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 400px;
}

.md-editor-preview h1, .md-preview h1,
.md-editor-preview h2, .md-preview h2,
.md-editor-preview h3, .md-preview h3 {
  color: var(--text-primary);
  margin: 14px 0 8px;
  font-weight: 600;
}

.md-editor-preview h2, .md-preview h2,
.md-editor-preview h3, .md-preview h3 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.md-editor-preview code, .md-preview code {
  background: rgba(240, 185, 11, 0.08);
  color: var(--active-yellow);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}

.md-editor-preview pre code, .md-preview pre code {
  display: block;
  padding: 12px;
  background: var(--ink);
  color: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-md);
}

.md-editor-preview ul, .md-preview ul,
.md-editor-preview ol, .md-preview ol {
  padding-left: 20px;
  margin: 8px 0;
}

.md-editor-preview li, .md-preview li {
  margin: 4px 0;
}

.md-editor-preview blockquote, .md-preview blockquote {
  border-left: 3px solid var(--yellow);
  padding-left: 14px;
  color: var(--text-slate);
  margin: 8px 0;
}

.md-editor-preview a, .md-preview a {
  color: var(--yellow);
  text-decoration: none;
}

.md-editor-preview a:hover, .md-preview a:hover {
  text-decoration: underline;
}

.md-editor-preview strong, .md-preview strong {
  color: var(--text-primary);
}

.md-editor-preview p, .md-preview p {
  margin: 8px 0;
}

.md-preview {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
  max-height: 300px;
  overflow-y: auto;
}

.md-preview-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--yellow);
  margin-bottom: 8px;
}

/* ===== NAV LOGOUT ===== */
.nav-logout {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-slate);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  margin-left: 16px;
  border: 1px solid var(--border);
  background: var(--white);
}

.nav-logout:hover {
  color: var(--red);
  border-color: rgba(246, 70, 93, 0.3);
}

/* ===== LOGIN PAGE ===== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--dark);
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-modal);
}

.login-header {
  text-align: center;
  margin-bottom: 36px;
}

.login-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.login-icon svg {
  width: 28px;
  height: 28px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-header p {
  font-size: 14px;
  color: var(--text-slate);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-error {
  font-size: 12px;
  color: var(--red);
  background: rgba(246, 70, 93, 0.06);
  border: 1px solid rgba(246, 70, 93, 0.15);
  padding: 10px 14px;
  border-radius: var(--radius-md);
}

.login-btn {
  width: 100%;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

/* ===== DASHBOARD DARK SECTION ===== */
.section-dark {
  background: var(--dark);
  padding: 32px 32px;
}

.section-dark .page-header h2 {
  color: var(--white);
}

/* ===== PROVIDER SELECT ===== */
.provider-select {
  width: 100%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .agent-grid {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .container {
    padding: 20px 16px;
  }
  .topnav {
    padding: 0 16px;
  }
  .topnav-links a {
    padding: 8px 10px;
    font-size: 13px;
  }
  .md-editor {
    grid-template-columns: 1fr;
  }
  .md-editor-pane textarea {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: 180px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .agent-show-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .topnav-inner {
    gap: 8px;
  }
  .topnav-links {
    gap: 2px;
  }
  .topnav-links a {
    padding: 6px 8px;
    font-size: 12px;
  }
  .nav-logout {
    margin-left: 4px;
    padding: 6px 10px;
    font-size: 11px;
  }
  .container {
    padding: 16px 12px;
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-slate);
}
