/* SMEK Digital rank tracker: one design for every screen, light and dark.
   Swap fonts here (and the font URL in BRAND in app/web/main.py); swap logos in BRAND. */
:root {
  --font-head: "Source Serif 4", Georgia, "Times New Roman", serif;   /* later: "SMEK Editorial" if licensed */
  --font-body: Inter, "Segoe UI", system-ui, sans-serif;               /* later: "SMEK Advisory" if licensed */
  --radius: 0px;          /* advanced: square, editorial */
  --radius-soft: 8px;     /* simple: a little warmer */
}


[data-theme="light"] {
  --bg: #FAF7F0; --surface: #FFFDF8; --surface-2: #F3EFE5; --side: #F3EFE5;
  --line: #E2DCCD; --line-strong: #CFC7B4;
  --ink: #1D3230; --muted: #5F6A67; --faint: #8A928F;
  --brand: #173E3A; --accent: #2D7F78; --accent-ink: #FFFFFF; --link: #1F6A63; --gold: #A88A47; --gold-soft: #F1E8D3;
  --up: #2F7D3A; --down: #A8432F;
  --rank-top: #4E8A2A; --rank-top-ink: #FFFFFF; --rank-mid: #E0A72E; --rank-mid-ink: #2A2110;
  --rank-low: #B5432F; --rank-low-ink: #FFFFFF; --rank-none: #7D8784; --rank-none-ink: #FFFFFF;
  --tint-top: #EAF2E2; --own-row: #EAF3F1; --comp-row: #F7F0E1;
  --chart-own: #173E3A; --chart-own-2: #2D7F78; --chart-maps: #A88A47; --chart-grid: #ECE6D8;
  --chart-a: #4E8A2A; --chart-b: #1F6A63;
}
[data-theme="dark"] {
  --bg: #0E1B19; --surface: #13231F; --surface-2: #182C28; --side: #0B1715;
  --line: #233A35; --line-strong: #2F4B45;
  --ink: #E8E3D6; --muted: #A2ADA9; --faint: #7A8783;
  --brand: #CFE3DF; --accent: #4FA79E; --accent-ink: #0E1B19; --link: #7CC3BA; --gold: #D4BB84; --gold-soft: #2E2A1E;
  --up: #7BC47F; --down: #E58A73;
  --rank-top: #5FA83A; --rank-top-ink: #0E1B19; --rank-mid: #E8B44A; --rank-mid-ink: #1B1508;
  --rank-low: #D2654E; --rank-low-ink: #0E1B19; --rank-none: #6E7A76; --rank-none-ink: #F1EEE6;
  --tint-top: #1C3322; --own-row: #17302C; --comp-row: #2A2619;
  --chart-own: #CFE3DF; --chart-own-2: #4FA79E; --chart-maps: #D4BB84; --chart-grid: #1E332F;
  --chart-a: #5FA83A; --chart-b: #7CC3BA;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font-body);
  font-feature-settings: "tnum" 1, "cv11" 1; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; } a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; color: var(--brand); letter-spacing: -0.01em; }
h1 { font-size: 30px; line-height: 1.15; margin: 4px 0 6px; }
h2 { font-size: 20px; margin: 0 0 10px; } h3 { font-size: 17px; margin: 0 0 10px; }
h4 { font: 600 11px/1.4 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .big { font-size: 16px; }
.up { color: var(--up); } .down { color: var(--down); }

/* shell: quiet left navigation + content */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); padding: 22px 18px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: block; color: var(--brand) !important; text-decoration: none !important; }
.logo img { display: block; max-width: 168px; height: auto; }
.wordmark { font: 600 22px var(--font-head); color: var(--brand); letter-spacing: .02em; }
.wordmark em { font-style: normal; color: var(--gold); }
.product { display: block; margin-top: 8px; font: 600 10.5px var(--font-body); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sidenav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidenav a { color: var(--ink); padding: 7px 10px; border-left: 2px solid transparent; font-size: 13.5px; }
.sidenav a.sub { padding-left: 14px; color: var(--muted); }
.sidenav a:hover { text-decoration: none; background: var(--surface-2); color: var(--ink); }
.sidenav a.on { border-left-color: var(--accent); color: var(--brand); background: var(--surface); font-weight: 500; }
.navlabel { font: 600 10.5px var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); padding: 14px 10px 4px; }
.sidefoot { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.sidefoot form { margin: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-strong); }
.seg button { border-radius: 0;  background: transparent; border: 0; padding: 6px 0; font: 500 12px var(--font-body); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--bg); }
.linkbtn { background: none; border: 0; padding: 2px 0; color: var(--muted); font: 12.5px var(--font-body); cursor: pointer; text-align: left; }
.linkbtn:hover { color: var(--ink); text-decoration: underline; }
.content { padding: 28px 40px 80px; max-width: 1320px; width: 100%; }


/* surfaces: flat, hairline borders, generous spacing */
.card { background: var(--surface); border: 1px solid var(--line); padding: 22px 24px; margin: 0 0 20px; }
.card.narrow { max-width: 760px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(500px, 1fr)); gap: 20px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } .two, .grid { grid-template-columns: 1fr; } .content { padding: 20px; } }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.crumbs { margin: 0; font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; }
.crumbs a { color: var(--muted); }

/* numbers as headlines */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0; border: 1px solid var(--line); background: var(--surface); margin: 14px 0 20px; }
.tile { padding: 18px 20px; border-right: 1px solid var(--line); }
.tile:last-child { border-right: 0; }
.tile b { display: block; font: 600 40px/1.05 var(--font-head); color: var(--brand); letter-spacing: -0.02em; }
.tile span { color: var(--muted); font-size: 13px; display: block; margin-top: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 0; margin: 10px 0 16px; border: 1px solid var(--line); background: var(--surface); }
.stats > div { padding: 12px 18px; border-right: 1px solid var(--line); min-width: 110px; }
.stats > div:last-child { border-right: 0; }
.stats b { display: block; font: 600 26px/1.1 var(--font-head); color: var(--brand); }
.stats span { font-size: 12px; color: var(--muted); }
.card .stats, .card .tiles { margin: 6px 0 14px; }
.project h2 a { color: var(--brand); }

/* lists, movers */
.movers ul, ul.plain { margin: 0; padding: 0; list-style: none; }
.movers li, ul.plain li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.movers li:last-child, ul.plain li:last-child { border-bottom: 0; }
h3.up::before, h4.up::before { content: "▲ "; } h3.down::before, h4.down::before { content: "▼ "; }
h3.up, h4.up { color: var(--up); } h3.down, h4.down { color: var(--down); }

/* controls */
.toggle { display: inline-flex; border: 1px solid var(--line-strong); background: var(--surface); }
.toggle a { padding: 6px 14px; color: var(--muted); font-size: 13px; }
.toggle a.on { background: var(--brand); color: var(--bg); }
.toggle a:hover { text-decoration: none; }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin: 8px 0 22px; }
.tabs a { padding: 9px 0; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13.5px; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--accent); font-weight: 500; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 18px; }
input, select, textarea { font: 13.5px var(--font-body); padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 2px;
  background: var(--surface); color: var(--ink); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
button, .button { font: 500 13px var(--font-body); padding: 7px 14px; border: 1px solid var(--brand); background: var(--brand); color: var(--bg);
  border-radius: 2px; cursor: pointer; display: inline-block; }
.button.secondary, button.secondary { background: transparent; color: var(--brand); }
.button:hover { text-decoration: none; opacity: .92; }
.pill { padding: 4px 12px; border: 1px solid var(--line-strong); color: var(--muted); font-size: 12.5px; }
.pill.on { border-color: var(--brand); color: var(--brand); background: var(--surface-2); }
label.check { display: inline-flex; gap: 6px; align-items: center; margin-right: 10px; }

/* tables: dense but calm, 13.5px */
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
table.data th { font: 600 11px var(--font-body); text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:hover td { background: var(--surface-2); }
td.n, th.n { text-align: right; white-space: nowrap; } .hide { display: none; }
tr.own td { background: var(--own-row); } tr.comp td { background: var(--comp-row); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border: 1px solid var(--line-strong); color: var(--muted); border-radius: 2px; }
.flash { padding: 10px 14px; margin: 0 0 16px; border: 1px solid var(--accent); background: var(--surface); }
.flash.error { border-color: var(--down); }

/* rank colours (pins, dots, grid table): never the brand green */
.dot { display: inline-block; min-width: 34px; text-align: center; padding: 2px 8px; font-weight: 600; font-size: 12.5px; border-radius: 2px; }
.dot.green, .pin.green, .gridtable td.green { background: var(--rank-top); color: var(--rank-top-ink); }
.dot.amber, .pin.amber, .gridtable td.amber { background: var(--rank-mid); color: var(--rank-mid-ink); }
.dot.red, .pin.red, .gridtable td.red { background: var(--rank-low); color: var(--rank-low-ink); }
.dot.grey, .pin.grey, .gridtable td.grey { background: var(--rank-none); color: var(--rank-none-ink); }
.pin { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  font: 600 12px var(--font-body); border: 2px solid var(--surface); }
.gridtable { border-collapse: separate; border-spacing: 3px; margin-top: 10px; }
.gridtable td { width: 34px; height: 28px; text-align: center; font: 600 12px var(--font-body); border-radius: 2px; }
.mapbox { height: 460px; border: 1px solid var(--line); } .mapbox.small { height: 300px; }
.mapnote { padding: 14px 16px; border: 1px dashed var(--gold); background: var(--gold-soft); color: var(--ink); }
.pinpop { font: 13px var(--font-body); color: #1D3230; }

/* charts */
.chartbox { position: relative; height: 340px; } .chartbox.short { height: 230px; }
.chart-controls { margin-top: 8px; color: var(--muted); }
.chart-controls a { margin: 0 4px; }

/* advanced keyword table extras */
.strip { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); margin: 12px 0; background: var(--surface); }
.strip button { background: transparent; color: var(--ink); border: 0; border-right: 1px solid var(--line); text-align: left; padding: 8px 14px; border-radius: 0; }
.strip button.on { box-shadow: inset 0 -2px 0 var(--accent); }
.strip button b { font: 600 18px var(--font-head); color: var(--brand); } .strip button small { color: var(--muted); }
td.d { text-align: center; white-space: nowrap; } td.d.in10 { background: var(--tint-top); }
.tablewrap { overflow-x: auto; }
.menu { position: relative; } .menu summary { cursor: pointer; list-style: none; }
.menu-list { position: absolute; z-index: 5; background: var(--surface); border: 1px solid var(--line-strong); padding: 10px 14px; min-width: 220px; }
.gridstats b { font-size: 30px; }
/* stat blocks as an even grid of hairline cells */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; background: var(--line); }
.stats > div { background: var(--surface); border-right: 0; min-width: 0; }
.card .stats { grid-template-columns: repeat(3, 1fr); }
.tiles { gap: 1px; background: var(--line); } .tile { background: var(--surface); border-right: 0; }
.tile b em, .stats b em { font-style: normal; }
.tile b em.up { color: var(--up); } .tile b em.down { color: var(--down); }
.stats b { white-space: nowrap; font-size: 24px; }
.gridtable td { width: 46px; height: 38px; font-size: 14px; } .gridtable { border-spacing: 4px; }

/* ---------------------------------------------------------------- shared pieces the mock-ups did not cover */
.banner { font-size: 13px; padding: 8px 12px; margin: 0 0 18px; border: 1px solid var(--gold); background: var(--gold-soft); color: var(--ink); }
.banner.muted { border-color: var(--line); background: var(--surface); color: var(--muted); }
.flash.ok { border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.form-grid .wide { grid-column: 1 / -1; } .form-grid button { justify-self: start; }
.form-grid label.check { flex-direction: row; color: var(--ink); font-size: 13.5px; }
fieldset { border: 1px solid var(--line); padding: 10px 14px; margin: 0; }
legend { font: 600 11px var(--font-body); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 6px; }
textarea { width: 100%; }
input.short { width: 220px; }
form.inline { display: inline; }
button.link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }
tr.muted td { color: var(--faint); } tr.bad td { background: var(--comp-row); }
.narrow { max-width: 760px; }
details summary { cursor: pointer; }
.newloc { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.newloc label { display: block; margin: 6px 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline .date { font-variant-numeric: tabular-nums; color: var(--muted); margin-right: 8px; }
.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--line); margin: 8px 0 12px; }
.bar div { height: 100%; background: var(--accent); } .bar div.warn { background: var(--down); }
.legend span { margin-right: 14px; display: inline-block; }
.costtable td, .costtable th { text-align: right; } .costtable td:first-child, .costtable th:first-child { text-align: left; }
.colchooser .menu-list { min-width: 220px; }
.colchooser summary.button { display: inline-block; }

/* sign-in and error pages (no navigation) */
.bare { max-width: 420px; margin: 9vh auto 40px; padding: 0 20px; }
.bare-logo { margin-bottom: 22px; } .bare-logo img { max-width: 190px; height: auto; }
.login label { display: block; margin: 12px 0; font-size: 13px; color: var(--muted); }
.login input { width: 100%; margin-top: 5px; font-size: 15px; padding: 9px 11px; }
.login button { margin-top: 6px; padding: 9px 18px; }

/* mobile menu button (hidden on wide screens) */
.sidehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.menubtn { display: none; }

/* ---------------------------------------------------------------- phone and small laptop widths */
@media (max-width: 900px) {
  .shell { display: block; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; gap: 10px; }
  .menubtn { display: inline-block; background: transparent; color: var(--brand); border: 1px solid var(--line-strong); padding: 5px 12px; }
  .sidenav, .sidefoot { display: none; }
  body.navopen .sidenav, body.navopen .sidefoot { display: flex; }
  .logo img { max-width: 140px; }
  .content { padding: 18px 16px 60px; }
  h1 { font-size: 24px; }
  .two, .grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr !important; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  table.data { display: block; overflow-x: auto; white-space: nowrap; }
  table.data td { white-space: nowrap; }
  .tabs { overflow-x: auto; gap: 16px; }
  .strip button { flex: 1 1 45%; }
  .card .stats { grid-template-columns: repeat(2, 1fr); }
  .mapbox { height: 340px; }
}

/* ---------------------------------------------------------------- simple mode: same character, warmer, easier
   Bigger numbers, one plain sentence each, softer corners, 15px body text (never below 14px), clear green wins. */
body.simple { font-size: 15px; }
body.simple .small, body.simple .muted.small, body.simple p.small { font-size: 14px; }
body.simple .card, body.simple .tiles, body.simple .mapbox, body.simple .mapnote, body.simple .flash,
body.simple input, body.simple select, body.simple button, body.simple .button, body.simple .seg { border-radius: var(--radius-soft); }
body.simple .tiles { overflow: hidden; }
body.simple .tile { padding: 22px 22px 20px; }
body.simple .tile b { font-size: 48px; }
body.simple .tile span { font-size: 15px; color: var(--ink); line-height: 1.4; margin-top: 8px; }
body.simple .tile .why { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }
body.simple h1 { font-size: 32px; }
body.simple .lede { font-size: 16px; color: var(--muted); margin: 0 0 6px; max-width: 760px; }
body.simple table.data { font-size: 15px; }
body.simple table.data th { font-size: 12px; }
body.simple .dot { font-size: 14px; min-width: 40px; padding: 3px 10px; border-radius: 6px; }
body.simple ul.plain li { padding: 10px 0; font-size: 15px; }
body.simple .wins li::before { content: "▲ "; color: var(--up); font-weight: 600; }
body.simple .losses li::before { content: "▼ "; color: var(--down); font-weight: 600; }
body.simple .gridtable td { border-radius: 6px; }
body.simple .stats { border-radius: var(--radius-soft); overflow: hidden; }
body.simple .sidenav a.on { border-radius: 0 6px 6px 0; }
@media (max-width: 900px) { body.simple .tile b { font-size: 40px; } body.simple h1 { font-size: 26px; } }
/* keep wide tables inside their own scroll box */
.shell { grid-template-columns: 236px minmax(0, 1fr); }
.content { min-width: 0; }
#kwtable td:first-child { min-width: 220px; }
#kwtable td.small, #kwtable td:nth-child(2) { white-space: nowrap; }
body.simple h4 { font-size: 13px; }
@media (max-width: 900px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  body.simple .tile { padding: 16px; } body.simple .tile b { font-size: 34px; } body.simple .tile span { font-size: 14px; }
  .head { align-items: flex-start; }
}
@media (max-width: 900px) { .stats > div:last-child:nth-child(odd) { grid-column: span 2; } }
@media (min-width: 901px) { .card .stats > div:last-child:nth-child(3n+1) { grid-column: span 3; } .card .stats > div:last-child:nth-child(3n+2) { grid-column: span 2; } }
