@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  color-scheme: dark;

  /* ink palette */
  --bg: #0a0a0c;
  --bg-2: #0f0f13;
  --surface: #141419;
  --surface-2: #191920;
  --line: #262630;
  --line-2: #34343f;

  /* text */
  --ink: #ece7dd;
  --muted: #918c82;
  --faint: #6b675f;

  /* accent: warm amber / gold */
  --accent: #e8b450;
  --accent-2: #f0c674;
  --accent-soft: rgba(232, 180, 80, 0.12);
  --accent-line: rgba(232, 180, 80, 0.34);

  /* semantic, desaturated, used sparingly */
  --pos: #79c08b;
  --neg: #e0786b;
  --warn: #e8b450;
  --info: #86a6c8;

  /* type */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* radius */
  --r1: 8px; --r2: 12px; --r3: 16px;

  --shadow: 0 1px 0 rgba(255,255,255,0.03), 0 12px 32px rgba(0,0,0,0.36);
  --nav-w: 264px;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
  position: relative;
}

/* atmosphere: faint warm glow + film grain */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 80% at 100% -10%, rgba(232,180,80,0.06), transparent 55%),
    radial-gradient(80% 60% at -10% 0%, rgba(134,166,200,0.05), transparent 50%);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.022; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }
code { font-family: var(--font-mono); color: var(--accent-2); font-size: 0.92em; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 46px); line-height: 1.05; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 19px; }
h3 { margin: 0 0 var(--s2); font-size: 16px; }
h4 { margin: var(--s2) 0; font-size: 14px; color: var(--ink); }

/* sidebar */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--nav-w);
  padding: var(--s6) var(--s5);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--line);
  overflow-y: auto; z-index: 2;
  display: flex; flex-direction: column; gap: var(--s5);
}
.brand { display: flex; gap: var(--s3); align-items: center; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: var(--r2); border: 1px solid var(--accent-line);
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-display); font-weight: 600; font-size: 22px;
}
.brand strong { font-family: var(--font-display); font-size: 20px; letter-spacing: 0.02em; }
.brand span { display: block; color: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; }

nav { display: flex; flex-direction: column; gap: var(--s5); }
.nav-group { display: grid; gap: 2px; }
.nav-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--faint); margin: 0; padding: 0 var(--s3) var(--s2);
}
nav a {
  position: relative; padding: 9px var(--s3); border-radius: var(--r1);
  color: #c4bfb4; font-size: 14px; transition: background .15s, color .15s;
}
nav a:hover { background: var(--surface); color: var(--ink); }
nav a.active { color: var(--ink); background: var(--accent-soft); }
nav a.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 99px; background: var(--accent);
}

.sidebar-note {
  padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r2);
  color: var(--muted); font-size: 12px; line-height: 1.55; background: var(--surface);
}
.sidebar-foot { margin-top: auto; display: grid; gap: var(--s3); padding-top: var(--s4); border-top: 1px solid var(--line); }
.sidebar-user { color: var(--muted); font-family: var(--font-mono); font-size: 12px; word-break: break-all; }
.logout-btn, .button-link {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: transparent; color: var(--ink); padding: 8px 14px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: border-color .15s, color .15s;
}
.logout-btn:hover, .button-link:hover { border-color: var(--accent-line); color: var(--accent); }

/* page shell */
.page-shell { margin-left: var(--nav-w); padding: var(--s7) var(--s7) var(--s8); max-width: 1320px; position: relative; z-index: 1; }
.page-header { margin-bottom: var(--s6); }
.eyebrow { font-family: var(--font-mono); color: var(--accent); letter-spacing: 0.16em; text-transform: uppercase; font-size: 11px; font-weight: 500; margin: 0 0 var(--s3); }
.eyebrow.small { font-size: 10px; margin: 0 0 var(--s1); }
.subtitle { max-width: 760px; color: var(--muted); font-size: 16px; margin: var(--s3) 0 0; }

/* hero (dashboard) */
.hero {
  position: relative; margin-bottom: var(--s6);
  padding: var(--s7); padding-left: calc(var(--s7) + 8px);
  border: 1px solid var(--line); border-radius: var(--r3);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  overflow: hidden;
}
.hero::before { content: ""; position: absolute; left: 0; top: var(--s6); bottom: var(--s6); width: 3px; border-radius: 99px; background: linear-gradient(var(--accent), transparent); }
.hero-eyebrow { font-family: var(--font-mono); color: var(--accent); letter-spacing: .14em; text-transform: uppercase; font-size: 11px; margin: 0 0 var(--s4); }
.hero-title { font-family: var(--font-display); font-size: clamp(26px, 3.4vw, 40px); line-height: 1.14; font-weight: 500; max-width: 24ch; margin: 0; }
.hero-focus { margin: var(--s5) 0 0; display: grid; gap: var(--s2); max-width: 72ch; }
.hero-focus li { color: var(--muted); }

/* grid */
.grid { display: grid; gap: var(--s4); margin-bottom: var(--s5); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* panels & cards */
.panel { padding: var(--s6); margin-bottom: var(--s5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); }
.panel-header { display: flex; justify-content: space-between; gap: var(--s3); align-items: baseline; margin-bottom: var(--s5); padding-bottom: var(--s4); border-bottom: 1px solid var(--line); }
.panel-foot { margin-top: var(--s5); }
.status-pill, .tag {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .03em;
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  color: var(--muted); border: 1px solid var(--line-2); background: var(--bg-2);
}
.tag.good { color: var(--pos); border-color: rgba(121,192,139,.34); background: rgba(121,192,139,.10); }
.tag.warn { color: var(--warn); border-color: var(--accent-line); background: var(--accent-soft); }

.metric-card { position: relative; padding: var(--s5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); }
.metric-card span { display: block; color: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.metric-card strong { display: block; font-family: var(--font-mono); font-size: 32px; font-weight: 500; line-height: 1.1; margin: var(--s3) 0 var(--s1); color: var(--ink); }
.metric-card small { color: var(--faint); font-size: 12px; }
.metric-card.good strong { color: var(--pos); }
.metric-card.warn strong { color: var(--warn); }
.metric-card.bad strong { color: var(--neg); }
.metric-card.neutral strong { color: var(--ink); }
.metric-card::after { content: ""; position: absolute; left: 0; top: var(--s5); bottom: var(--s5); width: 2px; border-radius: 99px; background: var(--line-2); }
.metric-card.good::after { background: var(--pos); }
.metric-card.warn::after { background: var(--warn); }
.metric-card.bad::after { background: var(--neg); }
.metric-card.neutral::after { background: var(--accent); }

.callout { padding: var(--s5); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r2); background: var(--surface); margin-top: var(--s4); color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r2); }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); text-align: left; }
th { font-family: var(--font-mono); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; background: var(--bg-2); }
tr:last-child td { border-bottom: none; }
td { color: var(--ink); font-size: 14px; }

ul.clean, ol.clean { padding-left: 18px; margin: 0; }
ul.clean li, ol.clean li { margin: var(--s1) 0; }
.muted { color: var(--muted); }

/* timeline */
.timeline { display: grid; gap: var(--s3); }
.timeline-item { padding: var(--s4); border: 1px solid var(--line); border-left: 2px solid var(--line-2); border-radius: var(--r2); background: var(--bg-2); }
.timeline-item h3 { font-family: var(--font-ui); font-weight: 600; font-size: 15px; }
.timeline-item p { margin: var(--s1) 0; color: var(--muted); font-size: 14px; }

/* progress */
.progress-bar { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* archive links */
.archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s3); }
.archive-grid.dense { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.archive-link { padding: var(--s4); display: grid; gap: var(--s1); border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface); transition: border-color .15s, transform .15s, background .15s; }
.archive-link strong { font-family: var(--font-ui); font-weight: 600; font-size: 14px; }
.archive-link span { color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.archive-link:hover, .archive-link.active { border-color: var(--accent-line); background: var(--surface-2); transform: translateY(-1px); }
.archive-link.active { box-shadow: inset 2px 0 0 var(--accent); }

/* agents */
.agent-card { padding: var(--s5); border: 1px solid var(--line); border-radius: var(--r3); background: var(--surface); }
.agent-card-head, .agent-head { display: flex; justify-content: space-between; gap: var(--s4); align-items: start; margin-bottom: var(--s3); }
.agent-head h3 { font-family: var(--font-display); font-size: 17px; margin: 0; }
.agent-head p { color: var(--accent); font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; margin: var(--s1) 0 0; }
.agent-areas { display: grid; gap: var(--s2); }
.business-detail, .markdown-detail { border: 1px solid var(--line); border-radius: var(--r1); padding: var(--s3) var(--s4); background: var(--bg-2); }
.business-detail summary, .markdown-detail summary { cursor: pointer; color: var(--ink); font-family: var(--font-ui); font-weight: 600; font-size: 13px; }
.business-detail[open] summary, .markdown-detail[open] summary { margin-bottom: var(--s2); color: var(--accent); }
.markdown-detail pre { white-space: pre-wrap; overflow: auto; color: var(--muted); font-family: var(--font-mono); font-size: 12px; margin: var(--s2) 0 0; }

/* auth */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: var(--s5); position: relative; z-index: 1; }
.auth-card { width: 100%; max-width: 400px; padding: var(--s7); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); box-shadow: var(--shadow); }
.auth-card h2 { font-family: var(--font-display); font-size: 26px; margin: var(--s5) 0 var(--s1); }
.auth-sub { margin: 0 0 var(--s5); color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.auth-card form { display: grid; gap: var(--s4); }
.auth-card label { display: grid; gap: 6px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.auth-card input { padding: 11px 13px; border-radius: var(--r1); border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink); font-size: 15px; font-family: var(--font-ui); }
.auth-card input:focus { outline: none; border-color: var(--accent); }
.auth-card button[type="submit"] { margin-top: var(--s1); padding: 12px; border: none; border-radius: var(--r1); cursor: pointer; background: var(--accent); color: #1a1407; font-size: 15px; font-weight: 700; font-family: var(--font-ui); transition: filter .15s; }
.auth-card button[type="submit"]:hover { filter: brightness(1.06); }
.auth-error { margin-bottom: var(--s4); padding: 10px 12px; border-radius: var(--r1); font-size: 13px; background: rgba(224,120,107,.12); border: 1px solid rgba(224,120,107,.34); color: #f0b6ad; }
.auth-foot { margin: var(--s5) 0 0; font-size: 13px; color: var(--muted); }
.auth-foot a { color: var(--accent); }

.footer-space { height: var(--s8); }

/* motion */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
.page-shell > * { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
.page-shell > *:nth-child(2) { animation-delay: .06s; }
.page-shell > *:nth-child(3) { animation-delay: .12s; }
.page-shell > *:nth-child(4) { animation-delay: .18s; }
.page-shell > *:nth-child(5) { animation-delay: .24s; }
.page-shell > *:nth-child(6) { animation-delay: .30s; }
@media (prefers-reduced-motion: reduce) {
  .rise, .page-shell > * { animation: none; }
}

/* responsive */
@media (max-width: 980px) {
  .sidebar { position: static; width: auto; }
  .page-shell { margin-left: 0; padding: var(--s5); }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .hero { padding: var(--s6); }
}
