:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #4a4a5e;
  --border: #e2e5ea;
  --primary: #1b3d8a;
  --accent: #c026d3;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --sidebar: #12172b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 236px;
  background: var(--sidebar);
  color: #fff;
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 30;
}
.brand { padding: 0 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand h1 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.3px; }
.brand p { font-size: .72rem; color: #94a3b8; margin-top: 3px; }
.nav-label {
  font-size: .65rem; text-transform: uppercase; letter-spacing: .8px;
  color: #64748b; padding: 16px 20px 6px; font-weight: 700;
}
.nav-item {
  padding: 9px 20px; cursor: pointer; font-size: .84rem;
  color: #cbd5e1; display: flex; align-items: center; gap: 9px;
  border-left: 3px solid transparent; transition: .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: rgba(59,130,246,.16); color: #fff;
  border-left-color: #3b82f6; font-weight: 600;
}
.nav-item .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .6; }

/* ---------- Main ---------- */
.main { margin-left: 236px; flex: 1; padding: 24px 28px 60px; max-width: 100%; }
.page { display: none; }
.page.active { display: block; }

.topbar { margin-bottom: 20px; }
.topbar h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: -.4px; }
.topbar p { color: var(--muted); font-size: .84rem; margin-top: 4px; }

/* ---------- Cards ---------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.kpi {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; text-align: center;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.kpi .ico {
  width: 40px; height: 40px; border-radius: 11px; margin: 0 auto 9px;
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.kpi .lbl { font-size: .74rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.kpi .val { font-size: 1.35rem; font-weight: 800; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px; margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.card h3 { font-size: .95rem; font-weight: 700; margin-bottom: 14px; }
.card h3 small { font-weight: 400; color: var(--muted); font-size: .78rem; margin-left: 6px; }

/* ---------- Form ---------- */
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px;
}
label { display: block; font-size: .76rem; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 9px; font-size: .84rem; font-family: inherit;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(27,61,138,.25); border-color: var(--primary); }
textarea { resize: vertical; min-height: 62px; }

.btn {
  padding: 9px 16px; border: none; border-radius: 9px; cursor: pointer;
  font-size: .82rem; font-weight: 600; font-family: inherit; transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #16336f; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #a21caf; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f8fafc; }
.btn-danger { background: transparent; color: var(--red); padding: 4px 8px; font-size: .74rem; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: .74rem; }
.btn-row { display: flex; gap: 9px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th {
  text-align: left; padding: 9px 10px; background: #f8fafc;
  font-weight: 700; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .3px; color: var(--muted); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
tbody tr:hover { background: #fafbfc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: .7rem; font-weight: 700;
}
.b-green { background: #dcfce7; color: var(--green); }
.b-amber { background: #fef3c7; color: var(--amber); }
.b-red { background: #fee2e2; color: var(--red); }
.b-blue { background: #dbeafe; color: var(--primary); }
.b-gray { background: #f1f5f9; color: var(--muted); }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); font-size: .84rem; }

/* ---------- Levels ---------- */
.fase-title {
  font-size: .78rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .6px; color: var(--primary); margin: 18px 0 10px;
  border-left: 4px solid var(--primary); padding-left: 10px;
}
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.level-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
}
.level-card .n {
  display: inline-flex; width: 26px; height: 26px; border-radius: 8px;
  background: var(--primary); color: #fff; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 800; margin-bottom: 8px;
}
.level-card h4 { font-size: .86rem; font-weight: 700; margin-bottom: 5px; }
.level-card p { font-size: .78rem; color: var(--muted); line-height: 1.5; }

/* ---------- Score result ---------- */
.score-box {
  text-align: center; padding: 22px; border-radius: 12px;
  background: #f8fafc; border: 1px solid var(--border); margin-top: 14px;
}
.score-box .big { font-size: 3rem; font-weight: 800; line-height: 1; }
.score-box .verdict { font-size: .92rem; font-weight: 700; margin-top: 8px; }
.score-box .meta { font-size: .8rem; color: var(--muted); margin-top: 6px; }

.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 999;
  background: #12172b; color: #fff; padding: 12px 18px;
  border-radius: 10px; font-size: .84rem; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(10px); transition: .22s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #b91c1c; }

.hint {
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px;
  padding: 11px 14px; font-size: .8rem; color: #1e3a8a; margin-bottom: 16px;
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: .25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 16px; }
  .menu-btn { display: block !important; }
}
.menu-btn {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 40;
  background: var(--sidebar); color: #fff; border: none;
  width: 38px; height: 38px; border-radius: 9px; font-size: 1.1rem; cursor: pointer;
}
