/* Edwards & Co — CS Assistant
   Tokens taken from the edwardsandco.nz Shopify theme. Gotham is licensed, so
   Montserrat (headings) and Figtree (body) — the theme's own fallbacks — are used. */

:root {
  --accent: #f94e1a;
  --accent-hover: #c72e00;
  --accent-light: #ffc0ad;
  --accent-fade: rgba(249, 78, 26, 0.06);
  --ink: #413e3e;
  --text: #555959;
  --text-light: #888b8b;
  --bg: #ffffff;
  --bg-soft: #f4f4f3;
  --bg-softer: #fafaf9;
  --border: #e7e6e3;
  --success: #3f8f52;
  --success-bg: rgba(86, 173, 106, 0.14);
  --warn: #a35b00;
  --warn-bg: #fff1dc;
  --error: #721c24;
  --error-bg: #f8d7da;
  --neutral-bg: #eeeeec;
  --radius-pill: 300px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(65, 62, 62, 0.04), 0 4px 16px rgba(65, 62, 62, 0.05);
  --font-head: "Montserrat", "Gotham", sans-serif;
  --font-body: "Figtree", "Gotham", sans-serif;
  --font-serif: "Playfair Display", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg-softer);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); }
a:hover { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-head); color: var(--ink); margin: 0; }
h1 { font-weight: 900; font-size: 28px; letter-spacing: -0.01em; }
h2 { font-weight: 800; font-size: 17px; }
h3 { font-weight: 700; font-size: 14px; }
.serif { font-family: var(--font-serif); font-weight: 500; font-style: italic; }
.muted { color: var(--text-light); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 24px;
  height: 68px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 30px; width: auto; display: block; }
.brand .wordmark { font-family: var(--font-head); font-weight: 900; color: var(--ink); font-size: 18px; }
.brand .app {
  font-family: var(--font-head); font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
  padding-left: 12px; border-left: 1px solid var(--border);
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  text-decoration: none; color: var(--text); font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius-pill);
}
.nav a:hover { background: var(--bg-soft); color: var(--ink); }
.nav a.active { background: var(--ink); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user { font-size: 13px; color: var(--text-light); }

.page { max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head p { margin: 6px 0 0; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.grid-wide { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); align-items: start; }
.grid-run { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) {
  .grid-2, .grid-run, .grid-wide { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 12px; padding-bottom: 8px; gap: 10px 16px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .topbar-right .user, .topbar-right .badge { display: none; }
  .brand .wordmark { white-space: nowrap; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.card-body { padding: 20px 22px; }
.card-body.flush { padding: 0; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { padding: 18px 18px 16px; }
.kpi .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-light); }
.kpi .value { font-family: var(--font-head); font-weight: 900; font-size: 30px; color: var(--ink); margin: 6px 0 2px; line-height: 1.1; }
.kpi .sub { font-size: 12.5px; color: var(--text-light); }
.kpi.accent { background: var(--ink); border-color: var(--ink); }
.kpi.accent .label, .kpi.accent .sub { color: rgba(255,255,255,0.65); }
.kpi.accent .value { color: #fff; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-head); font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
  padding: 10px 20px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--ink); background: var(--bg); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--ink); color: #fff; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); }
.btn-sm { padding: 6px 14px; font-size: 12px; }

input[type=text], input[type=email], input[type=search], input[type=password], input[type=number], select {
  font: inherit; color: var(--ink);
  border: 1px solid var(--border); background: var(--bg);
  padding: 9px 16px; border-radius: var(--radius-pill); outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-fade); }
select { padding-right: 34px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.filters input[type=search] { flex: 1; min-width: 220px; }

.segmented { display: inline-flex; background: var(--bg-soft); border-radius: var(--radius-pill); padding: 4px; }
.segmented a { text-decoration: none; padding: 6px 14px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 600; color: var(--text); }
.segmented a.on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--neutral-bg); color: var(--text); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-drafted { background: var(--success-bg); color: var(--success); }
.badge-needs_human { background: var(--warn-bg); color: var(--warn); }
.badge-error, .badge-failed { background: var(--error-bg); color: var(--error); }
.badge-not_cs, .badge-skipped { background: var(--neutral-bg); color: var(--text-light); }
.badge-queued, .badge-running { background: var(--accent-fade); color: var(--accent-hover); }
.badge-shadow { background: #ecebff; color: #4a43a8; }
.badge-assist { background: var(--success-bg); color: var(--success); }
.badge-cat { background: var(--bg-soft); color: var(--ink); }
.badge-cat::before { display: none; }

/* ---------- Tables ---------- */
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-light); padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg-softer);
}
.table td.when { white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.link-row { cursor: pointer; }
.table tr.link-row:hover td { background: var(--accent-fade); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .summary { color: var(--ink); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* ---------- Charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.bar-stack { flex: 1; width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 2px 2px; overflow: hidden; background: var(--bg-soft); }
.bar-stack span { display: block; width: 100%; }
.seg-drafted { background: var(--accent); }
.seg-human { background: var(--accent-light); }
.seg-other { background: #d9d8d4; }
.bar-label { font-size: 10.5px; color: var(--text-light); white-space: nowrap; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-light); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.hbar-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 12px; align-items: center; padding: 9px 0; }
.hbar-row + .hbar-row { border-top: 1px dashed var(--border); }
.hbar-track { height: 10px; background: var(--bg-soft); border-radius: var(--radius-pill); overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: var(--radius-pill); }
.hbar-fill.noncs { background: #cfcdc8; }
.hbar-label { font-size: 13.5px; color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-meta { font-size: 12.5px; color: var(--text-light); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Run detail ---------- */
.meta-list { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; margin: 0; font-size: 14px; }
.meta-list dt { color: var(--text-light); }
.meta-list dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.message {
  white-space: pre-wrap; background: var(--bg-softer); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px; color: var(--ink); font-size: 14.5px; line-height: 1.6;
}
.draft {
  white-space: pre-wrap; background: #fff; border: 1.5px solid var(--accent-light);
  border-radius: 12px; padding: 18px 20px; color: var(--ink); font-size: 15px; line-height: 1.65;
}
.callout { border-radius: 12px; padding: 14px 16px; font-size: 14px; }
.callout-warn { background: var(--warn-bg); color: #6b3d00; }
.callout-error { background: var(--error-bg); color: var(--error); }
.callout-info { background: var(--bg-soft); color: var(--ink); }
.stack > * + * { margin-top: 20px; }
.section-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-light); margin: 0 0 8px; }
.sources { margin: 0; padding-left: 18px; }
.sources li { margin: 4px 0; color: var(--ink); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: -6px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 3px solid var(--accent); }
.timeline .dot.err { border-color: var(--error); }
.timeline .dot.model { border-color: var(--ink); }
.timeline .t-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--ink); font-weight: 600; }
.timeline details { margin-top: 6px; }
.timeline summary { cursor: pointer; font-size: 12.5px; color: var(--text-light); }
.timeline pre { white-space: pre-wrap; word-break: break-word; background: var(--bg-softer); border: 1px solid var(--border); border-radius: 8px; padding: 10px; max-height: 260px; overflow: auto; margin: 6px 0 0; }

.rating-group { display: flex; flex-wrap: wrap; gap: 8px; }
.rating-group button.on { background: var(--ink); color: #fff; }
.meter { height: 8px; border-radius: var(--radius-pill); background: var(--bg-soft); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }

/* ---------- Integrations ---------- */
.int-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 800px) { .int-grid { grid-template-columns: 1fr; } }
.int-card .card-body { display: flex; flex-direction: column; gap: 14px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-dot.ok { background: var(--success); }
.status-dot.no { background: #c9c7c2; }
code.inline { background: var(--bg-soft); padding: 2px 8px; border-radius: 6px; font-size: 12.5px; color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Messages & empty ---------- */
.flash { max-width: 1240px; margin: 16px auto 0; padding: 0 24px; }
.flash div { padding: 12px 18px; border-radius: 12px; font-size: 14px; margin-bottom: 8px; }
.flash .success { background: var(--success-bg); color: #24572f; }
.flash .error { background: var(--error-bg); color: var(--error); }
.flash .info { background: var(--bg-soft); color: var(--ink); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-light); }
.empty h3 { margin-bottom: 6px; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; border-top: 1px solid var(--border); font-size: 13px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-form label { font-size: 13px; font-weight: 600; color: var(--ink); }
.login-form input { width: 100%; }

.attn { display: block; text-decoration: none; padding: 12px 0; }
.attn + .attn { border-top: 1px dashed var(--border); }
.attn-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.attn-title { color: var(--ink); font-weight: 600; font-size: 14px; }
.attn-ticket { font-size: 12px; color: var(--text-light); white-space: nowrap; }
.attn .badge { margin-top: 6px; }
