/* Campaign Planner. All text/background pairs are >= 4.5:1. */
:root {
  --bg: #f0f3f4; --surface: #ffffff; --surface-2: #e6ecee; --line: #cbd5d9;
  --ink: #12252b; --ink-2: #3a4f56; --ink-3: #4d6169;
  --accent: #0b5f73; --accent-ink: #ffffff; --accent-soft: #d7ecf1;
  --good: #146c2e; --warn: #8a4b00; --bad: #a3271f; --info: #1d4f91;
  --focus: #0b5f73;
  --serif: 'Libre Baskerville', Georgia, serif; --sans: 'Open Sans', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a1e; --surface: #16262c; --surface-2: #1d3239; --line: #35505a;
    --ink: #eaf2f4; --ink-2: #c3d3d8; --ink-3: #a9bcc2;
    --accent: #6cc3d8; --accent-ink: #06222a; --accent-soft: #1d3a44;
    --good: #6fd08a; --warn: #f0b060; --bad: #ff8f86; --info: #8ab8f0; --focus: #6cc3d8;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1a1e; --surface: #16262c; --surface-2: #1d3239; --line: #35505a;
  --ink: #eaf2f4; --ink-2: #c3d3d8; --ink-3: #a9bcc2;
  --accent: #6cc3d8; --accent-ink: #06222a; --accent-soft: #1d3a44;
  --good: #6fd08a; --warn: #f0b060; --bad: #ff8f86; --info: #8ab8f0; --focus: #6cc3d8;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 7rem; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
a { color: var(--accent); } a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 3px; }
.muted { color: var(--ink-3); } .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header + nav */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .row { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; padding: .6rem 1rem; max-width: 1400px; margin: 0 auto; }
.brand { font: 700 1.05rem var(--serif); margin-right: auto; }
.tabs { display: flex; gap: .25rem; }
.tabs a { padding: .35rem .8rem; border-radius: 6px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
.who { color: var(--ink-3); font-size: .85rem; display: flex; gap: .75rem; align-items: center; }
.totals { display: flex; flex-wrap: wrap; gap: .5rem 1.75rem; padding: .5rem 1rem .7rem; max-width: 1400px; margin: 0 auto; }
.total b { display: block; font: 700 1.15rem var(--serif); font-variant-numeric: tabular-nums; }
.total span { font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.viewdate { display: flex; align-items: center; gap: .5rem; margin-left: auto; font-size: .9rem; }
.jump { display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: 0 1rem .5rem; max-width: 1400px; margin: 0 auto; font-size: .85rem; }

main.page { max-width: 1400px; margin: 0 auto; padding: 1rem; display: grid; gap: 1.25rem; }
section.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; overflow-x: auto; }
section.card > header { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin-bottom: .75rem; }
section.card > header h2 { margin: 0 auto 0 0; }

/* controls */
.button, button { font: 600 .9rem var(--sans); padding: .4rem .85rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
.button.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.danger, button.danger { color: var(--bad); border-color: var(--bad); }
.button.small, button.small { padding: .15rem .55rem; font-size: .8rem; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--ink-3); border-radius: 6px; padding: .35rem .5rem; max-width: 100%; }
label { font-weight: 600; font-size: .85rem; display: block; margin-bottom: .2rem; }
.field { margin-bottom: .85rem; } .field .hint { font-size: .8rem; color: var(--ink-3); font-weight: 400; }
.inline { display: inline-flex; gap: .4rem; align-items: center; } .inline label { margin: 0; font-weight: 400; }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .4rem .55rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); white-space: nowrap; }
th.num, td.num { text-align: right; }
tr.group td { background: var(--surface-2); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
tfoot td { font-weight: 700; border-top: 2px solid var(--ink-3); }
.swatch { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; background: var(--ch); border: 1px solid var(--ink-3); vertical-align: -1px; margin-right: .3rem; }
.swatch.off { opacity: .3; }
.chan-head { border-bottom: 3px solid var(--ch); }

/* status + notices */
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .75rem; font-weight: 700; border: 1px solid currentColor; }
.pill.live { color: var(--good); } .pill.paused { color: var(--warn); } .pill.upcoming { color: var(--info); }
.pill.ended, .pill.none { color: var(--ink-3); } .pill.undated { color: var(--warn); }
.notice { padding: .55rem .8rem; border-left: 4px solid var(--info); background: var(--surface-2); border-radius: 4px; margin: .5rem 0; }
.notice.error { border-color: var(--bad); } .notice.warn { border-color: var(--warn); } .notice.ok { border-color: var(--good); }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: .5rem; }
.legend a { display: flex; gap: .5rem; align-items: baseline; padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); background: var(--surface); }
.legend a[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.legend b { font-variant-numeric: tabular-nums; }

/* map */
.mapwrap { position: relative; }
.mapctl { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; margin-bottom: .6rem; }
svg.map { width: 100%; height: auto; display: block; background: var(--surface-2); border-radius: 8px; }
svg.map text { font-family: var(--sans); fill: var(--ink); }
svg.map .state { fill: var(--surface); stroke: var(--ink-3); stroke-width: .6; }
svg.map .state.sel { fill: var(--accent-soft); }
svg.map .dma { stroke: var(--ink-3); stroke-dasharray: 4 3; stroke-width: 1; fill: none; }
svg.map .dma-fill { fill: var(--accent); opacity: .12; }
svg.map .leader { stroke: var(--ink-2); stroke-width: 1; fill: none; }
svg.map .pin { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
svg.map .pin.idle { fill: var(--surface); stroke: var(--ink-2); stroke-width: 2; }
svg.map .pin.planned { fill: var(--surface); stroke: var(--ink-2); stroke-dasharray: 2 2; stroke-width: 2; }
svg.map .card rect.bg { fill: var(--surface); stroke: var(--ink-3); }
svg.map .card.sel rect.bg { stroke: var(--accent); stroke-width: 2.5; }
svg.map .card { cursor: pointer; }
svg.map .card text.name { font-weight: 700; font-size: 12.5px; } svg.map .card text.amt { font-size: 12px; fill: var(--ink-2); }
svg.map .lbl { font-size: 11px; fill: var(--ink-2); }
svg.map .dot.live { fill: var(--good); } svg.map .dot.paused { fill: var(--warn); } svg.map .dot.upcoming { fill: var(--info); }
svg.map .dot.ended, svg.map .dot.none { fill: var(--ink-3); } svg.map .dot.undated { fill: var(--warn); }

/* gantt */
.gantt { min-width: 900px; font-size: .8rem; }
.gantt .axis, .gantt .row { display: grid; grid-template-columns: 220px 1fr; align-items: center; }
.gantt .axis .track { position: relative; height: 1.4rem; border-bottom: 1px solid var(--line); }
.gantt .tick { position: absolute; top: 0; font-size: .7rem; color: var(--ink-3); border-left: 1px solid var(--line); padding-left: 3px; height: 100%; }
.gantt .track { position: relative; height: 1.5rem; }
.gantt .today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); z-index: 3; }
.gantt .grp { grid-column: 1 / -1; background: var(--surface-2); font-weight: 700; font-size: .75rem; text-transform: uppercase; padding: .2rem .5rem; margin-top: .5rem; }
.gantt .lab { padding: .1rem .5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt .lab.sub { padding-left: 1.6rem; color: var(--ink-3); }
.gantt .win { position: absolute; top: 2px; bottom: 2px; border: 2px dashed var(--ink-3); border-radius: 4px; }
.gantt .win span { position: absolute; left: 4px; top: -1px; font-size: .68rem; background: var(--surface); padding: 0 3px; color: var(--ink-2); }
.gantt .bar { position: absolute; top: 5px; bottom: 5px; border-radius: 3px; background: var(--ch); border: 1px solid var(--ink-3); }
.gantt a.rowlink { display: contents; color: inherit; text-decoration: none; }
.gantt a.rowlink:hover .lab { text-decoration: underline; }

/* DMA cards (optimization) */
.dmagrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.dmacard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; }
.dmacard h3 { display: flex; justify-content: space-between; gap: .5rem; }
.dmacard ul { margin: .25rem 0 .5rem; padding-left: 1.1rem; }
.strip { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.strip span { font-size: .78rem; border: 1px solid var(--line); border-radius: 6px; padding: .1rem .4rem; }
.planning { border-top: 1px dashed var(--line); margin-top: .6rem; padding-top: .5rem; font-size: .88rem; color: var(--ink-2); }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 50; overflow-y: auto; padding: 1rem 1.25rem 0; border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,.25); }
.drawer[hidden], .drawer-backdrop[hidden] { display: none; }
.drawer { transition: transform .18s ease; }
.drawer { --drawer-w: min(560px, 100vw); width: var(--drawer-w); }
/* Narrow screens: the editor covers the drawer beneath, which fades back so it reads as a card behind. */
.drawer.under { transform: translateX(-2rem); opacity: .55; pointer-events: none; }
/* Wide screens: the editor opens to the left of the drawer beneath, so both stay fully visible. */
@media (min-width: 1250px) {
  #drawer-2 { right: var(--drawer-w); }
  #drawer.under { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }
@media (min-width: 1100px) { body.has-inspector main.page { margin-right: min(580px, 40vw); } main.page { transition: margin-right .18s ease; } }
.drawer .close { float: right; }
.editor .rowbox { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem; margin-bottom: .6rem; }
.editor .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.editor .actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem -1.25rem 0; position: sticky; bottom: 0; background: var(--surface); padding: .7rem 1.25rem; border-top: 1px solid var(--line); }
section.card.editor .actions { margin: 1rem 0 0; padding-left: 0; padding-right: 0; position: static; }
.tabsub { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .75rem; }
.tabsub a { padding: .25rem .7rem; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; font-size: .85rem; }
.tabsub a[aria-current="page"] { background: var(--accent-soft); font-weight: 700; }

.login { max-width: 460px; margin: 12vh auto; padding: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
@media (max-width: 720px) { .editor .grid2 { grid-template-columns: 1fr; } .viewdate { margin-left: 0; } }

.kv td.num { text-align: left; }
.kv th { width: 12rem; }
label > input, label > select { display: block; font-weight: 400; font-size: 1rem; margin-top: .2rem; }
.label-like { font-weight: 600; font-size: .85rem; display: block; margin-bottom: .2rem; }
@media (max-width: 900px) { .mapwrap { overflow-x: auto; } svg.map { min-width: 820px; } }
@media (min-width: 901px) { svg.map { max-height: calc(100vh - 17rem); min-height: 480px; } }

dl.facts { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1rem; margin: .5rem 0 1rem; }
dl.facts div { border-bottom: 1px solid var(--line); padding-bottom: .4rem; }
dl.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
dl.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.chip { padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 8px; }
ul.plain { list-style: none; padding: 0; margin: .25rem 0 1rem; } ul.plain li { padding: .15rem 0; }
.drawer h3 { margin-top: 1.1rem; }

/* Drawers slide in from the right and back out; the page's backdrop fades in. */
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes drawer-out { from { transform: none; } to { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }
.drawer.enter { animation: drawer-in .26s cubic-bezier(.2, .8, .2, 1); }
.drawer.leave { animation: drawer-out .2s ease-in forwards; pointer-events: none; }
.drawer-backdrop:not([hidden]) { animation: fade-in .2s ease-out; }
/* Side by side: the editor comes out from behind the detail drawer. */
@media (min-width: 1250px) { #drawer-2 { z-index: 49; } }
@media (prefers-reduced-motion: reduce) { .drawer.enter, .drawer.leave, .drawer-backdrop:not([hidden]) { animation: none; } }
