/* TB Chest Counter — single stylesheet, no external dependencies. */

:root {
  --bg: #0f131b;
  --bg-soft: #161c27;
  --bg-card: #18202c;
  --line: #26303f;
  --text: #e8ecf5;
  --muted: #8a97ad;
  --gold: #f0b429;
  --gold-dark: #c98f16;
  --ok: #35c98a;
  --danger: #ef5f5f;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .28);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 80% -10%, #1d2637 0%, var(--bg) 60%);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

.muted { color: var(--muted); }
.small { font-size: .85em; }
.strong { font-weight: 700; }
.dim { opacity: .55; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 1.1rem .8rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; color: var(--text); font-size: 1.05rem;
  padding: .3rem .5rem .8rem;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.3rem; }
.brand-lg { font-size: 1.25rem; justify-content: center; }

.clan-badge {
  display: flex; flex-direction: column; gap: .35rem;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .55rem .7rem; margin-bottom: .6rem;
}
.clan-name { font-weight: 600; font-size: .92rem; }

.nav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .7rem; border-radius: 9px;
  color: var(--text); font-size: .93rem;
}
.nav-link:hover { background: rgba(255, 255, 255, .05); text-decoration: none; }
.nav-link.active { background: rgba(240, 180, 41, .14); color: var(--gold); font-weight: 600; }
.nav-icon { width: 1.2rem; text-align: center; }
.nav-button { width: 100%; background: none; border: 0; cursor: pointer; font: inherit; text-align: left; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: .5rem; }

.main { flex: 1; min-width: 0; padding: 1.4rem 1.6rem 2.5rem; }

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap;
}
.topbar p { margin: 0; }
.topbar-actions { display: flex; gap: .5rem; }

.foot {
  margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-size: .82rem; color: var(--muted);
}

/* ---------- cards & grids ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
.card-narrow { max-width: 640px; }
.card h3 { margin-top: 1.4rem; }
.card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.card-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.card-actions form { margin: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.1rem; align-items: start; }
/* Wide list on the left, narrow editor on the right. */
.grid-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1.1rem; align-items: start; }
[hidden] { display: none !important; }
.card-sticky { position: sticky; top: 1rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.stat {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1rem; display: flex; flex-direction: column; gap: .15rem;
}
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; flex: 1 1 160px; }
.field label { font-size: .82rem; color: var(--muted); }
.row { display: flex; gap: .8rem; flex-wrap: wrap; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], input[type=search], input[type=tel],
input[type=file], select, textarea {
  background: #10161f; border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); padding: .5rem .6rem; font: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(240, 180, 41, .5); outline-offset: 1px; }
input[type=checkbox] { accent-color: var(--gold); }
.check { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; font-size: .9rem; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: .4rem; flex-wrap: wrap; }
.inline-form { display: flex; gap: .3rem; align-items: center; }
.inline-form select { width: auto; padding: .25rem .4rem; font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--text);
  padding: .5rem .9rem; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 600;
}
.btn:hover { border-color: #3a475c; text-decoration: none; }
.btn-primary { background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%); border-color: var(--gold-dark); color: #20160a; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-active { border-color: var(--gold); color: var(--gold); }
.btn-danger { background: transparent; border-color: rgba(239, 95, 95, .5); color: var(--danger); }
.btn-lg { padding: .7rem 1.3rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled=true] { opacity: .55; cursor: not-allowed; }

.link { background: none; border: 0; color: var(--gold); cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }

.filters { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 120px; }
.field-actions { flex-direction: row; gap: .5rem; align-items: center; flex: 0 0 auto; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.table tbody tr:hover { background: rgba(255, 255, 255, .03); }
.table-scroll { overflow-x: auto; }
.row-actions { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; display: flex; gap: .4rem; align-items: center; }
.row-actions input[type=text] { width: 8.5rem; padding: .25rem .45rem; font-size: .85rem; }

.rank { font-weight: 700; color: var(--muted); }
.rank-1 { color: #f5cf5c; }
.rank-2 { color: #cdd6e4; }
.rank-3 { color: #d9975a; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: .8rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }

.pager { display: flex; gap: .3rem; margin-top: .8rem; flex-wrap: wrap; }
.page { padding: .25rem .55rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text); font-size: .85rem; }
.page.active { background: var(--gold); border-color: var(--gold); color: #20160a; font-weight: 700; }

/* ---------- chips, bars, chart ---------- */
.pill {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.pill-free, .pill-muted { background: rgba(138, 151, 173, .18); color: var(--muted); }
.pill-pro, .pill-ok { background: rgba(53, 201, 138, .16); color: var(--ok); }
.pill-warn { background: rgba(240, 180, 41, .18); color: var(--gold); }
.pill-bad { background: rgba(239, 95, 95, .18); color: var(--danger); }

.rarity { font-weight: 600; }
.rarity-common { color: #b9c4d4; }
.rarity-rare { color: #5fa8ef; }
.rarity-epic { color: #b481f0; }
.rarity-legendary { color: var(--gold); }
.rarity-event { color: #ef8fbf; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.bars li { display: grid; grid-template-columns: minmax(90px, 150px) 1fr auto; gap: .6rem; align-items: center; font-size: .9rem; }
.bar-track { background: #101722; border-radius: 999px; height: 9px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-dark), var(--gold)); }
.bar-value { font-variant-numeric: tabular-nums; color: var(--muted); }

.chart-wrap { display: flex; flex-direction: column; gap: .3rem; }
.chart { width: 100%; height: 170px; display: block; }
.chart .bar { fill: var(--gold); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart-axis { display: flex; justify-content: space-between; gap: .5rem; font-size: .78rem; color: var(--muted); }
.chart-max { color: var(--gold); }

.qty-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin: .6rem 0 .9rem; }
.qty { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; }
.qty input { padding: .35rem .5rem; }

.usage { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }

/* ---------- flash & notices ---------- */
.flash-stack { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.flash { padding: .6rem .8rem; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-card); font-size: .92rem; }
.flash-success { border-color: rgba(53, 201, 138, .5); background: rgba(53, 201, 138, .1); }
.flash-error { border-color: rgba(239, 95, 95, .5); background: rgba(239, 95, 95, .1); }
.flash-info { border-color: rgba(95, 168, 239, .5); background: rgba(95, 168, 239, .1); }
.notice { padding: .7rem .9rem; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--bg-card); margin-bottom: 1rem; }
.code { background: #0c1119; border: 1px solid var(--line); border-radius: 9px; padding: .6rem .8rem; overflow-x: auto; font-size: .82rem; }

/* ---------- auth / public ---------- */
.centered { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--bg-card); border: 1px solid var(--line); border-radius: 16px; padding: 1.6rem; box-shadow: var(--shadow); }
.auth-links { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem; font-size: .88rem; }

.public-nav { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.6rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; gap: .6rem; }
.public-nav nav { display: flex; gap: 1rem; align-items: center; }
.public-main { max-width: 1080px; margin: 0 auto; padding: 2.2rem 1.2rem; }
.public-foot { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; border-top: 1px solid var(--line); font-size: .85rem; }

.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2rem; align-items: center; margin-bottom: 3rem; }
.hero h1 { font-size: 2.2rem; }
.lead { font-size: 1.05rem; color: #c3cddd; }
.hero-actions { display: flex; gap: .7rem; margin: 1.2rem 0 .4rem; flex-wrap: wrap; }
.hero-card { background: var(--bg-card); border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem; box-shadow: var(--shadow); }
.hero-row { display: grid; grid-template-columns: 2rem 1fr auto; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--line); align-items: center; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 3rem; }
.feature-grid article { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.plan-card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; display: flex; flex-direction: column; gap: .4rem; }
.plan-featured, .plan-current { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(240, 180, 41, .25); }
.plan-price { font-size: 1.8rem; font-weight: 700; margin: .2rem 0; }
.plan-price .muted { font-size: .9rem; font-weight: 400; }
.ticks { list-style: none; margin: .4rem 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
.ticks li::before { content: "✓ "; color: var(--ok); }
.ticks li.off { color: var(--muted); text-decoration: line-through; }
.ticks li.off::before { content: "✗ "; color: var(--muted); }

.faq details { border-bottom: 1px solid var(--line); padding: .7rem 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.page-head { margin-bottom: 1.6rem; }

/* ---------- automatic capture ---------- */
.capture-table select { min-width: 8rem; padding: .3rem .4rem; font-size: .85rem; }
.capture-table input[type=number] { width: 5rem; padding: .3rem .4rem; }
.capture-shot { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.capture-raw { max-height: 18rem; overflow: auto; white-space: pre-wrap; }

/* ---------- user manual ---------- */
.manual { display: grid; grid-template-columns: minmax(200px, 240px) minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.manual-toc { position: sticky; top: 1rem; font-size: .9rem; }
.manual-toc ol { margin: 0 0 .9rem; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .3rem; }
.manual-toc a { color: var(--text); }
.manual-toc a:hover { color: var(--gold); }
.manual-body section { scroll-margin-top: 1rem; }
.manual-body h2 { font-size: 1.35rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.manual-body h3 { margin-top: 1.6rem; color: var(--gold); }
.manual-body :target { animation: manual-flash 1.6s ease-out; }
@keyframes manual-flash { from { box-shadow: 0 0 0 2px var(--gold); } to { box-shadow: var(--shadow); } }

.steps { margin: .6rem 0 1rem; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .45rem; }
.steps li::marker { color: var(--gold); font-weight: 700; }

.faq-list { margin: 0; }
.faq-list dt { font-weight: 600; margin-top: .9rem; }
.faq-list dd { margin: .2rem 0 0; color: var(--muted); }

@media (max-width: 900px) {
  .manual { grid-template-columns: 1fr; }
  .manual-toc { position: static; }
}

/* ---------- installer ---------- */
.install-body { max-width: 720px; margin: 0 auto; padding: 2rem 1.2rem 4rem; }
.steps { display: flex; gap: .5rem; margin-bottom: 1.4rem; flex-wrap: wrap; font-size: .85rem; }
.steps span { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.steps .current { border-color: var(--gold); color: var(--gold); font-weight: 600; }
.steps .done { border-color: rgba(53, 201, 138, .5); color: var(--ok); }
.check-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.check-list li { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.ok { color: var(--ok); }
.bad { color: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .grid-side { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: column; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: .3rem; }
  .sidebar-foot { display: flex; gap: .5rem; align-items: center; }
  .main { padding: 1rem; }
  .card-sticky { position: static; }
}

@media print {
  .sidebar, .topbar-actions, .filters, .card-actions, .foot { display: none !important; }
  body { background: #fff; color: #111; }
  .card, .stat { border-color: #ccc; box-shadow: none; background: #fff; }
  .muted { color: #555; }
}
