:root {
  --paper: #f8f7f3;
  --white: #ffffff;
  --ink: #20231f;
  --muted: #5f625a;
  --line: #e3e4dc;
  --accent: #e75c32;
  --accent-text: #b13f1a;
  --green: #28684f;
  --pale: #eef1e9;
  --dark: #202c25;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.container { max-width: 1328px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-header { border-bottom: 1px solid var(--line); background: var(--paper); }
.header-row { display: flex; align-items: center; gap: 40px; min-height: 76px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 26px; text-decoration: none; margin: 0; }
.nav { display: flex; gap: 28px; flex-wrap: wrap; }
.nav a { font-weight: 500; font-size: 15px; text-decoration: none; padding: 12px 0; }
.nav a[aria-current="page"] { color: var(--accent-text); font-weight: 600; }
.nav a[aria-disabled="true"] { color: var(--muted); }

.main { padding-top: 32px; padding-bottom: 64px; }
.crumb { margin: 0 0 12px; font-size: 13px; font-weight: 500; color: var(--muted); }
h1 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 40px); font-weight: 600; letter-spacing: -0.02em; }
.meta { margin: 0 0 24px; font-size: 14px; color: var(--muted); }

.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 0 0 12px; font-size: 15px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tab.is-active { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.tab small { font-size: 11px; margin-left: 4px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 16px; }
.field { display: inline-flex; align-items: center; gap: 8px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.filters input[type="search"], .filters select {
  font: inherit; font-size: 14px; height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--ink);
}
.filters input[type="search"] { width: 220px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
.count { margin-left: auto; font-size: 13px; color: var(--muted); }

.table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.wl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.wl th, .wl td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.wl thead th { background: var(--paper); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding-top: 12px; padding-bottom: 12px; }
.wl .th-sub { font-weight: 500; text-transform: none; letter-spacing: 0; }
.wl th:first-child, .wl td:first-child { padding-left: 20px; }
.wl th:last-child, .wl td:last-child { padding-right: 20px; }
.wl .num { text-align: right; }
.wl tbody tr:last-child td { border-bottom: 0; }
.wl tbody tr:hover { background: #fbfbf8; }
.wl td { font-size: 14px; }
.wl .sym { position: sticky; left: 0; z-index: 1; background: var(--white); box-shadow: 1px 0 0 var(--line); }
.wl thead .sym { background: var(--paper); z-index: 2; }
.wl tbody tr:hover .sym { background: #fbfbf8; }
.wl .sym strong { display: block; font-size: 15px; font-weight: 700; }
.wl .sym span { font-size: 11px; color: var(--muted); }
.wl .price { font-weight: 600; }
.wl .empty { color: var(--muted); }
.wl .near { color: var(--accent-text); font-weight: 600; }
.wl .up { color: var(--green); }
.wl .down { color: #c0392b; }
.wl .flat { color: #8a6a00; }
.wl .src { display: block; font-size: 10px; font-weight: 500; color: var(--muted); }

.score { display: inline-flex; gap: 5px; vertical-align: middle; }
.cell { display: inline-block; width: 20px; height: 20px; border-radius: 5px; }
.cell.s0 { border: 1.5px dashed #b9bbb1; }
.cell.s1 { background: var(--pale); border: 1px solid var(--green); }
.cell.s2 { background: var(--accent); }

.status { margin: 12px 0 0; font-size: 13px; color: var(--muted); min-height: 1em; }
.status.is-error { color: var(--accent-text); font-weight: 600; }

.explain { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 32px; }
.explain h2 { margin: 0 0 10px; font-size: 19px; font-weight: 600; }
.explain p { margin: 0; font-size: 14px; line-height: 1.6; }
.explain-main { flex: 2 1 520px; background: var(--pale); border-radius: var(--radius); padding: 24px 28px; }
.explain-side { flex: 1 1 300px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 18px; padding: 0; margin: 16px 0 0; font-size: 13px; font-weight: 500; }
.legend li { display: inline-flex; align-items: center; gap: 8px; }

.disclaimer { margin: 24px 0 0; font-size: 12px; color: var(--muted); }

.site-footer { border-top: 1px solid var(--line); padding: 40px 0; font-size: 14px; }
.site-footer p { margin: 0 0 8px; }
.site-footer .logo { font-size: 22px; }

a.tab { text-decoration: none; }
a.tab:hover { color: var(--ink); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-value.up { color: var(--green); }
.kpi-value.down { color: #c0392b; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.section-title { font-size: 20px; font-weight: 600; margin: 28px 0 12px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; margin-top: 28px; }
.section-head .section-title { margin: 0; }
.section-head .filters { margin: 0; flex: 1 1 auto; }
.wl .strong { font-weight: 600; }
.badge.warn { background: #fdf0d5; color: #7a4f00; }
.badge.danger { background: #fdecea; color: #8c1d18; }

.user-menu { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: 14px; flex-wrap: wrap; }
.user-menu a, .link-btn { color: var(--ink); font-weight: 500; text-decoration: none; padding: 12px 0; }
.user-name { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { font: inherit; font-size: 14px; background: none; border: 0; cursor: pointer; }
.user-menu a:hover, .link-btn:hover { color: var(--accent-text); }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 420px; }
.card h1 { font-size: 26px; margin: 0 0 6px; }
.card .lead { margin: 0 0 24px; font-size: 14px; color: var(--muted); line-height: 1.55; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.form input, .form select {
  font: inherit; font-size: 15px; height: 46px; padding: 0 12px; border: 1px solid #cfd1c6;
  border-radius: 8px; background: var(--white); color: var(--ink);
}
.form input:focus-visible, .form select:focus-visible, .btn:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.btn { font: inherit; font-size: 15px; font-weight: 600; height: 46px; padding: 0 20px; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--white); cursor: pointer; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.secondary { background: var(--white); color: var(--ink); border-color: #cfd1c6; }
.btn.small { height: 36px; padding: 0 12px; font-size: 13px; font-weight: 500; }
.btn.danger { background: var(--white); color: #b3261e; border-color: #e7b7b2; }
.msg { margin: 0; padding: 12px 14px; border-radius: 8px; font-size: 14px; line-height: 1.5; }
.msg.error { background: #fdecea; color: #8c1d18; }
.msg.ok { background: var(--pale); color: var(--green); }
.msg[hidden] { display: none; }
.temp-pass { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; font-weight: 600; letter-spacing: 0.04em; background: var(--paper); padding: 2px 8px; border-radius: 6px; color: var(--ink); }

.admin-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.admin-grid .card { max-width: none; }
.admin-add { flex: 1 1 320px; max-width: 420px !important; }
.admin-list { flex: 999 1 560px; min-width: 0; padding: 0 !important; overflow: hidden; }
.admin-list h2, .admin-add h2 { font-size: 19px; margin: 0 0 16px; }
.admin-list h2 { padding: 24px 24px 0; }
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th, .users td { text-align: left; padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.users thead th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--paper); }
.users .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-block; white-space: nowrap; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--pale); color: var(--green); }
.badge.admin { background: #fbe7df; color: var(--accent-text); }
.badge.off { background: #eeeeea; color: var(--muted); }
.table-scroll { overflow-x: auto; }

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .header-row { gap: 12px 24px; padding: 12px 0; }
  .nav { gap: 18px; }
  .filters input[type="search"] { width: 100%; }
  .field:first-child { flex: 1 1 100%; }
  .count { margin-left: 0; }
}
