/* DataMind dashboard — Switchboard brand tokens (same as datamindlabs.co.uk) */
:root {
  --ink: #111111;
  --bone: #F6F5F1;
  --red: #E5432D;
  --red-hover: #F05A45;
  --red-text: #C8321E;
  --grey: #BDBBB4;
  --soft: #ECEAE4;
  --muted: #5A5A5A;
  --line-dark: #3A3A3A;
  --ok: #1F7A3F;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--bone); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.label { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 2px solid var(--ink); background: transparent; font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; border-radius: 0; }
.btn:hover { background: var(--soft); }
.btn-red { background: var(--red); font-weight: 800; }
.btn-red:hover { background: var(--red-hover); }
.btn-dark { background: var(--ink); color: var(--bone); }
.btn-dark:hover { background: #2A2A2A; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--red-text); outline-offset: 2px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-name { font-weight: 900; font-stretch: 115%; letter-spacing: 0.01em; font-size: 17px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: #fff; border: 2px solid var(--ink); padding: 32px; }
.login-card h1 { font-size: 30px; line-height: 1.1; margin: 24px 0 8px; font-weight: 900; }
.login-card p { margin: 0 0 24px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field input, .field select, .field textarea { border: 2px solid var(--ink); background: #fff; padding: 10px 12px; border-radius: 0; min-height: 44px; }
.field textarea { min-height: 260px; font-family: var(--mono); font-size: 13px; line-height: 1.55; resize: vertical; }
.field .hint { font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.error { color: var(--red-text); font-weight: 600; margin: 0 0 12px; }
.success { color: var(--ok); font-weight: 600; margin: 0 0 12px; }

/* App shell */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--ink) 240px, var(--bone) 240px); }
.side { background: var(--ink); color: var(--bone); padding: 24px 16px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.side .brand { color: var(--bone); padding: 0 8px; }
.side nav { display: flex; flex-direction: column; }
.side nav a { color: var(--bone); text-decoration: none; padding: 12px 8px; border-bottom: 1px solid var(--line-dark); display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.side nav a:hover { background: #1E1E1E; }
.side nav a.active { color: var(--red); }
.side nav a .count { font-family: var(--mono); font-size: 12px; background: var(--red); color: var(--ink); padding: 1px 7px; }
.side .foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 8px; }
.side .foot .who { font-size: 13px; color: var(--grey); word-break: break-all; }
.side .foot .btn { border-color: var(--bone); color: var(--bone); }
.side .foot .btn:hover { background: #2A2A2A; }

.main { padding: 32px clamp(16px, 3vw, 40px) 64px; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h1 { font-size: 34px; line-height: 1.05; margin: 6px 0 0; font-weight: 900; }
.client-picker select { border: 2px solid var(--ink); background: #fff; min-height: 44px; padding: 0 12px; min-width: 220px; }

/* Cards / KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 2px solid var(--ink); background: #fff; margin-bottom: 28px; }
.kpi { padding: 18px 20px; border-right: 2px solid var(--ink); }
.kpi:last-child { border-right: 0; }
.kpi .value { font-size: 34px; font-weight: 900; line-height: 1.1; margin-top: 6px; }
.kpi .sub { font-size: 13px; color: var(--muted); }

.panel { background: #fff; border: 2px solid var(--ink); margin-bottom: 28px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 2px solid var(--ink); }
.panel-head h2 { font-size: 18px; margin: 0; font-weight: 800; }
.panel-body { padding: 18px; }
.empty { padding: 28px 18px; color: var(--muted); }

/* Bar chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 18px 18px 0; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.bar .fill { width: 100%; background: var(--ink); min-height: 2px; }
.bar:last-child .fill { background: var(--red); }
.bar .x { font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; }
.bars-legend { padding: 8px 18px 14px; font-size: 13px; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--soft); vertical-align: top; }
th { font-family: var(--mono); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); border-bottom: 2px solid var(--ink); white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bone); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 700; }
.cell-clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .02em; padding: 2px 8px; border: 1.5px solid var(--ink); white-space: nowrap; }
.badge.ok { border-color: var(--ok); color: var(--ok); }
.badge.fail { border-color: var(--red-text); color: var(--red-text); }
.badge.red { background: var(--red); }
.badge.dark { background: var(--ink); color: var(--bone); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
select.status { border: 2px solid var(--ink); background: #fff; min-height: 34px; padding: 0 8px; font-weight: 600; }

/* Transcript */
.transcript { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--bone); }
.msg { max-width: 75%; padding: 10px 14px; white-space: pre-wrap; word-wrap: break-word; border: 2px solid var(--ink); }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--bone); }
.msg.assistant { align-self: flex-start; background: #fff; }
.msg .meta { display: block; font-family: var(--mono); font-size: 11px; opacity: .65; margin-top: 6px; }
.lead-box { border: 2px solid var(--red); background: #fff; padding: 14px 18px; margin: 0 0 20px; }
.lead-box dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 8px 0 0; }
.lead-box dt { font-family: var(--mono); font-size: 12px; text-transform: uppercase; color: var(--muted); }
.lead-box dd { margin: 0; }

.snippet { font-family: var(--mono); font-size: 12px; background: var(--ink); color: var(--bone); padding: 14px; white-space: pre-wrap; word-break: break-all; margin: 0; }
.back { display: inline-flex; margin-bottom: 12px; font-weight: 700; text-decoration: none; }
.back:hover { text-decoration: underline; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: var(--bone); padding: 12px 18px; border: 2px solid var(--bone); z-index: 50; font-weight: 600; }

/* Phones and small tablets */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); background: var(--bone); }
  .side { position: sticky; top: 0; z-index: 20; height: auto; padding: 12px 16px; gap: 10px; }
  .side nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .side nav a { border-bottom: 0; padding: 8px 10px; white-space: nowrap; gap: 8px; }
  .side .foot { display: none; }
  .side .top-row { display: flex; justify-content: space-between; align-items: center; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 2px solid var(--ink); }
  .form-grid { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
  /* Tables become stacked cards on phones */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tfoot, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: 12px 14px; border-bottom: 2px solid var(--soft); }
  table.cards td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 96px 1fr; gap: 10px; text-align: left; }
  table.cards td::before { content: attr(data-label); font-family: var(--mono); font-size: 11px; text-transform: uppercase; color: var(--muted); padding-top: 3px; }
  table.cards td[data-label=""]::before { content: none; }
  table.cards td[data-label=""] { display: block; }
  table.cards td.num { text-align: left; }
  table.cards td > * { grid-column: 2; }
  table.cards td[data-label=""] > * { grid-column: auto; }
  .bar .x { font-size: 9px; }
  .side .top-row .btn { flex-shrink: 0; }
  .cell-clip { max-width: none; }
  .topbar h1 { font-size: 28px; }
  .client-picker select { min-width: 0; width: 100%; }
  .client-picker { width: 100%; }
}
.mobile-signout { display: none; }
@media (max-width: 900px) { .mobile-signout { display: inline-flex; border-color: var(--bone); color: var(--bone); } }
