/* ==========================================================================
   Dasa App — shared app-shell & auth-shell on top of DASA UI. Built
   entirely from DASA UI's own custom properties (see
   https://ui.dasa.my.id/v1/tokens.css) so light/dark theming keeps working
   without duplicating any color decision here. Domain-specific styling
   (reimbursement workflow, cuti leave workflow) lives in reimbursement.css
   and cuti.css instead — this file is loaded on every page.
   ========================================================================== */

/* -- App shell: topbar + sidebar + content ------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  /* Dasa UI v2 memberi .app-shell align-items:start (untuk shell bawaannya);
     shell ini butuh sidebar yang meregang setinggi halaman. */
  align-items: stretch;
}

.app-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

/* -- Sidebar hamburger toggle (mobile/tablet only) ------------------------ */

.app-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  color: var(--color-text);
  cursor: pointer;
}

.app-sidebar-toggle:hover,
.app-sidebar-toggle:focus-visible {
  opacity: 0.7;
}

.app-sidebar-toggle svg {
  width: 22px;
  height: 22px;
}

.app-sidebar-backdrop {
  display: none;
}

.app-sidebar {
  grid-area: sidebar;
  background: var(--color-brand-ink);
  color: var(--dasa-slate-300, var(--color-text-secondary));
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-lg);
  color: var(--dasa-white, #fff);
  margin-bottom: var(--space-5);
}

.app-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* -- Sidebar collapse toggle (desktop/tablet — a persistent rail-collapse
   next to the brand, distinct from .app-sidebar-toggle above which is the
   mobile-only overlay drawer and only appears ≤900px). Collapsed state is
   an <html> class (not <body> — see the pre-paint restore script in
   layout/app.html's own <head>, which needs to run before <body> exists),
   persisted in localStorage so it survives a full page navigation (this is
   a server-rendered MPA, not a client-side router). ------------------- */

.app-sidebar-collapse-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.app-sidebar-collapse-toggle:hover,
.app-sidebar-collapse-toggle:focus-visible {
  opacity: 0.7;
}

.app-sidebar-collapse-toggle svg {
  width: 20px;
  height: 20px;
}

@media (min-width: 901px) {
  .app-sidebar-collapse-toggle {
    display: inline-flex;
  }

  html.sidebar-collapsed .app-shell {
    grid-template-columns: 64px 1fr;
  }

  html.sidebar-collapsed .app-sidebar {
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }

  html.sidebar-collapsed .app-sidebar__brand {
    justify-content: center;
  }

  html.sidebar-collapsed .app-sidebar__brand-label,
  html.sidebar-collapsed .app-sidebar__nav,
  html.sidebar-collapsed .app-sidebar__version {
    display: none;
  }
}

/* Pushed to the bottom of the sidebar's flex column (.app-sidebar itself is
   `display:flex; flex-direction:column`) by its own margin-top:auto — no
   flex-grow needed on .app-sidebar__nav above it, which would otherwise
   force it to fill height even when its own content is short. */
.app-sidebar__version {
  margin-top: auto;
  padding-top: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: color-mix(in srgb, currentColor 55%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: var(--font-weight-medium);
  font-size: var(--text-sm);
  color: inherit;
  text-decoration: none;
}

.app-sidebar__link:hover {
  background: color-mix(in srgb, var(--dasa-white, #fff) 10%, transparent);
  color: var(--dasa-white, #fff);
}

.app-sidebar__link--active {
  background: color-mix(in srgb, var(--color-brand-secondary) 25%, transparent);
  color: var(--dasa-white, #fff);
}

/* -- Sidebar nav groups (Finance/HRD/Superuser) — native <details>/<summary>,
   no JS needed for expand/collapse. -------------------------------------- */

.app-sidebar__group {
  margin: var(--space-2) 0 0;
}

.app-sidebar__group-summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dasa-slate-300, var(--color-text-secondary));
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.app-sidebar__group-summary::-webkit-details-marker {
  display: none;
}

.app-sidebar__group-summary::marker {
  content: "";
}

.app-sidebar__group-summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--duration-fast) var(--ease-standard);
  flex-shrink: 0;
  margin-left: auto;
}

.app-sidebar__group[open] > .app-sidebar__group-summary::after {
  transform: rotate(-135deg);
}

.app-sidebar__group-summary:hover {
  background: color-mix(in srgb, var(--dasa-white, #fff) 10%, transparent);
  color: var(--dasa-white, #fff);
}

.app-sidebar__group-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-left: var(--space-3);
  margin-top: var(--space-1);
}

/* -- Nested submenus (HRD > Cuti > Pengaturan, HRD > Karyawan) — same
   summary/items look as a top-level group, reused via the shared classes
   above; kept off the .app-sidebar__group selector on the <details> itself
   so app.js's top-level accordion exclusivity leaves these alone. --------- */

.app-sidebar__subgroup {
  margin: var(--space-1) 0 0;
}

.app-sidebar__subgroup[open] > .app-sidebar__group-summary::after {
  transform: rotate(-135deg);
}

.app-sidebar__subgroup .app-sidebar__group-summary {
  text-transform: none;
  letter-spacing: normal;
  font-weight: var(--font-weight-medium);
  font-size: var(--text-sm);
  color: inherit;
}

.app-main {
  grid-area: main;
  padding: var(--space-6);
  background: var(--color-bg);
  /* CSS Grid items default to min-width:auto, not 0 — without this, a wide
     child (a <table> inside .table-wrap, which DOES have overflow-x:auto)
     still forces this "1fr" grid track to grow past the viewport instead
     of letting the table scroll internally, blowing the whole page out
     sideways. Classic grid-blowout; reported by the user as a Lifecycle
     Template Gate table getting clipped at a narrower viewport width. */
  min-width: 0;
}

/* -- Page header (title + action button(s) row) — the single most-repeated
   layout idiom in this app (~45 pages), previously copy-pasted inline on
   every one of them as `style="display:flex;justify-content:space-between;
   align-items:center;..."` with no wrapping at all: on a narrow/portrait
   phone, a longer <h1> plus 1-2 .btn actions routinely don't fit on one
   line and the buttons get clipped off-screen instead of moving to their
   own line (reported on "Reimbursement Saya"'s list page). This class also
   now lives in dasa-design-system's own components.css (the CDN
   stylesheet this app loads `.btn`/`.card`/etc from) — kept here too so
   this app doesn't have to wait on that CDN bundle being republished. The
   trailing `> *:last-child` covers the equally-common case where that
   last child is itself a small `<div style="display:flex;gap:...">`
   wrapping 2+ buttons — it needs to wrap *within itself* too, and this
   works without touching that div's own markup. */
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

.page-header > *:last-child {
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    z-index: 850;
    transform: translateX(-100%);
    transition: transform var(--duration-base, 0.2s) var(--ease-standard, ease);
  }
  .app-sidebar-toggle {
    display: inline-flex;
  }
  body.sidebar-open .app-sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 800;
    background: rgba(0, 0, 0, 0.4);
  }
  body.sidebar-open .app-sidebar-backdrop {
    display: block;
  }

  /* Icon-only topbar dropdown triggers — the name label would overflow
     alongside the bell icon and hamburger toggle at this width. */
  .dropdown__trigger-label {
    display: none;
  }
}

/* -- Dashboard: which app a group of stat cards belongs to — the Finance/
   HRD dashboards blend more than one feature app's numbers on a single
   page (Reimburse + Payment under Finance; only Cuti under HRD today, but
   that's expected to grow the same way), so each group gets a small
   owning-app label above it rather than leaving the source ambiguous. --- */

.dashboard-source-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-2);
}

/* -- Dashboard stat cards (Finance/HRD) — DASA UI's own `.grid--3` drops
   to a single column below 600px, so on a phone this became 5-6 full-
   width cards stacked in a row, each mostly the big centered `.stat`
   whitespace around one number: "a lot of cards, very little info per
   screen" (reported on Dashboard Finance). Keep two columns and shrink
   each card down to a compact number+label row instead of a big centered
   block — same numbers, same click targets, far less scrolling. Desktop/
   tablet (>600px) are untouched, still the bigger centered card look. */
@media (max-width: 600px) {
  .dashboard-stat-grid.grid--3 {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }
  .dashboard-stat-grid .card {
    padding: var(--space-3);
  }
  .dashboard-stat-grid .stat {
    text-align: left;
  }
  .dashboard-stat-grid .stat__value {
    font-size: var(--text-lg);
    margin-bottom: var(--space-1);
  }
  .dashboard-stat-grid .stat__label {
    font-size: var(--text-xs);
  }
}

/* -- Auth shell (login / password reset) ---------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--color-bg);
}

.auth-shell__card {
  width: 100%;
  max-width: 380px;
}

.auth-shell__brand {
  text-align: center;
  margin-bottom: var(--space-5);
}

.auth-shell__brand h1 {
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-2xl);
  color: var(--color-heading);
  margin: 0;
}

.auth-shell__tagline {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: var(--space-1) 0 0;
}

.auth-shell__title {
  text-align: center;
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-xl);
  color: var(--color-heading);
  margin: 0 0 var(--space-4);
}

.auth-shell__field-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.auth-shell__field-row label {
  margin: 0;
}

.auth-shell__forgot-link {
  font-size: var(--text-xs);
  white-space: nowrap;
}

.auth-shell__identity {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.auth-shell__identity-value {
  color: var(--color-heading);
  font-weight: var(--font-weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-shell__divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
}

.auth-shell__divider::before,
.auth-shell__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* DASA UI's own .alert carries no bottom margin, and it's routinely
   followed immediately by something else with nothing in between — the
   django-messages block in layout/app.html sits right above {{ slot }},
   the auth shell's messages sit right above its form, and a status alert
   on a detail page (e.g. reimbursement_detail.html's "Disetujui" banner)
   sits right above the next <c-ui.card> — all cramped together whenever a
   message/alert is actually shown. Applied app-wide rather than scoped to
   one shell, since the gap is the same everywhere `<c-ui.alert>` is used
   inline on a page rather than as a modal/toast. */
.alert {
  margin-bottom: var(--space-4);
}

/* DASA UI's own .card carries no external margin either (border + padding
   + shadow only) — fine for a single card, but pages that stack several
   in a row with nothing but template whitespace between them (which
   collapses to zero in rendered HTML) end up with the cards touching, e.g.
   apps.workflows' version_detail.html rendering one <c-ui.card> per Phase
   in a loop. Uses the adjacent-sibling form (`.card + .card`), not a
   blanket margin-bottom like .alert above, so it only adds the gap
   *between* consecutive cards — never trailing space after the last card
   on a page, and never double-spacing when a heading or other element
   already sits between two cards with its own margin. */
.card + .card {
  margin-top: var(--space-4);
}

/* -- "Sign in with Google" button: Google's own brand guidelines call for a
   white/outlined button with its multi-color "G" mark, distinct from DASA
   UI's solid primary/secondary variants — background/border/text still come
   from DASA UI tokens, only the "G" mark itself uses Google's fixed colors. */

.btn--google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-heading);
}

.btn--google:hover {
  background: var(--color-surface-muted);
}

/* -- Danger button variant --------------------------------------------------- */
.btn--danger,
button.btn--danger,
a.btn--danger {
  background-color: var(--color-danger, #ef4444) !important;
  border-color: var(--color-danger, #ef4444) !important;
  color: #ffffff !important;
}

.btn--danger:hover,
button.btn--danger:hover,
a.btn--danger:hover,
.btn--danger:focus,
button.btn--danger:focus,
a.btn--danger:focus {
  background-color: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
}

/* -- Toast (HX-Trigger driven) ---------------------------------------------- */

.toast-stack {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-heading);
  color: var(--color-on-heading);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  animation: toast-in var(--duration-base) var(--ease-standard);
}
.toast--success { background: var(--color-success); color: var(--dasa-white, #fff); }
.toast--danger { background: var(--color-danger); color: var(--dasa-white, #fff); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* -- Modal overlay: DASA UI defines the look (.modal__overlay/.modal/...)
   but not fixed viewport positioning, since its own use case is an inline
   mockup, not a real dismissible overlay. DASA UI's own overlay also
   centers the modal with `align-items: center` and never constrains its
   height, so a form with enough fields (first hit: quality.UatScenarioForm,
   6 fields, Irisan 9) renders taller than the viewport with no way to
   reach the footer's Save button — nothing scrolls, since neither the
   overlay nor the modal box declares `overflow-y`. `flex-start` + its own
   scrollbar fixes that for every modal at once, not just this one. */

.modal__overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  align-items: flex-start;
  overflow-y: auto;
  padding: var(--space-8) var(--space-4);
}

/* -- Two-column field pairing for a long modal form (e.g. Provider AI) —
   a generic layout helper, not tied to any one form: wrap two
   <c-ui.field>s meant to sit side by side in a div with this class
   instead of stacking every field full-width, so a form with 8-10
   fields doesn't turn into one long scroll. Collapses back to a single
   column on narrow viewports, same breakpoint convention as this file's
   other mobile rules. ------------------------------------------------ */

.field-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--space-4);
  /* Same grid-blowout as .app-main above: a number input's intrinsic
     content width can keep a "1fr" track from actually shrinking to 50%,
     pushing the row past a modal's edge. */
}

.field-grid-2 > * {
  min-width: 0;
}

@media (max-width: 640px) {
  .field-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* -- Checkbox/radio fields: DASA UI's ".field input" rule styles every input
   like a text box (padding, border, radius) with no type discrimination —
   fine for text/email/etc., wrong for a checkbox. */

.field input[type="checkbox"],
.field input[type="radio"] {
  width: auto;
  padding: 0;
  border: none;
  box-shadow: none;
}

/* -- Standalone inputs without .field wrapper:
   DASA UI's styles.css normally only styles ".field input", leaving standalone inputs
   (such as search bars, chat boxes, inline filter controls) naked with raw browser styling.
   This safety fallback ensures any standard text-like input or .input element
   always renders with matching DASA UI skinning (padding, border, radius, focus ring). */
input[type="text"]:not([type="checkbox"]):not([type="radio"]),
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="tel"],
.input {
  font-family: inherit;
  font-size: var(--text-base);
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:not([type="checkbox"]):not([type="radio"]):focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

/* -- Button-styled <label> nested inside a .field (e.g. the "Ambil Foto"/
   "Upload Struk" hidden-file-input triggers on the reimbursement form):
   DASA UI's own `.field label` descendant selector (specificity 0,1,1)
   unintentionally repaints these navy, beating `.btn--cta`/
   `.btn--brand`'s own white-text rule (0,1,0) — .field's own shape only
   ever meant a label as a direct child, not one nested further down inside
   its content. Fixed at the source too (dasa-design-system's `.field label`
   -> `.field > label`) but kept here as well so this app isn't stuck showing
   the bug until that CDN bundle is republished. */
.field label.btn--cta,
.field label.btn--brand {
  color: var(--color-text-on-brand);
}

.field__checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

/* -- Tabs: DASA UI ships no tabs component, so this is bespoke. JS toggle
   in app.js (switchTab). ----------------------------------------------- */

.tabs__list {
  display: flex;
  gap: var(--space-5);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}

.tabs__tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: var(--space-3) 0;
  font: inherit;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.tabs__tab:hover {
  color: var(--color-heading);
}

.tabs__tab--active {
  color: var(--color-brand-primary);
  border-bottom-color: var(--color-brand-primary);
}

/* -- Form row: lays out a group of related <c-ui.field>s side by side instead
   of DASA UI's default one-field-per-line stack. ------------------------- */

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
}

/* -- Empty state ------------------------------------------------------------- */

.empty-state {
  /* Dasa UI v2 menjadikan .empty-state kotak flex berbingkai putus-putus; sel tabel
     (td.empty-state) harus tetap sel tabel biasa. */
  text-align: center;
  padding: var(--space-8) var(--space-5);
  color: var(--color-text-secondary);
}

.placeholder-panel {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  color: var(--color-text-secondary);
  background: var(--color-surface-muted);
}

td.empty-state,
th.empty-state {
  display: table-cell;
  border: 0;
  border-radius: 0;
}

/* -- Generic dropdown: DASA UI has no menu/popover component at all, so
   this is bespoke — shared by the topbar user menu and the notification
   menu. JS toggle in app.js (toggleDropdown). ---------------------------- */

.dropdown {
  position: relative;
  display: block; /* v2: .dropdown = inline-block; dropdown di sini selalu blok/flex-item */
}

.dropdown__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

.dropdown__trigger:hover {
  background: var(--color-surface-muted);
}

.dropdown__panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  min-width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-2);
  z-index: 950;
  /* A long menu (many actions per row, e.g. the Provider AI table's ⋮
     menu) opened near the top or bottom of the viewport can be taller
     than the space available on EITHER side — app.js's
     clampDropdownPanelToViewport only flips it to whichever side has
     MORE room, which doesn't guarantee it actually FITS there either.
     This is the real, unconditional guarantee: past this height, the
     panel scrolls internally instead of silently rendering items
     off-screen with no way to reach them. */
  max-height: calc(100vh - 2 * var(--space-4));
  overflow-y: auto;
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.dropdown__item:hover {
  background: var(--color-surface-muted);
}

.dropdown__divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-2) 0;
}

.dropdown__panel--wide {
  min-width: 260px;
}

.dropdown__panel-header {
  font-family: var(--font-body);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
  color: var(--color-heading);
  padding: var(--space-2) var(--space-3);
}

/* "Grup & Hak Akses"'s app picker reuses the generic themed combobox
   (.combobox-panel, further down this file) — no dedicated CSS needed
   here. */

/* DASA UI's own .table-wrap sets overflow-x: auto for wide tables, which
   clips a `.dropdown__panel` opened from inside a table cell (positioned
   absolutely below/above its trigger, contributing nothing to the wrap's
   own height, so it renders past the wrap's edge — exactly the kind of
   content that edge then clips). Most visible on the FIRST row: a tall
   menu (many actions, e.g. Provider AI's ⋮ menu) flips upward
   (clampDropdownPanelToViewport in app.js) when there's more room above
   the trigger than below, and the flipped-upward panel extends past the
   wrap's TOP edge — reported as the menu always being cut off specifically
   on the top row.

   First fix attempt here was `overflow-y: visible` alone (keeping
   `overflow-x: auto` for the table's own horizontal scroll) — that
   silently never worked either: per the CSS Overflow spec, if one axis
   is "visible" and the other isn't, the "visible" one computes to "auto"
   instead. Mixing overflow-x:auto with overflow-y:visible on the same
   box is NOT actually two independent axes — it still clips vertically.
   `overflow: visible` on both axes is the only way to genuinely stop
   clipping the dropdown; the trade-off is this table no longer gets its
   own horizontal scrollbar on a narrow viewport, which its column count
   doesn't need in practice (unlike a wider table sitewide, why this stays
   opt-in per table rather than changing `.table-wrap` globally). First
   attempt at scoping this per-table was `.ai-provider-table.table-wrap`
   (passing `class="ai-provider-table"` straight to <c-ui.table>) — that
   silently never worked either: templates/cotton/ui/table.html hardcodes
   `class="table-wrap"` on the div and appends passed-through attrs
   after it, so the rendered element ends up with two separate `class`
   attributes and the browser only keeps the FIRST ("table-wrap"),
   dropping "ai-provider-table" entirely — django-cotton does not merge
   `class` for you here. A plain wrapping element with a descendant
   selector sidesteps that: */
.ai-provider-table-wrap .table-wrap {
  overflow: visible;
}

/* -- Badges (generic component styling for <c-ui.badge>) -------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: var(--text-xs, 0.75rem);
  font-weight: var(--font-weight-semibold, 600);
  line-height: 1.25;
  border-radius: var(--radius-pill, 9999px);
  background: var(--color-surface-muted, #f1f5f9);
  color: var(--color-text-secondary, #475569);
  white-space: nowrap;
}

.badge--danger {
  background: color-mix(in srgb, var(--color-danger, #ef4444) 15%, transparent);
  color: var(--color-danger, #ef4444);
  border: 1px solid color-mix(in srgb, var(--color-danger, #ef4444) 30%, transparent);
}

.badge--success {
  background: color-mix(in srgb, var(--color-success, #22c55e) 15%, transparent);
  color: var(--color-success, #22c55e);
  border: 1px solid color-mix(in srgb, var(--color-success, #22c55e) 30%, transparent);
}

.badge--warning {
  background: color-mix(in srgb, var(--color-warning, #f59e0b) 15%, transparent);
  color: var(--color-warning, #d97706);
  border: 1px solid color-mix(in srgb, var(--color-warning, #f59e0b) 30%, transparent);
}

.badge--info {
  background: color-mix(in srgb, var(--color-info, #3b82f6) 15%, transparent);
  color: var(--color-info, #3b82f6);
  border: 1px solid color-mix(in srgb, var(--color-info, #3b82f6) 30%, transparent);
}

.badge--neutral {
  background: var(--color-surface-muted, #f1f5f9);
  color: var(--color-text-secondary, #475569);
  border: 1px solid var(--color-border, #e2e8f0);
}

/* -- Notification icon wrapper & counter badge on topbar (shared dropdown,
   merged reimbursement Notification + cuti LeaveNotification) ------------ */

.notification-icon-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notification-count-badge {
  position: absolute;
  top: -4px;
  right: -7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 3.5px;
  border-radius: var(--radius-pill, 9999px);
  background: var(--color-danger, #ef4444);
  color: #ffffff !important;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 0 0 1.5px var(--color-surface, #ffffff), 0 1px 2px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

[data-theme="dark"] .notification-count-badge {
  box-shadow: 0 0 0 1.5px var(--color-surface, #1e293b), 0 1px 2px rgba(0, 0, 0, 0.4);
}

.notification-unread-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  background: var(--color-danger, #ef4444);
  display: inline-block;
  margin-left: auto;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-danger, #ef4444) 20%, transparent);
}

.notification-item--unread {
  background-color: color-mix(in srgb, var(--color-brand-primary, #ff5722) 10%, transparent) !important;
  font-weight: 500;
}

.notification-item--unread:hover {
  background-color: color-mix(in srgb, var(--color-brand-primary, #ff5722) 18%, transparent) !important;
}

.theme-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.theme-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.theme-switch__track {
  position: absolute; inset: 0; background: var(--color-border);
  border-radius: var(--radius-pill); transition: background var(--duration-fast) var(--ease-standard);
}
.theme-switch__track::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 2px; top: 2px;
  background: var(--color-surface); border-radius: 50%; box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-standard);
}
.theme-switch input:checked ~ .theme-switch__track { background: var(--color-brand-secondary); }
.theme-switch input:checked ~ .theme-switch__track::before { transform: translateX(16px); }

/* -- Error pages (400/403/404/405/500/503/302 — see templates/*.html and
   templates/pages/errors/302.html) — ported from cuti's own app.css, the
   only one of the three merged apps that had custom error pages. --------- */

.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8) var(--space-4);
  max-width: 620px;
  margin: 0 auto;
}

.error-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 12px;
  border-radius: var(--radius-pill, 9999px);
  font-size: var(--text-xs, 0.75rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.error-badge--404 {
  background: color-mix(in srgb, var(--color-primary, #ff5722) 15%, transparent);
  color: var(--color-primary, #ff5722);
  border: 1px solid color-mix(in srgb, var(--color-primary, #ff5722) 30%, transparent);
}

.error-badge--500 {
  background: color-mix(in srgb, var(--color-danger, #ef4444) 15%, transparent);
  color: var(--color-danger, #ef4444);
  border: 1px solid color-mix(in srgb, var(--color-danger, #ef4444) 30%, transparent);
}

.error-badge--403 {
  background: color-mix(in srgb, #f59e0b 15%, transparent);
  color: #d97706;
  border: 1px solid color-mix(in srgb, #f59e0b 30%, transparent);
}

[data-theme="dark"] .error-badge--403 {
  color: #fbbf24;
}

.error-badge--400,
.error-badge--405 {
  background: color-mix(in srgb, #64748b 15%, transparent);
  color: #475569;
  border: 1px solid color-mix(in srgb, #64748b 30%, transparent);
}

[data-theme="dark"] .error-badge--400,
[data-theme="dark"] .error-badge--405 {
  color: #94a3b8;
}

.error-badge--503 {
  background: color-mix(in srgb, #eab308 15%, transparent);
  color: #ca8a04;
  border: 1px solid color-mix(in srgb, #eab308 30%, transparent);
}

.error-badge--302 {
  background: color-mix(in srgb, #06b6d4 15%, transparent);
  color: #0891b2;
  border: 1px solid color-mix(in srgb, #06b6d4 30%, transparent);
}

.error-icon-wrapper {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}

.error-icon-wrapper--404 {
  background: color-mix(in srgb, var(--color-primary, #ff5722) 12%, transparent);
  color: var(--color-primary, #ff5722);
}

.error-icon-wrapper--500 {
  background: color-mix(in srgb, var(--color-danger, #ef4444) 12%, transparent);
  color: var(--color-danger, #ef4444);
}

.error-icon-wrapper--403 {
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  color: #d97706;
}

[data-theme="dark"] .error-icon-wrapper--403 {
  color: #fbbf24;
}

.error-icon-wrapper--400,
.error-icon-wrapper--405 {
  background: color-mix(in srgb, #64748b 12%, transparent);
  color: #475569;
}

.error-icon-wrapper--503 {
  background: color-mix(in srgb, #eab308 12%, transparent);
  color: #ca8a04;
}

.error-icon-wrapper--302 {
  background: color-mix(in srgb, #06b6d4 12%, transparent);
  color: #0891b2;
}

.error-title {
  font-size: var(--text-2xl, 1.75rem);
  font-weight: 700;
  color: var(--color-heading);
  margin: 0 0 var(--space-2);
  line-height: 1.25;
}

.error-description {
  font-size: var(--text-base, 1rem);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0 0 var(--space-6);
  max-width: 500px;
}

.error-detail-box {
  background: var(--color-surface-muted, #f8fafc);
  border: 1px dashed var(--color-border, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  padding: var(--space-3) var(--space-4);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  max-width: 100%;
  word-break: break-word;
}

.error-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* -- HTMX loading indicator (standard htmx recipe, shared app-wide) --------
   htmx adds the `htmx-request` class to whichever element issues a request
   for the duration of that request (no `hx-indicator` needed for that part)
   — an element with `.htmx-indicator` INSIDE that element (or referenced
   via `hx-indicator="#id"`) fades in for exactly that long. Not scoped to
   any one feature — any future htmx form in this app can reuse this same
   pair of classes instead of inventing its own loading markup. -------- */

.htmx-indicator {
  opacity: 0;
  transition: opacity 150ms ease-in;
}

.htmx-indicator.htmx-request,
.htmx-request .htmx-indicator {
  opacity: 1;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-brand-primary);
  border-radius: 50%;
  vertical-align: middle;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -- Generic themed combobox (static/js/app.js) ----------------------------
   Portal panel appended to <body>, positioned via JS against whichever
   [data-combobox-options] input is focused — see app.js's own comment for
   why (a native <datalist> can't be restyled to match DASA UI at all). */

.combobox-panel {
  position: fixed;
  z-index: 1000;
  display: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.15));
  max-height: 240px;
  overflow-y: auto;
}

.combobox-panel--open {
  display: block;
}

.combobox-panel__option {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox-panel__option:hover,
.combobox-panel__option--active {
  background: var(--color-surface-muted);
}

.combobox-panel__empty {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* -- Draggable photo viewer (static/js/app.js) ------------------------------
   Deliberately NOT a `.modal__overlay` — that's a full-viewport, page-
   blocking backdrop, wrong for "drag this next to what you're comparing
   it against" (first use: reimbursement's receipt-scan photo vs. the
   AI-extracted item table, `templates/pages/reimbursement
   /_receipt_scan_section.html`). One shared portal panel appended to
   <body>, same idiom as .combobox-panel above, positioned absolutely and
   moved by JS both on open and while its header is being dragged. */

.draggable-viewer {
  position: fixed;
  z-index: 970;
  display: none;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.25));
  /* CSS `resize` needs a concrete starting width/height, not just a max-*
     cap, or the drag handle a browser draws at the bottom-right corner has
     nothing to resize FROM and is easy to miss entirely. */
  width: 420px;
  height: 520px;
  min-width: 240px;
  min-height: 200px;
  max-width: min(90vw, 720px);
  max-height: 90vh;
  overflow: hidden;
  resize: both;
}

.draggable-viewer--open {
  display: flex;
}

.draggable-viewer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
  cursor: move;
  user-select: none;
}

.draggable-viewer__title {
  font-family: var(--font-body);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draggable-viewer__close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-lg, 1.25rem);
  line-height: 1;
  color: inherit;
  padding: 0 var(--space-1);
}

.draggable-viewer__body {
  overflow: auto;
  padding: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.draggable-viewer__body img {
  max-width: 100%;
  display: block;
}

/* -- Bar tab halaman kerja (templates/pages/core/_tab_bar.html) ---------------- */
.manage-tabs { margin-bottom: var(--space-5); }
.manage-tabs .tabs__link { text-decoration: none; }
