/* =============================================================================
   Naffith | نَفِّذ — Design System v1.0
   Tokens → base → layout → components → pages → utilities
   RTL/LTR: logical properties (inline-start/end) everywhere.
   ============================================================================= */

/* ---------------------------------------------------------------- Fonts */
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 700; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 700; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../fonts/inter-latin-700-normal.woff2") format("woff2"); }

/* ---------------------------------------------------------------- Tokens */
:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-ring: rgba(37, 99, 235, .10);

  --background: #F7F8FA;
  --surface: #FFFFFF;
  --surface-secondary: #F9FAFB;

  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;

  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --checkbox-border: #D1D5DB;

  --success: #16A34A;
  --success-bg: #F0FDF4;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --warning-border: rgba(217, 119, 6, .20);
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --info: #0284C7;
  --info-bg: #F0F9FF;

  /* Spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* Radius */
  --r-sm: 8px; --r-input: 10px; --r-btn: 10px; --r-card: 14px; --r-modal: 16px; --r-pill: 999px;

  /* Shadows */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .03);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, .06);
  --shadow-dropdown: 0 10px 30px rgba(0, 0, 0, .10);
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, .15);
  --overlay: rgba(15, 23, 42, .45);

  /* Layout */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 76px;
  --header-h: 68px;
  --bottom-nav-h: 68px;
  --content-max: 1440px;
  --page-px: 32px;
  --page-py: 28px;

  /* Z-index */
  --z-content: 1; --z-sticky: 50; --z-header: 100; --z-bottom-nav: 200;
  --z-dropdown: 300; --z-overlay: 900; --z-modal: 1000; --z-toast: 1100;

  /* Motion */
  --t-hover: 150ms ease; --t-check: 150ms ease; --t-modal: 180ms ease;
  --t-sidebar: 200ms ease; --t-progress: 250ms ease;

  /* Type */
  --font-ar: "IBM Plex Sans Arabic", Tahoma, Arial, sans-serif;
  --font-en: "Inter", Arial, sans-serif;
  --font: var(--font-ar);

  color-scheme: light;
}

:root[dir="ltr"] { --font: var(--font-en); }

/* Dark mode — explicit choice */
:root[data-theme="dark"] {
  --background: #0F1115;
  --surface: #181B21;
  --surface-secondary: #20242C;
  --text-primary: #F9FAFB;
  --text-secondary: #AEB4BE;
  --text-muted: #737A86;
  --border: #2B3039;
  --border-light: #23272F;
  --checkbox-border: #4B5262;
  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-light: rgba(59, 130, 246, .14);
  --primary-ring: rgba(59, 130, 246, .22);
  --success: #22C55E;
  --success-bg: rgba(34, 197, 94, .12);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, .10);
  --warning-border: rgba(245, 158, 11, .24);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, .12);
  --info: #38BDF8;
  --info-bg: rgba(56, 189, 248, .10);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-hover: 0 4px 14px rgba(0, 0, 0, .35);
  --shadow-dropdown: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, .55);
  --overlay: rgba(3, 6, 12, .62);
  color-scheme: dark;
}

/* Dark mode — follow the system when the user chose "system" */
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --background: #0F1115;
    --surface: #181B21;
    --surface-secondary: #20242C;
    --text-primary: #F9FAFB;
    --text-secondary: #AEB4BE;
    --text-muted: #737A86;
    --border: #2B3039;
    --border-light: #23272F;
    --checkbox-border: #4B5262;
    --primary: #3B82F6;
    --primary-hover: #60A5FA;
    --primary-light: rgba(59, 130, 246, .14);
    --primary-ring: rgba(59, 130, 246, .22);
    --success: #22C55E;
    --success-bg: rgba(34, 197, 94, .12);
    --warning: #F59E0B;
    --warning-bg: rgba(245, 158, 11, .10);
    --warning-border: rgba(245, 158, 11, .24);
    --danger: #EF4444;
    --danger-bg: rgba(239, 68, 68, .12);
    --info: #38BDF8;
    --info-bg: rgba(56, 189, 248, .10);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow-hover: 0 4px 14px rgba(0, 0, 0, .35);
    --shadow-dropdown: 0 12px 32px rgba(0, 0, 0, .45);
    --shadow-modal: 0 20px 50px rgba(0, 0, 0, .55);
    --overlay: rgba(3, 6, 12, .62);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-light); }
.icon { flex-shrink: 0; stroke-width: 1.9; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
[dir="ltr"] .flip-ltr { transform: scaleX(-1); }
.icon.inline { display: inline-block; vertical-align: -3px; }
.ltr-text { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.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; }
.skip-link { position: absolute; inset-inline-start: 16px; top: -60px; z-index: var(--z-toast); background: var(--primary); color: #fff; padding: 10px 16px; border-radius: var(--r-btn); transition: top var(--t-hover); }
.skip-link:focus { top: 12px; color: #fff; }

/* ---------------------------------------------------------------- Typography */
.page-title { font-size: 28px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: var(--s-1); }
.section-title { font-size: 20px; font-weight: 700; line-height: 1.35; }
.card-title { font-size: 16px; font-weight: 600; line-height: 1.4; }
.card-subtitle, .text-secondary { font-size: 13px; color: var(--text-secondary); }
.text-small { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-primary-c { color: var(--primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- App layout */
.app { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-header);
  transition: width var(--t-sidebar), transform var(--t-sidebar);
}
.sidebar-logo {
  height: 72px;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-5);
  flex-shrink: 0;
  color: var(--text-primary);
}
.logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.logo-text strong { font-size: 18px; font-weight: 700; font-family: var(--font-ar); }
.logo-text span { font-size: 12px; color: var(--text-secondary); font-family: var(--font-en); letter-spacing: .02em; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--s-2) var(--s-3); display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background var(--t-hover), color var(--t-hover);
  position: relative;
}
.nav-item:hover { background: var(--surface-secondary); color: var(--text-primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item .nav-badge { margin-inline-start: auto; }
.nav-divider { height: 1px; background: var(--border-light); margin: var(--s-2) 6px; }
.nav-label { font-size: 12px; font-weight: 600; color: var(--text-muted); padding: var(--s-3) 14px var(--s-1); }
.sidebar-bottom { padding: var(--s-3); border-top: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 2px; }
.sidebar-user {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) 10px; margin-top: var(--s-1); border-radius: 10px; color: var(--text-primary);
}
.sidebar-user:hover { background: var(--surface-secondary); color: var(--text-primary); }
.sidebar-user .meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sidebar-user .meta strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .meta span { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { margin-inline-start: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin var(--t-sidebar); }

.header {
  position: sticky; top: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--page-px);
  z-index: var(--z-header);
}
.header-title { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.header-title .crumb { font-size: 12px; color: var(--text-muted); line-height: 1.2; }
.header-title h1 { font-size: 16px; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: var(--s-2); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; background: transparent; color: var(--text-secondary);
  position: relative;
  transition: background var(--t-hover), color var(--t-hover), border-color var(--t-hover);
}
.icon-btn:hover { background: var(--surface-secondary); color: var(--text-primary); }
.icon-btn.bordered { border-color: var(--border); }
.icon-btn .dot-count {
  position: absolute; top: 5px; inset-inline-end: 5px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: var(--r-pill);
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; line-height: 1; border: 2px solid var(--surface);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0; border: 0;
}
.menu-toggle { display: none; }

.content { flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--page-py) var(--page-px); }
.content.narrow { max-width: 1100px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-head .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* Small desktop: collapsed sidebar */
@media (min-width: 1024px) and (max-width: 1199px) {
  .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar .logo-text, .sidebar .nav-text, .sidebar .nav-label, .sidebar .sidebar-user .meta, .sidebar .nav-badge { display: none; }
  .sidebar-logo { padding: 0; justify-content: center; }
  .nav-item { justify-content: center; padding: 0; }
  .sidebar-user { justify-content: center; padding: var(--s-2) 0; }
  .main { margin-inline-start: var(--sidebar-w-collapsed); }
}

/* Tablet: drawer */
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-modal); z-index: var(--z-modal); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0) !important; }
  .main { margin-inline-start: 0; }
  .menu-toggle { display: inline-grid; }
  :root { --page-px: 24px; }
  .header { padding: 0 var(--page-px); }
}
.drawer-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-overlay); opacity: 0; pointer-events: none; transition: opacity var(--t-sidebar); }
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }

/* Mobile: bottom navigation */
.bottom-nav { display: none; }
@media (max-width: 768px) {
  :root { --page-px: 16px; --page-py: 20px; }
  .page-title { font-size: 24px; }
  .header { padding: 0 16px; }
  .menu-toggle { display: none; }
  .sidebar { display: none; }
  .content { padding-bottom: 90px; }
  .bottom-nav {
    display: flex; position: fixed; inset-inline: 0; bottom: 0;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
    z-index: var(--z-bottom-nav);
    align-items: stretch; justify-content: space-around;
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; min-width: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 11px; font-weight: 500; color: var(--text-secondary); background: none; border: 0; padding: 0;
  }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .icon { width: 22px !important; height: 22px !important; }
  .bottom-nav .add-btn {
    flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%;
    background: var(--primary); color: #fff; align-self: center;
    transform: translateY(-10px); box-shadow: 0 6px 16px rgba(37, 99, 235, .35);
  }
  .bottom-nav .add-btn .icon { width: 24px !important; height: 24px !important; }
}

/* ---------------------------------------------------------------- Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--s-5);
  box-shadow: var(--shadow-card);
}
.card.flush { padding: 0; }
.card.flush > .table-wrap:last-child { border-radius: 0 0 var(--r-card) var(--r-card); }
.req-progress { max-width: 240px; }
.notif-foot { display: block; }
.dropdown-head strong { display: block; color: var(--text-primary); }
.brand-en { font-family: var(--font-en); font-weight: 500; color: var(--text-secondary); }
.card.hoverable { transition: box-shadow var(--t-hover), border-color var(--t-hover); }
.card.hoverable:hover { box-shadow: var(--shadow-hover); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card.flush .card-head { padding: var(--s-5) var(--s-5) 0; margin-bottom: var(--s-3); }
.card-head .link { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.card-foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border-light); }
.stack { display: flex; flex-direction: column; gap: var(--s-5); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-3); }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); margin-bottom: var(--s-5); }
.kpi {
  min-height: 118px; padding: var(--s-5); border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--s-3); min-width: 0;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.kpi-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-light); color: var(--primary); }
.kpi-icon.success { background: var(--success-bg); color: var(--success); }
.kpi-icon.warning { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.info { background: var(--info-bg); color: var(--info); }
.kpi-icon.danger { background: var(--danger-bg); color: var(--danger); }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.kpi-hint { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value.text { font-size: 16px; font-weight: 600; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); }
@media (max-width: 1199px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1023px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
  .kpi-grid { gap: var(--s-3); }
  .kpi { min-height: 104px; padding: var(--s-4); }
  .kpi-value { font-size: 24px; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 359px) { .kpi-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- Buttons */
.btn {
  height: 40px; padding: 0 16px; border-radius: var(--r-btn);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; background: var(--surface); color: var(--text-primary);
  transition: background var(--t-hover), border-color var(--t-hover), color var(--t-hover), box-shadow var(--t-hover);
  text-decoration: none; user-select: none;
}
.btn:hover { color: inherit; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: var(--surface-secondary); color: var(--text-primary); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-secondary); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); color: #fff; }
.btn-soft { background: var(--primary-light); color: var(--primary); }
.btn-soft:hover { color: var(--primary-hover); }
.btn-lg { height: 46px; padding: 0 20px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(255, 255, 255, .9) rgba(255, 255, 255, .9) transparent transparent;
  animation: spin .7s linear infinite;
}
.btn-secondary.loading::after, .btn-ghost.loading::after { border-color: var(--primary) var(--primary) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: var(--s-4); }
.label { font-size: 13px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.label .hint { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px;
  font-size: 14px; color: var(--text-primary);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-input);
  transition: border-color var(--t-hover), box-shadow var(--t-hover);
  appearance: none; -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.textarea { min-height: 110px; height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.select {
  padding-inline-end: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
[dir="rtl"] .select { background-position: left 12px center; }
.input[type="date"], .input[type="time"], .input[type="datetime-local"] { direction: ltr; text-align: start; }
[dir="rtl"] .input[type="date"], [dir="rtl"] .input[type="time"], [dir="rtl"] .input[type="datetime-local"] { text-align: right; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.field-error { font-size: 12px; color: var(--danger); }
.field-help { font-size: 12px; color: var(--text-muted); }
.input-group { position: relative; }
.input-group .icon-start { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-group .input { padding-left: 40px; padding-right: 40px; }
.input-group .toggle-pass { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row + .form-row, .form-row + .field, .field + .form-row { margin-top: var(--s-4); }
.form-row .field + .field { margin-top: 0; }
@media (max-width: 640px) { .form-row, .form-row.three { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-6); flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; user-select: none; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }

/* Segmented control (types, priority) */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  height: 34px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--border);
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; background: var(--surface);
  transition: all var(--t-hover);
}
.segmented label:hover { border-color: var(--text-muted); color: var(--text-primary); }
.segmented input:checked + label { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.segmented input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }

.color-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.color-pick input { position: absolute; opacity: 0; pointer-events: none; }
.color-pick label { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); display: grid; place-items: center; color: #fff; }
.color-pick input:checked + label { box-shadow: 0 0 0 2px var(--text-primary); }
.color-pick input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 3px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 40px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 22px; border-radius: 999px; background: var(--checkbox-border); position: relative; transition: background var(--t-hover); flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: inset-inline-start var(--t-hover); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { inset-inline-start: 21px; }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------------------------------------------------------- Badges & pills */
.badge {
  height: 26px; padding: 0 9px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--surface-secondary); color: var(--text-secondary); border: 1px solid var(--border-light);
}
.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-primary { background: var(--primary-light); color: var(--primary); border-color: transparent; }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-sm { height: 22px; padding: 0 8px; font-size: 11px; }
.count-pill { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot-critical { background: var(--danger); }
.dot-high { background: var(--warning); }
.dot-medium { background: var(--primary); }
.dot-low { background: var(--text-muted); }

.course-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-secondary); min-width: 0; }
.course-chip .swatch { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.course-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- Progress */
.progress { height: 8px; border-radius: 999px; background: var(--border-light); overflow: hidden; }
.progress.sm { height: 6px; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); width: 0; transition: width var(--t-progress); }
.progress.success > span { background: var(--success); }
.progress.warning > span { background: var(--warning); }

/* ---------------------------------------------------------------- Today: task rows */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row {
  min-height: 72px; padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--t-hover), opacity var(--t-check);
  position: relative;
}
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--surface-secondary); }
.task-row.is-now { background: linear-gradient(90deg, var(--primary-light), transparent 70%); }
[dir="rtl"] .task-row.is-now { background: linear-gradient(270deg, var(--primary-light), transparent 70%); }
.task-row.is-now::before { content: ""; position: absolute; inset-block: 12px; inset-inline-start: 0; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
[dir="rtl"] .task-row.is-now::before { border-radius: 3px 0 0 3px; }

.check-circle {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--checkbox-border); background: transparent;
  display: grid; place-items: center; flex-shrink: 0; padding: 0;
  color: transparent;
  transition: background var(--t-check), border-color var(--t-check), color var(--t-check), transform var(--t-check);
  position: relative;
}
.check-circle::after { content: ""; position: absolute; inset: -10px; } /* 44px touch target */
.check-circle:hover { border-color: var(--success); }
.check-circle:active { transform: scale(.92); }
.check-circle svg { width: 14px; height: 14px; stroke-width: 3; }
.task-row.is-done .check-circle { background: var(--success); border-color: var(--success); color: #fff; }
.task-row.is-missed .check-circle { border-style: dashed; border-color: var(--danger); color: var(--danger); }
.task-row.is-done .task-main, .task-row.is-done .task-meta-end { opacity: .55; }
.task-row.is-done .task-title { text-decoration: line-through; text-decoration-color: var(--text-muted); text-decoration-thickness: 1px; }
.task-row.is-missed .task-main { opacity: .7; }

.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; transition: opacity var(--t-check); }
.task-title { font-size: 15px; font-weight: 600; line-height: 1.45; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-course { font-size: 12px; font-weight: 500; }
.task-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.task-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-muted); }
.task-meta .meta-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.task-meta-end { display: flex; align-items: center; gap: 8px; flex-shrink: 0; transition: opacity var(--t-check); }
.duration-badge { height: 26px; padding: 0 9px; border-radius: 999px; background: var(--surface-secondary); border: 1px solid var(--border); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.task-actions { display: flex; align-items: center; gap: 4px; }
.task-actions .btn-sm { height: 32px; }
.phase-tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--surface-secondary); color: var(--text-secondary); }
.phase-tag.review { background: var(--warning-bg); color: var(--warning); }
.phase-tag.practice { background: var(--info-bg); color: var(--info); }

@media (max-width: 768px) {
  .task-row { min-height: 78px; padding: 14px; gap: 12px; align-items: flex-start; }
  .check-circle { width: 26px; height: 26px; margin-top: 2px; }
  .task-meta-end .duration-badge { display: none; }
  .task-actions .btn-label { display: none; }
}

/* "What now" focus card */
.now-card {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-5); border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card);
  position: relative; overflow: hidden;
}
.now-card::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--primary); }
.now-card .now-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--primary-light); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
.now-card .now-body { flex: 1; min-width: 0; }
.now-card .now-label { font-size: 12px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .02em; }
.now-card .now-title { font-size: 17px; font-weight: 700; line-height: 1.4; margin-top: 2px; }
.now-card .now-meta { font-size: 13px; color: var(--text-secondary); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.now-card.all-done::before { background: var(--success); }
.now-card.all-done .now-icon { background: var(--success-bg); color: var(--success); }
.now-card.all-done .now-label { color: var(--success); }
@media (max-width: 640px) {
  .now-card { flex-wrap: wrap; padding: var(--s-4); }
  .now-card .now-icon { width: 40px; height: 40px; }
  .now-card .btn { width: 100%; }
}

/* Today progress card */
.progress-card { padding: var(--s-5); min-height: 110px; }
.progress-card .top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.progress-card .percent { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.day-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin-top: var(--s-4); }
.day-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.day-stat .k { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 5px; }
.day-stat .v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 768px) {
  .day-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--s-4); }
}

/* ---------------------------------------------------------------- Smart alert */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px; border-radius: var(--r-card);
  background: var(--warning-bg); border: 1px solid var(--warning-border);
}
.alert .alert-icon { color: var(--warning); margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.alert-text { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.alert-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.alert-suggestions { margin: 8px 0 0; padding-inline-start: 18px; font-size: 13px; color: var(--text-secondary); }
.alert.info { background: var(--info-bg); border-color: transparent; }
.alert.info .alert-icon { color: var(--info); }
.alert.danger { background: var(--danger-bg); border-color: transparent; }
.alert.danger .alert-icon { color: var(--danger); }
.alert.success { background: var(--success-bg); border-color: transparent; }
.alert.success .alert-icon { color: var(--success); }
.alert + .alert { margin-top: var(--s-3); }
.flash-area { margin-bottom: var(--s-5); }

/* ---------------------------------------------------------------- Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-light); min-width: 0; }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); display: block; }
.list-item .sub { font-size: 12px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.type-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-secondary); color: var(--text-secondary); }

/* Week bars (dashboard) */
.week-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 120px; margin-top: var(--s-2); }
.week-bar { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week-bar .bar { width: 100%; max-width: 26px; border-radius: 6px 6px 3px 3px; background: var(--border-light); position: relative; overflow: hidden; height: 100%; display: flex; align-items: flex-end; }
.week-bar .bar span { display: block; width: 100%; background: var(--primary); border-radius: 6px 6px 3px 3px; transition: height var(--t-progress); }
.week-bar.today .bar span { background: var(--success); }
.week-bar .lbl { font-size: 11px; color: var(--text-muted); }
.week-bar.today .lbl { color: var(--text-primary); font-weight: 600; }

/* ---------------------------------------------------------------- Empty state */
.empty { text-align: center; padding: var(--s-10) var(--s-5); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty .empty-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--surface-secondary); color: var(--text-muted); display: grid; place-items: center; margin-bottom: var(--s-2); }
.empty .empty-title { font-size: 16px; font-weight: 600; }
.empty .empty-text { font-size: 13px; color: var(--text-secondary); max-width: 360px; }
.empty .btn { margin-top: var(--s-3); }
.empty.compact { padding: var(--s-6) var(--s-4); }

/* ---------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  height: 44px; padding: 0 16px; text-align: start; white-space: nowrap;
  background: var(--surface-secondary); color: var(--text-secondary);
  font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--border);
}
.table td { height: 54px; padding: 8px 16px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-secondary); }
.table .t-strong { font-weight: 600; color: var(--text-primary); }
.table .t-sub { font-size: 12px; color: var(--text-secondary); }
.table .t-actions { text-align: end; white-space: nowrap; }
@media (max-width: 768px) {
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
  .table.responsive td { display: flex; justify-content: space-between; gap: 12px; height: auto; padding: 4px 0; border: 0; }
  .table.responsive td::before { content: attr(data-label); color: var(--text-secondary); font-size: 12px; font-weight: 600; }
  .table.responsive td.t-actions { justify-content: flex-end; }
  .table.responsive td.t-actions::before { content: none; }
}
.pagination { display: flex; gap: 6px; justify-content: center; padding: var(--s-4); flex-wrap: wrap; }

/* ---------------------------------------------------------------- Tabs / filters */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--s-5); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { height: 42px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; background: none; border-top: 0; border-inline: 0; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.filters { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s-4); }
.filters .select, .filters .input { height: 38px; width: auto; min-width: 140px; }
.chip-filter { height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip-filter:hover { color: var(--text-primary); border-color: var(--text-muted); }
.chip-filter.active { background: var(--text-primary); color: var(--surface); border-color: var(--text-primary); }
.segmented-tabs { display: inline-flex; padding: 3px; background: var(--surface-secondary); border: 1px solid var(--border); border-radius: 10px; gap: 2px; }
.segmented-tabs button, .segmented-tabs a { height: 32px; padding: 0 12px; border-radius: 8px; border: 0; background: transparent; font-size: 13px; font-weight: 500; color: var(--text-secondary); display: inline-flex; align-items: center; }
.segmented-tabs .active { background: var(--surface); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,.06); font-weight: 600; }

/* ---------------------------------------------------------------- Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0;
  min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-dropdown); padding: 6px; z-index: var(--z-dropdown);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity var(--t-hover), transform var(--t-hover);
}
.dropdown.open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; font-size: 14px; color: var(--text-primary); background: none; border: 0; text-align: start; }
.dropdown-item:hover { background: var(--surface-secondary); color: var(--text-primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-sep { height: 1px; background: var(--border-light); margin: 6px 0; }
.dropdown-head { padding: 8px 10px; font-size: 12px; color: var(--text-secondary); }

/* Notifications dropdown */
.notif-menu { width: 360px; padding: 0; max-width: calc(100vw - 24px); }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border-light); }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border-light); color: var(--text-primary); position: relative; }
.notif-item:hover { background: var(--surface-secondary); color: var(--text-primary); }
.notif-item.unread::after { content: ""; position: absolute; top: 18px; inset-inline-end: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.notif-item .n-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--surface-secondary); color: var(--text-secondary); display: grid; place-items: center; flex-shrink: 0; }
.notif-item .n-title { display: block; font-size: 13px; font-weight: 600; padding-inline-end: 14px; }
.notif-item .n-body { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.notif-item .n-when { display: block; font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.notif-foot { padding: 10px; text-align: center; font-size: 13px; font-weight: 600; }
@media (max-width: 768px) { .notif-menu { position: fixed; top: calc(var(--header-h) + 6px); inset-inline: 12px; width: auto; } }

/* ---------------------------------------------------------------- Modal */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-overlay);
  display: flex; align-items: center; justify-content: center; padding: 12px;
  opacity: 0; pointer-events: none; transition: opacity var(--t-modal);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  width: 520px; max-width: calc(100% - 24px); max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--surface); border-radius: var(--r-modal); box-shadow: var(--shadow-modal);
  z-index: var(--z-modal); transform: translateY(8px) scale(.98); transition: transform var(--t-modal);
  border: 1px solid var(--border);
}
.modal.lg { width: 720px; }
.modal-overlay.open .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-6) var(--s-6) 0; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.modal-body { padding: var(--s-5) var(--s-6) var(--s-6); }
.modal-foot { display: flex; gap: var(--s-2); justify-content: flex-end; padding: var(--s-4) var(--s-6); border-top: 1px solid var(--border-light); position: sticky; bottom: 0; background: var(--surface); }
@media (max-width: 768px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal, .modal.lg { width: 100%; max-width: 100%; border-radius: var(--r-modal) var(--r-modal) 0 0; max-height: 92vh; transform: translateY(24px); }
  .modal-head { padding: var(--s-5) var(--s-5) 0; }
  .modal-body { padding: var(--s-4) var(--s-5) var(--s-5); }
  .modal-foot { padding: var(--s-3) var(--s-5) calc(var(--s-3) + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
}

/* Bottom sheet (mobile "+" menu) */
.sheet-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 8px 4px; background: none; border: 0; border-bottom: 1px solid var(--border-light); color: var(--text-primary); font-size: 15px; font-weight: 500; text-align: start; }
.sheet-item:last-child { border-bottom: 0; }
.sheet-item .type-icon { width: 40px; height: 40px; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 10px auto 0; display: none; }
@media (max-width: 768px) { .sheet-handle { display: block; } }

/* ---------------------------------------------------------------- Toasts */
.toast-region { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
[dir="rtl"] .toast-region { transform: translateX(50%); }
.toast {
  max-width: 320px; padding: 14px 16px; border-radius: 10px;
  background: #111827; color: #F9FAFB; box-shadow: var(--shadow-dropdown);
  display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500;
  pointer-events: auto; animation: toast-in 180ms ease;
}
:root[data-theme="dark"] .toast { background: #F9FAFB; color: #111827; }
.toast .t-icon { color: #4ADE80; }
.toast.error .t-icon { color: #F87171; }
.toast .t-action { margin-inline-start: auto; background: none; border: 0; color: #93C5FD; font-weight: 700; padding: 4px 6px; border-radius: 6px; white-space: nowrap; }
:root[data-theme="dark"] .toast .t-action { color: var(--primary); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 180ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 768px) { .toast-region { bottom: 92px; } }

/* ---------------------------------------------------------------- Auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: 45% 55%; background: var(--surface); }
.auth-brand {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: #0E1A33; color: #E5ECFA;
}
.auth-brand::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(600px 400px at 85% 10%, rgba(37, 99, 235, .55), transparent 60%),
    radial-gradient(500px 360px at 10% 95%, rgba(59, 130, 246, .28), transparent 60%);
}
.auth-brand > * { position: relative; }
.auth-brand .brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; color: #fff; }
.auth-brand .brand .logo-mark { width: 40px; height: 40px; background: #fff; color: var(--primary); }
.auth-brand .brand span { font-family: var(--font-en); font-weight: 500; opacity: .75; }
.auth-brand h2 { font-size: 34px; line-height: 1.3; font-weight: 700; color: #fff; max-width: 420px; }
.auth-brand p.lead { margin-top: 14px; font-size: 15px; color: #B7C4DE; max-width: 400px; line-height: 1.7; }
.auth-preview { margin-top: 36px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); border-radius: 16px; padding: 18px; max-width: 400px; backdrop-filter: blur(4px); }
.auth-preview .ap-head { font-size: 13px; color: #B7C4DE; margin-bottom: 10px; display: flex; justify-content: space-between; }
.auth-preview .ap-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 14px; color: #fff; }
.auth-preview .ap-row:first-of-type { border-top: 0; }
.auth-preview .ap-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); flex-shrink: 0; display: grid; place-items: center; }
.auth-preview .ap-row.done .ap-check { background: #22C55E; border-color: #22C55E; }
.auth-preview .ap-row.done .ap-text { opacity: .6; text-decoration: line-through; }
.auth-preview .ap-time { margin-inline-start: auto; font-size: 12px; color: #B7C4DE; white-space: nowrap; }
.auth-brand .foot { font-size: 12px; color: #8EA0C3; }
.auth-main { display: flex; flex-direction: column; padding: 32px; }
.auth-top { display: flex; justify-content: flex-end; gap: 8px; }
.auth-form-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.auth-form { width: 100%; max-width: 420px; }
.auth-form .mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: 700; font-size: 18px; }
.auth-form h1 { font-size: 28px; font-weight: 700; line-height: 1.3; }
.auth-form .sub { color: var(--text-secondary); margin-top: 6px; margin-bottom: 28px; font-size: 14px; }
.auth-form .row-between { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 8px; flex-wrap: wrap; }
.auth-form .btn-block { margin-top: 22px; }
.auth-form .alt { text-align: center; margin-top: 22px; font-size: 14px; color: var(--text-secondary); }
.demo-box { margin-top: 24px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 12px; font-size: 12px; color: var(--text-secondary); }
.demo-box strong { color: var(--text-primary); }
.demo-box code { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--text-primary); }
@media (max-width: 1023px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form .mobile-brand { display: flex; }
}
@media (max-width: 768px) { .auth-main { padding: 20px 16px; } .auth-form h1 { font-size: 24px; } }

/* ---------------------------------------------------------------- Onboarding */
.onb { min-height: 100vh; background: var(--background); padding: 28px 16px 60px; }
.onb-wrap { max-width: 720px; margin: 0 auto; }
.onb-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.onb-progress { margin-bottom: 18px; }
.onb-progress .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.onb-progress .progress { height: 6px; }
.onb-steps { display: flex; gap: 6px; margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.onb-steps > a, .onb-steps > span { flex: 1; min-width: 88px; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; padding: 6px 0; }
.onb-steps .num { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.onb-steps .done { color: var(--text-secondary); }
.onb-steps .done .num { background: var(--success); border-color: var(--success); color: #fff; }
.onb-steps .current { color: var(--text-primary); font-weight: 600; }
.onb-steps .current .num { border-color: var(--primary); color: var(--primary); }
.onb-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow-card); }
.onb-card h1 { font-size: 24px; font-weight: 700; line-height: 1.35; }
.onb-card .lead { color: var(--text-secondary); margin: 6px 0 24px; }
.onb-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; gap: 12px; flex-wrap: wrap; }
.repeater-row { display: grid; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--border-light); border-radius: 12px; background: var(--surface-secondary); }
.repeater-row + .repeater-row { margin-top: 10px; }
.repeater-row .rm { align-self: center; }
.rows-courses { grid-template-columns: 2fr 1fr auto auto; }
.rows-schedule { grid-template-columns: 1.6fr 1fr 1fr 1fr auto; }
.rows-reqs { grid-template-columns: 2fr 1.2fr 1fr 1.4fr .8fr auto; }
@media (max-width: 768px) {
  .onb-card { padding: 20px; }
  .rows-courses, .rows-schedule, .rows-reqs { grid-template-columns: 1fr 1fr; }
  .repeater-row .full { grid-column: 1 / -1; }
}
.existing-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; background: var(--surface); }
.ready-hero { text-align: center; padding: 12px 0 4px; }
.ready-hero .big-check { width: 72px; height: 72px; border-radius: 50%; background: var(--success-bg); color: var(--success); display: grid; place-items: center; margin: 0 auto 18px; }

/* ---------------------------------------------------------------- Availability grid */
.week-editor .day-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--border-light); }
.week-editor .day-row:last-child { border-bottom: 0; }
.week-editor .day-name { font-weight: 600; padding-top: 9px; display: flex; flex-direction: column; }
.week-editor .day-name small { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.slot .input { width: 130px; height: 38px; }
.slot .arrow { color: var(--text-muted); }
.no-study { font-size: 13px; color: var(--text-muted); padding-top: 9px; }
@media (max-width: 640px) {
  .week-editor .day-row { grid-template-columns: 1fr auto; }
  .week-editor .slot-list { grid-column: 1 / -1; }
  .slot .input { width: calc(50% - 40px); min-width: 100px; }
}

/* ---------------------------------------------------------------- Calendar */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: var(--s-4); }
.cal-toolbar .nav { display: flex; align-items: center; gap: 6px; }
.cal-toolbar .range { font-size: 18px; font-weight: 700; min-width: 160px; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-bottom: var(--s-3); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-inline-start: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.cal-month .dow { padding: 10px; font-size: 12px; font-weight: 600; color: var(--text-secondary); background: var(--surface-secondary); border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: center; }
.cal-cell { min-height: 112px; padding: 6px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; min-width: 0; cursor: pointer; }
.cal-cell:hover { background: var(--surface-secondary); }
.cal-cell.other { background: var(--surface-secondary); }
.cal-cell.other .d { color: var(--text-muted); }
.cal-cell .d { font-size: 12px; font-weight: 600; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.cal-cell.today .d { background: var(--primary); color: #fff; }
.cal-ev { font-size: 11px; line-height: 1.3; padding: 2px 6px; border-radius: 5px; background: var(--surface-secondary); border-inline-start: 3px solid var(--c, var(--primary)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); cursor: pointer; text-align: start; border-top: 0; border-bottom: 0; border-inline-end: 0; width: 100%; }
.cal-ev.deadline { background: color-mix(in srgb, var(--c) 14%, var(--surface)); font-weight: 600; }
.cal-ev.lecture { color: var(--text-secondary); }
.cal-ev.done { opacity: .55; text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--text-secondary); padding: 0 6px; }
.cal-week { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.cal-week.day { grid-template-columns: 56px minmax(0, 1fr); }
.cal-week .wh { padding: 10px 6px; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-secondary); background: var(--surface-secondary); border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--border); }
.cal-week .wh.today { color: var(--primary); }
.cal-week .wh .n { display: block; font-size: 18px; color: var(--text-primary); }
.cal-week .wh.today .n { color: var(--primary); }
.cal-week .hours { position: relative; }
.cal-week .hour { height: 48px; font-size: 11px; color: var(--text-muted); text-align: center; border-bottom: 1px solid var(--border-light); padding-top: 2px; }
.cal-week .col { position: relative; border-inline-start: 1px solid var(--border); background-image: linear-gradient(var(--border-light) 1px, transparent 1px); background-size: 100% 48px; }
.cal-week .alldays { grid-column: 1 / -1; display: grid; grid-template-columns: inherit; border-bottom: 1px solid var(--border); }
.cal-week .block { position: absolute; inset-inline: 3px; border-radius: 6px; padding: 3px 6px; font-size: 11px; line-height: 1.3; overflow: hidden; background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-inline-start: 3px solid var(--c); color: var(--text-primary); cursor: pointer; text-align: start; border-top: 0; border-bottom: 0; border-inline-end: 0; }
.cal-week .block.lecture { background: var(--surface-secondary); color: var(--text-secondary); }
.cal-week .block.done { opacity: .55; }
.cal-week .block strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-deadlines { display: flex; flex-direction: column; gap: 3px; padding: 4px; border-inline-start: 1px solid var(--border); min-height: 32px; }
.cal-scroll { max-height: 640px; overflow-y: auto; }
@media (max-width: 768px) {
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-cell .cal-ev { display: none; }
  .cal-cell .dots { display: flex; gap: 3px; flex-wrap: wrap; }
  .cal-week { grid-template-columns: 40px repeat(7, minmax(44px, 1fr)); min-width: 560px; }
  .cal-week.day { min-width: 0; grid-template-columns: 44px minmax(0, 1fr); }
}
.cal-cell .dots { display: none; }
.cal-cell .dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }
.cal-day-list { margin-top: var(--s-4); }

/* ---------------------------------------------------------------- Plan (week) */
.plan-days { display: flex; flex-direction: column; gap: var(--s-4); }
.plan-day-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-light); }
.plan-day-head .dname { font-weight: 700; font-size: 15px; }
.plan-day-head .dmeta { font-size: 12px; color: var(--text-secondary); display: flex; gap: 10px; align-items: center; }
.load-meter { width: 90px; }
.plan-day.is-today { border-color: var(--primary); }

/* ---------------------------------------------------------------- Focus timer */
.timer-card { max-width: 520px; margin: 0 auto; text-align: center; padding: 32px 28px; }
.timer-ring { width: 220px; height: 220px; margin: 22px auto; position: relative; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 8; }
.timer-ring .bg { stroke: var(--border-light); }
.timer-ring .fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer-ring.over .fg { stroke: var(--warning); }
.timer-value { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-value .t { font-size: 48px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; direction: ltr; }
.timer-value .of { font-size: 13px; color: var(--text-secondary); }
.timer-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.timer-buttons .btn { min-width: 120px; }
.timer-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; text-align: start; }
.timer-facts .f { padding: 12px 14px; border-radius: 12px; background: var(--surface-secondary); border: 1px solid var(--border-light); }
.timer-facts .f .k { font-size: 12px; color: var(--text-secondary); }
.timer-facts .f .v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 768px) { .timer-value .t { font-size: 42px; } .timer-ring { width: 200px; height: 200px; } .timer-card { padding: 24px 18px; } }

/* ---------------------------------------------------------------- Statistics */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .stack-bar { width: 100%; max-width: 34px; height: 100%; display: flex; align-items: flex-end; gap: 3px; }
.bars .stack-bar span { flex: 1; border-radius: 5px 5px 2px 2px; min-height: 2px; transition: height var(--t-progress); }
.bars .planned { background: var(--border); }
.bars .actual { background: var(--primary); }
.bars .lbl { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dist-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name v" "bar bar"; align-items: center; gap: 6px 12px; padding: 8px 0; }
.dist-row .name { grid-area: name; }
.dist-row .progress { grid-area: bar; }
.dist-row .v { grid-area: v; }
.dist-row .name { min-width: 0; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.dist-row .v { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; min-width: 56px; text-align: end; }
.ring-stat { display: flex; align-items: center; gap: 18px; }
.ring { width: 92px; height: 92px; position: relative; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 9; }
.ring .bg { stroke: var(--border-light); }
.ring .fg { stroke: var(--success); stroke-linecap: round; transition: stroke-dashoffset var(--t-progress); }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; font-weight: 700; }

/* ---------------------------------------------------------------- Courses */
.course-card { display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; color: var(--text-primary); }
.course-card:hover { color: var(--text-primary); }
.course-card::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 3px; background: var(--c); }
.course-card .c-head { display: flex; gap: 12px; align-items: flex-start; }
.course-card .c-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: var(--c); flex-shrink: 0; }
.course-card .c-name { font-size: 15px; font-weight: 700; line-height: 1.4; }
.course-card .c-code { font-size: 12px; color: var(--text-secondary); }
.course-card .c-stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.course-card .c-stats span { display: inline-flex; align-items: center; gap: 5px; }
.course-header { display: flex; gap: 16px; align-items: center; }
.course-header .c-icon { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: var(--c); }

.subtask-list { list-style: none; margin: 0; padding: 0; }
.subtask { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.subtask:last-child { border-bottom: 0; }
.subtask .check-circle { width: 22px; height: 22px; }
.subtask.is-done .check-circle { background: var(--success); border-color: var(--success); color: #fff; }
.subtask.is-done .st-title { text-decoration: line-through; color: var(--text-muted); }
.subtask .st-title { flex: 1; font-weight: 500; min-width: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 13px; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; font-weight: 500; text-align: end; }

/* ---------------------------------------------------------------- Admin */
/* Admin keeps the drawer on mobile instead of the student bottom nav */
@media (max-width: 768px) {
  .is-admin .sidebar { display: flex; }
  .is-admin .menu-toggle { display: inline-grid; }
  .is-admin .content { padding-bottom: 28px; }
}
.admin-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--danger-bg); color: var(--danger); font-family: var(--font-en); letter-spacing: .03em; }
.key-list { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; text-align: left; background: var(--surface-secondary); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.9; max-height: 260px; overflow-y: auto; user-select: all; }
.mini-bars { display: flex; align-items: flex-end; gap: 4px; height: 70px; }
.mini-bars span { flex: 1; background: var(--primary); border-radius: 3px 3px 1px 1px; min-height: 2px; opacity: .85; }
.log-line { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; direction: ltr; text-align: left; padding: 6px 0; border-bottom: 1px solid var(--border-light); word-break: break-word; white-space: pre-wrap; }

/* ---------------------------------------------------------------- Utilities */
.flex { display: flex; } .inline-flex { display: inline-flex; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; } .justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; } .flex-1 { flex: 1; min-width: 0; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 20px; }
.w-full { width: 100%; } .hidden { display: none !important; } .nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.text-center { text-align: center; } .text-end { text-align: end; }
.divider { height: 1px; background: var(--border-light); margin: var(--s-5) 0; }
.w-80 { width: 80px; }
.bg-border { background: var(--border); }
.bg-primary { background: var(--primary); }
.summary-kv { max-width: 420px; margin: 0 auto; }
.plan-current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.file-input { height: auto; padding: 10px 12px; }
.file-input::file-selector-button { margin-inline-end: 12px; border: 1px solid var(--border); background: var(--surface-secondary); color: var(--text-primary); border-radius: 8px; padding: 6px 12px; font-weight: 600; cursor: pointer; }
.page-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.error-card { max-width: 480px; width: 100%; }
@media (max-width: 768px) { .hide-mobile { display: none !important; } }
@media (min-width: 769px) { .show-mobile { display: none !important; } }

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

/* ---------------------------------------------------------------- University integration */
.uni-connect-head { display: flex; align-items: flex-start; gap: var(--s-4); }
.uni-connect-icon { flex-shrink: 0; }
.uni-connect.is-available { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.uni-connect-text { margin-top: var(--s-4); color: var(--text-secondary); font-size: 14px; }
.uni-connect-form { display: flex; gap: var(--s-2); align-items: flex-end; flex-wrap: wrap; margin-top: var(--s-4); }
.uni-connect-btn { min-width: 220px; }
.uni-trust { list-style: none; margin: var(--s-4) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.uni-trust li { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.uni-trust li .icon { color: var(--success); }
.uni-change summary { cursor: pointer; font-size: 13px; color: var(--primary); font-weight: 600; width: fit-content; }
.uni-change summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.onb-or { display: flex; align-items: center; gap: var(--s-3); margin: var(--s-5) 0; color: var(--text-muted); font-size: 13px; }
.onb-or::before, .onb-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.onb-lms-done { margin-bottom: var(--s-5); }
.uni-connect + .onb-or { margin-top: var(--s-6); }
.onb .uni-connect { padding: 28px; }

.lms-counts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.mini-stat { border: 1px solid var(--border-light); background: var(--surface-secondary); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-stat .v { font-size: 22px; font-weight: 700; line-height: 1.2; }
.mini-stat .l { font-size: 12px; color: var(--text-secondary); }
.lms-actions { justify-content: flex-start; margin-top: var(--s-5); }
.lms-actions form { display: contents; }
.how-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.how-list li { display: flex; gap: var(--s-3); font-size: 13px; color: var(--text-secondary); align-items: flex-start; }
.how-list .n { width: 22px; height: 22px; border-radius: 999px; background: var(--primary-light); color: var(--primary); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.demo-tools { border-style: dashed; }
.demo-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-4); }
.source-badge { background: var(--info-bg); color: var(--info); border-color: transparent; vertical-align: middle; }
.source-badge.is-demo { background: var(--warning-bg); color: var(--warning); }
.t-strong + .source-badge { margin-inline-start: 6px; }

.sync-card { max-width: 560px; margin: 0 auto; padding: 28px; }
.sync-head { display: flex; gap: var(--s-4); align-items: center; margin-bottom: var(--s-5); }
.sync-spinner { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-light); color: var(--primary); flex-shrink: 0; }
.sync-spinner .icon, .sync-spinner svg { animation: spin 1s linear infinite; }
.sync-spinner.is-ok, .sync-spinner.is-partial, .sync-spinner.is-error { animation: none; }
.sync-spinner.is-ok svg, .sync-spinner.is-partial svg, .sync-spinner.is-error svg { animation: none; }
.sync-spinner.is-ok { background: var(--success-bg); color: var(--success); }
.sync-spinner.is-partial { background: var(--warning-bg); color: var(--warning); }
.sync-spinner.is-error { background: var(--danger-bg); color: var(--danger); }
.sync-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sync-step { display: flex; gap: var(--s-3); align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border-light); color: var(--text-muted); transition: color var(--t-hover); }
.sync-step:last-child { border-bottom: 0; }
.sync-step-icon { width: 24px; height: 24px; display: grid; place-items: center; flex-shrink: 0; }
.sync-step-icon.spin svg { animation: spin 1s linear infinite; }
.sync-step-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sync-step-label { font-size: 14px; font-weight: 600; }
.sync-step-detail { font-size: 12px; color: var(--text-secondary); }
.sync-step.is-running { color: var(--text-primary); }
.sync-step.is-running .sync-step-icon { color: var(--primary); }
.sync-step.is-ok { color: var(--text-primary); }
.sync-step.is-ok .sync-step-icon { color: var(--success); }
.sync-step.is-partial .sync-step-icon { color: var(--warning); }
.sync-step.is-partial, .sync-step.is-unavailable, .sync-step.is-skipped, .sync-step.is-error { color: var(--text-primary); }
.sync-step.is-unavailable .sync-step-icon, .sync-step.is-skipped .sync-step-icon { color: var(--text-muted); }
.sync-step.is-error .sync-step-icon { color: var(--danger); }
.sync-foot { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--border-light); }
.sync-foot .justify-end { justify-content: flex-end; }

.result-card { max-width: 520px; margin: 0 auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: 32px 24px; }
.result-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin-bottom: var(--s-2); }
.result-icon.is-danger { background: var(--danger-bg); color: var(--danger); }
.result-icon.is-warning { background: var(--warning-bg); color: var(--warning); }
.justify-center { justify-content: center; }

.demo-consent { max-width: 460px; margin: 40px auto; padding: 28px; display: flex; flex-direction: column; gap: var(--s-3); }
.demo-ribbon { align-self: stretch; text-align: center; font-size: 12px; font-weight: 600; color: var(--warning); background: var(--warning-bg); border-radius: 8px; padding: 6px 10px; display: flex; gap: 6px; align-items: center; justify-content: center; }
.demo-consent-brand { display: flex; align-items: center; gap: var(--s-3); }
.demo-consent-brand > div { display: flex; flex-direction: column; }
.consent-scopes { list-style: none; margin: var(--s-2) 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.consent-scopes li { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.consent-scopes li .icon { color: var(--success); }
.consent-scopes li.no { color: var(--text-secondary); }
.consent-scopes li.no .icon { color: var(--text-muted); }
.consent-actions { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-3); }

@media (max-width: 767px) {
  .uni-connect-btn { width: 100%; }
  .lms-counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mini-stat .v { font-size: 18px; }
  .sync-card, .demo-consent { padding: 20px; }
  .demo-consent { margin: 16px auto; }
  .consent-actions .btn { flex: 1; }
}
.btn.text-danger { color: var(--danger); }
