:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e2e5ea;
  --ink: #1c2430;
  --muted: #6b7480;
  --accent: #2f6df6;
  --accent-soft: #e8f0ff;
  --all: #eef2f7;
  --heat: 122, 199, 122;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.pad { padding: 24px; }
.err { color: #b00020; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px; width: 320px; box-shadow: 0 6px 24px rgba(0,0,0,.06);
  display: grid; gap: 12px;
}
.login-card h1 { margin: 0 0 4px; font-size: 18px; }
.login-card input, .login-card button {
  font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
}
.login-card button { background: var(--accent); color: #fff; border: none; cursor: pointer; font-weight: 600; }

/* header */
.header {
  position: sticky; top: 0; z-index: 5; background: var(--card);
  border-bottom: 1px solid var(--line); padding: 12px 20px;
}
.hrow { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hrow h1 { margin: 0; font-size: 18px; }
.hactions { display: flex; align-items: center; gap: 12px; }
.hactions button {
  font: inherit; font-weight: 600; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.hactions button:disabled { opacity: .6; cursor: default; }
.gen { color: var(--muted); font-size: 12px; }
.logout { color: var(--muted); font-size: 12px; }
.winsel { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.winsel button {
  font: inherit; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.winsel button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* sections + tables */
.section { padding: 16px 20px 4px; }
.section h2 { font-size: 15px; margin: 8px 0 10px; }
.section h3 { font-size: 13px; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.section .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th {
  position: sticky; top: 0; background: #fafbfc; text-align: right; font-weight: 600;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none;
}
thead th.left { text-align: left; }
thead th.sorted { color: var(--ink); }
td.num, .num { text-align: right; }
td.left { text-align: left; }
td.link { color: var(--accent); font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--accent-soft); }
tbody tr.all { background: var(--all); font-weight: 600; }
tbody tr.drilled { outline: 2px solid var(--accent); outline-offset: -2px; }
td.pct.subReg { background: rgba(var(--heat), calc(var(--v, 0))); }

/* drill */
.section.drill { border-top: 1px dashed var(--line); margin-top: 8px; }
.section.drill .close {
  border: none; background: none; font-size: 20px; line-height: 1; cursor: pointer;
  color: var(--muted); margin-left: 8px;
}
.section.drill tbody tr { cursor: default; }
.section.drill tbody tr:hover { background: transparent; }
