/* ============================================================================
   cl- DESIGN SYSTEM  (single reusable stylesheet — the app's 'Bootstrap')
   Phase 0 foundation: tokens + components consolidated from base_operation.html
   and includes/_{list_page_theme,form_card,modal_theme,centre_modal_theme}.html,
   plus new shared components. Loaded globally; pages use .cl-* classes and drop
   their own per-page CSS over the migration phases.
   ========================================================================== */


/* ---- TOKENS (light + dark) ---- */
  :root,
  body[data-theme="light"] {
    --cream: #ffffff;
    --cream-2: #f3ede2;
    --paper: #ffffff;
    --forest: #1b4332;
    --forest-2: #2d5a47;
    --forest-light: #d9e4dd;
    --gold: #b7925a;
    --gold-soft: #e8d5b0;
    --gold-bg: rgba(183, 146, 90, 0.08);

    /* ── Semantic brand tokens (Phase 1, multi-tenant prep) ────────────
       --brand-primary aliases the system primary. Declaring it once is
       enough — var(--forest) re-resolves under body[data-theme="dark"],
       so the alias automatically tracks both themes. Tenant overrides
       only need to touch --brand-primary; cards, surfaces, typography,
       and ink tokens stay locked because they aren't aliased. */
    --brand-primary: var(--forest);
    /* color-mix() fallback: 18% forest tint for browsers without it.
       The second line wins everywhere that supports color-mix (all
       major browsers since 2023). */
    --brand-primary-soft: rgba(27, 67, 50, 0.18);
    --brand-primary-soft: color-mix(in srgb, var(--brand-primary) 18%, transparent);

    /* ── Guardrail token engine (Phase 4) ──────────────────────────────
       Tenants only ever set --brand-primary. The five tokens below are
       derived deterministically from the design system so the color
       picker can never break categorical meaning or surface contrast.

       --brand-secondary*: namespace exists for future flexibility, but
       today it aliases --gold (locked design accent). Decorative gold
       surfaces — top accent borders, side rails, italic emphases,
       hover rings — read from this alias.

       --surface-cream: semantic name for the page-canvas cream. Aliases
       --cream so dark-theme inversion still works automatically.

       --status-pending / --semantic-warning: categorical safeguards.
       "At-risk" and "upcoming/pending" data surfaces map here instead
       of touching --brand-secondary, so urgency meaning is never
       repainted by the tenant's color picker. */
    --brand-secondary: var(--gold, #b7925a);
    --brand-secondary-soft: rgba(183, 146, 90, 0.18);
    --brand-secondary-soft: color-mix(in srgb, var(--brand-secondary, #b7925a) 18%, transparent);
    --surface-cream: var(--cream, #faf7f2);
    --status-pending: var(--gold, #b7925a);
    --semantic-warning: #c47a00;

    /* ── Semantic color system (Phase 5) ────────────────────────────
       Universal status colors used across the app. They DO NOT track
       the tenant brand — by design — because meanings like
       "success = green", "danger = red", "warning = amber" must
       remain recognizable regardless of brand. Each has a paired
       *-soft mix for backgrounds, and a *-tint for borders/atmospheres.
       Soft + tint variants use color-mix() so tweaking the base hue
       once cascades through every derived atmosphere automatically —
       mirrors the --brand-primary / --brand-primary-soft pattern.
       Visual hierarchy:
         --primary  → tenant brand (already declared above as --brand-primary)
         --secondary → tonal soft brand (use --brand-primary-soft directly)
         --success  → emerald
         --warning  → amber (same hue as --semantic-warning, aliased)
         --info     → cyan-blue
         --danger   → rose-red */
    --success:        #1f9d55;
    --success-soft:   color-mix(in srgb, var(--success) 14%, transparent);
    --success-tint:   color-mix(in srgb, var(--success) 35%, transparent);
    --warning:        var(--semantic-warning, #c47a00);
    --warning-soft:   color-mix(in srgb, var(--warning) 14%, transparent);
    --warning-tint:   color-mix(in srgb, var(--warning) 35%, transparent);
    --info:           #2c7be5;
    --info-soft:      color-mix(in srgb, var(--info) 12%, transparent);
    --info-tint:      color-mix(in srgb, var(--info) 35%, transparent);
    --danger:         #c0392b;
    --danger-soft:    color-mix(in srgb, var(--danger) 12%, transparent);
    --danger-tint:    color-mix(in srgb, var(--danger) 35%, transparent);

    --rose: #c08479;
    --rose-soft: #f4e0dc;
    --ink: #2d3142;
    --ink-dim: #6c7080;
    --ink-muted: #a0a4b8;
    --border: rgba(45, 49, 66, 0.08);
    --border-strong: rgba(45, 49, 66, 0.14);
    --shadow: 0 1px 2px rgba(45,49,66,0.03), 0 12px 32px -12px rgba(45,49,66,0.08);
    --shadow-hover: 0 2px 4px rgba(45,49,66,0.04), 0 20px 48px -16px rgba(45,49,66,0.12);
    --sidebar-bg: rgba(255, 255, 255, 0.4);
    /* Single font primitive — the one place the family literal lives.
       --display/--body point at it so a reskin is a one-line change, and
       the Bootstrap neutralization in the legacy stacks reads var(--body)
       (per-shell: Inter here, Inter Tight in the student shell). */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --display: var(--font-sans);
    --body: var(--font-sans);
    --radius: 16px;
    --radius-sm: 10px;

    /* ── Card spacing (single source of truth — see DESIGN.md §1.4) ──────
       --gap-row : vertical gap between stacked cards (.cl-card margin-bottom).
       --pad-card: body padding for *content* cards (.cl-card-pad).
       Dashboards may raise --gap-row to 20px for an airier KPI layout; table
       cards leave .cl-card-body at its padding:0 default (cells space them). */
    --gap-row: 18px;
    --pad-card: 22px 24px;
  }

  /* ─── Dark palette ─── */
  body[data-theme="dark"] {
    --cream: #0f1714;
    --cream-2: #161f1a;
    --paper: #1a2420;
    --forest: #7bc4a5;
    --forest-2: #5ba88a;
    --forest-light: rgba(123, 196, 165, 0.14);
    --gold: #d4a973;
    --gold-soft: rgba(212, 169, 115, 0.25);
    --gold-bg: rgba(212, 169, 115, 0.10);
    --rose: #d6a097;
    --rose-soft: rgba(214, 160, 151, 0.16);
    --ink: #e8eaf0;
    --ink-dim: #a9aebe;
    --ink-muted: #6d7388;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 12px 32px -12px rgba(0,0,0,0.3);
    --shadow-hover: 0 2px 4px rgba(0,0,0,0.3), 0 20px 48px -16px rgba(0,0,0,0.4);
    --sidebar-bg: rgba(10, 15, 20, 0.6);

    /* Semantic colors — dark-mode variants. Slightly brighter base hues
       so they pop against the dark canvas; soft + tint variants stay
       color-mix() derivations so the system stays single-sourced. */
    --success:        #3fc97c;
    --success-soft:   color-mix(in srgb, var(--success) 18%, transparent);
    --success-tint:   color-mix(in srgb, var(--success) 40%, transparent);
    --warning:        #e0a93f;
    --warning-soft:   color-mix(in srgb, var(--warning) 18%, transparent);
    --warning-tint:   color-mix(in srgb, var(--warning) 40%, transparent);
    --info:           #5b9dff;
    --info-soft:      color-mix(in srgb, var(--info) 16%, transparent);
    --info-tint:      color-mix(in srgb, var(--info) 40%, transparent);
    --danger:         #e74c3c;
    --danger-soft:    color-mix(in srgb, var(--danger) 18%, transparent);
    --danger-tint:    color-mix(in srgb, var(--danger) 40%, transparent);
  }

/* ---- MODALS (from _modal_theme.html) ---- */
/* ───────── Side-drawer modal ───────── */
  .custom-modal {
    /* Hidden by default. Only the `.show` class flips display + transform.
       Belt-and-suspenders: even if `transform` gets overridden by another
       stylesheet, `display: none` keeps the modal out of the layout. */
    display: none;
    position: fixed;
    z-index: 1050;
    right: 0; top: 0;
    height: 100%;
    width: 100%;
    max-width: 520px;
    background: var(--paper);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.18);
    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.32s ease;
    flex-direction: column;
    font-family: var(--body); color: var(--ink);
  }
  @media (min-width: 1024px) { .custom-modal { max-width: 760px; } }
  @media (min-width: 1440px) { .custom-modal { max-width: 920px; } }
  .custom-modal.show { display: flex; transform: translateX(0); opacity: 1; }

  .custom-modal-backdrop {
    display: none;
    position: fixed; inset: 0;
    background-color: rgba(15, 23, 19, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  .custom-modal-backdrop.show { display: block; opacity: 1; }

  .custom-modal-header {
    padding: 20px 26px;
    background: var(--brand-primary, #b7925a);
    color: var(--cream);
    flex-shrink: 0;
  }
  .custom-modal-header h5 {
    margin: 0;
    font-family: var(--display); font-weight: 600;
    font-size: 19px; letter-spacing: 0.01em;
  }

  .custom-modal-body {
    padding: 24px 26px;
    overflow-y: auto;
    flex: 1 1 auto;
    background: var(--cream);
  }

  .close-btn {
    position: absolute;
    left: -18px; top: 22px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--brand-primary, #b7925a);
    color: var(--cream);
    border: 3px solid var(--paper);
    cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease, background 0.15s ease;
  }
  .close-btn:hover { background: var(--brand-primary, #b7925a); transform: scale(1.06); }
  .close-btn:before { content: "\2715"; font-size: 14px; font-weight: 700; }

  /* ───────── Bootstrap dropdown override (theme-aware) ───────── */
  .dropdown-menu {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    padding: 6px;
  }
  .dropdown-item {
    border-radius: 6px;
    font-size: 13px;
    padding: 8px 12px;
    color: var(--ink);
    background: transparent;
    border: 0;
  }
  .dropdown-item:hover,
  .dropdown-item:focus {
    background: var(--cream-2, rgba(255,255,255,0.06));
    color: var(--ink);
  }
  .dropdown-item.text-danger:hover,
  .dropdown-item.text-danger:focus {
    background: rgba(220, 53, 69, 0.12);
    color: #ff6b7a;
  }
  .dropdown-divider {
    border-top: 1px solid var(--border);
    margin: 4px 0;
  }
  .dropdown-toggle::after { color: currentColor; }

  /* ───────── Dark-mode-specific tweaks ───────── */
  body[data-theme="dark"] .custom-modal {
    box-shadow: -8px 0 36px rgba(0, 0, 0, 0.55);
  }
  body[data-theme="dark"] .custom-modal-backdrop {
    background-color: rgba(0, 0, 0, 0.6);
  }
  body[data-theme="dark"] .custom-modal-header {
    /* In dark mode the forest var becomes a light mint — pair with high-contrast dark text */
    color: #0f1714;
  }
  body[data-theme="dark"] .custom-modal-body {
    /* `--cream` is near-black in dark mode; lift to `--paper` so the modal
       reads as a panel instead of a void. */
    background: var(--paper);
  }
  body[data-theme="dark"] .close-btn {
    border-color: var(--paper);
    color: #0f1714;
  }
  body[data-theme="dark"] .dropdown-menu {
    background: #1f2a26;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.6);
  }
  body[data-theme="dark"] .dropdown-item { color: var(--ink); }
  body[data-theme="dark"] .dropdown-item:hover,
  body[data-theme="dark"] .dropdown-item:focus {
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
  }
  body[data-theme="dark"] .dropdown-divider {
    border-top-color: rgba(255, 255, 255, 0.08);
  }

/* ---- CENTRE MODAL (from _centre_modal_theme.html) ---- */
.rl-modal-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(45, 49, 66, 0.55);
    backdrop-filter: blur(3px);
    z-index: 9998; opacity: 0;
    transition: opacity .2s ease;
  }
  .rl-modal-backdrop.show { display: block; opacity: 1; }

  .rl-modal {
    display: none;
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -45%) scale(.96);
    width: min(820px, 94vw);
    max-height: 88vh;
    background: var(--paper);
    border: 1px solid var(--cream-2);
    border-radius: 16px;
    box-shadow: 0 30px 80px -20px rgba(0,0,0,0.35);
    z-index: 9999; opacity: 0;
    transition: all .22s cubic-bezier(.25,.8,.25,1);
    overflow: hidden;
    flex-direction: column;
  }
  .rl-modal.show {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  /* Compact variant for tiny one-field dialogs (e.g. add department) */
  .rl-modal.rl-modal--compact { width: min(480px, 92vw); }
  /* Wider variant if needed (kept for future use) */
  .rl-modal.rl-modal--wide { width: min(960px, 94vw); }

  .rl-modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--cream-2);
    background: linear-gradient(135deg, var(--cream-2), var(--paper));
    flex-shrink: 0;
  }
  .rl-modal-head h5 {
    font-family: var(--display); font-size: 17px; font-weight: 500;
    color: var(--ink); margin: 0;
    display: flex; align-items: center; gap: 10px; letter-spacing: -0.01em;
  }
  .rl-modal-head h5 em { color: var(--brand-primary, #b7925a); font-style: italic; font-weight: 400; }
  .rl-modal-head h5 i { color: var(--brand-primary, #b7925a); }

  .rl-modal-close {
    background: transparent; border: 1px solid var(--cream-2);
    color: var(--ink-dim); width: 30px; height: 30px;
    border-radius: 8px; cursor: pointer;
    display: grid; place-items: center;
    font-size: 16px; line-height: 1;
    transition: all .15s ease;
    padding: 0;
  }
  .rl-modal-close:hover {
    background: var(--rose-soft, rgba(196,80,90,0.12));
    color: var(--rose-deep, #8a3741);
    border-color: var(--rose, rgba(196,80,90,0.5));
  }

  /* Content slot: holds the inner form (body+foot) or read-only view body.
     Children handle their own scrolling so the footer never scrolls away. */
  .rl-modal-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .rl-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }
  .rl-form-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 22px 24px;
    background: var(--cream);
  }
  .rl-form-body::-webkit-scrollbar { width: 8px; }
  .rl-form-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
  .rl-form-body::-webkit-scrollbar-track { background: transparent; }

  .rl-form-foot {
    flex-shrink: 0;
    padding: 14px 22px;
    background: var(--paper);
    border-top: 1px solid var(--cream-2);
    display: flex; justify-content: flex-end; gap: 10px;
    box-shadow: 0 -4px 12px -8px rgba(45,49,66,0.12);
  }

  /* Read-only view body */
  .rl-view-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 22px 24px;
    background: var(--cream);
  }
  .rl-view-body::-webkit-scrollbar { width: 8px; }
  .rl-view-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
  .rl-view-body::-webkit-scrollbar-track { background: transparent; }

/* ---- LIST PAGE / HEADER / BTN / CARD / TABLE / STATUS / PROGRESS (from _list_page_theme.html) ---- */
.cl-page { font-family: var(--body); color: var(--ink); animation: clFadeUp 0.5s ease both; }

  .cl-page .breadcrumb {
    background: transparent; padding: 0; margin-bottom: 12px;
    font-size: 12.5px; color: var(--ink-dim);
  }
  .cl-page .breadcrumb a { color: var(--ink-dim); text-decoration: none; }
  .cl-page .breadcrumb a:hover { color: var(--ink); }
  .cl-page .breadcrumb .active { color: var(--ink); font-weight: 600; }

  /* Match the canonical .topbar / .page-title pattern from base_operation.html */
  .cl-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    flex-wrap: wrap; gap: 16px;
    margin-bottom: 32px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    animation: clHeaderFade 0.6s ease;
  }
  @keyframes clHeaderFade { from { opacity: 0; transform: translateY(-6px);} to { opacity: 1; transform: translateY(0);} }
  .cl-header > div:first-child { flex: 1; min-width: 240px; }
  .cl-header h2 {
    font-family: var(--display);
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1.15;
    margin: 0 0 6px;
  }
  .cl-header h2 em { color: var(--brand-primary, #b7925a); font-style: italic; font-weight: 500; }
  .cl-header h2 i { display: none; } /* canonical topbar has no leading icon */
  .cl-header p {
    margin: 0;
    color: var(--ink-dim);
    font-size: 14px;
    font-family: var(--body);
    font-weight: 400;
  }
  /* legacy eyebrow — hidden so old markup doesn't render extra chrome */
  .cl-header .cl-eyebrow { display: none; }

  .cl-actions { display: flex; gap: 8px; flex-wrap: wrap; }
  .cl-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--body); font-size: 13px; font-weight: 600;
    border: 1px solid var(--border-strong);
    background: var(--paper); color: var(--ink);
    transition: all 0.18s ease;
    cursor: pointer; text-decoration: none;
  }
  .cl-btn:hover { background: var(--cream-2); color: var(--ink); border-color: var(--brand-primary, #b7925a); }
  .cl-btn-primary { background: var(--brand-primary); color: var(--cream); border-color: var(--brand-primary); }
  /* Hover darkens the brand color via color-mix so the press feedback
     follows the tenant's hue instead of always landing on system gold.
     The current design's forest→gold hover lives on .cl-btn-gold below
     if a page still wants that explicit two-tone treatment. */
  .cl-btn-primary:hover {
    background: color-mix(in srgb, var(--brand-primary), black 12%);
    color: var(--cream);
    border-color: color-mix(in srgb, var(--brand-primary), black 12%);
  }
  .cl-btn-gold {
    background: var(--brand-primary-soft);
    color: var(--brand-primary, #b7925a); border-color: color-mix(in srgb, var(--brand-primary, #b7925a) 30%, transparent);
  }
  .cl-btn-gold:hover { background: var(--brand-primary, #b7925a); color: var(--cream); border-color: var(--brand-primary, #b7925a); }
  .cl-btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
  .cl-btn-danger:hover { background: color-mix(in srgb, var(--danger), black 12%); border-color: color-mix(in srgb, var(--danger), black 12%); color: #fff; }

  /* Inline text link — brand-colored anchor for use INSIDE prose, table cells,
     and list rows (vs .cl-btn which is a chip). Underline appears on hover so
     dense tables stay calm. Pairs with a leading <i> when a glyph helps. */
  .cl-link { color: var(--brand-primary, #1b4332); text-decoration: none; font-weight: 600; transition: color 0.15s ease; }
  .cl-link:hover { color: var(--ink); text-decoration: underline; }

  /* Standalone back button — drop-in replacement for plain `<a>Back</a>` text
     links across the operational area. Slides on hover so the user feels the
     direction. Use as: <a class="cl-back-btn"><i class="fas fa-arrow-left"></i> Back …</a>. */
  .cl-back-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px;
    background: var(--paper);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--ink); font-size: 13px; font-weight: 600;
    text-decoration: none; margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(45,49,66,0.04);
    transition: all 0.18s ease;
  }
  .cl-back-btn:hover {
    background: var(--cream-2); color: var(--ink);
    border-color: var(--brand-primary, #b7925a); text-decoration: none;
    transform: translateX(-2px);
  }
  .cl-back-btn i { font-size: 11px; transition: transform 0.18s ease; }
  .cl-back-btn:hover i { transform: translateX(-2px); }

  .cl-toolbar {
    display: flex; gap: 12px; flex-wrap: wrap;
    margin-bottom: 14px; align-items: center; justify-content: space-between;
  }
  .cl-search { flex: 1; max-width: 420px; position: relative; }
  .cl-search input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background: var(--paper);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--body); font-size: 13.5px;
    color: var(--ink);
    transition: all 0.18s ease;
  }
  .cl-search input:focus {
    outline: none; border-color: var(--brand-primary, #b7925a);
    box-shadow: 0 0 0 3px var(--brand-primary-soft);
  }
  .cl-search > i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--ink-muted); font-size: 13px;
  }
  .cl-search-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: transparent; border: 0; color: var(--ink-muted);
    cursor: pointer; padding: 4px 8px;
  }
  .cl-search-clear:hover { color: var(--ink); }
  .cl-filter-group { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .cl-filter-group label { margin: 0; font-size: 12.5px; color: var(--ink-dim); }

  /* Operations-themed <select> — keeps the native dropdown behavior so
     clicking options works. We only restyle the closed pill (border, padding,
     font, hover/focus). Letting the OS render the arrow + open state means
     no event-handling weirdness from appearance:none + custom chevron. */
  .cl-page select,
  .cl-filter-group select,
  .cl-perpage select {
    border: 1px solid var(--border-strong);
    background: var(--paper);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    font-size: 13px;
    font-family: var(--body);
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 1px 2px rgba(45,49,66,0.04);
  }
  .cl-page select:hover,
  .cl-filter-group select:hover,
  .cl-perpage select:hover { border-color: var(--brand-primary, #b7925a); }
  .cl-page select:focus,
  .cl-filter-group select:focus,
  .cl-perpage select:focus {
    outline: none;
    border-color: var(--brand-primary, #b7925a);
    box-shadow: 0 0 0 3px var(--brand-primary-soft);
  }

  .cl-perpage { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-dim); font-weight: 600; }
  .cl-perpage span:first-child,
  .cl-perpage span:last-child { color: var(--ink-dim); }

  .cl-name-cell { display: flex; align-items: center; gap: 12px; }
  .cl-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--brand-primary, #b7925a); color: var(--cream);
    font-family: var(--display); font-weight: 600; font-size: 15px;
    display: grid; place-items: center;
    flex-shrink: 0;
  }
  .cl-name-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .cl-name-desc { color: var(--ink-dim); font-size: 11.5px; line-height: 1.4; }
  .cl-emoji-avatar {
    background: var(--cream-2, #f4ede2) !important;
    color: var(--ink) !important;
    font-size: 20px !important;
    border: 1px solid var(--border);
  }
  .cl-photo-avatar {
    background: transparent !important;
    border: 1px solid var(--border);
    overflow: hidden;
    padding: 0;
  }
  .cl-photo-avatar img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
  }
  .cl-name { font-weight: 600; color: var(--ink); }
  .cl-row-meta { color: var(--ink-dim); font-size: 12.5px; }
  .cl-pill {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 100px;
    background: var(--cream-2, #f4ede2);
    border: 1px solid var(--border);
    color: var(--ink); font-size: 11.5px; font-weight: 600;
  }
  .cl-pill.muted { color: var(--ink-muted); background: var(--paper); }

  .cl-action-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--ink-dim);
    display: inline-grid; place-items: center;
    transition: all 0.15s ease;
  }
  .cl-action-btn:hover { background: var(--cream-2); color: var(--ink); border-color: var(--brand-primary, #b7925a); }
  /* Suppress Bootstrap's auto-injected caret on .dropdown-toggle so we show ellipsis only */
  .cl-action-btn.dropdown-toggle::after,
  .cl-action-btn.dropdown-toggle::before { display: none !important; content: none !important; }
  .cl-page .dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    padding: 6px;
  }
  .cl-page .dropdown-item {
    border-radius: 6px; font-size: 13px;
    padding: 8px 12px; color: var(--ink);
  }
  .cl-page .dropdown-item:hover { background: var(--cream-2); color: var(--ink); }
  .cl-page .dropdown-item.text-danger { color: var(--danger); }
  .cl-page .dropdown-item.text-danger:hover { background: var(--danger-soft); color: var(--danger); }

  .cl-card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    /* Token-driven so dashboards can tune the stacked-card gap via --gap-row
       without re-declaring .cl-card; defaults to 18px everywhere else. */
    margin-bottom: var(--gap-row, 18px);
  }
  /* Standard CONTENT-card body padding. .cl-card-body defaults to padding:0
     (correct for cards wrapping a .cl-table — the cells provide spacing); add
     .cl-card-pad to a body that holds free content (text, forms, charts) so
     padding stays consistent app-wide instead of being re-invented per page.
     Variants: .flush = 0 (explicit), .compact = tighter. */
  /* Compound selector (.cl-card-body.cl-card-pad) so it OUT-specifies the
     bare `.cl-card-body { padding: 0 }` rule below regardless of source order;
     the standalone `.cl-card-pad` covers any non-body use. */
  .cl-card-pad,
  .cl-card-body.cl-card-pad { padding: var(--pad-card, 22px 24px); }
  .cl-card-pad.flush,
  .cl-card-body.cl-card-pad.flush { padding: 0; }
  .cl-card-pad.compact,
  .cl-card-body.cl-card-pad.compact { padding: 14px 18px; }
  .cl-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 22px;
    background: var(--cream-2, #f4ede2);
    border-bottom: 1px solid var(--border);
    font-family: var(--display);
    font-weight: 600; color: var(--ink);
    font-size: 15px;
  }
  .cl-badge {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--ink-dim);
    font-family: var(--body);
    font-size: 11px; font-weight: 600;
    padding: 4px 12px;
    letter-spacing: 0.04em;
  }
  .cl-card-body { padding: 0; }
  .cl-table { width: 100%; border-collapse: collapse; font-family: var(--body); }
  .cl-table thead th {
    background: var(--paper);
    color: var(--ink-dim);
    font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.14em;
    text-align: left;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
  }
  .cl-table tbody td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px; color: var(--ink); vertical-align: middle;
  }
  .cl-table tbody tr { transition: background 0.15s ease; }
  .cl-table tbody tr:hover { background: var(--cream); }
  .cl-table tbody tr:last-child td { border-bottom: none; }
  .cl-status {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 100px;
    font-size: 11.5px; font-weight: 600;
    border: 1px solid transparent;
    letter-spacing: 0.02em;
  }
  .cl-status-success { background: var(--brand-primary-soft); color: var(--ink); border-color: var(--brand-primary-soft); }
  .cl-status-warning { background: var(--gold-bg, rgba(183,146,90,0.12)); color: var(--brand-primary, #b7925a); border-color: color-mix(in srgb, var(--brand-primary, #b7925a) 30%, transparent); }
  .cl-status-danger  { background: rgba(192,57,43,0.08); color: var(--danger, #b02a37); border-color: rgba(192,57,43,0.2); }
  .cl-status-info    { background: rgba(45,90,71,0.08); color: var(--ink); border-color: rgba(45,90,71,0.2); }
  .cl-status-muted   { background: var(--cream-2, #f4ede2); color: var(--ink-muted); border-color: var(--border); }

  .cl-progress {
    position: relative;
    height: 22px;
    background: var(--cream-2, #f4ede2);
    border: 1px solid var(--border);
    border-radius: 100px;
    overflow: hidden;
    min-width: 140px;
  }
  .cl-progress-bar {
    position: absolute; inset: 0;
    background: linear-gradient(90deg, var(--ink), var(--brand-primary, #b7925a));
    transition: width 0.3s ease;
    border-radius: 100px;
  }
  .cl-progress-label {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 700;
    color: var(--ink);
    /* Theme-aware halo: dark text on light theme gets a paper halo, light text
       on dark theme gets a dark halo. The halo always contrasts the text, so the
       label stays readable over BOTH the gold/forest bar fill AND the cream-2
       empty track regardless of fill percentage or theme. */
    text-shadow:
      -1px 0 var(--paper),
      1px 0 var(--paper),
      0 -1px var(--paper),
      0 1px var(--paper),
      0 0 6px var(--paper);
    letter-spacing: 0.01em;
  }

  .cl-empty { text-align: center; padding: 56px 20px; color: var(--ink-dim); }
  .cl-empty i { font-size: 36px; color: var(--ink-muted); display: block; margin-bottom: 10px; }
  .cl-empty h6 { font-family: var(--display); color: var(--ink); margin: 0 0 4px; font-size: 18px; }

  /* Async tables live in .cl-card (overflow:hidden), so without their own
     horizontal scroll the wide table is clipped on phones. Mirror the
     .table-responsive overflow contract here (x:auto / y:hidden) so every
     data-cl-async-table pans on mobile without a per-page wrapper div. */
  .cl-table-wrapper { position: relative; transition: opacity 0.15s ease; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
  .cl-table-wrapper.cl-loading { opacity: 0.55; pointer-events: none; }
  .cl-table-wrapper.cl-loading::after {
    content: "";
    position: absolute; top: 14px; right: 14px;
    width: 18px; height: 18px;
    border: 2px solid var(--brand-primary, #b7925a);
    border-top-color: transparent;
    border-radius: 50%;
    animation: clSpin 0.7s linear infinite;
  }
  @keyframes clSpin { to { transform: rotate(360deg); } }
  @keyframes clFadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

  /* ── Shared responsive cascade for every page that uses this theme.
     Putting these here means student/teacher login reports, course list,
     enrollment list, etc. all get the same mobile treatment without each
     template having to redeclare. */
  /* `.table-responsive` is a Bootstrap class that's not loaded here.
     Define it so wide tables can pan horizontally on phones. */
  .cl-page .cl-card .table-responsive {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .cl-page .cl-table th,
  .cl-page .cl-table td { white-space: nowrap; }

  @media (max-width: 900px) {
    .cl-page .cl-header h2 { font-size: 24px; }
    .cl-page .cl-table thead th,
    .cl-page .cl-table tbody td { padding: 10px 12px; }
  }

  @media (max-width: 720px) {
    .cl-page .cl-header { gap: 12px; }
    .cl-page .cl-header h2 { font-size: 22px; }
    .cl-page .cl-header p { font-size: 13px; }
    /* Right-side action chips drop below the title on phones. */
    .cl-page .cl-actions { width: 100%; }
    .cl-page .cl-actions .cl-status { font-size: 12px !important; padding: 6px 12px !important; }
    /* Toolbar stacks: search full-width, filter group on its own row. */
    .cl-page .cl-toolbar { flex-direction: column; align-items: stretch; }
    .cl-page .cl-toolbar .cl-search { max-width: none; width: 100%; }
    .cl-page .cl-toolbar .cl-filter-group { width: 100%; justify-content: space-between; flex-wrap: wrap; }
    .cl-page .cl-card-header { padding: 12px 16px; flex-wrap: wrap; gap: 6px; font-size: 14px; }
    .cl-card-pad,
    .cl-card-body.cl-card-pad { padding: 16px 18px; }
    .cl-page .cl-table thead th,
    .cl-page .cl-table tbody td { padding: 10px 12px; font-size: 12.5px; }
    .cl-page .cl-avatar { width: 28px; height: 28px; font-size: 11px; }
  }

  @media (max-width: 480px) {
    .cl-page .cl-header h2 { font-size: 20px; }
    .cl-page .cl-toolbar .cl-filter-group { flex-direction: column; align-items: stretch; gap: 8px; }
    .cl-page .cl-perpage { justify-content: flex-start; }
    .cl-page .cl-table thead th,
    .cl-page .cl-table tbody td { padding: 9px 10px; font-size: 12px; }
    .cl-page .cl-name-cell { gap: 8px; }
    .cl-page .cl-status { font-size: 10.5px; padding: 2px 7px; }
  }

/* ---- FORM CARD / FIELDS (from _form_card.html) ---- */
.cl-form-card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    max-width: 880px;
  }
  .cl-form-section { margin-bottom: 22px; }
  .cl-form-section h6 {
    font-family: var(--display);
    color: var(--ink);
    font-size: 15px; font-weight: 600;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
  }
  .cl-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
  }
  @media (max-width: 720px) { .cl-form-grid { grid-template-columns: 1fr; } }

  .cl-field { min-width: 0; }
  .cl-field.full { grid-column: 1 / -1; }
  .cl-field label {
    display: block;
    font-weight: 600; font-size: 11.5px;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--ink-dim); margin-bottom: 6px;
  }
  .cl-field .req { color: var(--danger, #c0392b); }
  .cl-field input[type="text"],
  .cl-field input[type="email"],
  .cl-field input[type="number"],
  .cl-field input[type="date"],
  .cl-field input[type="time"],
  .cl-field input[type="color"],
  .cl-field input[type="password"],
  .cl-field input[type="tel"],
  .cl-field select,
  .cl-field textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--body); font-size: 13.5px;
    background: var(--paper); color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .cl-field input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand-primary, #b7925a); margin-right: 6px; }
  .cl-field input[type="file"] {
    width: 100%; padding: 9px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm); background: var(--cream);
    font-size: 12.5px;
  }
  .cl-field input:focus, .cl-field select:focus, .cl-field textarea:focus {
    outline: none; border-color: var(--brand-primary, #b7925a);
    box-shadow: 0 0 0 3px var(--brand-primary-soft);
  }
  /* Validation copy. `.hint`/`.err` are the standard; `.field-hint`/`.field-error`
     are accepted as aliases so markup written for the modal vocabulary renders
     identically on any cl-field. Error color reads the --danger token. */
  .cl-field .hint,
  .cl-field .field-hint { color: var(--ink-muted); font-size: 11.5px; margin-top: 4px; font-weight: 400; text-transform: none; letter-spacing: 0; }
  .cl-field .err,
  .cl-field .field-error { color: var(--danger, #b02a37); font-size: 12px; margin-top: 4px; }
  /* Inline checkbox / radio label — box + text on one line (vs the stacked
     uppercase .cl-field label). Reusable for "Mark as featured"-style toggles. */
  .cl-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink); text-transform: none; letter-spacing: 0; cursor: pointer; margin: 0; }
  .cl-check input[type="checkbox"], .cl-check input[type="radio"] { width: 16px; height: 16px; accent-color: var(--brand-primary, #b7925a); margin: 0; }

  /* Numbered/iconed form-section header — groups fields under a titled rule.
     Use with .cl-form-section. Markup: .cl-form-section-head > [.cl-form-section-num] + div(.ttl + .sub). */
  .cl-form-section-head { display: flex; align-items: flex-start; gap: 14px; padding-bottom: 14px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
  .cl-form-section-num { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; background: var(--cream-2); color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 14px; display: grid; place-items: center; border: 1px solid var(--border); letter-spacing: -0.02em; }
  .cl-form-section-head .ttl { font-family: var(--display); color: var(--ink); font-size: 16.5px; font-weight: 600; margin: 0 0 3px; display: flex; align-items: center; gap: 9px; }
  .cl-form-section-head .ttl i { color: var(--brand-primary, #b7925a); font-size: 14px; }
  .cl-form-section-head .sub { font-size: 12.5px; color: var(--ink-dim); margin: 0; }

  /* Identity strip — avatar + name + role/id/email meta. Reusable header for
     profile-edit / detail pages. */
  .cl-identity { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
  .cl-identity-avatar { width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(135deg, var(--ink), var(--brand-primary, #b7925a)); color: var(--cream); display: grid; place-items: center; font-family: var(--display); font-size: 22px; font-weight: 700; flex-shrink: 0; }
  .cl-identity-name { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; margin: 0; }
  .cl-identity-meta { margin-top: 6px; font-size: 13px; color: var(--ink-dim); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .cl-identity-id { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--cream-2); padding: 3px 9px; border-radius: 100px; }

  /* Photo upload — square preview + dashed drop zone (file input fills the zone). */
  .cl-photo-upload { display: grid; grid-template-columns: 132px 1fr; gap: 22px; align-items: stretch; }
  @media (max-width: 720px) { .cl-photo-upload { grid-template-columns: 1fr; } }
  .cl-photo-upload-preview { width: 132px; height: 132px; border-radius: 16px; border: 1px solid var(--border-strong); background: var(--cream-2); overflow: hidden; display: grid; place-items: center; color: var(--ink-dim); text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
  .cl-photo-upload-preview img { width: 100%; height: 100%; object-fit: cover; }
  .cl-photo-upload-preview i { display: block; font-size: 26px; margin-bottom: 6px; color: var(--brand-primary, #b7925a); }
  .cl-photo-upload-zone { position: relative; border: 2px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--cream); padding: 18px 20px; display: flex; flex-direction: column; justify-content: center; transition: border-color 0.15s ease, background 0.15s ease; cursor: pointer; }
  .cl-photo-upload-zone:hover { border-color: var(--brand-primary, #b7925a); background: var(--brand-primary-soft); }
  .cl-photo-upload-zone .ttl { font-family: var(--display); font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
  .cl-photo-upload-zone .ttl em { color: var(--brand-primary, #b7925a); font-style: normal; font-weight: 700; }
  .cl-photo-upload-zone .sub { font-size: 12px; color: var(--ink-dim); line-height: 1.5; }
  .cl-photo-upload-zone .fname { margin-top: 10px; font-size: 12.5px; color: var(--ink); font-weight: 600; word-break: break-all; display: none; }
  .cl-photo-upload-zone .fname.has-file { display: block; }
  .cl-photo-upload-zone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

  .cl-form-actions {
    display: flex; gap: 10px;
    margin-top: 24px; padding-top: 18px;
    border-top: 1px solid var(--border);
  }

  .cl-form-alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 16px;
    border: 1px solid var(--border-strong);
  }
  .cl-form-alert.error, .cl-form-alert.danger {
    background: rgba(192,57,43,0.06);
    border-color: rgba(192,57,43,0.2);
    color: var(--danger, #8b2a1f);
  }

/* ---- NEW SHARED COMPONENTS (Phase 0 additions; token-based, brand + dark aware) ---- */

/* Tabs — URL- or JS-driven (mirrors the material-list ll-tabs pattern) */
.cl-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.cl-tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; background: none;
  color: var(--ink-dim); font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s ease, border-color .15s ease; }
.cl-tab:hover { color: var(--ink); }
.cl-tab.is-active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }
.cl-tab .cl-tab-count { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand-primary) 12%, transparent); color: var(--brand-primary); }

/* Alerts / inline messages — semantic, soft-tinted */
.cl-alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--cream-2); color: var(--ink); font-size: 13.5px; line-height: 1.5; }
.cl-alert i { margin-top: 2px; flex-shrink: 0; }
.cl-alert-success { background: var(--success-soft); border-color: var(--success-tint); color: var(--ink); }
.cl-alert-success i { color: var(--success); }
.cl-alert-warning { background: var(--warning-soft); border-color: var(--warning-tint); }
.cl-alert-warning i { color: var(--warning); }
.cl-alert-danger  { background: var(--danger-soft);  border-color: var(--danger-tint); }
.cl-alert-danger i { color: var(--danger); }
.cl-alert-info    { background: var(--info-soft);    border-color: var(--info-tint); }
.cl-alert-info i { color: var(--info); }

/* Inline code / token chip — monospace value (API keys, IDs, slugs). */
.cl-code {
  font-family: ui-monospace, "SF Mono", "Courier New", monospace;
  background: var(--cream-2, #f3ede2);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
  font-size: 12.5px;
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* Stat grid — dashboard summary tiles */
.cl-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.cl-stat { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 18px; box-shadow: var(--shadow); }
.cl-stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-muted); margin-bottom: 6px; }
.cl-stat-value { font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cl-stat-sub { font-size: 12px; color: var(--ink-dim); margin-top: 3px; }
.cl-stat-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 10px;
  background: color-mix(in srgb, var(--brand-primary) 12%, transparent); color: var(--brand-primary); font-size: 15px; }

/* ── Reusable DataTables skin — tones the bootstrap-5 DataTables controls
   (search / length / info / pagination) to the cl- look. Applies wherever a
   .dataTables_wrapper renders, so DataTables pages don't each re-style it. ── */
/* Side padding so a DataTables sitting in a padding:0 .cl-card-body isn't flush.
   The bootstrap5 DataTables renders its controls in Bootstrap .row (negative
   side margins) — neutralize those so the wrapper padding actually shows. */
.dataTables_wrapper { padding: 14px 18px; }
.dataTables_wrapper > .row { margin-left: 0 !important; margin-right: 0 !important; }
.dataTables_wrapper > .row > [class*="col"] { padding-left: 0 !important; padding-right: 0 !important; }
.dataTables_filter input, .dataTables_length select {
  border: 1px solid var(--border-strong); border-radius: 100px;
  padding: 6px 14px; background: var(--paper); color: var(--ink); font-size: 13px;
}
.dataTables_filter input:focus, .dataTables_length select:focus {
  outline: none; border-color: var(--brand-primary, #b7925a); box-shadow: 0 0 0 3px var(--brand-primary-soft);
}
.dataTables_info { color: var(--ink-dim); font-size: 12.5px; }
.dataTables_paginate .paginate_button {
  border-radius: 8px !important; margin: 0 2px !important; color: var(--ink-dim) !important; border: 1px solid transparent !important;
}
.dataTables_paginate .paginate_button.current, .dataTables_paginate .paginate_button.current:hover {
  background: var(--brand-primary, #1b4332) !important; color: var(--cream) !important; border-color: var(--brand-primary, #1b4332) !important;
}
.dataTables_paginate .paginate_button:hover {
  background: var(--cream-2) !important; color: var(--ink) !important; border-color: var(--border-strong) !important;
}

/* Inline input — compact number/text input for in-table editors (score boxes).
   Pair with .cl-inline-edit (flex row); is-valid / is-invalid feedback states. */
.cl-inline-edit { display: inline-flex; align-items: center; gap: 8px; }
.cl-inline-input {
  width: 90px; padding: 7px 10px; background: var(--cream);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums;
}
.cl-inline-input:focus { outline: none; border-color: var(--brand-primary, #b7925a); box-shadow: 0 0 0 3px var(--brand-primary-soft); }
.cl-inline-input.is-valid { border-color: #16a085; box-shadow: 0 0 0 3px rgba(22,160,133,0.15); }
.cl-inline-input.is-invalid { border-color: var(--danger, #c0392b); box-shadow: 0 0 0 3px rgba(192,57,43,0.15); }
.cl-inline-denom { color: var(--ink-muted); font-size: 13px; font-weight: 600; }

/* ─── Compact density ────────────────────────────────────────────────────
   Opt-in workspace density, toggled via Profile.ui_prefs and applied as
   data-density="compact" on <body>. Tightens the repeated, data-heavy
   surfaces — tables, stat tiles, card chrome — by ~25% without disturbing
   type hierarchy. The default ("comfortable") leaves every rule above
   untouched, so this is purely additive. */

/* Primary lever: the operations dashboards drive their grid gaps and card
   padding through these shared custom properties on .cl-page, so overriding
   them here tightens every dashboard at once (and outspecifies each page's
   own `.cl-page { --pad-card: … }` declaration). */
body[data-density="compact"] .cl-page {
  --gap-row: 12px;
  --gap-col: 12px;
  --gap-tile: 9px;
  --pad-card: 13px 16px;
}
body[data-density="compact"] .cl-card { margin-bottom: 12px; }
body[data-density="compact"] .cl-card-header { padding: 9px 16px; font-size: 14px; }
body[data-density="compact"] .cl-table thead th { padding: 8px 14px; }
body[data-density="compact"] .cl-table tbody td { padding: 8px 14px; font-size: 12.5px; }
body[data-density="compact"] .cl-stat-grid { gap: 10px; }
body[data-density="compact"] .cl-stat { padding: 11px 13px; }
body[data-density="compact"] .cl-stat-label { margin-bottom: 4px; }
body[data-density="compact"] .cl-stat-value { font-size: 21px; }
body[data-density="compact"] .cl-stat-icon { width: 30px; height: 30px; margin-bottom: 7px; font-size: 13px; }

/* Bespoke dashboard KPI tiles use per-page prefixes (acd/ca/it/ph/rg/sa/tk)
   rather than the shared classes or vars, so tighten the tile padding and
   grid gap explicitly. Values only reduce the generous dashboard defaults. */
body[data-density="compact"] .acd-kpi,
body[data-density="compact"] .ca-kpi,
body[data-density="compact"] .it-kpi,
body[data-density="compact"] .ph-kpi,
body[data-density="compact"] .rg-kpi,
body[data-density="compact"] .sa-kpi,
body[data-density="compact"] .tk-kpi { padding: 12px 14px; }
body[data-density="compact"] .acd-kpis,
body[data-density="compact"] .ca-kpis,
body[data-density="compact"] .it-kpis,
body[data-density="compact"] .ph-kpis,
body[data-density="compact"] .rg-kpis,
body[data-density="compact"] .sa-kpis,
body[data-density="compact"] .tk-kpis { gap: 10px; }

/* BR-6 — bounded auto-growing textarea (paired with static/js/cl-autosize.js) */
.cl-autosize { max-height: 42vh; overflow-y: auto; resize: none; }
