:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --border: #e4e1da;
  --text: #1c1b19;
  --text-2: #5f5b53;
  --text-3: #8d887e;
  --accent: #c2410c;
  --accent-soft: #fde7d9;
  --ok: #15803d;
  --ok-soft: #dcf3e3;
  --warn: #a16207;
  --warn-soft: #fbf0cf;
  --bad: #b91c1c;
  --bad-soft: #fde2e2;
  --bar-track: #ebe8e1;
  --shadow: 0 1px 2px rgba(28, 27, 25, .05), 0 4px 16px rgba(28, 27, 25, .04);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211;
    --surface: #1c1b1a;
    --surface-2: #252422;
    --border: #2f2d2a;
    --text: #f1efea;
    --text-2: #b4afa5;
    --text-3: #807b72;
    --accent: #fb923c;
    --accent-soft: #3a2416;
    --ok: #4ade80;
    --ok-soft: #173222;
    --warn: #facc15;
    --warn-soft: #352c10;
    --bad: #f87171;
    --bad-soft: #3b1a1a;
    --bar-track: #2c2a27;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --surface: #1c1b1a; --surface-2: #252422; --border: #2f2d2a;
  --text: #f1efea; --text-2: #b4afa5; --text-3: #807b72; --accent: #fb923c;
  --accent-soft: #3a2416; --ok: #4ade80; --ok-soft: #173222; --warn: #facc15;
  --warn-soft: #352c10; --bad: #f87171; --bad-soft: #3b1a1a; --bar-track: #2c2a27;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1;
}
a { color: var(--accent); }
code, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .92em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.dim { color: var(--text-3); }
.small { font-size: 12px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 16px 48px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 11px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.logo svg { width: 24px; height: 24px; }
h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.subtitle { margin: 0; color: var(--text-2); font-size: 13px; }
.actions { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn svg { width: 16px; height: 16px; }
.btn.spinning svg { animation: spin .8s linear infinite; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font: inherit; font-weight: 500; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.demo-banner { background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }

/* Summary tiles */
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile-label { color: var(--text-2); font-size: 12px; font-weight: 500; }
.tile-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.tile-value .of { font-size: 16px; color: var(--text-3); font-weight: 500; }
.tile-note { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.tile.warn .tile-note { color: var(--warn); }
.tile.bad .tile-note { color: var(--bad); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"] {
  flex: 1 1 240px; height: 36px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
.select { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.select select { height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.check-label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; cursor: pointer; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.is-maxed { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.card-head { display: flex; align-items: center; gap: 12px; }
.th { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-content: center; text-align: center; font-size: 10px; color: var(--text-2); font-weight: 600; line-height: 1.1; }
.th b { display: block; font-size: 18px; color: var(--text); }
.who { flex: 1; min-width: 0; }
.who h2 { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring {
  --p: 0; flex: none; width: 48px; height: 48px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--bar-track) 0);
  display: grid; place-items: center;
}
.card.is-maxed .ring { background: conic-gradient(var(--ok) 100%, var(--bar-track) 0); }
.ring span { width: 38px; height: 38px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.stats { display: flex; flex-wrap: wrap; gap: 6px; }
.stats span { background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 2px 10px; font-size: 12px; }

.next { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }
.next.done { background: var(--ok-soft); }
.next-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 600; }
.next-text { font-size: 13px; }
.check { width: 28px; height: 28px; border-radius: 8px; background: var(--ok); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }

.chip {
  --h: 220; flex: none; width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: hsl(var(--h) 70% 92%); color: hsl(var(--h) 60% 30%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 80% 80%); }
}
:root[data-theme="dark"] .chip { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 80% 80%); }
.chip.sm { width: 28px; height: 28px; font-size: 10px; border-radius: 8px; }
.chip.xs { width: 20px; height: 20px; font-size: 8px; border-radius: 6px; }

.heroes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hero { display: flex; align-items: center; gap: 10px; }
.hero-main { flex: 1; min-width: 0; }
.hero-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.hero-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-lvl { font-weight: 600; }
.bar { position: relative; height: 6px; border-radius: 99px; background: var(--bar-track); overflow: visible; }
.bar span { display: block; height: 100%; border-radius: 99px; background: var(--warn); }
.hero.max .bar span { background: var(--ok); }
.hero.rush .bar span { background: var(--bad); }
.bar .tick { position: absolute; top: -2px; width: 2px; height: 10px; background: var(--text-3); border-radius: 1px; opacity: .6; }

.badge { flex: none; min-width: 52px; text-align: center; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.muted { background: var(--surface-2); color: var(--text-3); }

.bb { font-size: 12px; color: var(--text-2); border-top: 1px dashed var(--border); padding-top: 10px; }

details { border-top: 1px solid var(--border); padding-top: 8px; }
summary { cursor: pointer; font-weight: 600; font-size: 13px; list-style: none; display: flex; align-items: center; gap: 6px; padding: 2px 0; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "›"; display: inline-block; width: 12px; color: var(--text-3); transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
.count { background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 0 8px; font-size: 11px; font-weight: 500; }
.eq-group { margin-top: 10px; }
.eq-owner { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.eq-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; }
.eq-list li { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 4px 8px; border-radius: 6px; }
.eq-list li:nth-child(odd) { background: var(--surface-2); }
.eq-list li.max .eq-lvl { color: var(--ok); }
.eq-name { min-width: 0; }
.eq-lvl { font-weight: 600; white-space: nowrap; }
.tag { font-size: 10px; font-weight: 600; padding: 0 6px; border-radius: 4px; vertical-align: 1px; }
.tag.epic { background: hsl(280 70% 92%); color: hsl(280 55% 38%); }
.tag.on { background: var(--accent-soft); color: var(--accent); }

/* Table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { width: 100%; border-collapse: collapse; min-width: 760px; }
.grid th, .grid td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--border); }
.grid th { font-size: 12px; color: var(--text-2); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
.grid th .chip { margin: 0 auto; }
.grid tr:last-child td { border-bottom: 0; }
.grid .left { text-align: left; padding-left: 14px; }
.t-name { font-weight: 600; }
.t-tag { color: var(--text-3); font-size: 11px; }
.th-sm { display: inline-block; min-width: 28px; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); font-weight: 700; }
.cell b { font-weight: 700; }
.cell span { color: var(--text-3); font-size: 11px; }
.cell.max { background: var(--ok-soft); }
.cell.max b { color: var(--ok); }
.cell.behind { background: var(--warn-soft); }
.cell.rush, .cell.locked { background: var(--bad-soft); }
.cell.rush b, .cell.locked b { color: var(--bad); }
.na { color: var(--text-3); }
.mini-bar { width: 64px; height: 6px; margin: 0 auto 2px; border-radius: 99px; background: var(--bar-track); overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: var(--accent); }
.ok-text { color: var(--ok); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--text-2); font-size: 12px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: -8px; vertical-align: -2px; }
.sw.max { background: var(--ok-soft); border: 1px solid var(--ok); }
.sw.behind { background: var(--warn-soft); border: 1px solid var(--warn); }
.sw.rush { background: var(--bad-soft); border: 1px solid var(--bad); }

/* Errors / setup */
.errors { display: grid; gap: 8px; margin-bottom: 14px; }
.error-card { background: var(--bad-soft); color: var(--text); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.setup { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); max-width: 720px; }
.setup h2 { margin: 0 0 6px; font-size: 18px; }
.setup ol { padding-left: 20px; display: grid; gap: 10px; margin: 16px 0 20px; }
.setup ul { margin: 6px 0 0; padding-left: 18px; }
.note { background: var(--warn-soft); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.empty { color: var(--text-3); text-align: center; padding: 40px 0; }

.foot { margin-top: 32px; color: var(--text-3); font-size: 12px; max-width: 720px; }

body.is-loading main { opacity: .55; transition: opacity .2s; }

@media (max-width: 860px) {
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
  .tile-value { font-size: 22px; }
  .card { padding: 14px; }
}
