/* ─────────────────────────────────────────────────────────────────────────────
   Design tokens. --brand is overwritten at runtime from the client record, so
   nothing in this file hard-codes a customer's identity.
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --brand: #1a1a1a;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, white);
  --brand-line: color-mix(in srgb, var(--brand) 22%, white);

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --line: #e5e7eb;
  --line-strong: #d3d7de;

  --text: #14161a;
  --text-2: #565d6b;
  --text-3: #878e9b;

  --ok: #157347;
  --ok-bg: #e8f5ee;
  --warn: #9a6700;
  --warn-bg: #fdf5e2;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --info: #0b5cad;
  --info-bg: #e8f1fb;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.011em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--brand); }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.hidden { display: none !important; }

/* ── buttons ── */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--brand); border-color: var(--brand); opacity: .88; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: rgba(0, 0, 0, .05); border-color: transparent; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, white); }
.btn-danger:hover:not(:disabled) { background: var(--bad-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ── inputs ── */
.input, .select, .textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%23878e9b' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; }
.label { font-size: 13px; font-weight: 500; color: var(--text-2); display: block; margin-bottom: 5px; }
.field-error { color: var(--bad); font-size: 13px; margin-top: 5px; }
.input.invalid, .textarea.invalid, .select.invalid { border-color: var(--bad); }

/* ── surfaces ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ── badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge-new { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-shortlisted { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-approved { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-rejected { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* ── score pill ── */
.score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.score-high { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.score-mid { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.score-low { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

/* ── app shell ── */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 232px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brandmark { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brandmark img { width: 30px; height: 30px; border-radius: var(--r-sm); object-fit: contain; }
.brandmark .initial {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); padding: 0 8px; margin-bottom: 6px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 9px; border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav .count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.content { padding: 24px 26px 60px; flex: 1; }
.content-narrow { max-width: 880px; }

/* ── tables ── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 0 12px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.selected { background: var(--brand-soft); }

/* ── empty & loading ── */
.empty { text-align: center; padding: 56px 24px; color: var(--text-2); }
.empty h3 { margin-bottom: 6px; color: var(--text); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--brand);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%);
  background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: var(--r-sm);
}
@keyframes sk { to { background-position: -200% 0; } }

/* ── drawer ── */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .35);
  z-index: 40; animation: fade .14s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg); z-index: 41;
  display: flex; flex-direction: column; animation: slide .18s cubic-bezier(.32, .72, 0, 1);
}
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
@keyframes slide { from { transform: translateX(18px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ── modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .4);
  z-index: 50; display: grid; place-items: center; padding: 20px; animation: fade .14s ease;
}
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: min(520px, 100%); max-height: 88vh; display: flex; flex-direction: column;
}
.modal-head { padding: 18px 20px 0; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ── toast ── */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff; padding: 10px 15px; border-radius: var(--r-sm);
  font-size: 14px; box-shadow: var(--shadow-lg); animation: slide .18s ease; max-width: 380px;
}
.toast.err { background: var(--bad); }

/* ── segmented filter ── */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button {
  appearance: none; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-2); padding: 5px 11px; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg .n { font-variant-numeric: tabular-nums; opacity: .55; margin-left: 4px; }

/* ── audio player ── */
.player { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.player audio { flex: 1; height: 34px; min-width: 0; }

/* ── public form ── */
.form-page { max-width: 620px; margin: 0 auto; padding: 40px 20px 80px; }
.form-head { text-align: center; margin-bottom: 32px; }
.form-head .logo {
  max-height: 76px;      /* the client's mark should be recognisable, not a footnote */
  max-width: min(260px, 70%);
  object-fit: contain;
  margin-bottom: 20px;
}
.form-head .initial-lg {
  width: 52px; height: 52px; border-radius: var(--r); margin: 0 auto 18px;
  background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 600;
}
.q { padding: 20px 0; border-bottom: 1px solid var(--line); }
.q:last-of-type { border-bottom: 0; }
.q-label { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.q-help { font-size: 13.5px; color: var(--text-2); margin-bottom: 12px; }
.req { color: var(--bad); margin-left: 3px; }

.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 11px; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); cursor: pointer;
  transition: border-color .12s, background .12s; font-size: 14.5px;
}
.choice:hover { border-color: var(--brand); }
.choice.on { border-color: var(--brand); background: var(--brand-soft); font-weight: 500; }
.choice input { accent-color: var(--brand); width: 16px; height: 16px; flex: none; }

.scale-row { display: flex; gap: 6px; flex-wrap: wrap; }
.scale-row button {
  flex: 1; min-width: 40px; appearance: none; font: inherit; font-weight: 500;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  border-radius: var(--r-sm); padding: 10px 0; cursor: pointer; transition: all .12s;
}
.scale-row button:hover { border-color: var(--brand); color: var(--text); }
.scale-row button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.scale-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-top: 7px; }

.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 26px; }
.stepper .bar { flex: 1; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.stepper .bar > i { display: block; height: 100%; background: var(--brand); transition: width .3s cubic-bezier(.32, .72, 0, 1); }

.rec { border: 1px solid var(--line-strong); border-radius: var(--r); padding: 16px; background: var(--surface-2); }
.rec-prompt { font-size: 14.5px; line-height: 1.55; margin-bottom: 14px; padding: 12px 14px; background: var(--surface); border-radius: var(--r-sm); border: 1px solid var(--line); }
.rec-btn {
  width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  transition: transform .12s, background .12s; flex: none;
}
.rec-btn:hover { transform: scale(1.04); }
.rec-btn.recording { background: var(--bad); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(180, 35, 24, .12); } }
.level { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; flex: 1; }
.level > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .08s; }
.timer { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text-2); min-width: 42px; }

/* ── auth ── */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(400px, 100%); }

/* ── builder ── */
.builder { display: grid; grid-template-columns: 210px 1fr; gap: 18px; align-items: start; }
.palette { position: sticky; top: 88px; }
.palette-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-sm); cursor: pointer; font: inherit; font-size: 13.5px; margin-bottom: 5px;
}
.palette-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.fld { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); margin-bottom: 10px; }
.fld-head { display: flex; align-items: center; gap: 10px; padding: 11px 13px; cursor: pointer; }
.fld-body { padding: 0 13px 14px; border-top: 1px solid var(--line); }
.fld-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 13px; }
.handle { color: var(--text-3); cursor: grab; font-size: 15px; line-height: 1; }

@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; z-index: 45; }
  .side.open { transform: none; }
  .builder { grid-template-columns: 1fr; }
  .palette { position: static; }
  .content { padding: 18px 16px 50px; }
  .fld-grid { grid-template-columns: 1fr; }
}
