:root {
  --bg: #0f1216;
  --bg-elevated: #161b21;
  --bg-card: #1b2129;
  --bg-hover: #222a33;
  --border: #2a323d;
  --text: #e4e8ed;
  --text-muted: #9aa5b1;
  --text-faint: #6b7483;
  --accent: #5b9bd5;
  --accent-soft: rgba(91, 155, 213, 0.15);

  --good: #4caf7d;
  --good-bg: rgba(76, 175, 125, 0.14);
  --mid: #d9a441;
  --mid-bg: rgba(217, 164, 65, 0.14);
  --bad: #d5685b;
  --bad-bg: rgba(213, 104, 91, 0.14);

  --radius: 10px;
  --sidebar-w: 230px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
}
.sidebar-brand img { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; }
.sidebar-brand span { font-weight: 700; font-size: 16px; letter-spacing: 0.3px; }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-list a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
}
.nav-list a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-list a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Main content */
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 60px;
  max-width: 1320px;
}

.page-header { margin-bottom: 22px; }
.page-header h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.page-header p { margin: 0; color: var(--text-muted); font-size: 13.5px; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card + .card { margin-top: 14px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.card-grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* Badges / tiers */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.mid { background: var(--mid-bg); color: var(--mid); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

.stat-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-tile .stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-tile .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* Finding / priority rows */
.finding {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 10px;
  background: var(--bg-elevated);
}
.finding-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.finding-title { font-weight: 600; font-size: 14px; }
.finding-explanation { color: var(--text-muted); font-size: 13px; }

/* Bars */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { width: 170px; flex: 0 0 170px; font-size: 13px; color: var(--text-muted); }
.bar-track { flex: 1; height: 10px; background: var(--bg-elevated); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-fill.good { background: var(--good); }
.bar-fill.mid { background: var(--mid); }
.bar-fill.bad { background: var(--bad); }
.bar-value { width: 70px; flex: 0 0 70px; font-size: 12.5px; color: var(--text-muted); text-align: right; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; position: sticky; top: 0; background: var(--bg-card); }
tbody tr:hover { background: var(--bg-hover); }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table-scroll table { margin: 0; }
.table-scroll .table-scroll table th:first-child, td:first-child { position: sticky; left: 0; background: var(--bg-card); }

/* Forms */
label { font-size: 12.5px; color: var(--text-muted); display: block; margin-bottom: 4px; }
input[type=text], input[type=number], select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
}
input[type=file] { color: var(--text-muted); font-size: 13px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-row label { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text); margin: 0; }

button, .btn {
  background: var(--accent);
  color: #0b1116;
  border: none;
  border-radius: 7px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
button:hover, .btn:hover { opacity: 0.88; text-decoration: none; }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }

/* Tabs */
.tab-row { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-row a { padding: 9px 14px; font-size: 13px; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tab-row a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 12px; }
.pill { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; color: var(--text-muted); }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request.htmx-indicator { display: inline; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.pagination a, .pagination span { padding: 5px 10px; border-radius: 6px; font-size: 12.5px; }
.pagination a { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }
.pagination .current { color: var(--text); font-weight: 600; }

.chart-wrap { position: relative; height: 220px; }
.chart-wrap.tall { height: 320px; }

.best-cell { outline: 2px solid var(--good); outline-offset: -2px; border-radius: 4px; }

.empty-state { color: var(--text-faint); padding: 30px; text-align: center; font-size: 13.5px; }

.print-only { display: none; }

@media print {
  .sidebar, .tab-row, form, .pagination, .no-print { display: none !important; }
  .app-shell { display: block; }
  .main { max-width: none; padding: 0; margin: 0; }
  body { background: #fff; color: #000; }
  .card, .finding, .stat-tile { background: #fff; border-color: #ccc; break-inside: avoid; }
  .badge.good { background: #e4f3ea; color: #1e7a46; }
  .badge.mid { background: #fbf0dd; color: #8a6116; }
  .badge.bad { background: #fbe9e6; color: #a4392e; }
  .print-only { display: block; }
  a { color: inherit; text-decoration: none; }
}
