:root {
  --bg: #f5f6f4;
  --panel: #ffffff;
  --ink: #17201c;
  --ink-2: #57625c;
  --ink-3: #8b958f;
  --line: #e3e6e2;
  --accent: #0f6b55;
  --accent-ink: #ffffff;
  --accent-soft: #e4f1ec;
  --warn: #b5541c;
  --warn-soft: #fbece2;
  --danger: #b42318;
  --ok: #1d7a46;
  --ok-soft: #e3f3e8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 32, 28, 0.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 'Manrope', system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }

.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #12201b; color: #d8e2dd; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 17px; color: #fff; padding: 4px 10px 18px; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 11px; font-weight: 500; color: #8fa89d; letter-spacing: 0.04em; text-transform: uppercase; margin-top: 2px; }
.nav a { display: block; color: #c4d2cb; padding: 8px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: #1c2f28; text-decoration: none; color: #fff; }
.nav a.active { background: #1f3d33; color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .who { font-size: 12px; color: #8fa89d; padding: 8px 10px; }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { color: var(--ink-2); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--ink-2); font-weight: 600; background: #fafbf9; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7faf8; }
.table-wrap { overflow-x: auto; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
label.field .hint { font-weight: 400; color: var(--ink-3); }
input, textarea, select { font: inherit; color: var(--ink); background: #fff; border: 1px solid #cfd5d0; border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
textarea.tall { min-height: 260px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.check input { width: auto; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #cfd5d0; background: #fff; color: var(--ink); padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f5f3; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef0ed; color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.module { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 10px; }
.module > .module-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.module > .module-head .num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.module > .module-body { border-top: 1px solid var(--line); padding: 16px; display: grid; gap: 14px; }
.sub { border: 1px dashed #d4dad5; border-radius: 8px; padding: 12px; background: #fbfcfb; }
.quiz-q { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; display: grid; gap: 8px; }

.chat { display: grid; gap: 8px; }
.bubble { max-width: 78%; padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; }
.bubble.user { justify-self: end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.assistant { justify-self: start; background: #eef1ee; border-bottom-left-radius: 4px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.error { color: var(--danger); font-size: 13px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #12201b; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.18); z-index: 10; }
.toast.err { background: var(--danger); }
.empty { padding: 28px; text-align: center; color: var(--ink-2); }
.bar { height: 6px; background: #e9ecea; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 10px 10px 6px; min-width: 0; }
  .brand { padding: 6px 10px; }
  .sidebar .spacer { display: none; }
  .sidebar .who { position: absolute; top: 14px; right: 16px; padding: 0; }
  .nav { display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav a { flex: none; }
  .bubble { max-width: 92%; }
  .main { padding: 18px 16px 40px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}
