:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --text: #17201c;
  --muted: #5d6b64;
  --border: #dde4e0;
  --brand: #0b6e4f;
  --brand-ink: #ffffff;
  --brand-soft: #e1f2ea;
  --side: #2f8bcc;
  --side-text: #ffffff;
  --side-active: #1f6ea8;
  --accent: #f2a516;
  --ok: #1b7f3b;
  --ok-soft: #e3f4e7;
  --bad: #c62828;
  --bad-soft: #fde8e8;
  --shadow: 0 1px 2px rgba(16, 40, 30, .06), 0 4px 16px rgba(16, 40, 30, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513;
    --surface: #18201d;
    --surface-2: #212b27;
    --text: #e6eeea;
    --muted: #9aaba3;
    --border: #2c3833;
    --brand: #3fbf8c;
    --brand-ink: #062419;
    --brand-soft: #193a2e;
    --side: #2f8bcc;
    --side-text: #ffffff;
    --side-active: #1f6ea8;
    --ok: #6fd08c;
    --ok-soft: #173323;
    --bad: #ff8a80;
    --bad-soft: #3a1c1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.backdrop { display: none; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }

/* ------------------------------------------------------------ login */
.login-page { display: grid; place-items: center; min-height: 100%; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none;
}
.login-brand h1 { font-size: 20px; margin: 0; }
.login-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.error-msg { color: var(--bad); font-size: 14px; min-height: 20px; margin: 0 0 12px; }
.login-card .btn { width: 100%; padding: 12px; }
.login-page { min-height: auto; padding-top: max(48px, 12vh); }
.login-footer { text-align: center; padding: 28px 16px 32px; color: var(--muted); font-size: 13px; }
.login-footer p { margin: 10px 0 0; }
.login-footer a { color: var(--brand); font-weight: 600; }
.app-download {
  display: inline-flex; align-items: center; gap: 12px; padding: 12px 20px; border-radius: 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); text-decoration: none;
}
.app-download:hover { border-color: var(--brand); }
.app-download .ico { width: 26px; height: 26px; }
.app-download strong { display: block; color: var(--text); font-size: 15px; }
.app-download small { display: block; color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 272px 1fr; min-height: 100%; }
.sidebar {
  background: var(--side); color: var(--side-text); padding: 18px 12px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.side-brand .logo { width: 38px; height: 38px; background: var(--accent); color: #2b1d00; font-size: 13px; }
.side-brand strong { display: block; font-size: 15px; }
.side-brand small { color: var(--side-text); opacity: .95; }
.nav-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .9; padding: 8px 10px; }
.nav-module {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 0;
  background: transparent; color: #fff; padding: 10px; border-radius: 10px; font-weight: 700;
}
.nav-module:hover { background: rgba(255, 255, 255, .14); }
.nav-module.active { background: var(--side-active); }
.nav-module .chev { margin-left: auto; transition: transform .15s; opacity: .9; }
.nav-module.open .chev { transform: rotate(90deg); }
.nav-module small { display: block; font-weight: 500; opacity: .9; font-size: 12px; }
.nav-sub { list-style: none; margin: 2px 0 8px; padding: 0 0 0 18px; border-left: 1px solid rgba(255, 255, 255, .35); margin-left: 22px; }
.nav-sub button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: transparent;
  color: var(--side-text); padding: 8px 10px; border-radius: 8px; font-size: 14px;
}
.nav-sub button:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.nav-sub button.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav-sub .count { margin-left: auto; font-size: 12px; opacity: .9; }
.nav-sub .empty { padding: 6px 10px; font-size: 13px; opacity: .9; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .3); font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; word-break: break-all; }
.side-foot .role { opacity: .9; margin-bottom: 10px; }
.side-foot .btn { width: 100%; background: transparent; color: #fff; border-color: rgba(255, 255, 255, .6); }

.main { min-width: 0; }
.topbar {
  display: none; align-items: center; gap: 12px; padding: 12px 16px; background: var(--side); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.topbar .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .3); padding: 6px 10px; }
.content { padding: 28px clamp(16px, 2.5vw, 44px) 48px; width: 100%; max-width: none; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 26px; line-height: 1.2; }
.page-head .spacer { flex: 1; }
.ico { width: 20px; height: 20px; flex: none; }

/* ------------------------------------------------------------ cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.subject-card { padding: 18px; text-align: left; display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border); }
.subject-card:hover { border-color: var(--brand); }
.subject-card .icon-wrap { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.subject-card h3 { margin: 0; font-size: 16px; }
.subject-card p { margin: 0; color: var(--muted); font-size: 13px; }
.hero {
  padding: 22px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 24px;
  background: linear-gradient(135deg, var(--brand), #13855f); color: #fff; border: 0;
}
.hero h3 { margin: 0 0 4px; font-size: 19px; }
.hero p { margin: 0; opacity: .9; }
.hero .btn { margin-left: auto; background: var(--accent); border-color: var(--accent); color: #2b1d00; }
.section-title { font-size: 16px; margin: 28px 0 12px; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  border: 0; background: transparent; padding: 10px 16px; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; white-space: nowrap;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--brand-soft); color: var(--brand); }
.search { flex: 1; min-width: 180px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }

/* ------------------------------------------------------------ question */
.qcard { padding: 24px; }
.qmeta { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--brand); font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.qtext { font-size: 19px; font-weight: 600; margin: 0 0 20px; line-height: 1.45; }
.progress { height: 6px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-bottom: 18px; }
.progress > div { height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.options { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); text-align: left; width: 100%;
}
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt:disabled { cursor: default; }
.opt .letter { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; flex: none; }
.opt.selected { border: 2px solid var(--brand); background: var(--brand-soft); }
.opt.selected .letter { background: var(--brand); color: var(--brand-ink); }
.opt.correct { border: 2px solid var(--ok); background: var(--ok-soft); }
.opt.correct .letter { background: var(--ok); color: #fff; }
.opt.wrong { border: 2px solid var(--bad); background: var(--bad-soft); }
.opt.wrong .letter { background: var(--bad); color: #fff; }
.answer-box { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--brand-soft); }
.answer-box b { color: var(--brand); }
.answer-box .expl { margin-top: 6px; color: var(--muted); }
.qnav { display: flex; gap: 10px; margin-top: 20px; align-items: center; flex-wrap: wrap; }
.qnav .spacer { flex: 1; }
.jump { width: 90px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }

.qlist { display: grid; gap: 12px; }
.qitem { padding: 16px 18px; }
.qitem-head { display: flex; gap: 12px; align-items: flex-start; }
.qitem-head .num { color: var(--brand); font-weight: 700; min-width: 34px; }
.qitem-head .txt { flex: 1; font-weight: 600; }
.qitem-head .actions { display: flex; gap: 6px; }
.qitem ol { margin: 10px 0 0 46px; padding: 0; list-style: upper-alpha; color: var(--muted); }
.qitem ol li.right { color: var(--ok); font-weight: 700; }
.qitem .expl { margin: 8px 0 0 46px; font-size: 13px; color: var(--muted); }
.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 18px; color: var(--muted); }

/* ------------------------------------------------------------ mock */
.mock-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 16px;
  position: sticky; top: 0; z-index: 10;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; padding: 6px 12px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.mock-layout { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: start; }
.palette { padding: 16px; position: sticky; top: 76px; }
.palette h4 { margin: 0 0 10px; font-size: 14px; }
.pal-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pal-grid button { aspect-ratio: 1; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 12px; font-weight: 600; padding: 0; }
.pal-grid button.done { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.pal-grid button.cur { outline: 2px solid var(--accent); outline-offset: 1px; }
.legend { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid var(--border); }
.legend i.done { background: var(--brand); border-color: var(--brand); }

.result-hero { padding: 24px; text-align: center; margin-bottom: 20px; }
.score { font-size: 44px; font-weight: 800; color: var(--brand); line-height: 1.1; }
.stats { display: flex; justify-content: center; gap: 28px; margin-top: 16px; flex-wrap: wrap; }
.stat b { display: block; font-size: 22px; }
.stat.ok b { color: var(--ok); }
.stat.bad b { color: var(--bad); }
.stat span { color: var(--muted); font-size: 13px; }
.review-item { padding: 14px 16px; }
.review-item .tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.skip { background: var(--surface-2); color: var(--muted); }
table.history { width: 100%; border-collapse: collapse; }
table.history th, table.history td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.history th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }

/* ------------------------------------------------------------ dialog */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(620px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 20, 16, .5); }
.dlg-body { padding: 22px 24px; }
.dlg-body h3 { margin: 0 0 16px; }
.opt-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.opt-row input[type=radio] { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.opt-row input[type=text] { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); }
.hint { font-size: 12px; color: var(--muted); margin: -4px 0 12px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 100; max-width: calc(100vw - 32px);
}
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .mock-layout { grid-template-columns: 1fr; }
  .palette { position: static; }
  .pal-grid { grid-template-columns: repeat(10, 1fr); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .layout.nav-open .sidebar { transform: none; }
  .layout.nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); }
  .topbar { display: flex; }
  .content { padding: 18px 16px 40px; }
  .page-head h2 { font-size: 21px; }
  .qcard { padding: 18px; }
  .qtext { font-size: 17px; }
  .pal-grid { grid-template-columns: repeat(8, 1fr); }
  .mock-bar { top: 56px; }
  .qitem ol, .qitem .expl { margin-left: 20px; }
}
.mock-bar .spacer { flex: 1; }

/* ------------------------------------------------------------ settings */
.nav-label-gap { margin-top: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.settings-card { padding: 22px; }
.settings-card h3 { margin: 0 0 16px; font-size: 17px; }
.settings-card .sub-h { margin-top: 24px; }
.settings-card input:disabled { background: var(--surface-2); color: var(--muted); }
.muted { color: var(--muted); margin: 0 0 14px; }
.link-row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 760px) { .settings-grid { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ users */
.users-table td { vertical-align: middle; }
.head-actions { display: flex; gap: 8px; }
.col-check { width: 44px; }
.col-check input { width: 17px; height: 17px; accent-color: var(--brand); vertical-align: middle; }
.users-table tbody tr { cursor: pointer; }
.users-table tbody tr:hover { background: var(--surface-2); }
.users-table tbody tr.picked { background: var(--brand-soft); }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .form-2col { grid-template-columns: 1fr; } }
.users-hint { margin-top: 12px; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--brand); }
.users-table th, .users-table td { white-space: nowrap; }

/* ------------------------------------------------------------ roles */
dialog.wide { width: min(720px, calc(100vw - 32px)); }
.dlg-body { max-height: calc(100vh - 160px); overflow-y: auto; }
.perm-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.perm-head .field { margin: 0; }
.perm-quick { display: flex; gap: 6px; }
.perm-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 10px; }
.perm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.perm-table th { background: var(--surface-2); text-align: left; padding: 9px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.perm-table td { padding: 8px 12px; border-top: 1px solid var(--border); }
.perm-table .pc { width: 70px; text-align: center; }
.perm-table input { width: 18px; height: 18px; accent-color: var(--brand); vertical-align: middle; }
.perm-module td:first-child { font-weight: 700; }
.perm-module { background: var(--brand-soft); }
.perm-sub td:first-child { padding-left: 34px; color: var(--text); }
.col-check input:disabled { opacity: .35; }

/* ------------------------------------------------------------ SMS gateways */
.url-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.form-section { margin: 18px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); }
.dlg-body h3 + .form-section { margin-top: 0; }
.test-box { margin-top: 16px; padding: 4px 16px 12px; border: 1px dashed var(--border); border-radius: 12px; }
.test-row { display: flex; gap: 8px; }
.test-row input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.test-result { margin: 10px 0 0; font-size: 13px; word-break: break-word; color: var(--muted); }
.test-result.ok { color: var(--ok); }
.test-result.bad { color: var(--bad); }
.hint code { font-size: 12px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
.test-row { flex-wrap: wrap; }
.test-row input { min-width: 180px; }
/* ------------------------------------------------------------ OTP login */
.login-tabs { display: flex; width: 100%; margin-bottom: 18px; }
.login-tabs button { flex: 1; }
.otp-input { letter-spacing: .5em; font-size: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.otp-resend { margin-top: 8px; width: 100%; color: var(--brand); }
.login-card input[readonly] { background: var(--surface-2); color: var(--muted); }
/* ------------------------------------------------------------ languages */
.lang-list { display: grid; gap: 6px; margin-bottom: 16px; }
.lang-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.lang-row:hover { border-color: var(--brand); }
.lang-row input { width: 18px; height: 18px; accent-color: var(--brand); }
.lang-row span:nth-child(2) { font-weight: 600; }
.lang-native { margin-left: auto; color: var(--muted); }
/* full width: settings cards spread across wide screens */
.settings-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.sub-line { font-size: 12px; color: var(--muted); }
.syllabus-card { padding: 22px 26px; }
.syl-h { margin: 18px 0 8px; color: var(--brand); font-size: 15px; }
.syl-h:first-of-type { margin-top: 0; }
.syl-list { margin: 0 0 6px; padding-left: 22px; }
.syl-list li { margin: 4px 0; }
.syl-text { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font: 14px/1.6 ui-monospace, Menlo, Consolas, monospace; }
.users-table.app-table th, .users-table.app-table td { white-space: normal; }
.app-table th { font-size: 11px; }
.app-table td { font-size: 13px; }
.app-table td:nth-child(2) { width: 40px; }
