/* ============================================================
   ZAK theme → Bootstrap 5 bridge
   ------------------------------------------------------------
   Maps the ZAK tokens in zak-theme.css onto the --bs-* custom properties Sneat
   and Bootstrap 5.3.5 already read, so existing markup takes on the house look
   without being rewritten. Follows theme/MERGE-GUIDE.md §2 step 2.

   TWO RULES, BOTH DELIBERATE.

   1. SCOPED, NEVER :root. The guide is explicit that "a reskin that changes
      everything the moment it loads cannot be tried on one screen", so every
      mapping below hangs off .zak-theme. A page opts in with
      @section('body-class', 'zak-theme') and nothing else in the app moves.
      Putting these on :root would reskin all 589 routes in one commit, which
      is exactly the change nobody could review.

   2. LIGHT ONLY, FOR NOW. The ZAK system is paper (#ece8dd) with ink (#16181c)
      and states "NO PURE WHITE" as its first principle — it has no dark
      palette. v1 ships a working dark mode through [data-bs-theme="dark"], and
      forcing paper underneath it would produce ink-on-ink. So the bridge stands
      down in dark mode and Sneat's own dark palette keeps running. That is a
      gap to close with the theme's author, not something to guess at here.
   ============================================================ */

/* ------------------------------------------------------------
   1. TOKEN MAP  (MERGE-GUIDE.md §2 step 2, "If it is Bootstrap 5")
   ------------------------------------------------------------ */
.zak-theme {
  --bs-body-bg:        var(--paper);
  --bs-body-color:     var(--ink);
  --bs-secondary-bg:   var(--paper2);
  --bs-tertiary-bg:    var(--card);
  --bs-border-color:   var(--line);
  --bs-border-radius:  var(--r);
  --bs-border-radius-sm: var(--r-sm);
  --bs-border-radius-lg: var(--r-lg);

  /* The filled button is ink, not blue — the guide's words. Red is reserved:
     it is the brand AND it is stop, so nothing else in the system may be red. */
  --bs-primary:        var(--ink);
  --bs-danger:         var(--red);
  --bs-success:        var(--green);
  --bs-warning:        var(--amber);

  /* Small text needs 4.5:1 and the brand red is 3.83 against paper, so text
     uses the darkened pair and fills keep the brand colour. Measured by the
     theme's author, not adjusted here. */
  --bs-danger-text-emphasis:  var(--red-text);
  --bs-success-text-emphasis: var(--green-text);
  --bs-warning-text-emphasis: var(--amber-text);

  /* Sneat's cyan "info" and grey "secondary" have no equivalent in the ZAK
     palette — it has four meanings only (red, green, amber, gold). The merge
     guide's chart order is ink, red, green, amber, gold, muted, so info becomes
     gold and secondary becomes muted. This also fixes the charts, which read
     these tokens directly. */
  --bs-info:      var(--gold);

  /* --bs-secondary does double duty: Sneat fills with it AND inherits text from
     it, and one value cannot be both. --muted works as a fill (ink on it is
     4.51) but not as text (3.56 on card). The darkened value works as text
     (5.05) and as a fill if the label is paper rather than ink (4.84). So:
     darkened here, and the fills below flip their text to paper. */
  --bs-secondary: var(--zak-muted-text);

  /* Bootstrap's inline <code> is #e83e8c pink. There is no pink in this palette,
     and code on these screens is route names in a permissions table. */
  --bs-code-color: var(--red-text);

  /* --------------------------------------------------------------------
     Bootstrap's .bg-*, .text-bg-* and .border-* utilities do NOT read the hex
     tokens above — they read RGBA(var(--bs-success-rgb), …). Mapping only the
     hex leaves every `.bg-success` / `.badge.bg-secondary` on Sneat's palette,
     which is why the dashboard looked done and the events list did not: the
     dashboard used .bg-label-* (handled below) and never a plain .bg-*.
     Triplets, therefore, alongside every hex.
     -------------------------------------------------------------------- */
  --bs-primary-rgb:   22, 24, 28;      /* ink   #16181c */
  --bs-danger-rgb:   225, 37, 27;      /* red   #e1251b */
  --bs-success-rgb:   31, 138, 91;     /* green #1f8a5b */
  --bs-warning-rgb:  169, 121, 31;     /* amber #a9791f */
  --bs-info-rgb:     217, 164, 65;     /* gold  #d9a441 */
  /* Must track --bs-secondary above, which is the DARKENED muted. Left on the
     lighter #8a7f6b these disagreed, and anything reading the triplet — Sneat's
     .btn-text-secondary, for one — still rendered 3.56 text while the hex said
     otherwise. A token and its own rgb form are one value in two notations. */
  --bs-secondary-rgb: 111, 103, 87;    /* zak-muted-text #6f6757 */
  --bs-body-color-rgb: 22, 24, 28;
  --bs-body-bg-rgb:  236, 232, 221;    /* paper #ece8dd */

  /* Sneat paints the page shell from its own --bs-paper-bg, not --bs-body-bg. */
  --bs-paper-bg: var(--paper);

  /* Sneat's form-control token. Quill reads it for the editor chrome, and so do
     the inputs — found by tracing quill's own border rule rather than guessed. */
  --bs-input-border-color: var(--line);

  /* Bootstrap 5.3's subtle families. Widely read by things that never mention a
     colour directly — flatpickr's "today" is `var(--bs-primary-bg-subtle)`, and
     unmapped it stayed a purple wash behind a gold border. This is the third
     time the answer was "map the token", not "write a longer selector": a rule
     at (0,4,0) beats any reasonable scoped override, and should. */
  --bs-primary-bg-subtle:   var(--line2);
  --bs-secondary-bg-subtle: var(--line2);
  --bs-success-bg-subtle:   rgba(31, 138, 91, .12);
  --bs-danger-bg-subtle:    rgba(225, 37, 27, .12);
  --bs-warning-bg-subtle:   rgba(169, 121, 31, .14);
  --bs-info-bg-subtle:      rgba(217, 164, 65, .16);

  --bs-primary-border-subtle:   var(--line);
  --bs-secondary-border-subtle: var(--line);
  --bs-success-border-subtle:   rgba(31, 138, 91, .35);
  --bs-danger-border-subtle:    rgba(225, 37, 27, .35);
  --bs-warning-border-subtle:   rgba(169, 121, 31, .35);
  --bs-info-border-subtle:      rgba(217, 164, 65, .45);

  --bs-primary-text-emphasis:   var(--ink);
  --bs-secondary-text-emphasis: var(--zak-muted-text);
  --bs-info-text-emphasis:      var(--zak-gold-text);

  /* .text-bg-* picks the text colour from --bs-*-contrast. Against ink, amber
     and green the readable answer is paper, not white — no pure white. */
  --bs-primary-contrast:   var(--on-bar);
  --bs-success-contrast:   var(--on-bar);
  --bs-danger-contrast:    var(--on-bar);
  --bs-warning-contrast:   var(--ink);
  --bs-info-contrast:      var(--ink);
  --bs-secondary-contrast: var(--on-bar);

  /* The kit ships darkened pairs for red/green/amber/gold because the brand
     values fail small text — but not for muted, and --bs-secondary-color is the
     token behind every .text-body-secondary on the page. Measured on both
     surfaces this theme actually uses:

         muted    #8a7f6b   card 3.56   paper 3.22   FAIL
         darkened #6f6757   card 5.05   paper 4.57   ok

     So the bridge defines the missing pair rather than shipping 3.5:1 body
     text. Worth handing back to the theme's author as --muted-text. */
  --zak-muted-text: #6f6757;

  /* The kit's --gold-text does not meet its own promise. Measured on both
     surfaces this theme uses:

         --gold-text  #a37b31   paper 3.16   card 3.49   FAIL
         darkened     #80611b   paper 4.71   card 5.20   ok

     The other three darkened values do hold — green 4.64, red 4.69, amber 4.72
     on paper — so gold is the outlier, not the rule. Also worth handing back. */
  --zak-gold-text: #80611b;

  --bs-secondary-color: var(--zak-muted-text);
  --bs-heading-color:   var(--ink);
  --bs-link-color:      var(--ink);
  --bs-link-hover-color: var(--red-text);
  --bs-link-color-rgb:  22, 24, 28;

  /* Sneat styles `a` from its own --bs-custom-link-color, not --bs-link-color.
     Left unmapped it kept 205 elements on Sneat purple — mostly invisible
     (anchors with no text, images whose border defaults to currentColor), but
     it is the token every real link reads too. */
  --bs-custom-link-color: var(--ink);

  background-color: var(--paper);
  color: var(--ink);
}

/* ------------------------------------------------------------
   2. SURFACES
   Cards sit on paper2, paper2 sits on paper — three depths, carried by rules
   rather than by shadow ("this is paper, not glass").
   ------------------------------------------------------------ */
.zak-theme .card,
.zak-theme .modal-content,
.zak-theme .dropdown-menu,
.zak-theme .offcanvas {
  background-color: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.zak-theme .card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--line2);
}

.zak-theme .table { --bs-table-bg: transparent; --bs-table-color: var(--ink); }
.zak-theme .table > :not(caption) > * > * { border-bottom-color: var(--line2); }
.zak-theme .table > thead th {
  /* --muted measures 3.56 on these surfaces. This shipped in the first commit and
     was only caught once the sweep covered a screen with a plain <table>. */
  color: var(--zak-muted-text);
  font-size: var(--size-xs);
  letter-spacing: var(--track);
  text-transform: uppercase;
  border-bottom-color: var(--line);
}

/* ------------------------------------------------------------
   3. CONTROLS
   ------------------------------------------------------------ */
.zak-theme .btn-primary {
  --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink); --bs-btn-color: var(--on-bar);
  --bs-btn-hover-bg: #000; --bs-btn-hover-border-color: #000; --bs-btn-hover-color: var(--on-bar);
}
.zak-theme .btn-danger {
  --bs-btn-bg: transparent; --bs-btn-color: var(--red-text); --bs-btn-border-color: var(--red);
  --bs-btn-hover-bg: var(--red); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--red);
}
/* Solid buttons are the badge problem again: small text on a brand fill.
   .btn-success measured 3.75 with paper text, so the fills take the darkened
   values for the same reason — see the table in 3b. */
.zak-theme .btn-success {
  --bs-btn-bg: var(--green-text); --bs-btn-border-color: var(--green-text); --bs-btn-color: var(--on-bar);
  --bs-btn-hover-bg: #14603e; --bs-btn-hover-border-color: #14603e; --bs-btn-hover-color: var(--on-bar);
}
.zak-theme .btn-warning {
  --bs-btn-bg: var(--amber-text); --bs-btn-border-color: var(--amber-text); --bs-btn-color: var(--on-bar);
  --bs-btn-hover-bg: #6b4d13; --bs-btn-hover-border-color: #6b4d13; --bs-btn-hover-color: var(--on-bar);
}
.zak-theme .btn-secondary {
  --bs-btn-bg: var(--zak-muted-text); --bs-btn-border-color: var(--zak-muted-text); --bs-btn-color: var(--on-bar);
  --bs-btn-hover-bg: #5d5648; --bs-btn-hover-border-color: #5d5648; --bs-btn-hover-color: var(--on-bar);
}
.zak-theme .btn-info {
  --bs-btn-bg: var(--gold); --bs-btn-border-color: var(--gold); --bs-btn-color: var(--ink);
  --bs-btn-hover-bg: #c08f33; --bs-btn-hover-border-color: #c08f33; --bs-btn-hover-color: var(--ink);
}

/* Sneat's soft buttons, the sibling of .bg-label-*. Missed on the first two
   screens because neither used one; the Cancel button here measured 2.75. */
.zak-theme .btn-label-secondary,
.zak-theme .btn-label-primary {
  --bs-btn-bg: var(--line2); --bs-btn-color: var(--ink); --bs-btn-border-color: transparent;
  --bs-btn-hover-bg: var(--line); --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: transparent;
}
.zak-theme .btn-label-success { --bs-btn-bg: var(--card); --bs-btn-color: var(--green-text); --bs-btn-border-color: rgba(31,138,91,.45); }
.zak-theme .btn-label-danger  { --bs-btn-bg: var(--card); --bs-btn-color: var(--red-text); --bs-btn-border-color: rgba(225,37,27,.45); }
.zak-theme .btn-label-warning { --bs-btn-bg: var(--card); --bs-btn-color: var(--amber-text); --bs-btn-border-color: rgba(169,121,31,.45); }
.zak-theme .btn-label-info    { --bs-btn-bg: var(--card); --bs-btn-color: var(--zak-gold-text); --bs-btn-border-color: rgba(217,164,65,.5); }

.zak-theme .form-control,
.zak-theme .form-select {
  background-color: var(--paper2);
  border-color: var(--line);
  color: var(--ink);
}
.zak-theme .form-control:focus,
.zak-theme .form-select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 .15rem rgba(22, 24, 28, .12);
}

/* Sneat's soft label badges carry their own near-white fills.

   The coloured three keep the darkened text on a light tint of their own colour.
   The tint has to be light enough to work on BOTH surfaces this theme uses: it
   was first tuned at .08 against the card (#f7f3ea) and measured 4.24 on paper
   (#ece8dd), which is the darker of the two. Tuned against paper instead, so
   the badge is safe wherever it lands.

   The last line is where Bootstrap has six meanings and this palette has four.
   "info" and "secondary" have no ZAK equivalent, and the obvious answer — muted
   text on the line2 fill — measures 2.81, so it is not an answer. They collapse
   to one quiet treatment instead: ink text, no fill, a rule around it. Told
   apart from the others by shape rather than by a colour that does not exist. */
/* Not badge-only: .avatar-initial, .btn and bare spans all take .bg-label-*, and
   Sneat pairs its tint with the FULL brand colour as text — red on pink, 2.75.
   The selectors below therefore match any element, with .badge kept first purely
   so the intent reads. */
.zak-theme .bg-label-primary { background-color: var(--line2) !important; color: var(--ink) !important; }
.zak-theme .bg-label-success { background-color: var(--card) !important; color: var(--green-text) !important; box-shadow: inset 0 0 0 1px rgba(31,138,91,.45); }
.zak-theme .bg-label-danger  { background-color: var(--card) !important; color: var(--red-text) !important;   box-shadow: inset 0 0 0 1px rgba(225,37,27,.45); }
.zak-theme .bg-label-warning { background-color: var(--card) !important; color: var(--amber-text) !important; box-shadow: inset 0 0 0 1px rgba(169,121,31,.45); }
.zak-theme .bg-label-info,
.zak-theme .bg-label-secondary { background-color: var(--card) !important; color: var(--ink) !important; box-shadow: inset 0 0 0 1px var(--line); }

.zak-theme .badge.bg-label-primary { background-color: var(--line2) !important; color: var(--ink) !important; }
.zak-theme .badge.bg-label-success,
.zak-theme .badge.bg-label-danger,
.zak-theme .badge.bg-label-warning {
  /* Neutral fill, coloured ring. A tint of the SAME hue as the text moves the
     background toward the foreground and costs contrast — green-text is 4.64 on
     bare paper and only 4.39 on a 5% green wash of it. The card surface is
     lighter than paper, so it raises contrast instead: 5.13. The meaning is
     carried by the ring and the text colour, which is enough. */
  background-color: var(--card) !important;
}
.zak-theme .badge.bg-label-success { color: var(--green-text) !important; box-shadow: inset 0 0 0 1px rgba(31,138,91,.45); }
.zak-theme .badge.bg-label-danger  { color: var(--red-text) !important;   box-shadow: inset 0 0 0 1px rgba(225,37,27,.45); }
.zak-theme .badge.bg-label-warning { color: var(--amber-text) !important; box-shadow: inset 0 0 0 1px rgba(169,121,31,.45); }
.zak-theme .badge.bg-label-info,
.zak-theme .badge.bg-label-secondary {
  /* A real surface, not transparent. Transparent measured 16:1 on a card and
     1.0:1 on the dark date strip these also sit on — a badge cannot inherit the
     thing behind it and still promise contrast. */
  background-color: var(--card) !important;
  color: var(--ink) !important;
  box-shadow: inset 0 0 0 1px var(--line);
}

.zak-theme .progress { background-color: var(--line2); }

/* ------------------------------------------------------------
   3b. SOLID BADGES, MEASURED
   A .badge is small text on a filled surface, so it needs 4.5:1 — and the brand
   colours do not reach it. Measured in the browser against this theme's own
   tokens rather than estimated:

       on-bar on green        3.75   FAIL      on-bar on green-text   4.91  ok
       on-bar on red          4.05   FAIL      on-bar on red-text     4.96  ok
       on-bar on amber        3.34   FAIL      on-bar on amber-text   5.00  ok
       on-bar on muted        3.41   FAIL      INK    on muted        4.51  ok
                                               ink    on gold         7.90  ok

   Which is exactly what the theme says about itself: fills keep the brand
   colour, text uses the darkened pair. A badge is both at once, so it takes the
   darkened value as its FILL and pays for it in saturation, not legibility.

   Sneat also hardcodes #fff on these, which is the no-pure-white rule broken as
   well as the contrast one — hence the explicit colour on every line.
   ------------------------------------------------------------ */
/* Sneat sets color:#fff on .badge itself — rule 1 of this theme is no pure
   white, so it becomes paper.

   Wrapped in :where() so it weighs (0,1,0) and loses to any page-level rule
   like `.badge.ev-count-attendee` at (0,2,0). The first attempt was a plain
   `.zak-theme .badge` at (0,2,0), which — because the bridge loads after
   @yield('page-style') — silently out-ranked classes a screen had deliberately
   set and repainted their text. A theme must not win arguments it was not
   having. */
:where(.zak-theme) .badge { color: var(--on-bar); }

.zak-theme .badge.bg-success   { background-color: var(--green-text) !important; color: var(--on-bar) !important; }
.zak-theme .badge.bg-danger    { background-color: var(--red-text)   !important; color: var(--on-bar) !important; }
.zak-theme .badge.bg-warning   { background-color: var(--amber-text) !important; color: var(--on-bar) !important; }
.zak-theme .badge.bg-primary,
.zak-theme .badge.bg-dark      { background-color: var(--ink)        !important; color: var(--on-bar) !important; }
.zak-theme .badge.bg-secondary { background-color: var(--zak-muted-text) !important; color: var(--on-bar) !important; }
.zak-theme .badge.bg-info      { background-color: var(--gold)       !important; color: var(--ink)    !important; }

/* ------------------------------------------------------------
   4. THE WHITE LEAK  (MERGE-GUIDE.md §2 step 4, first item)
   Pure white arrives from places that do not read tokens: the page shell, the
   content wrapper, alerts, and any widget that hardcodes #fff. Named here
   rather than chased one at a time.
   ------------------------------------------------------------ */
.zak-theme .content-wrapper,
.zak-theme .container-xxl,
.zak-theme .layout-page,
.zak-theme .alert { background-color: transparent; }

.zak-theme .alert { border: 1px solid var(--line); }

/* Sneat colours alert text with the FULL brand value rather than the darkened
   one, which is 3.48 for the amber case. Same rule as everywhere else in this
   file: fills keep the brand colour, text uses the darkened pair. */
.zak-theme .alert-warning { color: var(--amber-text); border-color: rgba(169,121,31,.45); }
.zak-theme .alert-danger  { color: var(--red-text);   border-color: rgba(225,37,27,.45); }
.zak-theme .alert-success { color: var(--green-text); border-color: rgba(31,138,91,.45); }
.zak-theme .alert-info    { color: var(--zak-gold-text); border-color: rgba(217,164,65,.5); }
.zak-theme .alert-primary,
.zak-theme .alert-secondary { color: var(--ink); border-color: var(--line); }

/* The chat empty state is a hardcoded Sneat grey, 2.3 on paper. */
.zak-theme .chat-empty,
.zak-theme .chat-empty * { color: var(--zak-muted-text); }

/* ------------------------------------------------------------
   4b. THE SHELL
   The navbar and the sidebar are painted by Sneat's own bg-navbar-theme /
   menu classes, which hardcode white rather than reading a token. They sit
   inside .zak-theme but do not inherit from it, so they are named here — this
   is the "pure white leaks in" item again, at page-shell scale.
   ------------------------------------------------------------ */
.zak-theme .layout-navbar.bg-navbar-theme,
.zak-theme .layout-menu,
.zak-theme .menu-vertical,
.zak-theme .bg-menu-theme {
  background-color: var(--card) !important;
  border-color: var(--line);
}
.zak-theme .layout-navbar.navbar-detached { box-shadow: var(--shadow); }

/* The menu is driven entirely by --bs-menu-* tokens, so it is mapped rather
   than overridden. The first attempt wrote `.zak-theme .menu-inner
   .menu-item.active > .menu-link` and lost anyway: Sneat's own rule is
   `.menu-vertical .menu-inner > .menu-item.active > .menu-link:not(.menu-toggle)`
   at higher specificity, reading var(--bs-menu-active-bg). Mapping the token
   wins without a specificity war and is what the merge guide asks for —
   "map the tokens the existing framework already uses". */

/* Sneat's menu grey was chosen against white and measures 3.26 on paper, which
   is the whole sidebar failing AA. Ink for the links; the section headers stay
   quieter through opacity rather than a lighter grey, so they composite to
   something still readable rather than to 3.5:1. */
.zak-theme {
  --bs-menu-color:        var(--ink);
  --bs-menu-hover-color:  var(--ink);
  --bs-menu-hover-bg:     var(--line2);
  --bs-menu-active-color: var(--on-bar);
  /* The open submenu parent reads its own token — .menu-vertical
     .menu-item.active > .menu-toggle { color: var(--bs-menu-sub-active-color) }. */
  --bs-menu-sub-active-color: var(--ink);
  --bs-menu-active-bg:    var(--ink);
  --bs-menu-bg:           var(--card);
}
.zak-theme .menu-header,
.zak-theme .menu-header-text { color: var(--ink); opacity: .62; }
.zak-theme .menu-icon { color: currentColor; }

/* ------------------------------------------------------------
   6. THIRD-PARTY WIDGETS
   The merge guide's third warning: "Third party widgets do not read your
   tokens… list them before starting rather than discovering them one at a
   time." docs/ZAK-THEME.md holds that list; this is where they get handled.

   All of these portal their markup onto <body>, and .zak-theme is ON the body,
   so the scoping still holds — a widget opened from an unconverted screen is
   untouched.
   ------------------------------------------------------------ */

/* --- DataTables (28 screens, the big one) -------------------------------- */
.zak-theme .dataTables_wrapper .dataTables_length select,
.zak-theme .dataTables_wrapper .dataTables_filter input,
.zak-theme div.dt-container .dt-input,
.zak-theme div.dt-container .dt-search input {
  background-color: var(--paper2);
  border-color: var(--line);
  color: var(--ink);
}
.zak-theme .dataTables_wrapper .dataTables_info,
.zak-theme .dataTables_wrapper .dataTables_length,
.zak-theme .dataTables_wrapper .dataTables_filter,
.zak-theme div.dt-container .dt-info { color: var(--zak-muted-text); }

.zak-theme table.dataTable { border-color: var(--line2); }
.zak-theme table.dataTable > thead > tr > th {
  border-bottom-color: var(--line);
  color: var(--zak-muted-text);
}
.zak-theme table.dataTable.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-accent-bg: var(--paper2);
  box-shadow: inset 0 0 0 9999px var(--paper2);
}
.zak-theme table.dataTable > tbody > tr:hover > * {
  box-shadow: inset 0 0 0 9999px var(--line2);
}

/* Pagination runs through Bootstrap's .page-link, so it follows --bs-* — except
   the active page, which Sneat fills with its own primary. */
.zak-theme .pagination .page-link { color: var(--ink); background-color: transparent; border-color: var(--line); }
.zak-theme .pagination .page-item.active .page-link {
  background-color: var(--ink); border-color: var(--ink); color: var(--on-bar);
}
.zak-theme .pagination .page-item.disabled .page-link { color: var(--zak-muted-text); }
.zak-theme .pagination .page-link:hover { background-color: var(--line2); color: var(--ink); }

/* The responsive extension's expand control and child rows. */
.zak-theme table.dtr-column > tbody > tr > td.control:before,
.zak-theme table.dtr-inline.collapsed > tbody > tr > td:first-child:before {
  background-color: var(--ink); color: var(--on-bar); border-color: var(--ink);
}
.zak-theme table.dataTable > tbody > tr.child ul.dtr-details > li { border-bottom-color: var(--line2); }
.zak-theme .dtr-title { color: var(--zak-muted-text); }

/* --- bootstrap-select (6 screens) --------------------------------------- */
.zak-theme .bootstrap-select > .dropdown-toggle {
  background-color: var(--paper2); border-color: var(--line); color: var(--ink);
}
.zak-theme .bootstrap-select .dropdown-menu { background-color: var(--card); border-color: var(--line); }
.zak-theme .bootstrap-select .dropdown-item.active,
.zak-theme .bootstrap-select .dropdown-item:active { background-color: var(--ink); color: var(--on-bar); }

/* --- sweetalert2 (29 screens) ------------------------------------------- */
.zak-theme .swal2-popup {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.zak-theme .swal2-title { color: var(--ink); }
.zak-theme .swal2-html-container { color: var(--zak-muted-text); }
.zak-theme .swal2-actions { gap: var(--s2); }
.zak-theme .swal2-icon.swal2-success [class^='swal2-success-line'] { background-color: var(--green-text); }
.zak-theme .swal2-icon.swal2-success .swal2-success-ring { border-color: rgba(31, 138, 91, .3); }
.zak-theme .swal2-icon.swal2-error { border-color: var(--red); color: var(--red-text); }
.zak-theme .swal2-icon.swal2-warning { border-color: var(--amber); color: var(--amber-text); }
.zak-theme .swal2-icon.swal2-question,
.zak-theme .swal2-icon.swal2-info { border-color: var(--gold); color: var(--zak-gold-text); }

/* --- select2 (29 screens) ----------------------------------------------- */
.zak-theme .select2-container--default .select2-selection--single,
.zak-theme .select2-container--default .select2-selection--multiple {
  background-color: var(--paper2);
  border-color: var(--line);
  color: var(--ink);
}
.zak-theme .select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--ink); }
.zak-theme .select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--zak-muted-text); }
.zak-theme .select2-dropdown {
  background-color: var(--card);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.zak-theme .select2-container--default .select2-results__option { color: var(--ink); }
.zak-theme .select2-container--default .select2-results__option--highlighted[aria-selected],
.zak-theme .select2-container--default .select2-results__option--highlighted[data-selected] {
  background-color: var(--ink);
  color: var(--on-bar);
}
.zak-theme .select2-container--default .select2-results__option[aria-selected='true'],
.zak-theme .select2-container--default .select2-results__option[data-selected='true'] {
  background-color: var(--line2);
  color: var(--ink);
}
.zak-theme .select2-container--default .select2-search--dropdown .select2-search__field {
  background-color: var(--paper2);
  border-color: var(--line);
  color: var(--ink);
}
.zak-theme .select2-container--default .select2-selection--multiple .select2-selection__choice {
  background-color: var(--line2);
  border-color: var(--line);
  color: var(--ink);
}

/* --- flatpickr (12 screens) --------------------------------------------- */
.zak-theme .flatpickr-calendar {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.zak-theme .flatpickr-calendar.arrowTop:before,
.zak-theme .flatpickr-calendar.arrowTop:after { border-bottom-color: var(--card); }
.zak-theme .flatpickr-months .flatpickr-month,
.zak-theme .flatpickr-current-month,
.zak-theme .flatpickr-weekday { color: var(--ink); fill: var(--ink); }
.zak-theme .flatpickr-weekday { color: var(--zak-muted-text); }
.zak-theme .flatpickr-day { color: var(--ink); }
/* Adjacent-month days are meant to recede, not to disappear. The muted text
   token alone measures 5.05 on the calendar surface; the .55 opacity that was
   here as well took it to 2.1. Recede by colour, not by opacity. */
.zak-theme .flatpickr-day.prevMonthDay,
.zak-theme .flatpickr-day.nextMonthDay { color: var(--zak-muted-text); opacity: 1; }
.zak-theme .flatpickr-day.flatpickr-disabled { color: var(--zak-muted-text); opacity: .6; }
.zak-theme .flatpickr-day:hover { background: var(--line2); border-color: var(--line2); }
/* Sneat tints "today" with a 10% primary wash that is still purple — setting
   only the border left rgba(105,108,255,.1) sitting behind it. */
.zak-theme .flatpickr-day.today {
  /* background now arrives through --bs-primary-bg-subtle, mapped above */
  border-color: var(--gold);
  color: var(--ink);
}
.zak-theme .flatpickr-day.today:hover { background: rgba(217, 164, 65, .28); }
.zak-theme .flatpickr-day.selected,
.zak-theme .flatpickr-day.selected:hover,
.zak-theme .flatpickr-day.startRange,
.zak-theme .flatpickr-day.endRange {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-bar);
}
.zak-theme .flatpickr-day.inRange { background: var(--line2); border-color: var(--line2); box-shadow: none; }

/* --- jquery-timepicker (4 screens) -------------------------------------- */
.zak-theme .ui-timepicker-wrapper {
  background: var(--card);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.zak-theme .ui-timepicker-list li { color: var(--ink); }
.zak-theme .ui-timepicker-list li.ui-timepicker-selected,
.zak-theme .ui-timepicker-list li:hover { background: var(--ink); color: var(--on-bar); }

/* --- pickr, the colour picker (8 screens) ------------------------------- */
.zak-theme .pcr-app {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.zak-theme .pcr-app .pcr-interaction .pcr-result {
  background: var(--paper2);
  border: 1px solid var(--line);
  color: var(--ink);
}
.zak-theme .pcr-app .pcr-interaction .pcr-save { background: var(--ink); color: var(--on-bar); }

/* --- datatables-buttons (6 screens: 4 check-in desks + the user list) ---- */
.zak-theme .dt-buttons .btn,
.zak-theme .dt-buttons .dt-button {
  background-color: var(--card);
  border-color: var(--line);
  color: var(--ink);
}
.zak-theme .dt-buttons .btn:hover,
.zak-theme .dt-buttons .dt-button:hover { background-color: var(--line2); border-color: var(--line); color: var(--ink); }
.zak-theme .dt-button-collection {
  background-color: var(--card);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.zak-theme .dt-button-collection .dt-button { background-color: transparent; border-color: transparent; }
.zak-theme .dt-button-collection .dt-button.active,
.zak-theme .dt-button-collection .dt-button:hover { background-color: var(--ink); color: var(--on-bar); }

/* --- typeahead-js (organizer create/edit) ------------------------------- */
.zak-theme .tt-menu {
  background-color: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--r);
}
.zak-theme .tt-suggestion { color: var(--ink); }
.zak-theme .tt-suggestion:hover,
.zak-theme .tt-suggestion.tt-cursor { background-color: var(--ink); color: var(--on-bar); }
/* The match inside a suggestion. Bold rather than a second colour — on the
   highlighted row the background is ink, and a coloured match on ink would need
   its own contrast answer for every hue. */
/* (0,3,0) so it beats typeahead's own .tt-highlight{font-weight:500}, which a
   plain .zak-theme .tt-highlight tied with and lost on source order. */
.zak-theme .tt-suggestion .tt-highlight,
.zak-theme .tt-menu .tt-highlight { color: inherit; font-weight: 700; }
.zak-theme .tt-hint { color: var(--zak-muted-text); }

/* --- quill (ap/email, ap/calendar) -------------------------------------- */
.zak-theme .ql-toolbar.ql-snow,
.zak-theme .ql-container.ql-snow { border-color: var(--line); }
.zak-theme .ql-toolbar.ql-snow { background-color: var(--paper2); }
.zak-theme .ql-container.ql-snow { background-color: var(--card); }
.zak-theme .ql-editor { color: var(--ink); }
.zak-theme .ql-editor.ql-blank::before { color: var(--zak-muted-text); font-style: normal; }
/* Quill draws its icons as SVG strokes and fills, which do not read text colour. */
.zak-theme .ql-snow .ql-stroke { stroke: var(--ink); }
.zak-theme .ql-snow .ql-fill,
.zak-theme .ql-snow .ql-stroke.ql-fill { fill: var(--ink); }
.zak-theme .ql-snow .ql-picker { color: var(--ink); }
.zak-theme .ql-snow .ql-picker-options {
  background-color: var(--card);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.zak-theme .ql-snow.ql-toolbar button:hover .ql-stroke,
.zak-theme .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--red-text); }
.zak-theme .ql-snow.ql-toolbar button:hover .ql-fill,
.zak-theme .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--red-text); }

/* --- notyf toasts (11 screens) ------------------------------------------ */
.zak-theme .notyf__toast { border-radius: var(--r); box-shadow: var(--shadow); }
.zak-theme .notyf__toast--success .notyf__ribbon,
.zak-theme .notyf__toast--success { background-color: var(--green-text); color: var(--on-bar); }
.zak-theme .notyf__toast--error .notyf__ribbon,
.zak-theme .notyf__toast--error { background-color: var(--red-text); color: var(--on-bar); }

/* --- spinkit + block-ui (12 / 14 screens) ------------------------------- */
.zak-theme .sk-wave .sk-rect,
.zak-theme .sk-rect { background-color: var(--ink); }
.zak-theme .blockUI.blockOverlay { background-color: var(--ink) !important; }
.zak-theme .blockUI.blockMsg { color: var(--on-bar); }

/* ------------------------------------------------------------
   5. DARK MODE STANDS DOWN
   Everything above is undone when the user has chosen dark, so Sneat's own
   palette runs unchallenged. See rule 2 in the header.
   ------------------------------------------------------------ */
[data-bs-theme="dark"] .zak-theme {
  --bs-input-border-color: initial; --bs-code-color: initial;
  --bs-primary-bg-subtle: initial; --bs-secondary-bg-subtle: initial;
  --bs-success-bg-subtle: initial; --bs-danger-bg-subtle: initial;
  --bs-warning-bg-subtle: initial; --bs-info-bg-subtle: initial;
  --bs-primary-border-subtle: initial; --bs-secondary-border-subtle: initial;
  --bs-success-border-subtle: initial; --bs-danger-border-subtle: initial;
  --bs-warning-border-subtle: initial; --bs-info-border-subtle: initial;
  --bs-primary-text-emphasis: initial; --bs-secondary-text-emphasis: initial;
  --bs-info-text-emphasis: initial;
  --bs-menu-color: initial; --bs-menu-hover-color: initial; --bs-menu-hover-bg: initial;
  --bs-menu-sub-active-color: initial;
  --bs-menu-active-color: initial; --bs-menu-active-bg: initial; --bs-menu-bg: initial;
  --bs-secondary-color: initial; --bs-custom-link-color: initial; --bs-link-color-rgb: initial;
  --bs-body-bg: initial; --bs-body-color: initial;
  --bs-secondary-bg: initial; --bs-tertiary-bg: initial;
  --bs-border-color: initial; --bs-primary: initial;
  --bs-info: initial; --bs-secondary: initial;
  --bs-primary-rgb: initial; --bs-danger-rgb: initial; --bs-success-rgb: initial;
  --bs-warning-rgb: initial; --bs-info-rgb: initial; --bs-secondary-rgb: initial;
  --bs-body-color-rgb: initial; --bs-body-bg-rgb: initial; --bs-paper-bg: initial;
  --bs-primary-contrast: initial; --bs-success-contrast: initial; --bs-danger-contrast: initial;
  --bs-warning-contrast: initial; --bs-info-contrast: initial; --bs-secondary-contrast: initial;
  --bs-heading-color: initial; --bs-link-color: initial;
  background-color: initial; color: initial;
}
[data-bs-theme="dark"] .zak-theme .card,
[data-bs-theme="dark"] .zak-theme .modal-content,
[data-bs-theme="dark"] .zak-theme .dropdown-menu,
[data-bs-theme="dark"] .zak-theme .offcanvas,
[data-bs-theme="dark"] .zak-theme .card-header,
[data-bs-theme="dark"] .zak-theme .form-control,
[data-bs-theme="dark"] .zak-theme .tt-menu,
[data-bs-theme="dark"] .zak-theme .tt-suggestion,
[data-bs-theme="dark"] .zak-theme .dt-buttons .btn,
[data-bs-theme="dark"] .zak-theme .dt-button-collection,
[data-bs-theme="dark"] .zak-theme .ql-toolbar.ql-snow,
[data-bs-theme="dark"] .zak-theme .ql-container.ql-snow,
[data-bs-theme="dark"] .zak-theme .ql-editor,
[data-bs-theme="dark"] .zak-theme .btn-label-secondary,
[data-bs-theme="dark"] .zak-theme .btn-label-primary,
[data-bs-theme="dark"] .zak-theme .btn-label-success,
[data-bs-theme="dark"] .zak-theme .btn-label-danger,
[data-bs-theme="dark"] .zak-theme .btn-label-warning,
[data-bs-theme="dark"] .zak-theme .btn-label-info,
[data-bs-theme="dark"] .zak-theme .btn-success,
[data-bs-theme="dark"] .zak-theme .btn-warning,
[data-bs-theme="dark"] .zak-theme .btn-secondary,
[data-bs-theme="dark"] .zak-theme .btn-info,
[data-bs-theme="dark"] .zak-theme .badge.bg-success,
[data-bs-theme="dark"] .zak-theme .badge.bg-danger,
[data-bs-theme="dark"] .zak-theme .badge.bg-warning,
[data-bs-theme="dark"] .zak-theme .badge.bg-primary,
[data-bs-theme="dark"] .zak-theme .badge.bg-dark,
[data-bs-theme="dark"] .zak-theme .badge.bg-secondary,
[data-bs-theme="dark"] .zak-theme .badge.bg-info,
[data-bs-theme="dark"] .zak-theme .alert-warning,
[data-bs-theme="dark"] .zak-theme .alert-danger,
[data-bs-theme="dark"] .zak-theme .alert-success,
[data-bs-theme="dark"] .zak-theme .alert-info,
[data-bs-theme="dark"] .zak-theme .alert-primary,
[data-bs-theme="dark"] .zak-theme .alert-secondary,
[data-bs-theme="dark"] .zak-theme .chat-empty,
[data-bs-theme="dark"] .zak-theme .form-select,
[data-bs-theme="dark"] .zak-theme .menu-link,
[data-bs-theme="dark"] .zak-theme .menu-header,
[data-bs-theme="dark"] .zak-theme .menu-header-text,
[data-bs-theme="dark"] .zak-theme .layout-navbar.bg-navbar-theme,
[data-bs-theme="dark"] .zak-theme .layout-menu,
[data-bs-theme="dark"] .zak-theme .menu-vertical,
[data-bs-theme="dark"] .zak-theme .bg-menu-theme {
  background: initial; background-color: initial; border-color: initial;
  box-shadow: none; color: initial; opacity: initial;
}
