/* Agent Hub UI. Tokens and components follow DESIGN.md. No build step. */

@font-face { font-family: "Geist"; src: url("/static/fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/static/fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #f8fafc; --surface: #fdfdfe; --surface-2: #f1f5f9; --border: #e2e8f0;
  --text: #0f172a; --text-muted: #475569;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-contrast: #fdfdfe; --accent-soft: #eef2ff;
  --danger: #b91c1c; --danger-soft: #fef2f2; --warning: #a16207; --warning-soft: #fefce8; --success: #15803d; --success-soft: #f0fdf4;
  --shadow: 0 8px 24px rgb(15 23 42 / 0.12);
  --r-sm: 6px; --r-lg: 10px;
  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111827; --surface-2: #1e293b; --border: #273449;
    --text: #e2e8f0; --text-muted: #94a3b8;
    --accent: #818cf8; --accent-hover: #a5b4fc; --accent-contrast: #0b1120; --accent-soft: #1e1b4b;
    --danger: #f87171; --danger-soft: #2a1215; --warning: #facc15; --warning-soft: #2a2410; --success: #4ade80; --success-soft: #0f2a1a;
    --shadow: 0 8px 24px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111827; --surface-2: #1e293b; --border: #273449;
  --text: #e2e8f0; --text-muted: #94a3b8;
  --accent: #818cf8; --accent-hover: #a5b4fc; --accent-contrast: #0b1120; --accent-soft: #1e1b4b;
  --danger: #f87171; --danger-soft: #2a1215; --warning: #facc15; --warning-soft: #2a2410; --success: #4ade80; --success-soft: #0f2a1a;
  --shadow: 0 8px 24px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 0.875rem/1.5 var(--font); }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 600; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
code, pre, kbd, .mono { font-family: var(--mono); font-size: 0.8125rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -48px; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); z-index: 30; }
.skip-link:focus { top: 8px; }
.icon { width: 18px; height: 18px; fill: currentColor; flex: none; }
.muted { color: var(--text-muted); }

/* Layout */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px; padding: 20px 12px; border-right: 1px solid var(--border); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1rem; padding: 4px 8px 16px; color: var(--text); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-contrast); display: grid; place-items: center; font-size: 0.8125rem; font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text-muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-label { font-size: 0.75rem; color: var(--text-muted); padding: 16px 10px 4px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); }
.main { padding: 32px 24px 48px; max-width: 1200px; width: 100%; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header p { margin: 4px 0 0; color: var(--text-muted); max-width: 70ch; }
.topbar { display: none; }
.section { margin-top: 32px; }
.section > h2 { margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; }
.panel h2, .panel h3 { margin-bottom: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat strong { font-size: 1.5rem; font-weight: 600; font-family: var(--mono); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 0.875rem var(--font); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.btn-danger { color: var(--danger); }
.btn-danger-fill { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn-link { border: 0; background: none; padding: 0; min-height: auto; color: var(--accent); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 0.8125rem; }
.btn-block { width: 100%; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field legend { font-weight: 500; }
.help { color: var(--text-muted); font-size: 0.8125rem; }
.error-text { color: var(--danger); font-size: 0.8125rem; }
input[type="text"], input[type="number"], input[type="search"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; min-height: 36px; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* Tables */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; vertical-align: top; }
th { background: var(--surface-2); font-weight: 500; color: var(--text-muted); font-size: 0.8125rem; }
tbody tr + tr td { border-top: 1px solid var(--border); }
td.num, .mono-cell { font-family: var(--mono); font-size: 0.8125rem; }
td.actions { text-align: right; white-space: nowrap; }

/* Badges and notices */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--r-sm); border: 1px solid var(--border); font-size: 0.75rem; font-weight: 500; color: var(--text-muted); background: var(--surface-2); }
.badge-success { color: var(--success); background: var(--success-soft); border-color: transparent; }
.badge-warning { color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge-accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-2); }
.notice-warning { background: var(--warning-soft); border-color: transparent; }
.notice-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.notice-success { background: var(--success-soft); border-color: transparent; }
.empty { padding: 32px 20px; text-align: center; color: var(--text-muted); }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* Code and copy */
.copy-field { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); overflow: hidden; }
.copy-field code, .copy-field pre { flex: 1; min-width: 0; margin: 0; padding: 10px 12px; overflow-x: auto; white-space: pre; }
.copy-field .btn { border: 0; border-left: 1px solid var(--border); border-radius: 0; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; overflow-x: auto; margin: 0 0 12px; }

/* Tabs (connect guides) */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a { padding: 8px 12px; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.guide { max-width: 70ch; }
.guide ol { padding-left: 20px; } .guide li { margin-bottom: 10px; }

/* Centered pages (login, consent, device) */
.center-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.card { width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 28px; }
.card .brand { padding: 0 0 20px; }
.card h1 { font-size: 1.25rem; margin-bottom: 8px; }
.user-code { font: 600 1.75rem var(--mono); letter-spacing: 0.12em; text-align: center; text-transform: uppercase; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

dialog { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow); padding: 24px; max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgb(15 23 42 / 0.45); }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.htmx-request { opacity: 0.6; transition: opacity 100ms ease-out; }

/* Mobile */
@media (max-width: 1023px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; }
  .topbar details[open] .mobile-nav { display: flex; }
  .mobile-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; gap: 2px; padding: 12px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
  .main { padding: 20px 16px 40px; }
  .form-grid, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 639px) {
  table.stack-mobile thead { display: none; }
  table.stack-mobile tr { display: block; padding: 10px 14px; }
  table.stack-mobile tbody tr + tr { border-top: 1px solid var(--border); }
  table.stack-mobile tbody tr + tr td { border-top: 0; }
  table.stack-mobile td { display: grid; grid-template-columns: 110px 1fr; gap: 8px; padding: 4px 0; }
  table.stack-mobile td::before { content: attr(data-label); color: var(--text-muted); font-size: 0.8125rem; }
  table.stack-mobile td.actions { text-align: left; }
  .card { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.grow { flex: 1; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.mt-0 { margin-top: 0; }
.mb-16 { margin-bottom: 16px; }
.w-auto { width: auto; }
.mt-16 { margin-top: 16px; }
.h3 { font-size: 1rem; margin: 8px 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.link-panel { text-decoration: none; color: var(--text); }
.link-panel:hover { border-color: var(--accent); }
.label { font-weight: 500; }
@media (max-width: 1023px) { .grid-3 { grid-template-columns: 1fr; } }
.self-end { align-self: flex-end; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
input[type="file"] { font: inherit; color: var(--text-muted); max-width: 100%; }
input[type="file"]::file-selector-button { font: 500 0.8125rem var(--font); margin-right: 12px; padding: 6px 12px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.main, .panel, .table-wrap, .field { min-width: 0; }
ul.checks { list-style: none; margin: 0; padding: 0; }
