/* ============================================================
   AdPilots — Modern SaaS theme
   Design language: clean, calm, professional
   Inspired by Linear / Stripe / Vercel
============================================================ */

:root {
  /* Surfaces */
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f4f4f5;
  --surface: #ffffff;
  --surface-hover: #f9fafb;

  /* Borders */
  --border: #e5e7eb;
  --border-strong: #d4d4d8;
  --border-subtle: #f1f5f9;

  /* Text */
  --text: #0a0a0a;
  --text-secondary: #525252;
  --text-tertiary: #737373;
  --text-muted: #a3a3a3;
  --text-on-accent: #ffffff;

  /* Accent (primary brand) — indigo/blue */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-active: #1e40af;
  --accent-soft: #eff6ff;
  --accent-soft-border: #dbeafe;
  --accent-text: #1e40af;

  /* Status colors */
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --info-border: #bae6fd;

  /* Admin accent (differentiator) */
  --admin: #475569;
  --admin-hover: #334155;
  --admin-soft: #f1f5f9;
  --admin-border: #cbd5e1;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.16);
  --ring-admin: 0 0 0 3px rgba(71, 85, 105, 0.18);

  /* Typography */
  --f-sans: 'Inter', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 20px;
  --r-full: 9999px;

  /* Transitions */
  --t-fast: 120ms ease;
  --t-base: 180ms ease;
  --t-slow: 240ms ease;
}

* { box-sizing: border-box; }
*::selection { background: var(--accent-soft); color: var(--accent-text); }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--f-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-subtle);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

h1, h2, h3, h4, h5 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: 28px; line-height: 1.25; letter-spacing: -0.02em; }
h2 { font-size: 20px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.4; }
h4 { font-size: 14px; line-height: 1.4; font-weight: 500; }

p { margin: 0; color: var(--text-secondary); }
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.mono { font-family: var(--f-mono); }

/* ============================================================
   View Switcher (dev / preview)
============================================================ */
.view-switcher {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.view-switcher button {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  transition: all var(--t-fast);
}
.view-switcher button:hover { background: var(--bg-muted); color: var(--text); }
.view-switcher button.active { background: var(--accent); color: #fff; }
.view-switcher button.admin-tab.active { background: var(--admin); color: #fff; }

.view { display: none; }
.view.active { display: block; }

/* ============================================================
   Reusable components
============================================================ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

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

.btn-admin {
  background: var(--admin);
  color: #fff;
  border-color: var(--admin);
}
.btn-admin:hover { background: var(--admin-hover); border-color: var(--admin-hover); color: #fff; }
.btn-admin:focus-visible { box-shadow: var(--ring-admin); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-muted); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.field-hint { font-size: 12px; color: var(--text-tertiary); }
.input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: all var(--t-fast);
}
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder { color: var(--text-muted); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 13px; color: var(--text-tertiary); margin-top: 2px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  border-radius: var(--r-full);
  border: 1px solid;
}
.badge-neutral { background: var(--bg-muted); color: var(--text-secondary); border-color: var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-soft-border); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.badge-admin { background: var(--admin-soft); color: var(--admin); border-color: var(--admin-border); }

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Logo */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.logo-mark {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--f-sans);
  flex-shrink: 0;
}
.logo-mark-admin {
  background: linear-gradient(135deg, var(--admin) 0%, #1e293b 100%);
}

/* Utility */
.row { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-mono { font-family: var(--f-mono); font-size: 13px; }

/* ============================================================
   LOGIN VIEWS (Client + Admin)
============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(circle at 15% 10%, rgba(37, 99, 235, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(99, 102, 241, 0.04) 0%, transparent 40%),
    var(--bg-subtle);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
  text-align: center;
}
.auth-header .logo { margin-bottom: 16px; }
.auth-header h1 { font-size: 22px; margin-bottom: 6px; }
.auth-header p { font-size: 14px; color: var(--text-tertiary); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: -4px;
  font-size: 13px;
}
.auth-row label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); cursor: pointer; }
.auth-row input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--accent); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}
.auth-notice {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: var(--admin-soft);
  border: 1px solid var(--admin-border);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.auth-notice strong { color: var(--text); font-weight: 600; display: block; margin-bottom: 2px; }
.auth-notice .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--admin);
  margin-top: 2px;
}

/* Admin login variant */
.auth-card.admin .logo-mark { background: linear-gradient(135deg, var(--admin) 0%, #1e293b 100%); }
.auth-card.admin .input:focus { border-color: var(--admin); box-shadow: var(--ring-admin); }
.auth-card.admin .btn-primary {
  background: var(--admin);
  border-color: var(--admin);
}
.auth-card.admin .btn-primary:hover { background: var(--admin-hover); border-color: var(--admin-hover); }

/* ============================================================
   DASHBOARD SHELL (used by Client + Admin)
============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--bg-subtle);
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .logo { padding: 4px 8px 20px; }
.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}
.nav-section-title {
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}
.nav-link:hover { background: var(--bg-muted); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-link .icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-link .badge { margin-left: auto; }

.sidebar.admin .nav-link.active { background: var(--admin-soft); color: var(--admin); }
.sidebar.admin .logo-mark { background: linear-gradient(135deg, var(--admin) 0%, #1e293b 100%); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
}
.user-chip:hover { background: var(--bg-muted); }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-chip .user-info { display: flex; flex-direction: column; min-width: 0; }
.user-chip .user-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .user-role { font-size: 11px; color: var(--text-tertiary); }

/* Main content */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); }
.topbar-subtitle { font-size: 13px; color: var(--text-tertiary); }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  width: 320px;
  max-width: 100%;
  background: var(--bg-muted);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  transition: all var(--t-fast);
}
.search-box:focus-within { background: var(--surface); border-color: var(--accent); box-shadow: var(--ring); }
.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 14px;
  outline: none;
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box .icon { width: 14px; height: 14px; color: var(--text-tertiary); }
.kbd {
  font-family: var(--f-mono);
  font-size: 11px;
  padding: 1px 5px;
  color: var(--text-tertiary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast);
}
.icon-btn:hover { background: var(--bg-muted); color: var(--text); }
.icon-btn .dot-indicator {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

/* Content area */
.content {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1280px;
  width: 100%;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header .left h1 { font-size: 24px; margin-bottom: 4px; }
.page-header .left p { font-size: 14px; color: var(--text-tertiary); }
.page-header .right { display: flex; align-items: center; gap: 10px; }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}
.stat-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 500;
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Tables */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-head h3 { font-size: 15px; }
.table-head .table-meta { font-size: 13px; color: var(--text-tertiary); }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  padding: 10px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 20px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg-subtle); }
td.num { font-variant-numeric: tabular-nums; }
td.muted { color: var(--text-tertiary); }

/* Action feed */
.feed { display: flex; flex-direction: column; }
.feed-item {
  display: flex;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.feed-item:last-child { border-bottom: 0; }
.feed-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-muted);
  color: var(--text-secondary);
}
.feed-icon.success { background: var(--success-soft); color: var(--success); }
.feed-icon.warning { background: var(--warning-soft); color: var(--warning); }
.feed-icon.accent { background: var(--accent-soft); color: var(--accent); }
.feed-icon.info { background: var(--info-soft); color: var(--info); }
.feed-body { flex: 1; min-width: 0; }
.feed-title { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.feed-meta { font-size: 13px; color: var(--text-tertiary); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feed-time { font-variant-numeric: tabular-nums; }

/* Content matrix */
.matrix-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.matrix-tile {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.matrix-tile .matrix-meta { display: flex; align-items: center; justify-content: space-between; }
.matrix-tile .matrix-format { font-size: 11px; font-weight: 500; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; }
.matrix-tile .matrix-desc { font-size: 13px; color: var(--text); line-height: 1.5; }
.matrix-tile .matrix-score { font-family: var(--f-mono); font-size: 12px; color: var(--text-tertiary); }

/* Status list */
.status-list { display: flex; flex-direction: column; }
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}
.status-row:last-child { border-bottom: 0; }
.status-row .status-name { color: var(--text); font-weight: 500; }
.status-row .status-meta { font-size: 12px; color: var(--text-tertiary); font-family: var(--f-mono); }

/* Progress bar */
.progress {
  height: 6px;
  background: var(--bg-muted);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }

/* ============================================================
   AI ENGINE VIEW
============================================================ */
.engine-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 40px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: center;
}
.engine-hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 16px;
}
.engine-hero h1 {
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.engine-hero p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 560px;
}
.engine-hero-art {
  width: 200px;
  height: 200px;
  border-radius: var(--r-xl);
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 50%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 64px;
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title h2 { font-size: 20px; }
.section-title p { font-size: 14px; color: var(--text-tertiary); margin-top: 4px; }

.capabilities-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.cap-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--t-base);
}
.cap-card:hover { border-color: var(--accent-soft-border); box-shadow: var(--shadow-md); }
.cap-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cap-card h3 { font-size: 15px; }
.cap-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.55; }

/* Flow */
.flow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
}
.flow-steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  position: relative;
}
.flow-step {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  position: relative;
  text-align: center;
}
.flow-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -8px;
  width: 12px;
  height: 1px;
  background: var(--border-strong);
  z-index: 1;
}
.flow-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}
.flow-step h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.flow-step p { font-size: 12px; color: var(--text-tertiary); line-height: 1.45; }

/* Tech stack */
.tech-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.tech-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
}
.tech-item .tech-name { font-weight: 500; color: var(--text); }
.tech-item .tech-purpose { font-size: 12px; color: var(--text-tertiary); }
.tech-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* Requirements */
.req-list { display: flex; flex-direction: column; gap: 0; }
.req-item {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.req-item:last-child { border-bottom: 0; }
.req-check {
  width: 24px;
  height: 24px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.req-body h4 { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.req-body p { font-size: 13px; color: var(--text-secondary); line-height: 1.55; }

/* ============================================================
   MODAL
============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; }
.modal-close {
  background: transparent;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg-muted); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-steps { display: flex; flex-direction: column; gap: 16px; }
.modal-step {
  display: flex;
  gap: 14px;
  padding: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.modal-step-num {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.modal-step h4 { font-size: 14px; margin-bottom: 2px; }
.modal-step p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ============================================================
   RESPONSIVE
============================================================ */
.menu-toggle { display: none; }

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-1-1 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .capabilities-grid { grid-template-columns: repeat(2, 1fr); }
  .tech-list { grid-template-columns: repeat(2, 1fr); }
  .matrix-grid { grid-template-columns: repeat(2, 1fr); }
  .flow-steps { grid-template-columns: 1fr 1fr; }
  .flow-step:not(:last-child)::after { display: none; }
  .engine-hero { grid-template-columns: 1fr; gap: 24px; }
  .engine-hero-art { width: 120px; height: 120px; font-size: 40px; }
}

@media (max-width: 768px) {
  .view-switcher { top: 8px; right: 8px; padding: 3px; }
  .view-switcher button { padding: 5px 8px; font-size: 12px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    z-index: 50;
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 40;
    display: none;
  }
  .sidebar-backdrop.open { display: block; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .search-box { width: 0; flex: 1; }
  .content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 22px; }
  .capabilities-grid { grid-template-columns: 1fr; }
  .tech-list { grid-template-columns: 1fr; }
  .matrix-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 22px; }
  .engine-hero { padding: 24px; }
  .engine-hero h1 { font-size: 24px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .flow-steps { grid-template-columns: 1fr; }
  thead { display: none; }
  tbody td { display: block; padding: 6px 16px; }
  tbody tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
  tbody tr:last-child { border-bottom: 0; }
}

/* ============================================================
   TRIAL CHIP — used in adpilots.html topbar
============================================================ */
.trial-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.trial-chip .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.trial-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.trial-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.trial-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }

/* ============================================================
   DATE RANGE PICKER (dashboard topbar)
============================================================ */
.date-picker { position: relative; display: inline-block; }
.date-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px; z-index: 30;
  padding: 6px;
}
.date-opt {
  display: block; width: 100%; text-align: left;
  background: transparent; border: none;
  padding: 7px 12px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--text); cursor: pointer;
  font-family: inherit;
}
.date-opt:hover { background: var(--surface-hover); }
.date-opt.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
