:root {
  --blue: #0082C3;
  --blue-dark: #003D7A;
  --blue-50: #E8F4FB;
  --mint: #B8F1D8;

  --ink: #1A1A1A;
  --ink-2: #2E353C;
  --muted: #5B6370;
  --muted-2: #8A929C;

  --line: #E1E8ED;
  --line-strong: #CFD7DE;
  --surface: #F7F9FA;
  --surface-2: #EEF2F4;
  --white: #FFFFFF;

  --green: #1FAE6B;
  --green-50: #E6F8EE;
  --orange: #D97706;
  --orange-50: #FDF1E0;
  --red: #DC2626;
  --red-50: #FBE7E5;

  --r-xs: 4px;
  --r: 6px;
  --r-md: 8px;

  --shadow-hover: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(15, 26, 42, 0.08);
}

/* ── Tweak: density scale ── */
:root { --pad-scale: 1; --radius-scale: 1; --border-color: var(--line); }
:root[data-density="compact"]  { --pad-scale: 0.72; }
:root[data-density="cozy"]     { --pad-scale: 1; }
:root[data-density="spacious"] { --pad-scale: 1.35; }

/* ── Tweak: tone ── */
:root[data-tone="utility"]    { --radius-scale: 1; --border-color: var(--line); }
:root[data-tone="friendly"]   { --radius-scale: 2.2; --border-color: #ECF1F5; }
:root[data-tone="industrial"] { --radius-scale: 0; --border-color: #B7C2CC; }

:root[data-tone="industrial"] body { background: #ECEFF2; }
:root[data-tone="friendly"] body { background: #F4F7FA; }

/* apply scale to common surfaces */
.welcome-head, .panel-head, .stat-card, .card,
.module-list, .module-row, .lesson, .sidebar, .chat-side, .chat-shell,
.login-card, .admin-head, .admin-stat, .admin-table-wrap, .admin-codes-list,
.btn, .chip, .tag, .module-row .icon, .stat-icon, .composer .field, .login-form input {
  border-radius: calc(var(--r) * var(--radius-scale));
  border-color: var(--border-color);
}
.welcome-head { padding: calc(24px * var(--pad-scale)) calc(28px * var(--pad-scale)); }
.stat-card { padding: calc(14px * var(--pad-scale)) calc(16px * var(--pad-scale)); }
.panel-head { padding: calc(18px * var(--pad-scale)) calc(20px * var(--pad-scale)); }
.lesson { padding: calc(22px * var(--pad-scale)) calc(24px * var(--pad-scale)); }
.sidebar, .chat-side { padding: calc(16px * var(--pad-scale)); }
.module-row { padding-top: calc(12px * var(--pad-scale)); padding-bottom: calc(12px * var(--pad-scale)); }
.admin-stat { padding: calc(14px * var(--pad-scale)) calc(16px * var(--pad-scale)); }
.container { padding-top: calc(24px * var(--pad-scale)); padding-bottom: calc(40px * var(--pad-scale)); }

/* industrial: sharp, mono meta, heavier rules */
:root[data-tone="industrial"] .module-row { border-top-color: #C8D1DA; }
:root[data-tone="industrial"] .admin-table th { background: #DCE2E8; color: #1A1A1A; border-bottom-color: #B7C2CC; letter-spacing: 0.08em; }
:root[data-tone="industrial"] .admin-table td { border-bottom-color: #C8D1DA; }
:root[data-tone="industrial"] .eyebrow, :root[data-tone="industrial"] .module-row .num,
:root[data-tone="industrial"] .breadcrumb, :root[data-tone="industrial"] .section-title h3,
:root[data-tone="industrial"] .admin-stat .lbl {
  font-family: "Geist Mono", ui-monospace, monospace; letter-spacing: 0.06em;
}
:root[data-tone="industrial"] .stat-icon, :root[data-tone="industrial"] .module-row .icon {
  background: #DCE2E8; color: #1A1A1A;
}
:root[data-tone="industrial"] .tag { letter-spacing: 0.06em; text-transform: uppercase; font-size: 10.5px; }

/* friendly: soft tinted surfaces, no harsh lines */
:root[data-tone="friendly"] .welcome-head,
:root[data-tone="friendly"] .panel-head,
:root[data-tone="friendly"] .lesson,
:root[data-tone="friendly"] .sidebar,
:root[data-tone="friendly"] .chat-side,
:root[data-tone="friendly"] .chat-shell,
:root[data-tone="friendly"] .module-list,
:root[data-tone="friendly"] .admin-head,
:root[data-tone="friendly"] .admin-stat,
:root[data-tone="friendly"] .admin-table-wrap,
:root[data-tone="friendly"] .admin-codes-list,
:root[data-tone="friendly"] .stat-card,
:root[data-tone="friendly"] .login-card { box-shadow: 0 1px 0 rgba(15,26,42,0.02), 0 6px 18px -10px rgba(15,26,42,0.10); }
:root[data-tone="friendly"] .stat-icon, :root[data-tone="friendly"] .module-row .icon { background: var(--blue-50); color: var(--blue-dark); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--blue-dark); }

/* ────────────  APP SHELL  ──────────── */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  background: var(--blue);
  color: white;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.brand-word {
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 14px;
}
.brand-divider {
  height: 18px;
  width: 1px;
  background: rgba(255, 255, 255, 0.30);
}
.brand-section {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 500;
}
.brand-section .dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  margin: 0 8px 2px;
  vertical-align: middle;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav button {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.85);
  padding: 6px 12px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.nav button:hover { background: rgba(255, 255, 255, 0.10); color: white; }
.nav button.active {
  background: rgba(255, 255, 255, 0.16);
  color: white;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.10);
  border-radius: var(--r);
  padding: 2px;
  flex-shrink: 0;
}
.lang-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.65);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  min-width: 30px;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.lang-btn:hover { color: white; background: rgba(255, 255, 255, 0.08); }
.lang-btn.active {
  background: white;
  color: var(--blue);
}
.lang-btn.active:hover { background: white; color: var(--blue); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}
.user-chip .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
}
.user-chip .name { font-size: 13px; font-weight: 500; }
.logout-btn {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: 6px;
  cursor: pointer;
  font-family: inherit;
}
.logout-btn:hover { color: white; background: rgba(255, 255, 255, 0.08); }

.main { flex: 1; width: 100%; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

/* ────────────  COMMON UI  ──────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 13.5px;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn-primary {
  background: var(--blue);
  color: white;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary {
  background: white;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover { border-color: var(--blue); color: var(--blue-dark); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}
.eyebrow .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blue);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  letter-spacing: 0;
}
.tag.green { background: var(--green-50); color: #126B43; }
.tag.orange { background: var(--orange-50); color: #8C4B04; }
.tag.gray { background: var(--surface-2); color: var(--muted); }
.tag.blue { background: var(--blue-50); color: var(--blue-dark); }

/* shared card primitive */
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

/* ────────────  SCREEN 1: WELCOME  ──────────── */

.welcome {
  display: grid;
  gap: 20px;
}
.welcome-head {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 24px 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}
.welcome-head h1 {
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 700;
  margin: 8px 0 8px;
  color: var(--ink);
}
.welcome-head .lead {
  font-size: 14.5px;
  color: var(--muted);
  margin: 0;
  max-width: 60ch;
}
.welcome-head .ctas {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.welcome-head .meta-side {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
  min-width: 180px;
}
.welcome-head .meta-side strong { color: var(--ink); font-weight: 600; }

.welcome-head .next-step-card {
  appearance: none;
  background: var(--blue-50);
  border: 1px solid var(--blue-50);
  border-radius: calc(var(--r) * var(--radius-scale));
  padding: 14px 18px;
  min-width: 220px;
  max-width: 300px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.welcome-head .next-step-card:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}
.welcome-head .ns-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--blue-dark);
  margin-bottom: 6px;
}
.welcome-head .ns-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.welcome-head .ns-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.stat-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-hover); }
.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}
.stat-value {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}
.stat-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 1px;
}

/* ────────────  SCREEN 2: PANEL  ──────────── */

.panel-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
}
.panel-head h2 {
  font-size: 22px;
  letter-spacing: -0.01em;
  font-weight: 700;
  margin: 4px 0 4px;
}
.panel-head .sub {
  color: var(--muted);
  font-size: 13.5px;
}
.panel-head .sub strong { color: var(--ink); font-weight: 600; }

.progress-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 20px;
  border-left: 1px solid var(--line);
  min-width: 280px;
}
.ring {
  width: 44px;
  height: 44px;
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ring svg { transform: rotate(-90deg); }
.ring .pct {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--ink);
}
.progress-card .ttl { font-weight: 600; font-size: 13px; color: var(--ink); }
.progress-card .meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.progress-card .bar {
  margin-top: 6px;
  height: 4px;
  width: 180px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-card .bar > i {
  display: block;
  height: 100%;
  background: var(--blue);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-title h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.section-title .filters { display: flex; gap: 4px; }

.chip {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: var(--r);
  font-weight: 500;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.active { background: var(--ink); color: white; border-color: var(--ink); }

/* dense list-style module cards */
.module-list {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.module-row {
  display: grid;
  grid-template-columns: 4px 32px 1.4fr 1.4fr auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px 12px 0;
  border-top: 1px solid var(--line);
  background: white;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: background 0.12s;
}
.module-row:first-child { border-top: 0; }
.module-row:hover { background: var(--surface); }
.module-row .accent {
  width: 4px;
  height: 36px;
  border-radius: 0 2px 2px 0;
  background: var(--accent, var(--blue));
}
.module-row .icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-size: 14px;
}
.module-row .num {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 600;
  margin-bottom: 2px;
}
.module-row .title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.module-row .desc {
  font-size: 13px;
  color: var(--muted);
}
.module-row .stats {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  white-space: nowrap;
}
.module-row .duration {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
}
.module-row .arrow {
  color: var(--muted-2);
  font-size: 14px;
  padding-right: 4px;
}
.module-row:hover .arrow { color: var(--blue); }

/* ────────────  SCREEN 3: MODULE VIEW  ──────────── */

.module-view {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 64px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
}
.back-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  background: transparent;
  border: 0;
  padding: 0;
  margin-bottom: 14px;
  width: fit-content;
}
.back-link:hover { color: var(--blue-dark); }

.sidebar h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--ink);
}
.sidebar .meta {
  font-size: 12.5px;
  color: var(--muted);
}
.sidebar .bar {
  margin: 12px 0 4px;
  height: 4px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.sidebar .bar > i {
  display: block;
  height: 100%;
  background: var(--blue);
}
.sidebar .pct {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 14px;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.step {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 8px;
  border-radius: var(--r-xs);
  background: transparent;
  border: 0;
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}
.step:hover { background: var(--surface); }
.step.active {
  background: var(--blue-50);
}
.step.locked { opacity: 0.55; cursor: not-allowed; }
.step .stepnum {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.step.done .stepnum { background: var(--green); color: white; }
.step.active .stepnum { background: var(--blue); color: white; }
.step .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.step.active .label { color: var(--blue-dark); font-weight: 600; }
.step .sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.step .icon { font-size: 12px; color: var(--muted-2); }

.lesson {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px 24px;
}
.lesson .breadcrumb {
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.lesson h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  color: var(--ink);
}
.lesson .lead {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 18px;
  max-width: 64ch;
}

.logipad-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 24px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
  align-items: start;
}
.logipad {
  background: #11161D;
  border-radius: var(--r);
  padding: 16px;
  color: #DDE3EE;
  font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  position: relative;
  border: 1px solid #1F2630;
}
.logipad .screen-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #6F7E94;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.logipad .screen-top .battery { color: #6FD9A8; }
.logipad .lp-orow {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr 1.7fr 0.7fr;
  gap: 14px;
  align-items: start;
  padding: 50px 8px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 12px;
}
.logipad .lp-col {
  min-width: 0;
}
.logipad .lp-col-id .lp-zone {
  font-size: 17px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.04em;
  line-height: 1.2;
  margin-bottom: 6px;
}
.logipad .lp-col-id .lp-meta {
  font-size: 11px;
  color: #6F7E94;
  line-height: 1.5;
}
.logipad .lp-col-counts .lp-dead {
  font-size: 18px;
  font-weight: 700;
  color: white;
  margin-bottom: 6px;
  line-height: 1;
}
.logipad .lp-col-counts .lp-count-main {
  font-size: 14px;
  color: #9CD9B4;
  font-weight: 600;
  margin-bottom: 2px;
}
.logipad .lp-col-counts .lp-count-sec {
  font-size: 12.5px;
  color: #6F7E94;
  line-height: 1.5;
}
.logipad .lp-col-codes {
  font-size: 13.5px;
  color: #DDE3EE;
  line-height: 1.7;
  font-family: "Geist Mono", ui-monospace, monospace;
  word-spacing: 2px;
}
.logipad .lp-col-cities {
  font-size: 14px;
  color: white;
  font-weight: 600;
  line-height: 1.5;
  text-align: right;
}

.hotspot {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-weight: 700;
  font-size: 11px;
  display: grid;
  place-items: center;
  border: 2px solid white;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
  z-index: 4;
  padding: 0;
}
.hotspot:hover { transform: scale(1.10); }
.hotspot.active {
  background: white;
  color: var(--blue-dark);
  box-shadow: 0 0 0 2px var(--blue);
}

.legend {
  background: white;
  border-radius: var(--r);
  padding: 14px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.legend .ttl {
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.legend-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  text-align: left;
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  width: 100%;
  cursor: pointer;
  align-items: start;
  transition: opacity 0.12s;
}
.legend-item:first-child { border-top: 0; padding-top: 4px; }
.legend-item .pin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  margin-top: 1px;
}
.legend-item.active .pin { background: var(--blue); color: white; }
.legend-item.dim { opacity: 0.55; }
.legend-item .ttl-row { font-size: 13px; font-weight: 600; color: var(--ink); }
.legend-item .desc { font-size: 12.5px; color: var(--muted); margin-top: 1px; line-height: 1.45; }

.lesson-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.lesson-foot .step-meta {
  font-size: 12.5px;
  color: var(--muted);
}

/* ────────────  SCREEN 4: CHAT  ──────────── */

.chat-page {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: start;
}
.chat-page.solo {
  display: block;
  max-width: 860px;
  margin: 0 auto;
}
.chat-side {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  position: sticky;
  top: 64px;
}
.chat-side h4 {
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 8px;
}
.thread-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--r-xs);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
  display: block;
  margin-bottom: 1px;
  transition: background 0.12s;
}
.thread-item:hover { background: var(--surface); }
.thread-item.active { background: var(--blue-50); color: var(--blue-dark); font-weight: 600; }
.thread-item .when { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; font-weight: 400; }

.chat-shell {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: calc(100vh - 110px);
  min-height: 540px;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.chat-head .who { display: flex; align-items: center; gap: 10px; }
.chat-head .who .av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
}
.chat-head h3 { font-size: 14.5px; font-weight: 600; margin: 0; }
.chat-head .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.online {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--green-50);
  color: #126B43;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--r-xs);
}
.online::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
}
.msg-row { display: flex; gap: 10px; max-width: 78%; }
.msg-row.bot { align-self: flex-start; }
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 10.5px;
}
.msg-row.bot .av { background: var(--blue); color: white; }
.msg-row.user .av { background: var(--surface-2); color: var(--ink-2); }
.bubble {
  background: white;
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: var(--r);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
}
.msg-row.user .bubble {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.bubble strong { color: var(--blue-dark); font-weight: 600; }
.msg-row.user .bubble strong { color: white; }
.cite {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  background: white;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  font-weight: 500;
}
.cite .dotc {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--blue);
}

.typing { display: inline-flex; gap: 3px; align-items: center; padding: 3px 0; }
.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted-2);
  animation: blink 1.4s infinite ease-in-out both;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.suggestions {
  padding: 10px 18px 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: white;
  border-top: 1px solid var(--line);
}
.suggestion {
  border: 1px solid var(--line);
  background: white;
  border-radius: var(--r);
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.suggestion:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }

.composer {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid var(--line);
}
.composer .field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 7px 12px;
  transition: border-color 0.12s;
}
.composer .field:focus-within { border-color: var(--blue); }
.composer input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  color: var(--ink);
  font-family: inherit;
}
.composer input::placeholder { color: var(--muted-2); }
.composer .send {
  width: 32px;
  height: 32px;
  border-radius: var(--r);
  background: var(--blue);
  color: white;
  border: 0;
  display: grid;
  place-items: center;
  transition: background 0.12s;
}
.composer .send:hover { background: var(--blue-dark); }
.composer .send:disabled { background: var(--line-strong); cursor: not-allowed; }

/* ────────────  LOGIN  ──────────── */

.login-wrap {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 28px 28px 24px;
}
.login-card .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-50);
  padding: 3px 8px;
  border-radius: var(--r-xs);
  margin-bottom: 14px;
}
.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  color: var(--ink);
}
.login-card p {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 20px;
  line-height: 1.55;
}
.login-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.login-form .input-wrap {
  display: flex;
  gap: 8px;
}
.login-form input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: 15px;
  font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.06em;
  color: var(--ink);
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.12s;
  background: white;
}
.login-form input::placeholder { color: var(--muted-2); text-transform: none; letter-spacing: 0; font-family: inherit; }
.login-form input:focus { border-color: var(--blue); }
.login-form input.error { border-color: var(--red); }
.login-form .err {
  font-size: 12.5px;
  color: var(--red);
  margin-top: 8px;
}
.login-help {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}
.login-help strong { color: var(--ink); font-weight: 600; }
.login-help code {
  font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--ink);
}

/* ────────────  ADMIN  ──────────── */

.admin-head {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.admin-head h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 4px 0 2px;
  letter-spacing: -0.01em;
}
.admin-head .sub { font-size: 13px; color: var(--muted); }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.admin-stat {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
}
.admin-stat .lbl {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.admin-stat .val {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.admin-stat .delta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.admin-table-wrap {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.admin-toolbar h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}
.admin-toolbar .search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 5px 10px;
  font-size: 13px;
  color: var(--muted);
}
.admin-toolbar .search input {
  border: 0;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  width: 180px;
  background: transparent;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: var(--surface); }
.admin-table .name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-table .avx {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}
.admin-table .name-cell .meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
  font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
}
.admin-table .progress-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}
.admin-table .pbar {
  flex: 1;
  height: 5px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  min-width: 80px;
}
.admin-table .pbar > i {
  display: block;
  height: 100%;
  background: var(--blue);
}
.admin-table .pbar.done > i { background: var(--green); }
.admin-table .pbar.warn > i { background: var(--orange); }
.admin-table .pnum {
  font-size: 12px;
  color: var(--muted);
  min-width: 48px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.admin-table .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-xs);
}
.admin-table .status-pill.green { background: var(--green-50); color: #126B43; }
.admin-table .status-pill.orange { background: var(--orange-50); color: #8C4B04; }
.admin-table .status-pill.gray { background: var(--surface-2); color: var(--muted); }
.admin-table .status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.admin-table .row-action {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--r-xs);
}
.admin-table .row-action:hover { background: var(--surface-2); color: var(--blue-dark); }

/* code distribution panel */
.admin-codes {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.admin-codes-list {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
}
.admin-codes-list h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.code-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.code-row:first-of-type { border-top: 0; }
.code-row .c {
  font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.code-row .for { color: var(--muted); font-size: 12.5px; }
.code-row .copy-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  color: var(--muted);
  padding: 3px 8px;
  font-size: 11.5px;
}
.code-row .copy-btn:hover { border-color: var(--blue); color: var(--blue-dark); }
.code-row .copy-btn.copied { background: var(--green-50); color: #126B43; border-color: #B6E3C7; }

/* ────────────  ANIMATIONS  ──────────── */

.fade-in {
  animation: fadeIn 0.18s ease-out both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ────────────  ANNOUNCEMENTS  ──────────── */

.ann-card {
  background: white;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted-2);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ann-card.ann-prio-important {
  border-left-color: var(--orange);
  background: var(--orange-50);
}
.ann-card.ann-prio-event {
  border-left-color: var(--blue);
  background: var(--blue-50);
}
.ann-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ann-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.ann-badge.ann-prio-important { background: var(--orange); color: white; }
.ann-badge.ann-prio-event { background: var(--blue); color: white; }
.ann-date {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ann-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 2px 0 0;
}
.ann-body {
  font-size: 13.5px;
  color: var(--ink-2);
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
}
.ann-foot {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.ann-widget {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-top: 14px;
}
.ann-widget-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  gap: 12px;
}
.ann-widget-head h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.ann-widget-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link-btn {
  background: transparent;
  border: 0;
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

.ann-page h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  color: var(--ink);
}
.ann-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ann-empty {
  font-size: 13.5px;
  color: var(--muted);
  margin: 8px 0;
}

/* admin section */
.admin-ann {
  margin-top: 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
}
.admin-ann > h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--ink);
}
.admin-ann > h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
  letter-spacing: 0.06em;
}
.admin-ann-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-ann-form h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
  letter-spacing: 0.06em;
}
.admin-ann-form input,
.admin-ann-form textarea,
.admin-ann-form select {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.12s;
}
.admin-ann-form input:focus,
.admin-ann-form textarea:focus,
.admin-ann-form select:focus { border-color: var(--blue); }
.admin-ann-form textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.admin-ann-form-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.admin-ann-form-foot select { flex: 0 0 auto; min-width: 160px; }
.admin-ann-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-ann-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}
.btn-delete {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--red);
  border-radius: var(--r-xs);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.btn-delete:hover { background: var(--red-50); border-color: var(--red); }

/* ────────────  RESPONSIVE  ──────────── */

@media (max-width: 1024px) {
  .module-view { grid-template-columns: 1fr; }
  .chat-page { grid-template-columns: 1fr; }
  .sidebar, .chat-side { position: static; }
  .logipad-wrap { grid-template-columns: 1fr; }
  .module-row { grid-template-columns: 4px 32px 1.4fr 1fr auto auto; }
  .module-row .stats { display: none; }
}
@media (max-width: 900px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-codes { grid-template-columns: 1fr; }
  .admin-table th:nth-child(3), .admin-table td:nth-child(3) { display: none; }
}
@media (max-width: 720px) {
  .container { padding: 16px 14px 32px; }
  .admin-table th:nth-child(5), .admin-table td:nth-child(5) { display: none; }
  .header-inner { padding: 0 14px; gap: 10px; }
  .brand-section { display: none; }
  .nav button { padding: 5px 8px; font-size: 12.5px; }
  .user-chip { display: none; }
  .header-right { gap: 6px; }
  .lang-btn { padding: 4px 8px; font-size: 11px; min-width: 26px; }
  .stat-row { grid-template-columns: 1fr; }
  .panel-head { grid-template-columns: 1fr; }
  .progress-card { border-left: 0; padding-left: 0; padding-top: 14px; border-top: 1px solid var(--line); min-width: 0; }
  .lesson { padding: 16px; }
  .module-row { grid-template-columns: 4px 28px 1fr auto; padding: 10px 12px 10px 0; }
  .module-row .desc, .module-row .stats { display: none; }
  .msg-row { max-width: 90%; }
  .welcome-head { padding: 18px; }
  .welcome-head h1 { font-size: 22px; }
}
