:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #f8faf7;
  --ink: #1d2822;
  --muted: #6b776f;
  --line: #dde5dd;
  --green: #176b4d;
  --green-dark: #0f4d37;
  --green-soft: #e2f2e9;
  --amber: #b7791f;
  --red: #b83a37;
  --red-soft: #fbeaea;
  --blue: #2b5f8a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 42, 31, .04), 0 8px 24px rgba(22, 42, 31, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; letter-spacing: -.02em; }
h2 { font-size: 17px; }
p { margin: 0 0 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
pre { white-space: pre-wrap; max-width: 420px; font-size: 11px; color: var(--muted); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px !important; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px;
  background: #10291f;
  color: #dfece4;
  display: flex; flex-direction: column;
  padding: 24px 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  color: #fff; text-decoration: none; margin-bottom: 28px; padding: 0 6px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(140deg, #2f9b6f, #17573f);
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: .02em;
}
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; color: #93ada0; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar nav a {
  color: #b9cec2; padding: 9px 12px; border-radius: 9px; font-size: 13.5px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #205742; color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.user-chip { display: flex; gap: 9px; align-items: center; margin-bottom: 12px; min-width: 0; }
.user-chip strong { display: block; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: #93ada0; font-size: 10.5px; }
.avatar {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%;
  background: #2a624b; display: grid; place-items: center; color: #fff; font-weight: 700;
}
.main { flex: 1; min-width: 0; padding: 28px 32px 60px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.topbar p { margin-top: 4px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.metric > span { color: var(--muted); font-size: 12px; }
.metric > strong { font-size: 28px; letter-spacing: -.03em; }
.metric > small { color: var(--muted); font-size: 11.5px; }
.metric.accent { background: var(--green-soft); border-color: #c8e2d4; justify-content: center; }
.metric.accent > span { color: var(--green-dark); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.panel-head p { margin: 3px 0 0; }
.content-card .panel-head { margin-bottom: 12px; }
.content-card h2 { font-size: 20px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid #edf1ed; vertical-align: top; font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
table.compact td, table.compact th { padding: 7px 8px; font-size: 12px; }
.correct-row { background: #f1faf5; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  background: #eef1ee; color: var(--muted); font-size: 10.5px; font-weight: 600;
  white-space: nowrap;
}
.badge-ok, .badge-approved, .badge-info { background: var(--green-soft); color: var(--green-dark); }
.badge-off, .badge-rejected, .badge-error { background: var(--red-soft); color: var(--red); }
.badge-pending_review, .badge-warning { background: #fdf2df; color: var(--amber); }
.badge-learning { background: #fdf2df; color: var(--amber); }
.code { background: #eef4ef; border: 1px solid #d7e3da; padding: 3px 7px; border-radius: 6px; font-size: 12px; letter-spacing: .04em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; padding: 8px 13px;
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: .15s ease; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: #f0cece; }
.btn-danger:hover { background: #f6dcdc; }
.btn-sm { padding: 5px 9px; font-size: 11.5px; }
.btn-wide { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline { display: inline; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form select, .inline-form input { margin: 0; }
.row-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row-form label { min-width: 160px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: #405047; }
input, select {
  font: inherit; font-size: 13px; color: var(--ink);
  border: 1px solid #cfdad2; background: #fff; border-radius: 8px; padding: 8px 10px;
  min-height: 36px; width: 100%;
}
input:focus, select:focus { outline: 2px solid #b9dcc9; border-color: var(--green); }
.input-xs { width: 66px; min-height: 30px; padding: 4px 6px; display: inline-block; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.flash-ok { background: var(--green-soft); color: var(--green-dark); border: 1px solid #c6e3d4; }
.flash-error { background: var(--red-soft); color: var(--red); border: 1px solid #f0cece; }

.segmented { display: flex; background: #e8ede8; border-radius: 9px; padding: 3px; }
.segmented a { padding: 6px 12px; border-radius: 7px; font-size: 12px; color: var(--muted); }
.segmented a:hover { text-decoration: none; color: var(--ink); }
.segmented a.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600; }

.status-list { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.status-row { display: grid; grid-template-columns: 150px 1fr 42px; align-items: center; gap: 10px; font-size: 12.5px; }
.status-row strong { text-align: right; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: #b8c4bb; }
.dot-new { background: #9aa8a0; }
.dot-learning { background: #d59a34; }
.dot-review { background: #4e86ae; }
.dot-mastered { background: var(--green); }
.bar { height: 7px; background: #edf1ee; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.topic-list { display: flex; flex-direction: column; gap: 9px; padding-top: 4px; }
.topic-row { display: flex; justify-content: space-between; padding: 9px 11px; background: var(--surface-2); border-radius: 8px; font-size: 12.5px; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a {
  padding: 7px 12px; background: #fff; border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; color: var(--muted); display: inline-flex; gap: 7px; align-items: center;
}
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { background: var(--green); border-color: var(--green); color: #fff; }
.tabs a span { background: rgba(0,0,0,.08); padding: 1px 6px; border-radius: 999px; font-size: 10px; }
.tabs a.active span { background: rgba(255,255,255,.18); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #e4f2e9, transparent 55%), var(--bg); }
.login-card { width: min(420px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px; box-shadow: 0 24px 60px rgba(20, 51, 35, .1); }
.brand-login { color: var(--ink); margin-bottom: 26px; padding: 0; }
.brand-login small { color: var(--muted); }
.login-card h1 { margin-bottom: 4px; }
.login-card > .muted { margin-bottom: 20px; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 16px; overflow-x: auto; }
  .sidebar .brand { margin: 0 20px 0 0; }
  .sidebar nav { flex-direction: row; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 16px 48px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .topbar { flex-direction: column; }
  table { display: block; overflow-x: auto; }
  .panel { padding: 14px; }
}
