:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f5);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--hint) 25%, transparent);
  --ok: #34a853;
  --ok-bg: color-mix(in srgb, #34a853 15%, transparent);
  --bad: #e5484d;
  --bad-bg: color-mix(in srgb, #e5484d 14%, transparent);
  --warn: #d4900a;
  --warn-bg: color-mix(in srgb, #f5a524 18%, transparent);
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding-bottom: 72px; }
button { font: inherit; color: inherit; cursor: pointer; }
.view { padding: 14px 16px 24px; max-width: 640px; margin: 0 auto; }
.loading, .empty { color: var(--hint); text-align: center; padding: 48px 16px; }
.empty b { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; }

.roles { display: flex; gap: 6px; padding: 10px 16px 0; max-width: 640px; margin: 0 auto; }
.roles button, .seg button { border: 0; background: var(--bg2); color: var(--hint); border-radius: 999px; padding: 6px 14px; font-size: 13px; }
.roles button.on, .seg button.on { background: color-mix(in srgb, var(--btn) 16%, transparent); color: var(--link); }
.seg { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }

.sub { margin: 0; font-size: 13px; color: var(--hint); }
h1 { margin: 2px 0 12px; font-size: 19px; font-weight: 600; line-height: 1.35; }
h2 { margin: 20px 0 6px; font-size: 13px; font-weight: 500; color: var(--hint); }
.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.icon-btn { border: 0; background: none; color: var(--hint); font-size: 20px; padding: 4px 6px; }

.card { background: var(--bg2); border-radius: var(--radius); padding: 12px 14px; }
.summary { display: flex; align-items: center; gap: 16px; }
.summary .lines div { font-size: 14px; line-height: 1.9; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.metric { background: var(--bg2); border-radius: 10px; padding: 9px 11px; }
.metric span { display: block; font-size: 12px; color: var(--hint); }
.metric b { font-size: 21px; font-weight: 600; }

.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 0.5px solid var(--line); }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 12.5px; color: var(--hint); }
.row.tap { cursor: pointer; }
.chev { color: var(--hint); font-size: 18px; }
.av { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 600; flex-shrink: 0; background: var(--bad-bg); color: var(--bad); }
.t { width: 44px; flex-shrink: 0; color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.mute { background: var(--bg2); color: var(--hint); }
.pill.acc { background: color-mix(in srgb, var(--btn) 16%, transparent); color: var(--link); }

.btn { display: block; width: 100%; border: 0; border-radius: 10px; padding: 11px; background: var(--btn); color: var(--btn-text); font-weight: 500; margin-top: 12px; }
.btn.ghost { background: var(--bg2); color: var(--link); }
.btn:disabled { opacity: .55; }
.sm { border: 0; border-radius: 8px; padding: 6px 11px; background: var(--bg2); color: var(--link); font-size: 13px; white-space: nowrap; }
.sm:disabled { color: var(--hint); }
.link { border: 0; background: none; color: var(--link); padding: 8px 0 0; font-size: 13.5px; }

.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }
.bar-row .lbl { width: 34px; flex-shrink: 0; }
.bar-row .val { width: 40px; text-align: right; color: var(--hint); font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; }
.progress { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 13px; color: var(--hint); }

.grades { display: flex; gap: 5px; flex-shrink: 0; }
.grades button { width: 36px; height: 34px; border: 0; border-radius: 8px; background: var(--bg2); font-size: 15px; font-weight: 500; }
.grades button.on { background: var(--btn); color: var(--btn-text); }
.grades button:disabled { opacity: .5; }
.g2.on { background: var(--bad) !important; color: #fff !important; }
.savebar { position: sticky; bottom: 76px; padding-top: 8px; background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
.note { font-size: 12.5px; color: var(--hint); text-align: center; margin: 6px 0 0; }
.note.warn { color: var(--warn); }
.note.ok { color: var(--ok); }

.ann { padding: 11px 0; border-top: 0.5px solid var(--line); }
.ann:first-child { border-top: 0; }
.ann .text { white-space: pre-wrap; word-break: break-word; margin: 4px 0 8px; }
.ann.unread .text { font-weight: 500; }
.ann .foot { display: flex; align-items: center; justify-content: space-between; }

details { border-top: 0.5px solid var(--line); }
details:first-of-type { border-top: 0; }
details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
details .items { padding: 0 0 10px 46px; font-size: 13px; color: var(--hint); }

.nav { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg); border-top: 0.5px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
.nav button { border: 0; background: none; color: var(--hint); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.nav button .ic { font-size: 21px; line-height: 1; }
.nav button.on { color: var(--link); }
.nav .badge { position: absolute; top: -2px; left: calc(50% + 6px); background: var(--bad); color: #fff; border-radius: 999px; font-size: 10px; padding: 0 5px; line-height: 16px; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 13.5px; max-width: 90vw; text-align: center; z-index: 10; }
