:root {
  --bg: #e9eef3;
  --bg-accent: #e4f0ef;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-raised: #fcfdfd;
  --ink: #0b1220;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --brand: #0d9488;
  --brand-strong: #0f766e;
  --brand-soft: rgba(13, 148, 136, 0.12);
  --brand-glow: rgba(45, 212, 191, 0.28);
  --blue: #0ea5e9;
  --teal: #14b8a6;
  --amber: #d4a017;
  --orange: #ea580c;
  --red: #dc2626;
  --green: #059669;
  --gray: #64748b;
  --accent-gold: #d4a017;
  --accent-gold-soft: rgba(212, 160, 23, 0.14);
  --sidebar-bg: #0f3330;
  --sidebar-bg-2: #133d39;
  --sidebar-ink: rgba(255, 255, 255, 0.96);
  --sidebar-muted: rgba(204, 240, 236, 0.62);
  --sidebar-line: rgba(255, 255, 255, 0.1);
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 10px 32px rgba(15, 23, 42, 0.07);
  --shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.85) inset, 0 16px 48px rgba(15, 23, 42, 0.07);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --font-body: "Inter", "Be Vietnam Pro", "Segoe UI Variable", system-ui, -apple-system, sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 32px;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse 90% 60% at 100% -20%, rgba(13, 148, 136, 0.09), transparent 55%),
    radial-gradient(ellipse 70% 50% at 0% 100%, rgba(212, 160, 23, 0.06), transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 320px),
    var(--bg);
  color: var(--ink);
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--brand);
}

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 14px;
  color: var(--brand-strong);
  background:
    radial-gradient(ellipse 80% 60% at 70% 10%, rgba(13, 148, 136, 0.1), transparent 50%),
    radial-gradient(ellipse 60% 50% at 10% 90%, rgba(212, 160, 23, 0.08), transparent 48%),
    #f8fafc;
}

.boot img {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(13, 148, 136, 0.2);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 55% at 0% 5%, rgba(13, 148, 136, 0.13), transparent 46%),
    radial-gradient(ellipse 60% 50% at 100% 95%, rgba(212, 160, 23, 0.1), transparent 44%),
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(13, 148, 136, 0.07), transparent 40%),
    linear-gradient(160deg, #edfaf8 0%, #f4faf9 38%, #fdfaf2 100%);
}

.login-panel {
  width: min(1040px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}

.login-brand {
  display: grid;
  gap: 18px;
  align-content: start;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-row img {
  width: 58px;
  height: 58px;
}

.brand-row h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.login-brand p,
.login-tagline {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.login-form,
.panel,
.stat-card,
.attendance-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.login-form {
  padding: 24px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow-panel);
}

.login-brand .panel {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(13, 148, 136, 0.14);
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.9) inset, 0 16px 40px rgba(13, 148, 136, 0.1);
  backdrop-filter: blur(10px);
}

.login-form h2,
.panel h2,
.section-title h2 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--ink);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  outline: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.compact-select {
  width: 100%;
  max-width: 190px;
  margin-top: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.input-action-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-action-row input {
  min-width: 180px;
}

.input-action-row .btn {
  flex: 0 0 auto;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-btn {
  cursor: pointer;
}

.brand-settings-panel {
  overflow: hidden;
}

.brand-settings {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, var(--surface-raised));
}

.brand-logo-preview {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.brand-logo-preview img {
  max-width: 70px;
  max-height: 70px;
  border-radius: 8px;
  object-fit: contain;
}

.brand-settings-copy {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.brand-settings-copy strong {
  color: var(--ink);
  font-size: 17px;
}

.brand-settings-copy span {
  color: var(--muted);
  line-height: 1.5;
}

.setup-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.setup-step {
  display: grid;
  gap: 6px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-raised);
  color: var(--ink);
}

.setup-step span {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-weight: 700;
}

.setup-step.done span {
  background: var(--green);
}

/* ─── Role task grid ─── */
.role-task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
  gap: 12px;
  margin-top: 14px;
}

.role-task {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
  box-shadow: 0 1px 3px rgba(15,23,42,0.05);
}

.role-task:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(15,23,42,0.10);
}

.role-task .role-task-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.role-task .role-task-icon svg {
  width: 20px;
  height: 20px;
}

.role-task strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.role-task span {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.3;
}

/* Role task color themes */
.role-task-teal .role-task-icon { background: rgba(13,148,136,0.12); color: #0d9488; }
.role-task-teal:hover { border-color: #0d9488; background: rgba(13,148,136,0.04); }
.role-task-teal strong { color: #0d9488; }

.role-task-blue .role-task-icon { background: rgba(14,165,233,0.12); color: #0ea5e9; }
.role-task-blue:hover { border-color: #0ea5e9; background: rgba(14,165,233,0.04); }
.role-task-blue strong { color: #0369a1; }

.role-task-indigo .role-task-icon { background: rgba(99,102,241,0.12); color: #6366f1; }
.role-task-indigo:hover { border-color: #6366f1; background: rgba(99,102,241,0.04); }
.role-task-indigo strong { color: #4338ca; }

.role-task-cyan .role-task-icon { background: rgba(6,182,212,0.12); color: #0891b2; }
.role-task-cyan:hover { border-color: #06b6d4; background: rgba(6,182,212,0.04); }
.role-task-cyan strong { color: #0e7490; }

.role-task-amber .role-task-icon { background: rgba(217,119,6,0.12); color: #d97706; }
.role-task-amber:hover { border-color: #d97706; background: rgba(217,119,6,0.04); }
.role-task-amber strong { color: #b45309; }

.role-task-red .role-task-icon { background: rgba(220,38,38,0.12); color: #dc2626; }
.role-task-red:hover { border-color: #dc2626; background: rgba(220,38,38,0.04); }
.role-task-red strong { color: #b91c1c; }

.role-task-green .role-task-icon { background: rgba(5,150,105,0.12); color: #059669; }
.role-task-green:hover { border-color: #059669; background: rgba(5,150,105,0.04); }
.role-task-green strong { color: #047857; }

.duplicate-hint {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  color: #991b1b;
  font-size: 13px;
}

.duplicate-hint span {
  display: block;
}

.report-student-search {
  display: grid;
  gap: 10px;
}

.report-student-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  max-height: 210px;
  overflow: auto;
  padding-right: 2px;
}

.report-student-option {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  display: grid;
  gap: 3px;
}

.report-student-option.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(29, 95, 215, 0.1);
}

.report-student-option strong,
.report-student-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-student-option span {
  color: var(--muted);
  font-size: 12px;
}

.editable-copy,
.inline-comment {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

.editable-copy {
  min-height: 190px;
  padding: 12px;
  white-space: pre-wrap;
}

.inline-comment {
  min-width: 220px;
  min-height: 58px;
  padding: 8px;
  font: inherit;
}

.report-evaluation-field {
  margin-top: 4px;
}

.report-evaluation-field textarea {
  min-height: 110px;
}

.convert-wizard,
.wizard-step {
  display: grid;
  gap: 12px;
}

.wizard-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-raised);
}

.finance-drill-panel {
  align-items: stretch;
}

.finance-drilldown {
  min-width: 0;
}

.lead-status-groups,
.lead-advanced-filters {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.lead-status-groups summary,
.lead-advanced-filters summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  list-style-position: outside;
}

.lead-status-body,
.lead-advanced-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

details:not([open]) > .lead-status-body,
details:not([open]) > .lead-advanced-grid,
details:not([open]) > .lead-form-compact {
  display: none;
}

.lead-status-groups h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.btn {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: #eef2f6;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
  transition: transform 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.btn.primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: white;
  box-shadow: 0 10px 24px var(--brand-glow);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #14b8a6 0%, var(--brand-strong) 100%);
}

.btn.blue {
  background: var(--blue);
  color: white;
}

.btn.green {
  background: var(--green);
  color: white;
}

.btn.amber {
  background: var(--amber);
  color: #2b1b00;
}

.btn.orange {
  background: var(--orange);
  color: white;
}

.btn.red {
  background: var(--red);
  color: white;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  box-shadow: none;
}

.btn.ghost:hover {
  background: var(--brand-soft);
  border-color: rgba(13, 148, 136, 0.28);
  color: var(--brand-strong);
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.demo-account {
  background: var(--surface-soft);
  border: 1px solid #c7d9f4;
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  color: var(--ink);
}

.demo-account strong {
  display: block;
  font-size: 13px;
}

.demo-account span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
  margin-top: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

.side {
  position: sticky;
  top: 0;
  z-index: 10;
  background:
    linear-gradient(165deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 60%, #174e49 100%);
  border-bottom: 1px solid var(--sidebar-line);
  display: grid;
  gap: 12px;
  padding: 14px;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.side-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.side-brand-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.side-brand strong {
  display: block;
  color: var(--sidebar-ink);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.side-brand span {
  display: block;
  color: var(--sidebar-muted);
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.side .btn.ghost {
  border-color: var(--sidebar-line);
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, 0.03);
}

.side .btn.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--sidebar-ink);
}

.nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
}

.nav button {
  min-width: 0;
  min-height: 36px;
  border-radius: 8px;
  padding: 7px 12px;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav button.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 6px 18px rgba(0, 0, 0, 0.18);
}

.nav button:not(.active):hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-ink);
}

.module-toggles {
  border-top: 1px solid var(--sidebar-line);
  padding-top: 10px;
  color: var(--sidebar-muted);
  font-size: 13px;
}

.module-toggles summary {
  cursor: pointer;
  font-weight: 800;
}

.toggle-list {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.toggle-list label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.main {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 18px;
}

.topbar {
  display: grid;
  gap: 12px;
  padding: 4px 2px 0;
}

.topbar-copy {
  min-width: 0;
}

.topbar-eyebrow {
  margin: 0 0 4px;
  color: var(--brand-strong);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--ink);
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 14px 8px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent-gold));
  color: #ffffff;
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 6px 14px var(--brand-glow);
}

.user-chip-copy strong {
  display: block;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
}

.user-chip-copy span {
  display: block;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 400;
  line-height: 1.3;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 10px;
  align-items: end;
}

.toolbar .field {
  min-width: 0;
}

.panel {
  padding: 22px;
  display: grid;
  gap: 16px;
  min-width: 0;
  align-content: start;
  box-shadow: var(--shadow-panel);
}

.section-title {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 14px;
}

.section-title-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.section-title-icon svg {
  width: 18px;
  height: 18px;
}

.muted {
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-grid-inline {
  margin-top: 12px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

/* ═══════════════════════════════════════
   Dashboard Hero Header
═══════════════════════════════════════ */
.dash-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 8px 0 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.dash-hero-text {
  min-width: 0;
}

.dash-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin: 0;
  line-height: 1.1;
}

.dash-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 400;
}

/* ═══════════════════════════════════════
   KPI Section + Grid
═══════════════════════════════════════ */
.dash-kpi-section {
  margin-bottom: 0;
}

.dash-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.dash-section-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}

.dash-period-badge {
  flex-shrink: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-strong);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ═══════════════════════════════════════
   KPI Grid
═══════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(148px, 44%), 1fr));
  gap: 10px;
}

/* ═══════════════════════════════════════
   KPI Card  —  Vertical (icon top)
═══════════════════════════════════════ */
.kpi-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px 14px 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(15,23,42,0.05), 0 3px 12px rgba(15,23,42,0.04);
  border: 1px solid var(--line);
  border-top-width: 3px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
  min-width: 0;
  gap: 0;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(15,23,42,0.09);
}

/* Icon sits at top */
.kpi-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 10px;
}

.kpi-icon-wrap svg {
  width: 19px;
  height: 19px;
}

.kpi-body {
  width: 100%;
  min-width: 0;
}

/* Uppercase micro-label */
.kpi-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

/* Value — fixed 18 px, single line, tabular nums */
.kpi-value {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-hint {
  display: block;
  font-size: 10px;
  margin-top: 5px;
  color: var(--muted);
}

/* ─── KPI color themes  (border-top accent) ─── */
.kpi-teal    { border-top-color: #0d9488; }
.kpi-teal    .kpi-icon-wrap { background: rgba(13,148,136,0.11); color: #0d9488; }
.kpi-teal    .kpi-value { color: #0d9488; }

.kpi-blue    { border-top-color: #0ea5e9; }
.kpi-blue    .kpi-icon-wrap { background: rgba(14,165,233,0.11); color: #0ea5e9; }
.kpi-blue    .kpi-value { color: #0369a1; }

.kpi-indigo  { border-top-color: #6366f1; }
.kpi-indigo  .kpi-icon-wrap { background: rgba(99,102,241,0.11); color: #6366f1; }
.kpi-indigo  .kpi-value { color: #4338ca; }

.kpi-green   { border-top-color: #059669; }
.kpi-green   .kpi-icon-wrap { background: rgba(5,150,105,0.11); color: #059669; }
.kpi-green   .kpi-value { color: #047857; }

.kpi-cyan    { border-top-color: #06b6d4; }
.kpi-cyan    .kpi-icon-wrap { background: rgba(6,182,212,0.11); color: #0891b2; }
.kpi-cyan    .kpi-value { color: #0e7490; }

.kpi-amber   { border-top-color: #d97706; }
.kpi-amber   .kpi-icon-wrap { background: rgba(217,119,6,0.11); color: #d97706; }
.kpi-amber   .kpi-value { color: #b45309; }

.kpi-red     { border-top-color: #dc2626; }
.kpi-red     .kpi-icon-wrap { background: rgba(220,38,38,0.11); color: #dc2626; }
.kpi-red     .kpi-value { color: #b91c1c; }

.kpi-orange  { border-top-color: #ea580c; }
.kpi-orange  .kpi-icon-wrap { background: rgba(234,88,12,0.11); color: #ea580c; }
.kpi-orange  .kpi-value { color: #c2410c; }

.kpi-emerald { border-top-color: #10b981; }
.kpi-emerald .kpi-icon-wrap { background: rgba(16,185,129,0.11); color: #10b981; }
.kpi-emerald .kpi-value { color: #065f46; }

.kpi-purple  { border-top-color: #8b5cf6; }
.kpi-purple  .kpi-icon-wrap { background: rgba(139,92,246,0.11); color: #8b5cf6; }
.kpi-purple  .kpi-value { color: #6d28d9; }

.kpi-sky     { border-top-color: #0284c7; }
.kpi-sky     .kpi-icon-wrap { background: rgba(2,132,199,0.11); color: #0284c7; }
.kpi-sky     .kpi-value { color: #075985; }

.stat-card {
  padding: 16px 16px 16px 18px;
  box-shadow: none;
  min-width: 0;
  background: linear-gradient(180deg, #fff, var(--surface-raised));
  border-left: 3px solid var(--brand);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.stat-card small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
}

.grid-2,
.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.lead-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.lead-side-panel {
  align-self: start;
}

.lead-primary-toolbar {
  display: grid;
  grid-template-columns: minmax(200px, 1.4fr) repeat(3, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.lead-advanced-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.lead-create {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  padding: 12px;
}

.lead-create summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  list-style-position: outside;
}

.lead-form-compact {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 12px;
}

.lead-card-list {
  display: grid;
  gap: 10px;
}

.lead-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  min-width: 0;
  box-shadow: var(--shadow-soft);
}

.lead-card-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.lead-card-copy {
  min-width: 0;
}

.lead-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.lead-title-row h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.lead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 5px;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.4;
}

.lead-meta span {
  overflow-wrap: anywhere;
}

.lead-status-edit {
  display: grid;
  gap: 4px;
}

.lead-status-edit label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.lead-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.lead-card-actions .btn {
  min-height: 36px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  justify-content: center;
}
.btn-sm {
  font-size: var(--fs-xs);
  padding: 4px 10px;
  height: auto;
  min-height: 28px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
  font-size: var(--fs-sm);
  line-height: 1.45;
}

th {
  color: var(--muted);
  background: linear-gradient(180deg, #f8fafc, #eef2f6);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr:not(.student-group-row):hover td {
  background: rgba(13, 148, 136, 0.04);
}

tr:last-child td {
  border-bottom: 0;
}

.student-index-head,
.student-index-cell {
  width: 54px;
  text-align: center;
  white-space: nowrap;
}

.student-index-cell {
  color: var(--muted);
  font-weight: 700;
}

.student-group-row td {
  background: #f7faff;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.student-list-panel {
  overflow: hidden;
}

.student-campus-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  padding-bottom: 4px;
  overflow-x: auto;
}

.student-campus-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink-soft);
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}

.student-campus-tab.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 10px 24px var(--brand-glow);
}

.student-campus-tab .badge {
  min-width: 24px;
  justify-content: center;
}

.student-campus-panel {
  min-width: 0;
}

.student-table {
  min-width: 780px;
}

.student-table th:first-child,
.student-table td:first-child {
  padding-left: 16px;
}

.student-table th:last-child,
.student-table td:last-child {
  padding-right: 16px;
}

.student-table td strong {
  color: var(--ink);
  font-weight: 700;
}

.student-table .muted {
  display: inline-block;
  margin-top: 2px;
}

.student-actions {
  gap: 6px;
}

.student-actions .btn {
  min-height: 34px;
  padding: 8px 10px;
}

.student-detail-panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 253, 255, 0.98)),
    var(--surface);
}

.student-detail-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(90deg, var(--brand), var(--teal));
}

.student-detail-panel .task-row {
  background: #fff;
  border-color: #e8eef6;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: #edf2f7;
  color: var(--ink);
}

.badge.green {
  background: #e3f7ef;
  color: #0f6f4d;
}

.badge.yellow {
  background: #fff4d6;
  color: #8a5a07;
}

.badge.red {
  background: #fde8e8;
  color: #9f2f2f;
}

.badge.blue {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.badge.orange {
  background: #fff0df;
  color: #a64c13;
}

tr.row-warn > td { background: #fffbeb; }
tr.row-danger > td { background: #fff1f1; }
tr.row-warn:hover > td { background: #fef3c7; }
tr.row-danger:hover > td { background: #fee2e2; }

.badge.gray {
  background: #edf1f5;
  color: #455468;
}

.attendance-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.flex-attendance {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.flex-selection-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.flex-selection-bar label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--ink);
}

.flex-student-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 2px;
}

.flex-student-option {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.flex-student-option span {
  min-width: 0;
}

.flex-student-option strong,
.flex-student-option small {
  display: block;
}

.flex-student-option small {
  color: var(--muted);
  margin-top: 2px;
}

.flex-package-select {
  margin-top: 0.35rem;
  width: 100%;
  max-width: 280px;
}

.flex-student-option em {
  font-style: normal;
}

@media (max-width: 520px) {
  .flex-selection-bar,
  .flex-student-option {
    grid-template-columns: auto 1fr;
  }

  .flex-selection-bar {
    display: grid;
  }

  .flex-student-option em {
    grid-column: 2;
    justify-self: start;
  }
}

.attendance-card {
  padding: 18px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 12px;
  background: linear-gradient(180deg, #fff, var(--surface-raised));
  border-left: 3px solid var(--accent-gold);
}

.attendance-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.attendance-head h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.attendance-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.attendance-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.attendance-actions .btn {
  min-height: 46px;
  white-space: normal;
  text-align: center;
}

.comment-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.comment-row input {
  min-width: 0;
}

.task-list {
  display: grid;
  gap: 0;
}

.alert-list {
  display: grid;
  gap: 8px;
}

/* ─── Task row ─── */
.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  background: none;
  border-radius: 0;
  box-shadow: none;
}

.task-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.task-row-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.55;
}

.task-row span {
  flex: 1;
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.task-row strong {
  font-size: var(--fs-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 2ch;
  text-align: right;
}

.operational-task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.operational-task {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-soft);
}

.operational-task.high {
  border-left: 4px solid var(--red);
}

.operational-task.medium {
  border-left: 4px solid var(--amber);
}

.operational-task.low {
  border-left: 4px solid var(--brand);
}

.operational-task-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.operational-task-head strong {
  font-size: var(--fs-base);
  color: var(--ink);
}

.operational-task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* ─── Alert item ─── */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-left-color: var(--brand);
  box-shadow: none;
}

.alert-item.warning {
  border-left-color: var(--amber);
  background: rgba(217,119,6,0.04);
}

.alert-item.danger {
  border-left-color: var(--red);
  background: rgba(220,38,38,0.04);
}

.alert-item.notice {
  border-left-color: var(--teal);
}

.alert-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(217,119,6,0.10);
  color: #d97706;
  margin-top: 1px;
}

.alert-item.danger .alert-icon {
  background: rgba(220,38,38,0.10);
  color: #dc2626;
}

.alert-item.notice .alert-icon {
  background: rgba(13,148,136,0.10);
  color: #0d9488;
}

.alert-icon svg {
  width: 16px;
  height: 16px;
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-body strong {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.alert-body span {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: 2px;
}

.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e7edf5;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--teal));
}

.empty {
  min-height: 180px;
  padding: 24px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.94)),
    var(--surface-raised);
  line-height: 1.55;
}

.empty.danger {
  min-height: auto;
  color: #8f1f1f;
  border-color: #f2b8b5;
  background: #fff5f5;
}

.stat-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.package-balance-row {
  align-items: flex-start;
}

.package-reconcile-warning {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: 8px;
  background: rgba(254, 226, 226, 0.45);
}

.finance-debt-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.finance-debt-note {
  margin: -4px 0 12px;
  font-size: var(--fs-sm);
}

.finance-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.session-adjust-form {
  margin: -8px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.pkg-confirmation-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  padding: 10px 14px;
  margin: 4px 0 10px;
}

.pkg-confirmation-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.pkg-confirmation-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}

.pkg-confirmation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pkg-confirmation-meta strong {
  color: var(--text);
}

.pkg-conf-actions {
  margin-top: 6px;
  flex-wrap: wrap;
}

.badge.green {
  background: #ecfdf5;
  color: #065f46;
}

.badge.red {
  background: #fef2f2;
  color: #991b1b;
}

.ai-panel {
  background:
    linear-gradient(135deg, rgba(13, 148, 136, 0.07), rgba(212, 160, 23, 0.05)),
    var(--surface);
}

.ai-panel .section-title h2,
.ai-result h3 {
  margin: 0;
}

.ai-toolbar {
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
}

.ai-run-field .btn {
  width: 100%;
  min-height: 44px;
}

.ai-insight-result,
.ai-result,
.ai-section,
.ai-action-list {
  display: grid;
  gap: 14px;
}

.ai-context-box {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  padding: 14px;
}

.ai-empty {
  min-height: 118px;
}

.ai-mini-empty {
  min-height: auto;
  padding: 14px;
}

.ai-settings-grid {
  align-items: start;
}

.ai-setup-empty,
.ai-health-box {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  padding: 16px;
}

.ai-setup-empty {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.ai-setup-empty h3 {
  margin: 0 0 6px;
  color: var(--ink);
}

.ai-health-box {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin: 14px 0;
}

.ai-health-box div {
  display: grid;
  gap: 4px;
}

.ai-health-box span,
.help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
}

.switch-field input {
  width: 18px;
  height: 18px;
}

.ai-steps {
  margin: 0;
  padding-left: 22px;
  color: var(--ink);
  line-height: 1.7;
}

.ai-steps li + li {
  margin-top: 8px;
}

.ai-score-card {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  padding: 14px;
}

.ai-score-meter {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 26px;
  font-weight: 700;
}

.ai-score-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 18px;
}

.ai-score-card span,
.ai-action-item p,
.ai-action-next {
  color: var(--muted);
}

.ai-section {
  min-width: 0;
}

.ai-section h3 {
  font-size: 16px;
}

.ai-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ai-summary-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-soft);
}

.ai-summary-list li + li {
  margin-top: 8px;
}

.ai-action-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.ai-action-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.ai-action-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ai-action-item p {
  margin: 0;
}

.ai-action-item dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.ai-action-item dl div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-raised);
  min-width: 0;
}

.ai-action-item dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.ai-action-item dd {
  margin: 3px 0 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.ai-action-next {
  display: block;
  border-left: 3px solid var(--teal);
  padding-left: 10px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  background: #102033;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--red);
}

.split-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.copy-box {
  white-space: pre-wrap;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  line-height: 1.55;
}

.mini-chart {
  display: grid;
  gap: 8px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.chart-row span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-bar {
  height: 10px;
  border-radius: 999px;
  background: #e7edf5;
  overflow: hidden;
}

.chart-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.finance-visuals {
  align-items: stretch;
}

.finance-chart {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.finance-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.finance-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.finance-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--blue);
  flex-shrink: 0;
}

.finance-legend i.teal,
.finance-bar.teal {
  background: var(--teal);
}

.finance-legend i.blue,
.finance-bar.blue {
  background: var(--blue);
}

.finance-legend i.green,
.finance-bar.green {
  background: var(--green);
}

.finance-legend i.orange,
.finance-bar.orange {
  background: var(--orange);
}

.finance-legend i.red,
.finance-bar.red {
  background: var(--red);
}

.finance-chart-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.finance-chart-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(34px, 1fr));
  gap: 2px;
  min-width: max(100%, min(760px, calc(var(--columns) * 52px)));
  min-height: 210px;
  align-items: end;
  background:
    linear-gradient(0deg, var(--line-strong) 0, var(--line-strong) 1px, transparent 1px),
    repeating-linear-gradient(90deg, transparent 0, transparent calc(var(--columns) * 52px));
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 0;
}

.finance-chart-column {
  display: grid;
  gap: 4px;
  align-items: end;
  min-width: 0;
}

.finance-bars {
  height: 178px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 2px;
  padding: 4px 3px 0;
  background: none;
  border: none;
}

.finance-bar {
  flex: 1;
  max-width: 14px;
  min-width: 6px;
  min-height: 0;
  border-radius: 4px 4px 0 0;
  background: var(--blue);
  transition: opacity 0.1s;
}

.finance-bar:hover {
  opacity: 0.75;
  cursor: default;
}

.finance-chart-column small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  padding: 3px 2px 0;
}

/* --- Finance KPI grouped cards --- */
.finance-kpi-section {
  display: grid;
  gap: 12px;
}

.finance-kpi-group {
  display: grid;
  gap: 6px;
}

.finance-kpi-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 2px;
}

.finance-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.finance-kpi-row.secondary {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.finance-kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: 12px;
  padding: 14px 15px 12px;
  display: grid;
  gap: 5px;
  min-width: 0;
}

.finance-kpi-card.teal  { border-top-color: var(--teal); }
.finance-kpi-card.blue  { border-top-color: var(--blue); }
.finance-kpi-card.amber { border-top-color: var(--amber); }
.finance-kpi-card.red   { border-top-color: var(--red); }
.finance-kpi-card.orange{ border-top-color: var(--orange); }
.finance-kpi-card.green { border-top-color: var(--green); }
.finance-kpi-card.gray  { border-top-color: var(--line-strong); }

.finance-kpi-card span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.finance-kpi-card strong {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
  font-family: var(--font-display);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.finance-kpi-card.small strong {
  font-size: 14px;
}

/* --- Trend comparison cards (replaces growth rings) --- */
.trend-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  height: 100%;
  align-content: start;
}

.trend-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  display: grid;
  gap: 5px;
  min-width: 0;
}

.trend-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trend-card-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.trend-card-badge.up {
  background: rgba(5, 150, 105, 0.1);
  color: var(--green);
}

.trend-card-badge.down {
  background: rgba(220, 38, 38, 0.09);
  color: var(--red);
}

.trend-card-badge.neutral {
  background: var(--surface-soft);
  color: var(--muted);
}

.trend-card-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--ink);
  font-family: var(--font-display);
  overflow-wrap: anywhere;
}

.trend-card-compare {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}

.trend-card-prev {
  font-size: 12px;
  color: var(--muted);
}

.trend-card-delta {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.trend-card-delta.positive { color: var(--green); }
.trend-card-delta.negative { color: var(--red); }

@media (max-width: 759px) {
  .user-chip-copy {
    display: none;
  }

  .user-chip {
    padding-right: 10px;
    min-height: 42px;
  }

  .topbar-eyebrow {
    display: none;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .topbar p {
    display: none;
  }
}

@media (max-width: 759px) {
  .login-shell {
    padding: 12px;
    align-items: start;
  }

  .login-brand p {
    font-size: 14px;
    line-height: 1.5;
  }

  .demo-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .stat-grid-inline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell {
    min-height: 100dvh;
  }

  .side {
    padding: 10px;
    gap: 10px;
  }

  .side-brand {
    align-items: start;
  }

  .side-brand-main {
    min-width: 0;
  }

  .side-brand-main > div {
    min-width: 0;
  }

  .side-brand strong,
  .side-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-inline: 0;
    padding: 0;
  }

  .nav button {
    min-height: 42px;
    padding: 9px 10px;
    white-space: normal;
  }

  .module-toggles {
    max-height: 150px;
    overflow: auto;
  }

  .brand-settings {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .main {
    padding: 12px;
    gap: 12px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .topbar p {
    font-size: 13px;
    line-height: 1.45;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar .field {
    min-width: 0;
  }

  .ai-section-grid,
  .ai-score-card,
  .ai-action-item dl {
    grid-template-columns: 1fr;
  }

  .ai-score-meter {
    width: 64px;
    height: 64px;
  }

  .lead-primary-toolbar {
    grid-template-columns: 1fr;
  }

  .panel,
  .attendance-card,
  .stat-card {
    padding: 12px;
  }

  .button-row {
    align-items: stretch;
  }

  .button-row .btn {
    flex: 1 1 128px;
    white-space: normal;
    min-height: 44px;
    text-align: center;
  }

  .input-action-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .input-action-row .btn {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
  }

  td {
    border-bottom: 0;
    padding: 10px 12px;
  }

  td + td {
    border-top: 1px solid var(--line);
  }

  td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  .student-index-cell {
    display: inline-flex;
    width: auto;
    min-width: 32px;
    justify-content: center;
    margin: 10px 10px 0;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    padding: 4px 10px;
  }

  .student-index-cell + td {
    border-top: 0;
  }

  .compact-select {
    max-width: none;
  }

  .attendance-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .attendance-actions,
  .comment-row,
  .chart-row {
    grid-template-columns: 1fr;
  }

  .trend-card-grid {
    grid-template-columns: 1fr;
  }

  .finance-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .finance-kpi-row.secondary {
    grid-template-columns: repeat(2, 1fr);
  }

  .finance-row-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .finance-row-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .ai-setup-empty {
    grid-template-columns: 1fr;
  }

  .chart-row span:first-child {
    white-space: normal;
  }
}

@media (min-width: 760px) {
  .login-panel {
    grid-template-columns: 1fr 420px;
    align-items: center;
  }

  .form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat-grid-inline {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .attendance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (min-width: 980px) {
  .lead-layout {
    grid-template-columns: minmax(0, 2.2fr) minmax(280px, 0.8fr);
  }

  .lead-card-main {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 220px);
  }
}

@media (min-width: 1120px) {
  .app-shell {
    grid-template-columns: 272px 1fr;
  }

  .side {
    min-height: 100vh;
    border-right: 1px solid var(--sidebar-line);
    border-bottom: 0;
    align-content: start;
    padding: 20px 18px;
    position: sticky;
    top: 0;
  }

  .nav {
    display: grid;
    overflow-x: visible;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .nav button {
    width: 100%;
    text-align: left;
    justify-content: start;
    padding-left: 14px;
  }

  .nav button.active {
    border-left: 3px solid rgba(255, 255, 255, 0.7);
    padding-left: 11px;
  }

  .main {
    padding: 28px 32px 32px;
    max-width: none;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 16px;
  }

  .attendance-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .split-panel {
    grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.65fr);
  }
}

.student-import-block {
  margin-top: 12px;
}

.student-import-block > summary {
  margin-bottom: 8px;
}

.student-import-panel {
  margin-top: 12px;
}

.student-import-panel .legacy-import-dry-run {
  margin-top: 16px;
}

.legacy-import-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}

.legacy-select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.legacy-select-cell {
  width: 42px;
  text-align: center;
}

.legacy-select-cell input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.legacy-import-table-wrap {
  overflow-x: auto;
}

.legacy-import-table {
  min-width: 1200px;
}

.legacy-row-error {
  background: #fff1f2;
}

.legacy-applied-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.session-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.session-chip {
  min-height: 36px;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s;
}

.session-chip:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.session-chip.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px var(--brand-glow);
}

.btn.link,
.legacy-student-link {
  padding: 0;
  min-height: 0;
  background: none;
  border: none;
  color: var(--brand-strong);
  text-align: left;
  font-weight: 700;
}

.btn.link:hover,
.legacy-student-link:hover {
  text-decoration: underline;
}

/* ── Generic modal overlay ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { margin: 0; font-size: var(--fs-lg); }
.modal-body .info-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
}
.modal-body .info-row span { color: var(--ink-muted); min-width: 90px; }

/* ── Lead status timeline ──────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 20px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line-soft);
}
.timeline-item {
  display: flex;
  gap: 10px;
  position: relative;
  padding-bottom: 14px;
}
.timeline-dot {
  position: absolute;
  left: -17px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--brand);
  flex-shrink: 0;
}
.timeline-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.timeline-status {
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--text-primary);
}
.timeline-time {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
}
.timeline-note {
  margin: 4px 0 0;
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  font-style: italic;
}
.timeline-user {
  font-size: var(--fs-xs);
  color: var(--brand);
}
