/* Visual language shared with the ziroobank tool (tokens, cards, tables, buttons). */
:root {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #f0f2f7; --border: #e3e6ee;
  --text: #161a23; --muted: #646b7c;
  --primary: #4f46e5; --primary-ink: #ffffff; --primary-soft: #eceafd;
  --danger: #d92d3a; --danger-soft: #fdecee; --success: #138a52; --success-soft: #e3f5ec;
  --warn: #9a6400; --warn-soft: #fff4dc; --accent2: #0d9488;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117; --surface: #161b24; --surface-2: #1d2430; --border: #2a3240;
    --text: #e8ebf2; --muted: #9aa3b5;
    --primary: #8b85ff; --primary-ink: #0e1117; --primary-soft: #262a4a;
    --danger: #ff6b76; --danger-soft: #3a1a1f; --success: #4ad295; --success-soft: #16352a;
    --warn: #f5c25b; --warn-soft: #3a2f14; --accent2: #2dd4bf;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  max-width: 1180px; margin: 0 auto; padding: 0 16px 48px;
}
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .88rem; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.5rem; margin: 24px 0 4px; letter-spacing: -.01em; font-weight: 800; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
h3 { font-size: .98rem; margin: 16px 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }

/* inputs & buttons */
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: .55rem .7rem; min-width: 0;
}
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--success); cursor: pointer; padding: 0; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: .55rem .95rem;
  background: var(--primary); border: 1px solid var(--primary); color: var(--primary-ink);
  transition: filter .15s, background .15s, transform .05s;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .6; cursor: wait; }
button.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
button.ghost:hover { background: var(--surface-2); filter: none; }
button.x { background: transparent; border-color: transparent; color: var(--danger); padding: .3rem .6rem; font-size: .85rem; }
button.x:hover { background: var(--danger-soft); filter: none; }

/* header */
.top { padding-top: 4px; }
.search { display: flex; gap: 8px; }
.search input { flex: 1; }
.progress { margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.progress .bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width .2s; }
.progress span { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.error { color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); padding: 10px 12px; border-radius: 10px; font-size: .9rem; }

/* player */
.player { display: flex; align-items: center; gap: 14px; margin: 24px 0 16px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.player > div { flex: 1; min-width: 0; }
.avatar { width: 52px; height: 52px; border-radius: 12px; }
.player-name { font-size: 1.2rem; font-weight: 800; text-decoration: none; color: var(--text); }

/* stat cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; border-top: 4px solid var(--border); }
.card:nth-child(1) { border-top-color: var(--primary); }
.card:nth-child(2) { border-top-color: var(--success); }
.card:nth-child(3) { border-top-color: var(--accent2); }
.card:nth-child(4), .card:nth-child(5) { border-top-color: var(--primary); }
.card .label { color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 1.45rem; font-weight: 800; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card .hint { color: var(--muted); font-size: .82rem; }
.pos { color: var(--success); } .neg { color: var(--danger); } .warn { color: var(--warn); }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; min-width: 0; }
#compare { overflow-x: auto; }
.views { display: grid; grid-template-columns: auto repeat(5, minmax(0, 1fr)); gap: 0; font-variant-numeric: tabular-nums; margin-bottom: 12px; min-width: 520px; font-size: .92rem; }
.views > div { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.views .h { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
.views .h:first-child { border-top-left-radius: 10px; }
.views .h:nth-child(6) { border-top-right-radius: 10px; }
.notes { margin: 8px 0 0; padding-left: 18px; }
.notes li { margin: 4px 0; }
.app-form { display: flex; gap: 8px; margin-bottom: 4px; }
.app-form input { flex: 1; max-width: 260px; }
.manual-form { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; }
.manual-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.manual-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface-2); border-radius: 10px; overflow-wrap: anywhere; }
.rank { margin: 0; padding-left: 24px; }
.rank li { padding: 6px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.rank li:last-child { border-bottom: 0; }
.rank li span.r { float: right; margin-left: 8px; font-variant-numeric: tabular-nums; color: var(--muted); }
.whatif { font-size: .95rem; }
.whatif strong { font-size: 1.3rem; }
.cheap-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 16px 0 8px; flex-wrap: wrap; }
.cheap-head h3, .cheap-head h2 { margin: 0; }
.toggle { display: inline-flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--muted); cursor: pointer; }
.cheap-head select { padding: .35rem .6rem; font-size: .85rem; }

/* table */
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters input { flex: 1; min-width: 160px; }
.table-wrap { width: 100%; overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; vertical-align: middle; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: var(--surface-2); cursor: pointer; user-select: none; position: sticky; top: 0; }
th:hover { color: var(--text); }
th:first-child { border-top-left-radius: 10px; }
th:last-child { border-top-right-radius: 10px; }
th.asc::after { content: " ▲"; } th.desc::after { content: " ▼"; }
td.num, th.num { text-align: right; }
td .muted { font-size: .75rem; }
td.name { white-space: normal; min-width: 180px; }
td.name .gn { display: flex; align-items: center; gap: 8px; }
td.name img { width: 24px; height: 24px; border-radius: 6px; flex: none; }
tr.excluded td { opacity: .45; }
.flag { display: inline-flex; padding: .1rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; margin-right: 4px; background: var(--surface-2); color: var(--muted); }
.flag.perfect { background: var(--success-soft); color: var(--success); }
.flag.noplay, .flag.private { background: var(--warn-soft); color: var(--warn); }
.flag.manual, .flag.added { background: var(--primary-soft); color: var(--primary); }
.flag.unvetted { background: var(--danger-soft); color: var(--danger); }
.pbar { display: inline-block; width: 44px; height: 6px; background: var(--surface-2); border-radius: 999px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--success); border-radius: 999px; }
.foot { text-align: center; margin-top: 24px; }

@media (max-width: 720px) {
  h1 { font-size: 1.3rem; }
  .manual-form { grid-template-columns: 1fr 1fr; }
  .manual-form input:first-child { grid-column: 1 / -1; }
  .app-form input { max-width: none; }
  .card .value { font-size: 1.2rem; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 14px; }
  th:nth-child(4), td:nth-child(4) { display: none; }
}

/* external links (icons are files, masked so they follow the theme color) */
.links { display: inline-flex; gap: 2px; margin-left: 6px; vertical-align: middle; flex: none; }
a.ext[class*="i-"] { display: inline-block; width: 20px; height: 20px; border-radius: 6px; position: relative; color: var(--muted); }
a.ext[class*="i-"]::before { content: ""; position: absolute; inset: 3px; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
a.ext[class*="i-"]:hover { color: var(--primary); background: var(--primary-soft); }
a.i-store { --icon: url("icons/store.svg"); }
a.i-ach { --icon: url("icons/ach.svg"); }
a.i-sh { --icon: url("icons/sh.svg"); }
a.tlink { color: var(--text); text-decoration: none; border-bottom: 1px dotted var(--muted); }
a.tlink:hover { color: var(--primary); }
