/* ==========================================================================
   E-KOKUM DESIGN SYSTEM  ·  Sistem e-Kokurikulum Sekolah
   Gaya: Modern SaaS (light-first, high contrast, mesra guru)
   Guna: <link rel="stylesheet" href="shared/theme.css">
         atau salin keseluruhan fail ini ke dalam <style> modul single-file.
   ========================================================================== */

/* ---------- 1. TOKENS ---------- */
:root {
  /* Brand — neutral chrome, accent boleh ditukar per-modul */
  --accent:        #4338CA;   /* indigo 700 */
  --accent-hover:  #3730A3;
  --accent-soft:   #EEF2FF;
  --accent-border: #C7D2FE;
  --accent-text:   #3730A3;

  /* Neutral ramp */
  --bg:        #F6F7F9;
  --surface:   #FFFFFF;
  --surface-2: #FBFBFC;
  --line:      #E5E7EB;
  --line-soft: #F1F2F4;

  --text:      #16181D;
  --text-2:    #5B6270;
  --text-3:    #8A909C;
  --text-on-accent: #FFFFFF;

  /* Semantic */
  --ok:      #047857;  --ok-soft:   #ECFDF5;  --ok-border:   #A7F3D0;
  --warn:    #B45309;  --warn-soft: #FFFBEB;  --warn-border: #FDE68A;
  --danger:  #B91C1C;  --danger-soft:#FEF2F2; --danger-border:#FECACA;
  --info:    #1D4ED8;  --info-soft: #EFF6FF;  --info-border: #BFDBFE;

  /* Shape */
  --r-sm: 8px;  --r: 10px;  --r-lg: 14px;  --r-xl: 18px;  --r-full: 999px;

  /* Elevation — halus, bukan drop shadow tebal */
  --sh-1: 0 1px 2px rgba(16,24,40,.06), 0 1px 1px rgba(16,24,40,.04);
  --sh-2: 0 4px 12px -2px rgba(16,24,40,.10), 0 2px 4px -2px rgba(16,24,40,.06);
  --sh-3: 0 16px 40px -8px rgba(16,24,40,.18), 0 4px 12px -4px rgba(16,24,40,.08);

  /* Spacing scale (4px grid) */
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:20px; --s6:24px; --s8:32px; --s10:40px; --s12:48px;

  --font: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;

  --topbar-h: 60px;
  --sidebar-w: 244px;
}

/* Accent per-modul: <body data-accent="maroon"> */
[data-accent="maroon"] { --accent:#9F1239; --accent-hover:#881337; --accent-soft:#FFF1F2; --accent-border:#FECDD3; --accent-text:#881337; }
[data-accent="blue"]   { --accent:#1D4ED8; --accent-hover:#1E40AF; --accent-soft:#EFF6FF; --accent-border:#BFDBFE; --accent-text:#1E40AF; }
[data-accent="teal"]   { --accent:#0F766E; --accent-hover:#115E59; --accent-soft:#F0FDFA; --accent-border:#99F6E4; --accent-text:#115E59; }
[data-accent="amber"]  { --accent:#B45309; --accent-hover:#92400E; --accent-soft:#FFFBEB; --accent-border:#FDE68A; --accent-text:#92400E; }
[data-accent="violet"] { --accent:#6D28D9; --accent-hover:#5B21B6; --accent-soft:#F5F3FF; --accent-border:#DDD6FE; --accent-text:#5B21B6; }

/* ---------- 2. RESET & BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -.014em; color: var(--text); }
h1 { font-size: 24px; line-height: 1.25; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.35; }
p  { margin: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------- 3. TYPE UTILITIES ---------- */
.t-display { font-size: 30px; font-weight: 800; letter-spacing: -.025em; line-height: 1.15; }
.t-lead    { font-size: 15px; color: var(--text-2); }
.t-body    { font-size: 14px; }
.t-sm      { font-size: 13px; }
.t-xs      { font-size: 12px; }
.t-muted   { color: var(--text-2); }
.t-faint   { color: var(--text-3); }
.t-num     { font-variant-numeric: tabular-nums; }
.t-mono    { font-family: var(--font-mono); font-size: .92em; }
.t-label   { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); }
.t-clamp1  { display:-webkit-box; -webkit-line-clamp:1; -webkit-box-orient:vertical; overflow:hidden; }
.t-clamp2  { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

/* ---------- 4. APP SHELL ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4);
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__logo { width: 34px; height: 34px; object-fit: contain; flex: none; }
.topbar__title { font-size: 14px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sub { font-size: 11.5px; color: var(--text-3); line-height: 1.2; white-space: nowrap; }
.topbar__spacer { flex: 1; }

.shell { flex: 1; display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: var(--topbar-h);
  width: var(--sidebar-w); flex: none;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--s4) var(--s3);
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.sidebar__group + .sidebar__group { margin-top: var(--s5); }
.sidebar__heading { padding: 0 10px var(--s2); }

.navitem {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: var(--r);
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  transition: background .12s, color .12s;
}
.navitem:hover { background: var(--line-soft); color: var(--text); text-decoration: none; }
.navitem.is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 650; }
.navitem__icon { width: 16px; text-align: center; flex: none; opacity: .85; }
.navitem__count { margin-left: auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.main { flex: 1; min-width: 0; padding: var(--s6); }
.page { max-width: 1180px; margin: 0 auto; }
.page--narrow { max-width: 760px; }
.page__head { display: flex; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page__head-text { flex: 1; min-width: 200px; }
.page__actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* ---------- 5. CARD ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card--flat { box-shadow: none; }
.card--pad { padding: var(--s5); }
.card__head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line-soft);
}
.card__head-text { flex: 1; min-width: 0; }
.card__body { padding: var(--s5); }
.card__foot {
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  display: flex; align-items: center; gap: var(--s2);
}

/* Kad boleh klik (pilihan modul, pilihan unit) */
.card--action {
  display: block; width: 100%; text-align: left; cursor: pointer;
  transition: border-color .14s, box-shadow .14s, transform .14s;
}
.card--action:hover { border-color: var(--accent-border); box-shadow: var(--sh-2); transform: translateY(-1px); text-decoration: none; }
.card--action:active { transform: none; }

/* ---------- 6. BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; line-height: 1;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.btn--primary   { background: var(--accent); color: var(--text-on-accent); box-shadow: var(--sh-1); }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--sh-1); }
.btn--secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #D6D9DE; }

.btn--soft   { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-border); }
.btn--soft:hover:not(:disabled) { background: #E4E9FF; }

.btn--ghost  { background: transparent; color: var(--text-2); }
.btn--ghost:hover:not(:disabled) { background: var(--line-soft); color: var(--text); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #991B1B; }

.btn--lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: var(--r-lg); }
.btn--sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn--block { display: flex; width: 100%; }

/* ---------- 7. FORMS ---------- */
.field { display: block; margin-bottom: var(--s4); }
.field__label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field__req { color: var(--danger); margin-left: 2px; }
.field__hint { margin-top: 5px; font-size: 12px; color: var(--text-3); }
.field__error { margin-top: 5px; font-size: 12px; color: var(--danger); font-weight: 500; }

.input, .select, .textarea {
  width: 100%;
  min-height: 40px; padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 14px; color: var(--text);
  transition: border-color .12s, box-shadow .12s;
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: #D6D9DE; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.input[readonly], .input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-2); color: var(--text-2); cursor: not-allowed;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }

.select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%235B6270' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* Input dengan ikon carian */
.searchbox { position: relative; }
.searchbox .input { padding-left: 36px; }
.searchbox__icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none; font-size: 13px;
}

/* Baris borang responsif */
.form-grid { display: grid; gap: 0 var(--s4); grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .form-grid--3 { grid-template-columns: repeat(3, 1fr); } }

/* Checkbox / radio */
.check { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; cursor: pointer; font-size: 13.5px; }
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }

/* ---------- 8. FILTER / TOOLBAR ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.toolbar__grow { flex: 1 1 200px; min-width: 160px; }
.toolbar .input, .toolbar .select { min-height: 36px; padding-top: 7px; padding-bottom: 7px; }
.toolbar__divider { width: 1px; align-self: stretch; background: var(--line); margin: 0 2px; }

/* Segmented control — filter cepat / toggle sesi */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.segmented__btn {
  border: none; background: none; cursor: pointer;
  padding: 6px 13px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: background .12s, color .12s, box-shadow .12s;
}
.segmented__btn:hover { color: var(--text); }
.segmented__btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* Pills — senarai unit */
.pills { display: flex; flex-wrap: wrap; gap: var(--s2); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  font-size: 13px; font-weight: 550; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
  transition: all .12s;
}
.pill:hover { border-color: var(--accent-border); color: var(--text); text-decoration: none; }
.pill.is-active { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }

/* ---------- 9. BADGES ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 650; line-height: 1.5;
  border: 1px solid transparent; white-space: nowrap;
}
.badge--neutral { background: var(--line-soft); color: var(--text-2); border-color: var(--line); }
.badge--accent  { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-border); }
.badge--ok      { background: var(--ok-soft);     color: var(--ok);     border-color: var(--ok-border); }
.badge--warn    { background: var(--warn-soft);   color: var(--warn);   border-color: var(--warn-border); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge--info    { background: var(--info-soft);   color: var(--info);   border-color: var(--info-border); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- 10. KPI TILE ---------- */
.kpis { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  box-shadow: var(--sh-1);
}
.kpi__label { font-size: 12.5px; color: var(--text-2); font-weight: 550; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.kpi__value { font-size: 27px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi__meta  { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.kpi__bar { margin-top: 10px; height: 5px; border-radius: var(--r-full); background: var(--line-soft); overflow: hidden; }
.kpi__bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* ---------- 11. TABLE ---------- */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-1);
  overflow: auto;
  max-height: 70vh;
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left; font-size: 11.5px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table thead th.is-sortable { cursor: pointer; user-select: none; }
.table thead th.is-sortable:hover { color: var(--text-2); }
.table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr.is-clickable { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }

/* Kad menggantikan jadual pada telefon */
@media (max-width: 640px) {
  .table--stack thead { display: none; }
  .table--stack tbody tr { display: block; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
  .table--stack tbody td { display: flex; justify-content: space-between; gap: var(--s4); padding: 4px 0; border: none; }
  .table--stack tbody td::before { content: attr(data-label); font-size: 12px; font-weight: 650; color: var(--text-3); flex: none; }
}

/* ---------- 12. MINI CALENDAR ---------- */
/* Dihadkan supaya sel kekal segi empat sama walau kad selebar penuh */
.cal { user-select: none; max-width: 392px; margin-inline: auto; }
.cal__head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal__dow {
  text-align: center; font-size: 10.5px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-3);
  padding-bottom: 5px;
}
.cal__day {
  position: relative;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: none; cursor: default;
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text);
  transition: background .12s, border-color .12s;
}
.cal__day--muted { color: var(--text-3); opacity: .5; }
.cal__day--today { border-color: var(--accent); font-weight: 750; color: var(--accent-text); }
.cal__day--event { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; cursor: pointer; }
.cal__day--event:hover { background: var(--accent); color: var(--text-on-accent); }
.cal__day--range { background: var(--accent-soft); border-radius: 0; }
.cal__day--selected { background: var(--accent); color: var(--text-on-accent); font-weight: 700; }
.cal__dot { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.cal__flag { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.cal__legend { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s3); font-size: 12px; color: var(--text-2); }
.cal__legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal__legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- 13. LIST ROW (senarai perjumpaan / rekod) ---------- */
.rows { display: flex; flex-direction: column; gap: var(--s2); }
.row {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.row:hover { border-color: var(--accent-border); box-shadow: var(--sh-2); text-decoration: none; }
.row__date {
  flex: none; width: 52px; text-align: center;
  padding: 6px 0; border-radius: var(--r); background: var(--accent-soft); color: var(--accent-text);
}
.row__date b { display: block; font-size: 18px; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; }
.row__date span { display: block; font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 650; font-size: 14px; }
.row__meta { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.row__end { flex: none; display: flex; align-items: center; gap: var(--s2); color: var(--text-3); }

/* ---------- 14. MODAL ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(16,24,40,.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s4);
  animation: fadeIn .14s ease-out;
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
  animation: modalIn .18s cubic-bezier(.2,.8,.3,1);
}
.modal--wide { max-width: 880px; }
.modal__head { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s5) var(--s5) var(--s3); }
.modal__head-text { flex: 1; min-width: 0; }
.modal__body { padding: 0 var(--s5) var(--s5); overflow-y: auto; }
.modal__foot {
  display: flex; gap: var(--s2); justify-content: flex-end; flex-wrap: wrap;
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--line-soft); background: var(--surface-2);
}
@media (max-width: 560px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; max-height: 92vh; border-radius: var(--r-xl) var(--r-xl) 0 0; animation: sheetIn .2s cubic-bezier(.2,.8,.3,1); }
  .modal__foot > .btn { flex: 1; }
}

/* Senarai definisi dalam modal detail */
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 10px var(--s4); font-size: 13.5px; }
.dl dt { color: var(--text-2); font-weight: 550; }
.dl dd { margin: 0; font-weight: 550; }
@media (max-width: 480px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 8px; } }

/* ---------- 15. TOAST ---------- */
.toasts { position: fixed; z-index: 100; bottom: var(--s5); right: var(--s5); display: flex; flex-direction: column; gap: var(--s2); pointer-events: none; }
@media (max-width: 560px) { .toasts { left: var(--s3); right: var(--s3); bottom: var(--s3); } }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px; min-width: 240px;
  background: #16181D; color: #fff;
  border-radius: var(--r);
  box-shadow: var(--sh-3);
  font-size: 13.5px; font-weight: 550;
  pointer-events: auto;
  animation: toastIn .2s cubic-bezier(.2,.8,.3,1);
}
.toast--ok i    { color: #34D399; }
.toast--danger i{ color: #F87171; }
.toast--warn i  { color: #FBBF24; }

/* ---------- 16. STATES ---------- */
.empty { text-align: center; padding: var(--s10) var(--s5); }
.empty__icon {
  width: 46px; height: 46px; margin: 0 auto var(--s3);
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  background: var(--line-soft); color: var(--text-3); font-size: 19px;
}
.empty__title { font-weight: 650; margin-bottom: 4px; }
.empty__text { font-size: 13px; color: var(--text-2); max-width: 340px; margin: 0 auto; }

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--line-soft) 25%, #EAEBEE 37%, var(--line-soft) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

.spinner {
  width: 15px; height: 15px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite; opacity: .7;
}

/* ---------- 17. MISC ---------- */
.avatar {
  border-radius: 50%; object-fit: cover; object-position: center;
  background: var(--accent-soft); color: var(--accent-text);
  display: grid; place-items: center;
  font-weight: 750; letter-spacing: -.02em;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
  flex: none;
}
.dropzone {
  display: grid; place-items: center; gap: 6px;
  padding: var(--s6) var(--s4); text-align: center;
  border: 1.5px dashed var(--line); border-radius: var(--r-lg);
  background: var(--surface-2); color: var(--text-2);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

.divider { height: 1px; background: var(--line); border: none; margin: var(--s5) 0; }
.stack   { display: flex; flex-direction: column; gap: var(--s4); }
.stack--sm { gap: var(--s2); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.grid-auto { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- 17b. SKRIN LOG MASUK / PERSEDIAAN ---------- */
.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: var(--s5) var(--s4);
  background:
    radial-gradient(60rem 30rem at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth__kad {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-2);
  padding: var(--s8) var(--s6);
  text-align: center;
  animation: modalIn .3s cubic-bezier(.2,.8,.3,1) both;
}
.auth__kad--lebar { max-width: 620px; text-align: left; }
.auth__logo {
  width: 62px; height: 62px; margin: 0 auto var(--s4);
  object-fit: contain;
}
.auth__tajuk { font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.auth__sub { font-size: 13.5px; color: var(--text-2); margin-top: 6px; }
.auth__pemisah {
  display: flex; align-items: center; gap: var(--s3);
  margin: var(--s5) 0; font-size: 12px; color: var(--text-3);
}
.auth__pemisah::before, .auth__pemisah::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth__nota { margin-top: var(--s5); font-size: 12px; color: var(--text-3); line-height: 1.6; }

/* Langkah persediaan bernombor */
.langkah { display: flex; gap: var(--s3); padding: var(--s3) 0; }
.langkah__no {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--text-on-accent);
  font-size: 12px; font-weight: 750;
}
.langkah__badan { flex: 1; min-width: 0; padding-top: 2px; }
.langkah__tajuk { font-weight: 650; font-size: 14px; margin-bottom: 2px; }

/* Utiliti keterlihatan mengikut saiz skrin */
@media (max-width: 640px)  { .hide-sm { display: none !important; } }
@media (min-width: 641px)  { .only-sm { display: none !important; } }

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

/* ---------- 18. ANIMASI ---------- */
@keyframes fadeIn  { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes spin    { to { transform: rotate(360deg); } }

.animate-in { animation: modalIn .22s cubic-bezier(.2,.8,.3,1) both; }
.animate-in[data-delay="1"] { animation-delay: .04s; }
.animate-in[data-delay="2"] { animation-delay: .08s; }
.animate-in[data-delay="3"] { animation-delay: .12s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 19. MOBILE SHELL ---------- */
@media (max-width: 900px) {
  .main { padding: var(--s4) var(--s3); min-width: 0; }
  .shell { min-width: 0; }
  .page__head { gap: var(--s3); }
  .page__actions > .btn { flex: 1 1 auto; }
  h1 { font-size: 20px; }
  .t-display { font-size: 24px; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 45;
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%); transition: transform .2s cubic-bezier(.2,.8,.3,1);
    box-shadow: var(--sh-3);
  }
  .sidebar.is-open { transform: none; }
  .sidebar-scrim { position: fixed; inset: var(--topbar-h) 0 0; z-index: 44; background: rgba(16,24,40,.35); }
}
@media (min-width: 901px) { .only-mobile { display: none !important; } }

/* ---------- 20. CETAKAN ---------- */
@media print {
  .topbar, .sidebar, .page__actions, .toolbar, .btn, .toasts, .no-print { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .main { padding: 0; }
  .card, .table-wrap { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  .table-wrap { max-height: none; overflow: visible; }
}
