/* ==========================================================================
   Components (shared by every shell)
   ========================================================================== */

/* --- Buttons --------------------------------------------------------------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 9px 20px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 700; font-size: .95rem; line-height: 1.4; cursor: pointer; white-space: nowrap;
  background: var(--primary); color: var(--on-primary); box-shadow: 0 4px 12px rgba(18, 59, 50, .22);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .12s, color .15s;
}
.btn:hover { background: var(--primary-600); color: var(--on-primary); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(18, 59, 50, .28); }
.btn:active { transform: translateY(0); }
.btn-lg { min-height: 52px; padding: 12px 28px; font-size: 1.02rem; border-radius: 14px; }
.btn-sm { min-height: 38px; padding: 5px 14px; font-size: .88rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn-soft { background: var(--primary-50); color: var(--link); box-shadow: none; }
.btn-soft:hover { background: var(--primary-100); color: var(--primary-700); box-shadow: none; }
.btn-success { background: var(--success-solid); box-shadow: 0 4px 12px rgba(12, 125, 85, .22); }
.btn-success:hover { background: #096544; box-shadow: 0 6px 16px rgba(12, 125, 85, .28); }
.btn-danger { background: var(--danger-solid); box-shadow: 0 4px 12px rgba(180, 35, 24, .2); }
.btn-danger:hover { background: #911c12; }
.btn-danger-ghost { background: var(--surface); color: var(--danger); border-color: var(--danger-line); box-shadow: none; }
.btn-danger-ghost:hover { background: var(--danger-50); color: var(--danger); box-shadow: none; }
.btn-accent { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px rgba(217, 108, 74, .28); }
.btn-accent:hover { background: var(--accent-600); color: var(--on-accent); box-shadow: 0 6px 16px rgba(217, 108, 74, .36); }
.btn-light { background: #fff; color: var(--primary-700); box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.btn-light:hover { background: var(--primary-50); color: var(--primary-700); }
.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); box-shadow: none; }
.btn-outline-light:hover { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: none; }
.btn[disabled], .btn.is-disabled { opacity: .55; pointer-events: none; }
/* Loading state: set by app.js on submit. Layout stays put; a spinner replaces the text colour. */
.btn.is-loading { pointer-events: none; color: transparent !important; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn-ghost.is-loading::after, .btn-soft.is-loading::after, .btn-danger-ghost.is-loading::after {
  border-color: rgba(11, 91, 211, .25); border-top-color: var(--primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--primary-50); color: var(--link); border-color: var(--primary-100); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger-50); color: var(--danger); border-color: var(--danger-line); }
@media (pointer: coarse) { .icon-btn { width: 44px; height: 44px; } }
.inline-form { display: inline; }

/* --- Badges ---------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 11px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; line-height: 1.7; white-space: nowrap;
}
.badge-free { background: var(--success-50); color: var(--success); }
.badge-paid { background: var(--warning-50); color: var(--warning); }
.badge-locked { background: var(--surface-2); color: var(--muted); }
.badge-unlocked { background: var(--primary-50); color: var(--link); }
.badge-pending { background: var(--warning-50); color: var(--warning); }
.badge-approved { background: var(--success-50); color: var(--success); }
.badge-rejected, .badge-revoked { background: var(--danger-50); color: var(--danger); }
.badge-cancelled, .badge-hidden { background: var(--surface-2); color: var(--muted); }
.badge-published, .badge-active { background: var(--success-50); color: var(--success); }
.badge-solid { background: color-mix(in srgb, var(--surface) 95%, transparent); box-shadow: 0 2px 8px rgba(8, 42, 107, .18); }

/* --- Forms ----------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field > label { font-weight: 700; font-size: .93rem; color: var(--text); }
.field .hint { color: var(--faint); font-size: .85rem; }
.field .error { color: var(--danger); font-size: .87rem; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--border-strong), var(--text) 22%); }
.textarea { min-height: 120px; resize: vertical; }
.select { appearance: none; background-image: var(--chevron); background-repeat: no-repeat; background-position: left 14px center; padding-inline-end: 14px; padding-inline-start: 40px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-100); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
input[type="file"].input { padding: 8px 10px; min-height: 48px; }
input[type="file"]::file-selector-button { margin-inline-end: 12px; padding: 6px 14px; border: 0; border-radius: 8px; background: var(--primary-50); color: var(--link); font: inherit; font-weight: 700; cursor: pointer; }
.has-error .input, .has-error .textarea, .has-error .select { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-50); }
.input[dir="ltr"] { text-align: right; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.segmented label {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer;
  border: 1.5px solid var(--border-strong); border-radius: 12px; font-weight: 700; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.segmented input { accent-color: var(--primary); width: 18px; height: 18px; }
.segmented label:has(input:checked) { border-color: var(--primary); background: var(--primary-50); color: var(--primary-700); }
.segmented label:has(input:focus-visible) { box-shadow: var(--ring); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-inline-end: 50px; }
.pw-toggle { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 9px; cursor: pointer; color: var(--faint); border-radius: 8px; }
.pw-toggle:hover { color: var(--link); }
.color-input { width: 54px; height: 44px; padding: 3px; border: 1.5px solid var(--border-strong); border-radius: 10px; background: var(--surface); cursor: pointer; }

/* Search field with icon */
.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search .input { padding-inline-start: 44px; border-radius: 999px; background: var(--surface); }
.search svg { position: absolute; top: 50%; inset-inline-start: 16px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }

/* --- Cards & surfaces ------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-flat { box-shadow: none; }
.card-body { padding: 24px; }
.card-head { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.card-head h2 svg, .card-head h3 svg { color: var(--link); }
@media (max-width: 640px) { .card-body { padding: 18px; } .card-head { padding: 14px 18px; } }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head p { margin: 2px 0 0; }
.section { padding: 56px 0; }
.page-head { padding: 34px 0 14px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--faint); font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.back-link:hover { color: var(--link); }

/* --- Alerts / flash -------------------------------------------------------- */
.alert {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px; border-radius: 14px; margin-bottom: 18px;
  font-weight: 600; border: 1px solid transparent; line-height: 1.6;
}
.alert > svg { flex: none; margin-top: 3px; }
.alert-body { flex: 1; min-width: 0; }
.alert-close { flex: none; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 4px; border-radius: 6px; }
.alert-close:hover { opacity: 1; }
.alert-success { background: var(--success-50); color: var(--alert-success-ink); border-color: var(--alert-success-line); }
.alert-error { background: var(--danger-50); color: var(--alert-error-ink); border-color: var(--alert-error-line); }
.alert-info { background: var(--primary-50); color: var(--alert-info-ink); border-color: var(--primary-100); }
.alert-warning { background: var(--warning-50); color: var(--alert-warning-ink); border-color: var(--alert-warning-line); }
.alert.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .3s, transform .3s; }

/* --- Empty state ----------------------------------------------------------- */
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.empty .empty-icon { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-50); color: var(--link); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 420px; margin-inline: auto; }
.empty .btn { margin-top: 6px; }

/* --- Progress -------------------------------------------------------------- */
.progress { height: 8px; background: var(--primary-50); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--bar-a, var(--primary)), var(--bar-b, var(--sky))); border-radius: 99px; transition: width .4s ease; }
.progress.lg { height: 12px; }
.progress-row { display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--muted); }
.progress-row .progress { flex: 1; }
.progress-row strong { color: var(--text); min-width: 42px; text-align: end; }
.progress-done > span { background: linear-gradient(90deg, var(--success), #4cc38a); }

/* --- Stat cards ------------------------------------------------------------ */
/* flex, not grid: an incomplete last row (5 cards in 4 columns, say) would leave
   a grid track empty next to the lone card; flex-grow lets it fill that space instead. */
.stats { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 26px; }
.stats > .stat { flex: 1 1 170px; }
.stat { position: relative; padding: 20px; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
a.stat { color: inherit; transition: transform .15s, box-shadow .15s; }
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: inherit; }
.stat .k { color: var(--muted); font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.stat .k svg { flex: none; width: 34px; height: 34px; padding: 8px; border-radius: 11px; background: var(--primary-50); color: var(--link); box-sizing: border-box; }
.stat .v { font-size: 2rem; font-weight: 800; line-height: 1.2; color: var(--text); }
.stat .v small { font-size: .95rem; font-weight: 600; color: var(--faint); }
.stat .sub { color: var(--faint); font-size: .85rem; }
.stat.hl { background: linear-gradient(135deg, var(--hl-a), var(--hl-b)); color: #fff; border: 0; }
.stat.hl .k, .stat.hl .sub { color: rgba(255, 255, 255, .9); }
.stat.hl .k svg { background: rgba(255, 255, 255, .2); color: #fff; }
.stat.hl .v { color: #fff; }
.stat.warn .v { color: var(--warning); }
.stat.warn .k svg { background: var(--warning-50); color: var(--warning); }
.stat.tint-1 .k svg { background: var(--t1-50); color: var(--t1-ink); }
.stat.tint-2 .k svg { background: var(--t2-50); color: var(--t2-ink); }
.stat.tint-3 .k svg { background: var(--warning-50); color: #c46a00; }
.stat.tint-4 .k svg { background: var(--success-50); color: var(--success); }

/* --- Tabs / chips (link groups) ------------------------------------------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 24px; }
.chips { display: inline-flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 4px; flex-wrap: wrap; box-shadow: var(--shadow-sm); }
.chips a { padding: 7px 16px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: .92rem; transition: background .15s, color .15s; }
.chips a:hover { background: var(--surface-2); color: var(--text); }
.chips a.active, .chips a[aria-current="page"] { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(11, 91, 211, .25); }

/* --- Dropdown (details-based, JS only closes it on outside click) ---------- */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 80; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px;
}
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none;
  border-radius: 9px; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: start;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--primary-50); color: var(--link); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dropdown-menu .who { padding: 8px 12px 6px; }
.dropdown-menu .who strong { display: block; line-height: 1.3; }
.user-trigger { display: inline-flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; color: var(--text); }
.user-trigger:hover { border-color: var(--primary-100); background: var(--primary-50); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--sky)); color: #fff; font-weight: 800; font-size: .95rem;
}

/* --- Course cover & card --------------------------------------------------- */
.cover {
  --c1: var(--t0-a); --c2: var(--t0-b);
  position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden; color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2));
}
.cover.tint-1 { --c1: var(--t1-a); --c2: var(--t1-b); }
.cover.tint-2 { --c1: var(--t2-a); --c2: var(--t2-b); }
.cover.tint-3 { --c1: var(--t3-a); --c2: var(--t3-b); }
.cover.tint-4 { --c1: var(--t4-a); --c2: var(--t4-b); }
.cover::before, .cover::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .13); }
.cover::before { width: 60%; aspect-ratio: 1; inset-inline-end: -14%; top: -40%; }
.cover::after { width: 40%; aspect-ratio: 1; inset-inline-start: -10%; bottom: -35%; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .cover-fallback { position: relative; z-index: 1; display: grid; place-items: center; gap: 4px; text-align: center; }
.cover .cover-fallback svg { opacity: .9; }
.cover .cover-fallback b { font-size: 2rem; font-weight: 800; line-height: 1; opacity: .95; }
.cover .badge { position: absolute; z-index: 2; top: 12px; inset-inline-start: 12px; }
.cover .lock {
  position: absolute; z-index: 2; top: 12px; inset-inline-end: 12px; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(15, 51, 43, .75); color: #fff; display: grid; place-items: center; backdrop-filter: blur(4px);
}
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }
.course-card { display: flex; flex-direction: column; overflow: hidden; transition: transform .18s, box-shadow .18s, border-color .18s; }
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-100); }
.course-card .card-body { display: flex; flex-direction: column; flex: 1; gap: 8px; padding: 18px 20px 20px; }
.course-card h3 { margin: 0; font-size: 1.08rem; line-height: 1.5; }
.course-card h3 a { color: var(--text); }
.course-card h3 a:hover { color: var(--link); }
.course-card .desc { color: var(--muted); font-size: .93rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 3.3em; margin: 0; }
.course-meta { display: flex; gap: 6px 14px; color: var(--faint); font-size: .86rem; flex-wrap: wrap; align-items: center; }
.course-meta span { display: inline-flex; align-items: center; gap: 5px; }
.course-foot { margin-top: auto; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.price { font-weight: 800; font-size: 1.1rem; color: var(--text); }
.price.free { color: var(--success); }

/* --- Tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th { text-align: start; font-weight: 700; color: var(--muted); font-size: .83rem; padding: 12px 16px; background: var(--surface-2); white-space: nowrap; }
.table td { padding: 14px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: var(--row-hover); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; align-items: center; }
.cell-user { display: flex; gap: 10px; align-items: center; }
.cell-user .n { font-weight: 700; }
.cell-user .p { color: var(--faint); font-size: .85rem; direction: ltr; text-align: end; }
.thumb { width: 64px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; }
.thumb-fallback { display: grid; place-items: center; color: var(--link); font-weight: 800; }
/* A course row with no cover renders <span class="thumb cover tint-N">: without this,
   .thumb's flat background (same specificity, declared after .cover) hides the gradient. */
.thumb.cover { background: linear-gradient(135deg, var(--c1), var(--c2)); }
/* Tables become stacked cards when THEIR container is narrow (not the window), so a table
   next to the admin sidebar stacks as early as it needs to. */
.table-wrap { container-type: inline-size; }
@container (max-width: 860px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border-top: 1px solid var(--border); padding: 10px 4px; }
  .table.responsive tr:first-child { border-top: 0; }
  .table.responsive td { border: 0; padding: 6px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .table.responsive td[data-l]::before { content: attr(data-l); color: var(--faint); font-size: .84rem; font-weight: 600; flex: none; }
  .table.responsive .actions { justify-content: flex-start; flex-wrap: wrap; }
}

/* --- Lists ----------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 14px 20px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.list li + li { border-top: 1px solid var(--border); }

/* --- Files / attachments --------------------------------------------------- */
.resource { display: flex; align-items: center; gap: 14px; padding: 14px 20px; }
.resource + .resource { border-top: 1px solid var(--border); }
.resource .grow { min-width: 0; }
.resource .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-badge { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: .72rem; background: var(--danger-50); color: var(--danger); letter-spacing: .5px; }
.file-badge.link { background: var(--primary-50); color: var(--link); }
.attachment { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.link-danger { background: none; border: 0; padding: 0; font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; color: var(--danger); display: inline-flex; align-items: center; gap: 4px; }
.link-danger:hover { text-decoration: underline; }
.attach-form { margin-top: 4px; }
.attach-label { color: var(--link); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.attach-label:hover { text-decoration: underline; }
.attach-label:focus-within { outline: 3px solid rgba(232, 180, 74, .6); outline-offset: 2px; border-radius: 4px; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 14px; padding: 16px; background: var(--surface-2); }
.upload-progress { display: none; margin-top: 10px; }
.upload-progress.show { display: block; }

.payinfo {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border: 1.5px dashed var(--primary); border-radius: 14px; background: var(--primary-50);
}
.payinfo-value { font-size: 1.3rem; font-weight: 800; letter-spacing: 1px; display: block; }
@media (max-width: 480px) { .payinfo-value { font-size: 1.1rem; } }

/* --- Modal (native <dialog>, driven by app.js) ---------------------------- */
.modal { border: 0; padding: 0; background: transparent; max-width: 460px; width: calc(100% - 32px); color: var(--text); font-family: var(--font); }
.modal::backdrop { background: rgba(8, 24, 19, .6); backdrop-filter: blur(3px); }
.modal-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 28px 26px 22px; text-align: start; margin: 0; }
.modal-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 14px; background: var(--primary-50); color: var(--link); }
.modal.danger .modal-icon { background: var(--danger-50); color: var(--danger); }
.modal-title { margin: 0 0 6px; font-size: 1.15rem; }
.modal-text { margin: 0; color: var(--muted); white-space: pre-line; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 24px; flex-wrap: wrap; }
.modal-actions .btn { min-width: 120px; }
@media (max-width: 420px) { .modal-actions .btn { flex: 1; min-width: 0; } }
.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* --- Charts (server-rendered SVG) ------------------------------------------ */
.chart { margin: 0; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.chart-head h3 { margin: 0; font-size: 1.02rem; }
.chart-svg { width: 100%; height: auto; overflow: visible; display: block; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis-line { stroke: var(--border-strong); stroke-width: 1; }
.chart-svg .axis { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart-svg .axis.mid { text-anchor: middle; }
.chart-svg .bar-value { fill: var(--text); font-size: 12px; font-weight: 700; text-anchor: middle; font-family: var(--font); }
.chart-svg .bar { transition: opacity .12s; }
.chart-svg .bar-hit { fill: transparent; }
.chart-svg .bar-group:hover .bar-hit { fill: var(--surface-2); }
.chart-svg .bar-group:hover .bar { opacity: .82; }
.chart-empty { padding: 42px 16px; text-align: center; color: var(--muted); border: 1.5px dashed var(--border-strong); border-radius: 14px; }
.chart-table { margin-top: 12px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: .88rem; font-weight: 600; }
.chart-table table { margin-top: 8px; }
.chart-tip {
  position: fixed; z-index: 200; pointer-events: none; padding: 7px 12px; border-radius: 9px;
  background: var(--deep); color: #fff; font-size: .84rem; font-weight: 700; white-space: nowrap;
  box-shadow: var(--shadow-lg); transform: translate(-50%, -140%); opacity: 0; transition: opacity .1s;
}
.chart-tip.show { opacity: 1; }
.dist { display: flex; flex-direction: column; gap: 14px; }
.dist-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 12px; }
.dist-label { font-size: .9rem; color: var(--muted); }
.dist-track { display: block; background: var(--surface-2); border-radius: 99px; height: 14px; overflow: hidden; }
.dist-bar { display: block; height: 100%; border-radius: 99px; }
.dist-value { font-weight: 700; min-width: 64px; text-align: end; }
@media (max-width: 480px) { .dist-row { grid-template-columns: 78px 1fr auto; } }

/* --- Small helpers used by student pages ----------------------------------- */
.pb-0 { padding-bottom: 0 !important; } .pt-0 { padding-top: 0 !important; } .pb-5 { padding-bottom: 48px; }
.price-lg { font-size: 1.5rem; }
.course-name { font-size: 1.1rem; }
.card-highlight { border-color: var(--primary-100); background: linear-gradient(180deg, var(--primary-50), var(--surface)); }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .85rem; font-weight: 800; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.5rem; }

/* --- Utilities (replace one-off inline styles) ----------------------------- */
.mw-220 { max-width: 220px; } .mw-340 { max-width: 340px; } .mw-380 { max-width: 380px; }
.mw-420 { max-width: 420px; } .mw-440 { max-width: 440px; } .mw-520 { max-width: 520px; } .mw-820 { max-width: 820px; }
.m-0 { margin: 0 !important; }
.gap-1 { gap: 6px !important; } .gap-2 { gap: 10px !important; }
.text-inherit { color: inherit; } a.text-inherit:hover { color: inherit; }
.link-strong { color: var(--text); font-weight: 700; } .link-strong:hover { color: var(--link); }
.block { display: block; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; }
.pt-page { padding-top: 20px; padding-bottom: 40px; }
.self-start { align-self: flex-start; }
.section-flush { padding-top: 0; }
.row.justify-center { justify-content: center; }
.hint-block { display: block; margin-top: 6px; }
.select-sm { min-height: 40px; }
.title-sm { font-size: 1.5rem; margin: 6px 0 4px; }
.avatar-xl { width: 56px; height: 56px; font-size: 1.4rem; }
.round-img { border-radius: 12px; aspect-ratio: 16 / 9; object-fit: cover; margin-bottom: 8px; }
.divider-top { border-top: 1px solid var(--border); }
.cell-min { min-width: 150px; }

@media (max-width: 600px) {
  .stats { gap: 12px; }
  .stats > .stat { flex-basis: calc(50% - 6px); }
  .stat { padding: 14px; }
  .stat .k { font-size: .82rem; gap: 8px; }
  .stat .k svg { width: 30px; height: 30px; padding: 7px; }
  .stat .v { font-size: 1.6rem; }
}

/* --- Theme switch ---------------------------------------------------------- */
.i-moon, .i-sun { display: inline-flex; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: inline-flex; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .i-moon { display: none; }
  :root:not([data-theme]) .i-sun { display: inline-flex; }
}
.theme-toggle { flex: none; }
.dropdown-menu .theme-row { display: none; align-items: center; gap: 10px; }
@media (max-width: 900px) {
  /* Tight headers on phones: the switch lives in the account menu / mobile menu instead. */
  .topbar .theme-toggle { display: none; }
  .dropdown-menu .theme-row { display: flex; }
}
.mobile-nav .theme-row { display: flex; align-items: center; gap: 10px; }
.theme-float { position: absolute; top: 16px; left: 16px; z-index: 5; }
@media (max-width: 900px) { .theme-float { position: fixed; top: auto; bottom: 16px; left: 16px; } }
.theme-float .icon-btn { background: var(--glass); backdrop-filter: blur(8px); }
