/* Adamard brand palette.
 *
 * Taken from the live site's own theme, not invented: the values match
 * /opt/adamard/frontend/src/utils/brandTheme.js and the `theme` row in
 * app_settings that the marketing site actually renders with
 * (accent #d97757 "Refined Terracotta", warm near-black ground, warm paper in
 * light mode).
 *
 * The dashboard originally shipped with a cool blue/purple palette I chose
 * without reference to any brand asset, which is why it read as generic. Only
 * these tokens changed — every rule below is untouched. */
:root {
  --bg: #141413;
  --surface: #1c1c1a;
  --surface-2: #26261f;
  --border: #34342c;
  --text: #faf9f5;
  --text-dim: #b0aea5;
  --text-faint: #85837a;
  --accent: #d97757;          /* brand terracotta */
  --accent-dim: #c2603f;
  --ok: #788c5d;              /* brand sage */
  --warn: #e8b04b;
  --danger: #cf5f4a;
  --demo: #6a9bcc;            /* brand secondary — distinct from accent, so the
                                 demo badge never reads as a normal action */
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(0,0,0,.4);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2eee2;
    --surface: #f7f3e9;
    --surface-2: #e6e0d1;
    --border: #d8d1bf;
    --text: #2d2924;
    --text-dim: #5f584d;
    --text-faint: #8b8377;
    --shadow: 0 4px 20px rgba(45,41,36,.10);
  }
}

* { box-sizing: border-box; }

/* The `hidden` attribute must actually hide things.
 *
 * The UA stylesheet's [hidden] { display: none } is an attribute selector with
 * specificity (0,1,0) — the same as a class selector. Author styles win ties
 * against the UA sheet, so `.app { display: flex }` and
 * `.login-wrap { display: grid }` below silently defeated it, and BOTH views
 * rendered at once: the login screen filled the viewport while the dashboard
 * sat 100vh below the fold. Login worked; it just looked like nothing happened.
 *
 * !important is the right tool here, not a shortcut: `hidden` is a browser-level
 * assertion that an element is not relevant, and no layout rule should be able
 * to override it. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; color: var(--text-dim); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 1.25rem 1.25rem;
  display: flex; align-items: center; gap: .6rem;
  font-weight: 650; font-size: 1.05rem;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--demo));
  display: grid; place-items: center;
  color: #fff; font-size: .85rem; font-weight: 700;
}

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .6rem; }
.nav button {
  display: flex; align-items: center; gap: .65rem;
  width: 100%; text-align: left;
  padding: .55rem .7rem;
  background: none; border: 0; border-radius: var(--radius-sm);
  color: var(--text-dim); font: inherit; font-size: .9rem; cursor: pointer;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.active { background: var(--accent); color: #fff; font-weight: 500; }
.nav .ico { width: 16px; text-align: center; opacity: .9; }

.sidebar-foot { margin-top: auto; padding: 1rem 1.25rem 0; border-top: 1px solid var(--border); }
.who { font-size: .8rem; color: var(--text-faint); margin-bottom: .5rem; word-break: break-all; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; gap: 1rem;
}
.content { padding: 1.5rem; max-width: 1080px; width: 100%; }

/* ---------- pieces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-bottom: 1rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }

.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; }
.stat .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: .35rem; }
.stat .value { font-size: 1.7rem; font-weight: 650; letter-spacing: -.02em; }
.stat .sub { font-size: .8rem; color: var(--text-dim); margin-top: .15rem; }

.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .55rem; border-radius: 100px;
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-ok { background: rgba(120,140,93,.16); color: var(--ok); border-color: rgba(120,140,93,.38); }
.badge-warn { background: rgba(232,176,75,.15); color: var(--warn); border-color: rgba(232,176,75,.38); }
.badge-danger { background: rgba(207,95,74,.15); color: var(--danger); border-color: rgba(207,95,74,.38); }
.badge-demo { background: rgba(106,155,204,.18); color: var(--demo); border-color: rgba(106,155,204,.45); }
.badge-dim { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }

/* Demo-mode banner: deliberately loud. Nobody should be able to mistake a demo
   action for a real one, internally or in front of a guest. */
.demo-banner {
  display: flex; align-items: flex-start; gap: .7rem;
  background: rgba(106,155,204,.12);
  border: 1px solid rgba(106,155,204,.5);
  border-left: 3px solid var(--demo);
  border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: 1rem;
}
.demo-banner .t { font-weight: 650; color: var(--demo); font-size: .85rem; margin-bottom: .15rem; }
.demo-banner .d { font-size: .85rem; color: var(--text-dim); }

.notice { border-radius: var(--radius); padding: .75rem 1rem; font-size: .87rem; margin-bottom: 1rem; }
.notice-info { background: rgba(217,119,87,.10); border: 1px solid rgba(217,119,87,.35); color: var(--text-dim); }
.notice-warn { background: rgba(232,176,75,.10); border: 1px solid rgba(232,176,75,.38); color: var(--text-dim); }

button.btn {
  font: inherit; font-size: .88rem; font-weight: 500;
  padding: .5rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  cursor: pointer;
}
button.btn:hover { border-color: var(--text-faint); }
button.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn-primary:hover { background: var(--accent-dim); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.btn-sm { padding: .3rem .6rem; font-size: .8rem; }

input, textarea, select {
  font: inherit; font-size: .9rem; width: 100%;
  padding: .55rem .7rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 76px; font-family: inherit; }
label { display: block; font-size: .8rem; font-weight: 500; color: var(--text-dim); margin-bottom: .3rem; }
.field { margin-bottom: .85rem; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
td { padding: .6rem; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable:hover { background: var(--surface-2); cursor: pointer; }
.table-wrap { overflow-x: auto; }

.mono { font-family: var(--mono); font-size: .85em; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: .82rem; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: .6rem; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.stack { display: flex; flex-direction: column; gap: .5rem; }

/* ---------- onboarding ---------- */
.steps { display: flex; gap: .4rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.step {
  flex: 1; min-width: 120px;
  padding: .6rem .75rem; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  font-size: .82rem; color: var(--text-faint);
}
.step .n { font-weight: 700; margin-right: .4rem; }
.step.active { border-color: var(--accent); color: var(--text); background: rgba(217,119,87,.09); }
.step.done { border-color: var(--ok); color: var(--ok); }

.chip-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 100px; padding: .25rem .6rem; font-size: .8rem; display: inline-flex; align-items: center; gap: .4rem; }
.chip button { background: none; border: 0; color: var(--text-faint); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }

.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: 1.75rem; text-align: center; color: var(--text-dim);
  cursor: pointer; background: var(--surface-2);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--text); }

/* ---------- pricing ---------- */
.tier {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; position: relative;
  display: flex; flex-direction: column;
}
.tier.recommended { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tier .rec-flag {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700;
  padding: .15rem .6rem; border-radius: 100px; letter-spacing: .04em;
}
.tier .price { font-size: 1.9rem; font-weight: 680; letter-spacing: -.03em; margin: .4rem 0 .1rem; }
.tier .per { font-size: .8rem; color: var(--text-faint); }
.tier ul { list-style: none; padding: 0; margin: 1rem 0; font-size: .86rem; color: var(--text-dim); flex: 1; }
.tier li { padding: .3rem 0; display: flex; gap: .5rem; }
.tier li::before { content: "✓"; color: var(--ok); flex-shrink: 0; }
.tier li.off { color: var(--text-faint); }
.tier li.off::before { content: "—"; color: var(--text-faint); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 380px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 1.5rem; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); max-width: 680px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 1.25rem; }

.transcript { font-size: .87rem; }
.turn { padding: .5rem .7rem; border-radius: var(--radius-sm); margin-bottom: .4rem; }
.turn.caller { background: var(--surface-2); }
.turn.ai { background: rgba(217,119,87,.10); }
.turn .role { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: .15rem; }

.chat { max-height: 320px; overflow-y: auto; padding-right: .3rem; }
.msg { margin-bottom: .6rem; display: flex; }
.msg .bubble { padding: .5rem .8rem; border-radius: 12px; max-width: 78%; font-size: .88rem; }
.msg.ai .bubble { background: var(--surface-2); border-bottom-left-radius: 3px; }
.msg.me { justify-content: flex-end; }
.msg.me .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-faint); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: .6rem; overflow-x: auto; }
  .brand { padding: 0 .75rem 0 .5rem; }
  .nav { flex-direction: row; }
  .nav button { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .content { padding: 1rem; }
}
