/* Hudson+Co contacts. Palette "ledger slate": cool paper, ink, one cobalt accent, red reserved for do-not-email.
   The spreadsheets' own cell colours are content, so the chrome stays out of their way. */
:root {
  --ink: #16202e;
  --ink-2: #3b4657;
  --muted: #5c6779;
  --paper: #f4f6f8;
  --panel: #ffffff;
  --rule: #dce1e8;
  --rule-2: #c7ced8;
  --accent: #2747d9;
  --accent-soft: #e8ecfd;
  --stop: #b8322a;
  --stop-soft: #fbeceb;
  --ok: #1f7a4d;
  --grid: #e3e7ed;
  --sans: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --radius: 6px;
  --sidebar: 212px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--sans); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #d8dee8; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: #fff; padding: 2px 10px 2px; }
.brand-sub { font-size: 12px; color: #8b97aa; padding: 0 10px 18px; }
.nav a { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 10px; border-radius: var(--radius); color: #d8dee8; text-decoration: none; font-weight: 500; }
.nav a:hover { background: #222e40; }
.nav a[aria-current="page"] { background: #fff; color: var(--ink); }
.nav a .count { font-family: var(--mono); font-size: 11.5px; color: #8b97aa; }
.nav a[aria-current="page"] .count { color: var(--muted); }
.side-foot { margin-top: auto; font-size: 12.5px; color: #8b97aa; padding: 10px; border-top: 1px solid #2a3547; }
.side-foot button { background: none; border: 0; color: #d8dee8; padding: 0; cursor: pointer; text-decoration: underline; }
.main { min-width: 0; padding: 22px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.025em; margin: 0; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.lede { color: var(--muted); margin: 4px 0 0; }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule-2); background: var(--panel); border-radius: var(--radius); padding: 7px 12px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d38b5; }
.btn.danger { color: var(--stop); border-color: #e7b9b5; }
.btn.danger:hover { background: var(--stop-soft); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .label { font-size: 12px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  border: 1px solid var(--rule-2); border-radius: var(--radius); background: var(--panel); padding: 7px 10px; min-width: 0; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

/* ---------- search + filters */
.searchbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.searchbar input[type=search] { flex: 1; font-size: 16px; padding: 11px 14px; border-color: var(--rule-2); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { font-size: 13px; padding: 6px 9px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; font-weight: 600; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 5px; }
.picker { position: relative; }
.picker-pop { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; width: 340px; background: var(--panel); border: 1px solid var(--rule-2); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(22,32,46,.14); padding: 8px; }
.picker-pop input { width: 100%; margin-bottom: 6px; }
.picker-list { max-height: 300px; overflow: auto; }
.picker-list button { display: flex; justify-content: space-between; width: 100%; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 4px; cursor: pointer; gap: 10px; }
.picker-list button:hover, .picker-list button:focus-visible { background: var(--paper); }
.picker-list .n { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.resultbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.resultbar .total { font-weight: 700; }

/* ---------- table */
.tablewrap { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: #fafbfc; position: sticky; top: 0; }
.grid th button { border: 0; background: none; font: inherit; color: inherit; cursor: pointer; padding: 0; }
.grid th button[aria-sort] { color: var(--ink); }
.grid td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover td { background: #f7f9fc; }
.grid tbody tr.is-unsub td { color: var(--muted); }
.grid tbody tr.is-unsub .email { text-decoration: line-through; text-decoration-color: var(--stop); }
.grid td.mark { width: 6px; padding: 0; }
.grid td.mark span { display: block; width: 6px; min-height: 37px; height: 100%; }
.grid .email { font-family: var(--mono); font-size: 12.5px; }
.grid .who { font-weight: 600; }
.tag { display: inline-block; font-size: 12px; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 0 6px; margin: 0 4px 3px 0; white-space: nowrap; }
.tag.more { background: none; border-style: dashed; }
.stop { display: inline-block; font-size: 11px; font-weight: 700; color: var(--stop); background: var(--stop-soft); border-radius: 4px; padding: 1px 6px; letter-spacing: .02em; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.18); vertical-align: -2px; }
.swatch.text { border-radius: 50%; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- drawer */
.scrim { position: fixed; inset: 0; background: rgba(22,32,46,.28); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--panel); z-index: 41; overflow-y: auto; box-shadow: -12px 0 40px rgba(22,32,46,.18); }
.drawer-head { position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--rule); padding: 18px 24px 14px; z-index: 2; display: flex; justify-content: space-between; gap: 12px; }
.drawer-head h2 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.drawer-body { padding: 18px 24px 40px; display: flex; flex-direction: column; gap: 26px; }
.close { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.banner { border-radius: var(--radius); padding: 10px 14px; }
.banner.stop { display: block; font-size: 14px; font-weight: 500; letter-spacing: 0; color: #7d211b; background: var(--stop-soft); border: 1px solid #efc6c2; }
.banner.info { background: var(--accent-soft); color: #1b2f8f; }
.banner.ok { background: #e7f5ee; color: #155c39; }
.banner.err { background: var(--stop-soft); color: #7d211b; }

/* ---------- the signature: each original spreadsheet row, as it was */
.origin { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.origin-head { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; background: #fafbfc; border-bottom: 1px solid var(--rule); font-size: 13px; flex-wrap: wrap; }
.origin-head b { font-weight: 700; }
.sheet { overflow-x: auto; }
.sheet table { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
.sheet th, .sheet td { border: 1px solid #d4d9e0; padding: 4px 8px; white-space: nowrap; }
.sheet thead th { background: #eef1f4; color: var(--muted); font-weight: 500; font-family: var(--mono); font-size: 11px; text-align: center; }
.sheet .hdr td { background: #f7f8fa; font-weight: 600; color: var(--ink-2); font-size: 12px; }
.sheet .rownum { background: #eef1f4; color: var(--muted); font-family: var(--mono); font-size: 11px; text-align: right; width: 1%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.history { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--grid); }

/* ---------- markets index */
.index { columns: 3 260px; column-gap: 28px; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 18px; }
.index .letter { break-after: avoid; font-weight: 800; font-size: 18px; margin: 10px 0 4px; color: var(--accent); }
.index .letter:first-child { margin-top: 0; }
.index a { display: flex; justify-content: space-between; gap: 10px; padding: 3px 4px; text-decoration: none; color: var(--ink); border-radius: 4px; break-inside: avoid; }
.index a:hover { background: var(--paper); }
.index a .n { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; }
.card .v { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card .k { font-size: 12.5px; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }

.drop { border: 2px dashed var(--rule-2); border-radius: var(--radius); padding: 28px; text-align: center; background: var(--panel); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--ink); }
.login form { width: min(380px, 100%); background: var(--panel); border-radius: 10px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login .brand { color: var(--ink); padding: 0; font-size: 24px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.2); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand-sub, .side-foot { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .main { padding: 16px 14px 50px; }
  .form-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
