/* Doli Brain — committed design-token stylesheet.
   Hand-written, zero-build, dependency-free. Restrained professional ERP/finance
   look: calm neutral surfaces, one deep-ink accent, dense readable tables.
   Replaces the Tailwind Play CDN (which is not for production). */

/* ---------------------------------------------------------------- tokens */
:root {
  /* surfaces */
  --page: #f4f6f8;          /* near-white cool neutral page */
  --surface: #ffffff;       /* cards */
  --surface-muted: #f8fafc; /* subtle panels, zebra */
  --surface-sunken: #f1f5f9;/* code block */

  /* text */
  --text: #1f2937;          /* body, high contrast slate-800 */
  --text-strong: #0f172a;   /* headings */
  --text-muted: #64748b;    /* meta slate-500 */
  --text-faint: #94a3b8;

  /* lines */
  --border: #e2e8f0;        /* hairline slate-200 */
  --border-strong: #cbd5e1;

  /* accent — deep ink/navy for finance credibility */
  --accent: #1e3a5f;
  --accent-hover: #16314f;
  --accent-soft: #eef2f7;
  --accent-ink-text: #1e3a5f;

  /* semantic */
  --success: #047857;
  --success-soft: #ecfdf5;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;

  /* radii / shadow */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .05);

  /* type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter",
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas,
    "Liberation Mono", monospace;
}

/* ---------------------------------------------------------------- reset */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--text-strong); line-height: 1.25; margin: 0; }
p { margin: 0; }
a { color: var(--accent-ink-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- layout */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 880px; margin: 0 auto; padding: 24px 20px; flex: 1 0 auto; }
.container--wide { max-width: 1100px; }
.stack > * + * { margin-top: 16px; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand__mark {
  font-weight: 700; font-size: 16px; letter-spacing: -.01em; color: var(--text-strong);
}
.brand__by { font-size: 11px; color: var(--text-faint); }
.brand__logo {
  width: 24px; height: 24px; border-radius: 6px; background: var(--accent);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; margin-right: 8px;
}
.topnav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.topnav a {
  font-size: 13px; color: var(--text-muted); padding: 6px 10px; border-radius: var(--radius-sm);
}
.topnav a:hover { color: var(--text); background: var(--surface-muted); text-decoration: none; }

/* ---------------------------------------------------------------- footer */
.footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer__inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.footer__trust { font-size: 12px; color: var(--text-muted); }
.footer__trust strong { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card--pad { padding: 20px; }
.card__title { font-size: 16px; font-weight: 600; }
.muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* labels — uppercase small-caps tracking for meta sections */
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--surface-muted); }
.btn--sm { padding: 6px 10px; font-size: 13px; }
.btn--block { width: 100%; }
.btn-quiet {
  font: inherit; font-size: 12px; color: var(--text-muted); background: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 3px 8px; cursor: pointer;
}
.btn-quiet:hover { background: var(--surface-muted); color: var(--text); }

/* ---------------------------------------------------------------- forms */
.field { width: 100%; }
label.label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.input, .textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 64px; }

.form-msg { font-size: 13px; display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.form-msg--error { color: var(--danger); }

/* ---------------------------------------------------------------- chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; line-height: 1; padding: 5px 10px; border-radius: 999px;
  background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.chip--mono { font-family: var(--font-mono); }
.chip--ok { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.chip--accent { background: var(--accent-soft); color: var(--accent-ink-text); border-color: #c9d6e5; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  letter-spacing: .03em; padding: 3px 8px; border-radius: 5px;
}
.badge--ok { background: var(--success-soft); color: var(--success); border: 1px solid #a7f3d0; }

/* clickable suggestion chips (fill the composer) */
.suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest__btn {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 12px;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.suggest__btn:hover { background: var(--accent-soft); border-color: var(--accent); }

/* context chip (active profile) */
.context {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px;
}

/* ---------------------------------------------------------------- tables */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data thead th {
  position: sticky; top: 0;
  background: var(--surface-muted); color: var(--text-muted);
  font-weight: 600; text-align: left; white-space: nowrap;
  padding: 8px 12px; border-bottom: 1px solid var(--border-strong);
  font-size: 12px; letter-spacing: .02em;
}
table.data tbody td {
  padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: top;
  color: var(--text);
}
table.data tbody tr:nth-child(even) { background: var(--surface-muted); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-caption { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ---------------------------------------------------------------- code / SQL disclosure */
.disclosure { margin-top: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.disclosure > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; background: var(--surface-muted); font-size: 13px; color: var(--text);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { background: var(--surface-sunken); }
.disclosure[open] > summary { border-bottom: 1px solid var(--border); }
.disclosure__chevron { transition: transform .15s; color: var(--text-muted); }
.disclosure[open] .disclosure__chevron { transform: rotate(90deg); }
.disclosure__body { padding: 12px; background: var(--surface); }
.code-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
pre.code {
  margin: 0; background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; color: var(--text);
}

/* ---------------------------------------------------------------- answer / transcript */
.transcript { display: flex; flex-direction: column; gap: 20px; }
.qa__question {
  font-size: 14px; color: var(--text-muted); display: flex; gap: 8px; align-items: baseline;
  margin-bottom: 8px;
}
.qa__question b { color: var(--text-strong); font-weight: 600; }
.answer__text { white-space: pre-wrap; font-size: 15.5px; color: var(--text); line-height: 1.6; }
.answer__section + .answer__section { margin-top: 14px; }
.feedback { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.feedback__label { color: var(--text-muted); }

.notice {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px;
}
.notice--warn { background: var(--warning-soft); border: 1px solid var(--warning-border); color: #92400e; }

/* spinner / loading */
.indicator { display: none; align-items: center; gap: 10px; color: var(--text-muted); font-size: 14px; }
.htmx-request .indicator, .htmx-request.indicator { display: inline-flex; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- login / centered */
.centered { flex: 1 0 auto; display: flex; align-items: center; justify-content: center; padding: 24px 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand__mark { font-size: 20px; }
.positioning { font-size: 14px; color: var(--text-muted); margin-top: 6px; }

/* ---------------------------------------------------------------- profile cards */
.profile-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.profile-card {
  text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; cursor: pointer; font: inherit; color: inherit;
  display: flex; flex-direction: column; gap: 8px; transition: border-color .12s, box-shadow .12s;
}
.profile-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.profile-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.profile-card__name { font-weight: 600; font-size: 15px; color: var(--text-strong); }
.profile-card__type { font-size: 12px; color: var(--text-muted); }
.profile-card__icon {
  width: 36px; height: 36px; border-radius: 8px; background: var(--accent-soft);
  color: var(--accent-ink-text); display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.profile-card__desc { font-size: 13px; color: var(--text); }
.profile-card__examples { font-size: 12px; color: var(--text-muted); }
.profile-card__examples li { margin-top: 2px; }

/* ---------------------------------------------------------------- briefing (server-rendered fragment compat) */
.brief-header {
  background: var(--accent); color: #fff; border-radius: var(--radius-lg);
  padding: 22px 24px; margin-bottom: 20px;
}
.brief-header .eyebrow { color: rgba(255,255,255,.75); }
.brief-header h2 { color: #fff; font-size: 18px; margin-top: 4px; }
.brief-header__sub { color: rgba(255,255,255,.7); font-size: 12px; margin-top: 8px; }
.brief-grid { display: grid; gap: 16px; }
.brief-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px;
}
.brief-section h3 { font-size: 15px; font-weight: 600; }
.brief-section--na { background: var(--warning-soft); border-color: var(--warning-border); }
.brief-figure { display: flex; align-items: baseline; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); }
.brief-figure:last-child { border-bottom: none; }
.brief-figure__label { font-size: 13px; color: var(--text-muted); }
.brief-figure__val { font-weight: 600; color: var(--text-strong); }
.brief-narrative { font-size: 13px; color: var(--text-muted); margin-top: 10px; }
.dir-up-good, .dir-down-good { color: var(--success); }
.dir-up-bad, .dir-down-bad { color: var(--danger); }
.dir-flat { color: var(--text-faint); }

/* ---------------------------------------------------------------- responsive */
@media (min-width: 640px) {
  .profile-grid { grid-template-columns: repeat(2, 1fr); }
  .brief-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .container { padding: 16px 14px; }
  .topbar__inner, .footer__inner { padding-left: 14px; padding-right: 14px; }
  .footer__inner { flex-direction: column; align-items: flex-start; }
  .brand__by { display: none; }
}
