:root {
  --accent: #8b0000;
  --accent-2: #b91c1c;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 230px; background: #1e1b1b; color: #e7e5e4; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 18px 10px; font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.brand small { display: block; color: #a8a29e; font-weight: 400; font-size: 11px; margin-top: 2px; }
.nav { padding: 8px; overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: #d6d3d1; margin-bottom: 2px; font-weight: 500;
}
.nav a:hover { background: #2c2727; text-decoration: none; color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav .nav-sec { color: #78716c; font-size: 11px; text-transform: uppercase; padding: 12px 12px 4px; letter-spacing: .5px; }
.sidebar .userbox { padding: 12px 16px; border-top: 1px solid #3a3434; font-size: 12px; color: #a8a29e; }
.sidebar .userbox b { color: #e7e5e4; display: block; }

/* Content */
.content { flex: 1; min-width: 0; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line); padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; }
.container { padding: 24px 28px; max-width: 1280px; }

/* Cards & grid */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } .sidebar { display: none; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2, .card h3 { margin: 0 0 12px; font-size: 15px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.kpi .value { font-size: 28px; font-weight: 700; }
.kpi .sub { color: var(--muted); font-size: 12px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-muted { background: #f1f5f9; color: #475569; }

/* Forms & buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; border: none;
  padding: 9px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.btn:hover { background: var(--accent-2); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: #f8fafc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
label { font-size: 12px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 120px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.muted { color: var(--muted); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 26px 0 10px; font-weight: 700; }
.chart-wrap { position: relative; height: 280px; }
.report-vs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .report-vs { grid-template-columns: 1fr; } }
.report-box { white-space: pre-wrap; font-size: 13px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 14px; max-height: 520px; overflow: auto; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.markdown h2 { font-size: 16px; margin-top: 18px; }
.markdown h3 { font-size: 14px; }
.markdown table { margin: 10px 0; }
.notice { padding: 12px 14px; border-radius: 8px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; margin-bottom: 16px; }
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1e1b1b; }
.login-card { background: #fff; padding: 32px; border-radius: 14px; width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
