/* AdTycoon — a quiet "ad manager" look: cool slate neutrals, ink-blue accent, mono numbers. */
:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f6f8fb;
  --text: #16202d;
  --muted: #5b6878;
  --line: #dde3ea;
  --accent: #2c55c9;
  --accent-ink: #ffffff;
  --good: #16865a;
  --good-bg: #e3f4ec;
  --warn: #a8660b;
  --warn-bg: #fbf0dc;
  --bad: #c0392f;
  --bad-bg: #fbe6e3;
  --learn: #6a47b8;
  --learn-bg: #efe9fb;
  --c1: #2c55c9;
  --c2: #d9822b;
  --c3: #16865a;
  --c4: #9b4dca;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e131a; --panel: #151c26; --panel-2: #1a2230; --text: #e5eaf1; --muted: #93a0b2; --line: #263142;
    --accent: #7d9dff; --accent-ink: #0e131a;
    --good: #4fcf94; --good-bg: #133226; --warn: #f0b457; --warn-bg: #3a2b12; --bad: #ff7d70; --bad-bg: #3d1a17; --learn: #b79bff; --learn-bg: #2a2140;
    --c1: #7d9dff; --c2: #f0a256; --c3: #4fcf94; --c4: #c68cf0;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e131a; --panel: #151c26; --panel-2: #1a2230; --text: #e5eaf1; --muted: #93a0b2; --line: #263142;
  --accent: #7d9dff; --accent-ink: #0e131a;
  --good: #4fcf94; --good-bg: #133226; --warn: #f0b457; --warn-bg: #3a2b12; --bad: #ff7d70; --bad-bg: #3d1a17; --learn: #b79bff; --learn-bg: #2a2140;
  --c1: #7d9dff; --c2: #f0a256; --c3: #4fcf94; --c4: #c68cf0;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
table, input, select, button, textarea { font: inherit; color: inherit; }
h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; margin: 0 0 10px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; margin-top: 16px; }
h2 small, h3 small { font: 400 12px var(--sans); color: var(--muted); margin-left: 6px; }
small { color: var(--muted); }
.muted { color: var(--muted); }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.nowrap { white-space: nowrap; }

/* ---------- top bar ---------- */
#top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
.bar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px 22px; padding: 10px 16px; }
.logo { font: 800 20px var(--display); letter-spacing: -0.03em; align-self: center; }
.logo span { color: var(--accent); }
.stat { display: flex; flex-direction: column; min-width: 96px; }
.stat > span { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat b { font: 500 16px var(--mono); }
.stat b em { font-style: normal; font-size: 11px; color: var(--muted); }
.stat small { font-size: 11px; }
.prog { height: 4px; background: var(--line); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--accent); }
.time { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.time small { flex-basis: 100%; text-align: right; font-size: 10.5px; }
nav { display: flex; gap: 2px; padding: 0 12px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 9px 12px; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.badge { font-style: normal; font-size: 11px; background: var(--line); color: var(--text); border-radius: 9px; padding: 0 6px; }
.badge.hot { background: var(--bad); color: #fff; }

/* ---------- layout ---------- */
main { padding-block: 16px 60px; padding-inline: 16px; max-width: 1480px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-width: 0; }
.card.flush { padding: 0; }
.card.flush > h2, .pad { padding: 14px 16px 0; }
.card.flush .note { padding: 0 16px 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar.in { padding: 14px 16px 6px; }
.toolbar.in h2 { margin: 0 8px 0 0; }
.note { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; max-width: 110ch; }
.banner { padding: 12px 16px; border-radius: 8px; font-weight: 500; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.good { background: var(--good-bg); color: var(--good); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.flash { padding: 9px 14px; border-radius: 6px; background: var(--good-bg); color: var(--good); }
.flash.err { background: var(--bad-bg); color: var(--bad); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- controls ---------- */
button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
button.mini { padding: 1px 7px; font-size: 12px; }
.segs { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg { border: 0; border-radius: 0; background: var(--panel); padding: 5px 10px; font-size: 13px; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg.on { background: var(--accent); color: var(--accent-ink); }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
input[type=number], input[type=text], select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; width: 100%; min-width: 0; }
textarea { font: 12px var(--mono); resize: vertical; margin-top: 8px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px 14px; }
.fld { display: flex; flex-direction: column; gap: 3px; }
.fld > span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.fld small { font-size: 11.5px; line-height: 1.35; }
.budgetrow { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.budgetrow .fld { width: 160px; }
.crpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 6px; }
.crpick label { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; background: var(--panel-2); }
.crpick label span { display: flex; flex-direction: column; }
.crpick label.dis { opacity: 0.5; cursor: not-allowed; }
.ncgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 330px); gap: 16px; align-items: start; }
@media (max-width: 860px) { .ncgrid { grid-template-columns: 1fr; } }
.est { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.est h3 { margin-top: 0; }

/* ---------- tables ---------- */
.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
td small { display: block; font-size: 11.5px; line-height: 1.35; }
tbody tr:last-child td { border-bottom: 0; }
table.camps td, table.pl td { font-family: var(--mono); font-size: 12.5px; }
table.camps td.name { font-family: var(--sans); font-size: 13px; min-width: 220px; }
table.pl td:first-child { font-family: var(--sans); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
tr.sel td { background: var(--panel-2); box-shadow: inset 0 -1px 0 var(--accent); }
td.good, td.warn, td.bad { font-weight: 500; }
table.seas td, table.seas th { text-align: center; font-family: var(--mono); font-size: 12px; }
table.seas td:first-child { text-align: left; font-family: var(--sans); }
table.seas td.cur { background: var(--panel-2); outline: 1px solid var(--accent); }

.pill { display: inline-block; font-size: 11px; font-family: var(--sans); padding: 1px 7px; border-radius: 10px; background: var(--panel-2); color: var(--muted); white-space: nowrap; border: 1px solid var(--line); }
.pill.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.learn { background: var(--learn-bg); color: var(--learn); border-color: transparent; }
.pill.mute { opacity: 0.8; }

/* ---------- blocks ---------- */
.chart { display: block; width: 100%; }
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.alerts li { padding: 6px 10px; border-radius: 6px; font-size: 13px; border-left: 3px solid; }
.alerts li.bad { background: var(--bad-bg); border-color: var(--bad); color: var(--text); }
.alerts li.warn { background: var(--warn-bg); border-color: var(--warn); color: var(--text); }
.miles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.miles li { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; display: flex; flex-direction: column; font-family: var(--mono); }
.miles li span { font-size: 11px; color: var(--muted); }
.miles li em { font: 10px var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-style: normal; }
.miles li.done { background: var(--good-bg); border-color: transparent; }
.miles li.done b { color: var(--good); }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 14px; margin: 8px 0 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12.5px; }
.kv.wide { grid-template-columns: 150px minmax(0, 1fr); }
.kv.wide dd { text-align: left; font-family: var(--sans); font-size: 13px; }
.prods { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr)); gap: 16px; }
.prod { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.prod h3 { margin: 0 0 6px; font-size: 15px; }
.prod p { margin: 4px 0; font-size: 13px; }
.prod.locked { background: var(--panel-2); }
.meter { display: inline-block; position: relative; width: 110px; height: 7px; border-radius: 4px; background: var(--line); vertical-align: middle; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.meter b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); }
.meter.good i { background: var(--good); }
.meter.bad i { background: var(--bad); }
.detail .dhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.detail .dhead .row { margin-top: 0; align-self: flex-start; }
.detail .dhead p { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.summary { font-size: 13px; margin: 12px 0; line-height: 1.7; }
.summary b { font-family: var(--mono); font-weight: 500; }
.settings { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.rules { margin-top: 12px; }
.inbox { display: flex; flex-direction: column; gap: 8px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 6px; padding: 10px 14px; }
.msg.unread { border-left-color: var(--accent); }
.msg.good { border-left-color: var(--good); }
.msg.bad { border-left-color: var(--bad); }
.msg.decision { border-left-color: var(--warn); background: var(--warn-bg); }
.msg header { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.msg header span { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.msg p { margin: 6px 0 0; font-size: 13px; max-width: 110ch; }
.guide p, .guide li { max-width: 100ch; }
.guide h2 { margin-top: 22px; }
.guide h2:first-child { margin-top: 0; }
.guide .tw { margin: 10px 0; }

button.ghost { background: transparent; }
.tab.restart { margin-left: auto; color: var(--bad); }
button.danger.solid { background: var(--bad); color: #fff; }
.banner.confirm span { flex: 1 1 260px; color: var(--text); }
.btnlink { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; color: var(--text); background: var(--panel-2); text-decoration: none; }
.btnlink:hover { border-color: var(--muted); }
/* ---------- share popup ---------- */
body.modal-open { overflow: hidden; }
.backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgb(8 12 20 / 0.55);
            padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.dialog { width: min(520px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; box-shadow: 0 24px 60px rgb(0 0 0 / 0.3); }
.dialog .dhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog h2 { margin: 0; font-size: 19px; }
.dialog > p.muted { margin: 4px 0 0; font-size: 13px; }
.dialog textarea { font: 13px/1.5 var(--sans); margin-top: 12px; }
.dialog .flash { margin-top: 10px; }
button.x { border: 0; background: transparent; font-size: 24px; line-height: 1; padding: 2px 8px; color: var(--muted); }
button.x:hover { color: var(--text); }

/* ---------- phones ---------- */
@media (pointer: coarse) {
  button.mini { padding: 5px 11px; font-size: 13px; }
  .seg { padding: 8px 12px; }
}
@media (max-width: 640px) {
  #top { position: static; }
  .bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 10px 16px; }
  .logo { grid-column: 1 / -1; font-size: 18px; }
  .stat { min-width: 0; }
  .stat b { font-size: 14px; }
  .stat small { font-size: 10.5px; }
  .time { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; margin: 0; display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 6px;
          background: var(--panel); border-top: 1px solid var(--line); padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -4px 14px rgb(0 0 0 / 0.08); }
  .time small { display: none; }
  .time button { padding: 10px 4px; }
  main { padding-block: 12px 96px; gap: 12px; }
  .card { padding: 14px; }
  .toolbar { gap: 8px; }
  .kv.wide { grid-template-columns: 1fr; }
  .kv.wide dd { margin-bottom: 6px; }
  .budgetrow .fld { width: 100%; }
  table.camps td.name { min-width: 170px; }
  .backdrop { place-items: end center; padding: 0; }
  .dialog { border-radius: 14px 14px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
