:root {
  --bg: #f5f7fa;
  --surface: #fff;
  --ink: #17202a;
  --muted: #667085;
  --line: #e4e8ee;
  --brand: #176b5b;
  --brand-soft: #e8f4f1;
  --danger: #a73737;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
body { margin: 0; }
a { color: inherit; }
.app { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { background: #14231f; color: #e7f0ed; padding: 28px 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 1.05rem; font-weight: 750; display: flex; gap: 10px; align-items: center; margin: 0 10px 28px; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; background: #32a287; border-radius: 9px; color: white; }
.nav { display: grid; gap: 5px; }
.nav a { padding: 10px 12px; border-radius: 8px; text-decoration: none; color: #bfcfc9; font-size: .92rem; }
.nav a:hover, .nav a.active { background: #233b34; color: white; }
.sidebar-foot { position: absolute; bottom: 22px; left: 18px; right: 18px; font-size: .82rem; color: #96aaa3; }
.main { min-width: 0; padding: 28px clamp(18px, 3vw, 44px) 54px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h1 { font-size: 1.65rem; letter-spacing: -.025em; margin: 0 0 5px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; background: var(--surface); border: 1px solid var(--line); padding: 14px; border-radius: 12px; margin-bottom: 20px; box-shadow: var(--shadow); }
label { display: grid; gap: 5px; font-size: .78rem; font-weight: 650; color: #475467; }
select, input, textarea { font: inherit; border: 1px solid #ccd3dc; background: white; border-radius: 7px; padding: 8px 10px; color: var(--ink); min-width: 0; }
textarea { resize: vertical; }
.button, button { border: 0; border-radius: 7px; background: var(--brand); color: white; padding: 9px 14px; font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; display: inline-block; }
.button.secondary { background: white; color: var(--ink); border: 1px solid var(--line); }
.button.danger { background: var(--danger); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: .8rem; font-weight: 650; }
.kpi-value { font-size: 1.75rem; line-height: 1.15; font-weight: 750; margin: 7px 0 3px; letter-spacing: -.03em; }
.change { font-size: .76rem; color: var(--muted); }
.change.up { color: #187654; }
.change.down { color: #a13b3b; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 18px; margin-bottom: 18px; }
.card h2 { font-size: 1rem; margin: 0 0 4px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.chart { height: 245px; display: flex; gap: 5px; align-items: end; border-bottom: 1px solid var(--line); padding-top: 12px; }
.bar-wrap { height: 100%; flex: 1; min-width: 3px; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 6px; }
.bar { width: 80%; max-width: 28px; background: #39a98d; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-wrap span { height: 22px; font-size: .62rem; color: var(--muted); writing-mode: vertical-rl; display: none; }
.bar-wrap:nth-child(5n+1) span, .bar-wrap:last-child span { display: block; }
.insights { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.insights li { border-left: 3px solid #39a98d; padding: 2px 0 2px 11px; line-height: 1.45; font-size: .9rem; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; background: white; }
th, td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .035em; color: var(--muted); background: #f9fafb; }
table[data-sortable] th { cursor: pointer; }
table[data-sortable] th:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
tbody tr:last-child td { border-bottom: 0; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; padding: 3px 8px; border-radius: 99px; font-size: .72rem; background: var(--brand-soft); color: var(--brand); }
.status.off { background: #f1f2f4; color: #667085; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #eef3f1; }
.login-card { width: min(420px, 100%); background: white; border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: 0 12px 35px rgba(20, 35, 31, .08); }
.login-card h1 { margin: 0 0 7px; }
.login-card form { display: grid; gap: 16px; margin-top: 24px; }
.error { background: #fff0f0; color: #8c2727; border: 1px solid #f1c8c8; padding: 10px 12px; border-radius: 8px; font-size: .86rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.site-form { display: grid; grid-template-columns: 1.1fr 1fr 1.5fr auto auto auto; gap: 10px; align-items: end; padding: 14px 0; border-bottom: 1px solid var(--line); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; padding: 14px 18px; }
  .brand { margin: 0 0 12px; }
  .nav { display: flex; overflow: auto; padding-right: 90px; }
  .nav a { white-space: nowrap; }
  .sidebar-foot { position: absolute; top: 12px; bottom: auto; left: auto; right: 18px; font-size: 0; }
  .sidebar-foot form { margin-top: 0 !important; }
  .sidebar-foot .button { font-size: .78rem; padding: 7px 10px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .site-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .main { padding: 20px 14px 40px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 9px; }
  .card { padding: 14px; }
  .kpi-value { font-size: 1.4rem; }
  .filters { align-items: stretch; }
  .filters label { flex: 1 1 130px; }
  .filters select, .filters input { width: 100%; }
  .form-grid, .site-form { grid-template-columns: 1fr; }
  .chart { height: 190px; }
}
