/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;

  --text-xs: 11px;  --text-sm: 12px;  --text-base: 13px;
  --text-md: 14px;  --text-lg: 16px;  --text-xl: 20px;  --text-2xl: 24px;

  --weight-normal: 400;  --weight-medium: 500;
  --weight-semibold: 600;  --weight-bold: 700;

  --space-1: 4px;   --space-2: 8px;   --space-3: 12px;
  --space-4: 16px;  --space-5: 20px;  --space-6: 24px;
  --space-8: 32px;  --space-10: 40px;

  --radius-sm: 4px;  --radius-md: 6px;  --radius-lg: 8px;
  --radius-xl: 12px;  --radius-full: 9999px;

  --transition-base: 0.15s ease;

  /* Light theme */
  --bg-primary: #ffffff;    --bg-secondary: #f8f9fb;
  --bg-tertiary: #f0f1f3;   --bg-inset: #ebedf0;

  --text-primary: #1a1d23;  --text-secondary: #5c6370;
  --text-tertiary: #8b919a; --text-inverse: #ffffff;

  --border-primary: #e1e4e8;  --border-secondary: #ebedf0;
  --border-focus: #5b6abf;

  --accent-primary: #5b6abf;
  --accent-primary-hover: #4a58a8;
  --accent-primary-subtle: rgba(91,106,191,0.08);

  --color-success: #2da44e;   --color-success-subtle: rgba(45,164,78,0.1);
  --color-warning: #d4910a;   --color-warning-subtle: rgba(212,145,10,0.1);
  --color-danger: #cf222e;    --color-danger-subtle: rgba(207,34,46,0.1);
  --color-info: #0969da;      --color-info-subtle: rgba(9,105,218,0.1);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.12);
  --shadow-focus: 0 0 0 3px var(--accent-primary-subtle);

  --sidebar-width: 220px;
  --header-height: 52px;

  /* ── Responsive design system ────────────────────────────────
     Desktop-only support (1024 → 1920+). No mobile/tablet.
     Breakpoint tokens are documentation only — CSS @media rules
     use the raw px values (CSS custom properties don't work in
     @media queries). Keep these aligned. */
  --bp-laptop:  1024px;   /* minimum supported viewport */
  --bp-desktop: 1440px;   /* standard desktop target   */
  --bp-wide:    1920px;   /* global content cap         */

  /* Modal width tokens — used by .modal-sm / .modal-md / etc.
     Override these in @media (min-width: 1440px) to scale up. */
  --modal-sm-width: 480px;
  --modal-md-width: 640px;
  --modal-lg-width: 800px;
  --modal-xl-width: 960px;

  /* Centered card max-width (used by public pages — booking, downloads, etc.)
     Scales up at desktop breakpoints. */
  --card-page-width: 720px;
}

@media (min-width: 1440px) {
  :root {
    --modal-sm-width: 520px;
    --modal-md-width: 720px;
    --modal-lg-width: 920px;
    --modal-xl-width: 1080px;
    --card-page-width: 880px;
  }
}

@media (min-width: 1920px) {
  :root {
    --card-page-width: 1000px;
  }
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 13px; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-secondary);
  line-height: 1.5;
}
a { color: var(--accent-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login page ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}
.login-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-10) var(--space-8);
  width: 100%;
  max-width: 420px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}
.login-logo svg { flex-shrink: 0; }
.login-logo h1 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}
.login-logo span {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  font-weight: var(--weight-normal);
  display: block;
}
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}
.form-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  letter-spacing: 0.05em;
}
.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.login-error {
  font-size: var(--text-sm);
  color: var(--color-danger);
  background: var(--color-danger-subtle);
  border: 1px solid rgba(207,34,46,0.2);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
  display: none;
}
.login-error.visible { display: block; }
.login-footer {
  margin-top: var(--space-6);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.login-toggle {
  margin-top: var(--space-4);
  text-align: center;
  font-size: var(--text-sm);
}
.login-toggle button {
  background: none;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}
.login-toggle button:hover { color: var(--accent-primary-hover); }

/* ── Layout ────────────────────────────────────────────────── */
.portal-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  /* Global content cap: on ultra-wide monitors, center the whole shell
     so tables, modals, and forms don't stretch uncomfortably wide. */
  max-width: var(--bp-wide);
  margin: 0 auto;
  width: 100%;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-header {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.sidebar-logo {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-section {
  padding: var(--space-3) var(--space-2) var(--space-1);
}
.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 var(--space-2) var(--space-1);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-base);
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
  transition: background var(--transition-base), color var(--transition-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  font-weight: var(--weight-semibold);
}
.nav-icon { font-size: var(--text-md); flex-shrink: 0; }
.sidebar-footer {
  margin-top: auto;
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--border-secondary);
}

/* ── Main content ──────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.portal-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  flex-shrink: 0;
}
.portal-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.portal-breadcrumb {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.portal-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
/* Icon button in the portal header (e.g. Report a Bug). 32px square,
   ghost background, inverts on hover. */
.portal-icon-btn {
  background: transparent;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.portal-icon-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}
.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.tab-content-area {
  flex: 1;
  /* min-width: 0 lets a flex child shrink below content width — without this,
     wide tables expand the container and clip instead of triggering inner
     horizontal scroll on .adm-table-wrap. */
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-6);
}

/* ── Mobile off-canvas drawer (≤900px) ─────────────────────────
   Desktop (≥901px) is UNCHANGED: .portal-layout stays a flex row with
   the 220px fixed sidebar. Below 900px the sidebar becomes a fixed
   slide-in drawer over a dimming backdrop, and main goes full-width.
   The hamburger (#sidebar-toggle) + #sidebar-backdrop are hidden on
   desktop by the rules just below and only revealed inside the query.
   900px (not 768) so the whole tablet range — where the 220px fixed
   sidebar still strangles the dense tables — uses the drawer; the
   supported desktop floor is already 1024px (--bp-laptop). */
.sidebar-toggle { display: none; }
#sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  /* Layout collapses from a flex row to a block so main goes full-width
     and the sidebar can leave the flow. */
  .portal-layout {
    display: block;
    height: 100vh;
    height: 100dvh;          /* dynamic vh so mobile browser chrome doesn't crop it */
    overflow: hidden;        /* page never scrolls; main-area scrolls internally */
    max-width: none;         /* drop the 1920 cap on small screens */
  }

  /* Sidebar → off-canvas drawer. */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: 100vh;
    height: 100dvh;          /* dynamic vh — accounts for mobile browser chrome */
    width: min(82vw, 300px); /* leaves a sliver of backdrop to tap-to-close */
    z-index: 1100;           /* ABOVE the modal backdrop (1000) so the drawer is never trapped under a modal */
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 2px 0 16px rgba(0,0,0,0.18);
    padding-bottom: env(safe-area-inset-bottom, 0);
    will-change: transform;
  }
  .sidebar.open { transform: translateX(0); }

  /* Dimming backdrop behind the open drawer. */
  #sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1090;           /* below the drawer (1100), above content */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  #sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

  /* Lock body scroll behind the open drawer (belt-and-braces). */
  body.drawer-open { overflow: hidden; }

  /* Main area full-width + viewport-bounded so its flex child (.tab-content-area)
     actually scrolls. CRITICAL: .main-area's base `flex:1` is INERT now that
     .portal-layout is `display:block` (not a flex row), so without an explicit
     height it grows to full content height — then .tab-content-area's
     `overflow-y:auto` never engages and .portal-layout's `overflow:hidden` clips
     every tall tab (data tables / long forms) below the fold with no scroll. */
  .main-area { width: 100%; height: 100vh; height: 100dvh; min-height: 0; }
  .portal-header { padding: 0 var(--space-3); gap: var(--space-2); }
  .tab-content-area { padding: var(--space-3); }

  /* Show the hamburger (hidden on desktop). */
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    padding: 0;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-base), color var(--transition-base);
  }
  .sidebar-toggle:hover { background: var(--bg-secondary); color: var(--text-primary); }

  /* Modals go near-full-width with small margins (the backdrop already
     pads by var(--space-4); the cards already set width:100%). */
  .tab-modal-card,
  .tab-modal-card.modal-sm,
  .tab-modal-card.modal-md,
  .tab-modal-card.modal-lg,
  .tab-modal-card.modal-xl,
  .modal.modal-sm,
  .modal.modal-md,
  .modal.modal-lg,
  .modal.modal-xl {
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
  }
  .tab-modal-card { padding: var(--space-4); }
}

/* ── Mobile content reflow (≤640px) ────────────────────────────
   Phone-only reflow of CONTENT inside the (now full-width) main area.
   Two-column info/edit/form grids declared via NAMED classes collapse
   to one column; filter/search inputs that carry an inline min-width go
   full-width. Per-tab inline grids are converted to .grid-2/.grid-3 in
   the tab modules (which already collapse below 1024px). */
@media (max-width: 640px) {
  .op-info-grid, .op-edit-grid,
  .hk-info-grid, .hk-edit-grid,
  .sys-ver-grid,
  .cat-form-row, .cat-form-row.triple,
  .pkg-info-grid, .pkg-form-row {
    grid-template-columns: 1fr !important;
  }
  /* Filter/search inputs carry inline min-widths (240–260px) that force
     overflow; let them shrink. !important beats the inline min-width. */
  #op-search, #perms-user-select,
  .filter-bar input, .filter-bar select {
    min-width: 0 !important;
  }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition-base), color var(--transition-base),
    border-color var(--transition-base), opacity var(--transition-base);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.5;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
  border-color: var(--accent-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-primary-hover); border-color: var(--accent-primary-hover); }
.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-primary);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-secondary); }
.btn-danger {
  background: var(--color-danger);
  color: var(--text-inverse);
  border-color: var(--color-danger);
}
.btn-danger:hover:not(:disabled) { background: var(--color-danger-hover, #b01c26); }
.btn-success {
  background: var(--color-success);
  color: var(--text-inverse);
  border-color: var(--color-success);
}
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }
.btn-full { width: 100%; justify-content: center; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.badge-success { background: var(--color-success-subtle); color: var(--color-success); }
.badge-warning { background: var(--color-warning-subtle); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-subtle);  color: var(--color-danger);  }
.badge-info    { background: var(--color-info-subtle);    color: var(--color-info);    }
.badge-neutral { background: var(--bg-tertiary);          color: var(--text-secondary);}

/* ── Tables ────────────────────────────────────────────────── */
.adm-table-wrap {
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg-primary);
  /* Scrollbar styling — visible when table overflows but unobtrusive */
  scrollbar-width: thin;
}
.adm-table-wrap::-webkit-scrollbar { height: 8px; }
.adm-table-wrap::-webkit-scrollbar-track { background: transparent; }
.adm-table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: 4px;
}
.adm-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
.adm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.adm-table th {
  background: var(--bg-secondary);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-primary);
  white-space: nowrap;
}
.adm-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-secondary);
  vertical-align: middle;
  /* Columns size to their widest cell (table-layout is auto) and the
     .adm-table-wrap scroll container absorbs any overflow — no blanket
     max-width cap that squished Email while over-widening Role/Status.
     Cells that should wrap/cap opt in via .cell-wrap. */
  white-space: nowrap;
}
.adm-table tr:last-child td { border-bottom: none; }
.adm-table tr:hover td { background: var(--bg-secondary); }
/* Actions column:
   - width: 1% + white-space: nowrap is the canonical CSS trick to make a
     table column shrink to fit its own content, leaving the rest of the
     row's width to other columns. Without this, .adm-table td.actions used
     to claim a big slice of the row's slack because display:flex /
     max-width:none let it absorb whatever the parent had spare — which
     showed up as a big empty gap between the row's last data cell and
     the Edit / ⋯ buttons.
   - Use inline-flex on a wrapper element instead of display:flex on the
     td itself, because display:flex on a <td> breaks table column-width
     calculation in some browsers. */
.adm-table th.actions,
.adm-table td.actions {
  text-align: right;
  width: 1%;
  white-space: nowrap;
  max-width: none;
  overflow: visible;
}
.adm-table td.actions {
  /* Inline-block keeps the cell as a proper table-cell while letting the
     buttons sit on a single line; gap is faked via inline button margins. */
  vertical-align: middle;
}
.adm-table td.actions > * { vertical-align: middle; }
.adm-table td.actions > * + * { margin-left: var(--space-1); }

/* Wrap-cell: opt-in override of the default ellipsize-on-overflow behavior.
   Use on table cells whose content (long descriptions, badge lists, etc.)
   is more useful visible than truncated. The cell allows wrapping; the row
   height grows; sibling cells stay aligned because the table is still
   in standard table-cell layout. */
.adm-table td.cell-wrap {
  white-space: normal;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  line-height: 1.5;
}
.adm-table td.cell-wrap code {
  display: inline-block;
  margin: 1px 2px 1px 0;   /* lets variable chips reflow onto multiple lines */
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}
.card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

/* ── KPI grid ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.kpi-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.kpi-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}
.kpi-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.2;
}
.kpi-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
}
.page-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}
.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* ── Filter bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.filter-select, .filter-input {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-primary);
  height: 32px;
}
.filter-select:focus, .filter-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  color: var(--text-tertiary);
}
.empty-state-icon { font-size: 40px; margin-bottom: var(--space-3); }
.empty-state-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

/* ── Loading skeleton ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-inset) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line { height: 14px; margin-bottom: var(--space-2); border-radius: var(--radius-sm); }
.skeleton-line.w-full { width: 100%; }
.skeleton-line.w-3-4  { width: 75%;  }
.skeleton-line.w-1-2  { width: 50%;  }
.skeleton-line.w-1-4  { width: 25%;  }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl, 0 8px 32px rgba(0,0,0,0.16));
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-primary);
}
.modal-title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-tertiary); font-size: var(--text-lg); padding: var(--space-1);
}
.modal-body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-primary);
  display: flex; justify-content: flex-end; gap: var(--space-3);
}

/* ── Form elements ─────────────────────────────────────────── */
.field-group { margin-bottom: var(--space-4); }
.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}
.field-input, .field-textarea, .field-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-primary);
}
.field-input:focus, .field-textarea:focus, .field-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.field-textarea { resize: vertical; min-height: 80px; }

/* ── Modal width classes ───────────────────────────────────────
   Apply on top of .modal to standardize modal sizing instead of
   inline max-width:Xpx scattered across tab files. Widths scale
   up at the desktop breakpoint via --modal-*-width tokens. */
.modal.modal-sm { max-width: var(--modal-sm-width); }
.modal.modal-md { max-width: var(--modal-md-width); }
.modal.modal-lg { max-width: var(--modal-lg-width); }
.modal.modal-xl { max-width: var(--modal-xl-width); }

/* ── Action menu (⋯ overflow) ──────────────────────────────────
   Replaces multi-button action cells. Use renderActionMenu() in
   ui-helpers.js to generate markup; click handlers are wired by
   bindActionMenus(). The trigger is a single 28px square button. */
.action-menu {
  position: relative;
  display: inline-block;
}
.action-menu-trigger {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.action-menu-trigger:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}
.action-menu-trigger.open {
  background: var(--accent-primary-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.action-menu-list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  z-index: 100;
  display: none;
}
.action-menu-list.open { display: block; }
.action-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.action-menu-item:hover { background: var(--bg-secondary); }
.action-menu-item.danger { color: var(--color-danger); }
.action-menu-item.danger:hover { background: var(--color-danger-subtle); }
.action-menu-item:disabled { opacity: 0.5; cursor: not-allowed; }
.action-menu-divider {
  height: 1px;
  background: var(--border-secondary);
  margin: var(--space-1) 0;
}

/* Inline primary action button that lives next to .action-menu in a
   table's actions cell (e.g. View, Logs). Use these for visible primary
   actions; secondary actions go in the ⋯ menu. */
.adm-table td.actions { gap: var(--space-2); }
.adm-table td.actions .btn-sm { white-space: nowrap; }

/* ── Centered card page layout ─────────────────────────────────
   Public-facing pages (booking, downloads, package landing, manage)
   use this pattern: a centered card with max-width that scales up
   at desktop breakpoints. */
.card-page {
  max-width: var(--card-page-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}
@media (min-width: 1024px) {
  .card-page { padding: var(--space-8) var(--space-6); }
}
@media (min-width: 1440px) {
  .card-page { padding: var(--space-10) var(--space-8); }
}

/* ── Responsive utilities ──────────────────────────────────────
   For inline use where adding a per-component CSS rule is overkill. */
.flex-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr 1fr; gap: var(--space-4); }
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
}
@media (min-width: 1440px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Tightens table row text in dense tabs without going inline */
.adm-table.adm-table-compact td { padding: var(--space-1) var(--space-2); font-size: var(--text-sm); }
.adm-table.adm-table-compact th { padding: var(--space-1) var(--space-2); }

/* ── Modal backdrop ────────────────────────────────────────────
   Reusable backdrop for tab-local modals built inline (not via
   .modal-overlay). Replaces the
     style="position:fixed;inset:0;background:rgba(0,0,0,0.5);z-index:1000;display:flex;align-items:center;justify-content:center"
   block that was repeated ~18× across tab files. */
.tab-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.tab-modal-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: 100%;
  max-width: var(--modal-md-width);
  margin: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  max-height: 90vh;
  overflow-y: auto;
}
/* Use these to size the card */
.tab-modal-card.modal-sm { max-width: var(--modal-sm-width); }
.tab-modal-card.modal-md { max-width: var(--modal-md-width); }
.tab-modal-card.modal-lg { max-width: var(--modal-lg-width); }
.tab-modal-card.modal-xl { max-width: var(--modal-xl-width); }

/* ── Status badge (pill) ──────────────────────────────────────
   Replaces the inline
     style="display:inline-block;padding:2px 8px;font-size:11px;
            font-weight:600;border-radius:20px;color:X;background:Y;border:1px solid X"
   pattern that was repeated dozens of times for status pills.
   Use .pill + a color variant. The color variants reuse the existing
   --color-* tokens so they pick up theme changes. */
.pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: 20px;
  border: 1px solid currentColor;
  white-space: nowrap;
  line-height: 1.4;
}
.pill-success { color: var(--color-success); background: var(--color-success-subtle); }
.pill-warning { color: var(--color-warning); background: var(--color-warning-subtle); }
.pill-danger  { color: var(--color-danger);  background: var(--color-danger-subtle); }
.pill-info    { color: var(--color-info);    background: var(--color-info-subtle); }
.pill-neutral { color: var(--text-tertiary); background: var(--bg-tertiary); border-color: var(--border-primary); }

/* ── Common inline-style replacements ─────────────────────────
   Short utility classes covering the most-repeated inline patterns
   in tab files. Pull these out of tab JS strings so global rules
   in this file can actually cascade. */
.row-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.field-row   { display: flex; gap: var(--space-3); align-items: center; }
.field-row-end { display: flex; gap: var(--space-3); align-items: center; justify-content: flex-end; }
.mono-cell { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-info    { color: var(--color-info); }
.weight-medium { font-weight: var(--weight-medium); }

/* ── Page padding scales with viewport ─────────────────────────
   Override tab-content-area padding at wider breakpoints so the
   content has more breathing room on big monitors. */
@media (min-width: 1440px) {
  .tab-content-area { padding: var(--space-8); }
}
@media (min-width: 1920px) {
  .tab-content-area { padding: var(--space-10); }
}

/* ── Multi-select chips (api.js: multiSelectChips) ─────────────
   Dropdown with checkbox list; selected items render as removable
   chips above the trigger. Used by the Tasks operator filter. */
.ms-chips { position: relative; min-width: 220px; }
.ms-chips-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 6px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  min-height: 32px;
}
.ms-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  background: var(--accent-primary-subtle, #e0eaff);
  color: var(--accent-primary, #2563eb);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.ms-chip-x {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
  border-radius: var(--radius-full);
}
.ms-chip-x:hover { background: rgba(0,0,0,0.08); }
.ms-chips-trigger {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  font-size: var(--text-sm);
  flex: 1;
  text-align: left;
  min-width: 80px;
}
.ms-chips-trigger:focus { outline: 1px solid var(--border-focus); border-radius: var(--radius-sm); }
.ms-chips-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-width: 320px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md, 0 6px 16px rgba(0,0,0,0.12));
  z-index: 50;
  padding: 4px 0;
}
.ms-chips-menu.open { display: block; }
.ms-chips-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.ms-chips-option:hover { background: var(--bg-secondary); }
.ms-chips-option input { cursor: pointer; }
.ms-chips-empty {
  padding: 10px;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  text-align: center;
}

/* ── Pagination bar (api.js: paginationBar) ────────────────────
   Compact pager: ‹ 1 2 … 9 10 ›  +  "Showing 26-50 of 247 …" */
.pgn-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  margin-top: var(--space-3);
  border-top: 1px solid var(--border-secondary);
  flex-wrap: wrap;
}
.pgn-summary {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}
.pgn-controls { display: flex; gap: 2px; align-items: center; }
.pgn-page, .pgn-step {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-primary);
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}
.pgn-page:hover:not(:disabled),
.pgn-step:hover:not(:disabled) { background: var(--bg-secondary); color: var(--text-primary); }
.pgn-page.pgn-active {
  background: var(--accent-primary, #2563eb);
  color: #fff;
  border-color: var(--accent-primary, #2563eb);
  font-weight: var(--weight-semibold);
}
.pgn-page:disabled, .pgn-step:disabled { opacity: 0.4; cursor: not-allowed; }
.pgn-ellipsis {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  padding: 0 4px;
}

/* ── Tasks-tab specific: view toggle + my-tasks pill + sortable
       table headers + card-readability labels.
   Scoped to the tasks-bar / tasks-grid containers so they don't
   leak to other tabs. */
.tasks-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.tasks-bar-spacer { flex: 1; min-width: 12px; }
.tasks-mine-toggle {
  height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tasks-mine-toggle:hover { background: var(--bg-secondary); }
.tasks-mine-toggle.active {
  background: var(--accent-primary, #2563eb);
  color: #fff;
  border-color: var(--accent-primary, #2563eb);
  font-weight: var(--weight-medium);
}
.tasks-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 32px;
}
.tasks-view-btn {
  border: 0;
  background: var(--bg-primary);
  color: var(--text-secondary);
  padding: 0 10px;
  cursor: pointer;
  font-size: var(--text-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tasks-view-btn + .tasks-view-btn { border-left: 1px solid var(--border-primary); }
.tasks-view-btn:hover { background: var(--bg-secondary); }
.tasks-view-btn.active {
  background: var(--accent-primary, #2563eb);
  color: #fff;
  font-weight: var(--weight-medium);
}

.tasks-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tasks-table th.sortable:hover { color: var(--text-primary); }
.tasks-table th.sortable .sort-ind {
  display: inline-block;
  margin-left: 4px;
  color: var(--text-tertiary);
  font-size: 10px;
}
.tasks-table th.sortable.sort-active .sort-ind {
  color: var(--accent-primary, #2563eb);
}
.tasks-table .due-overdue { color: var(--color-danger); font-weight: var(--weight-medium); }

/* Card-readability — "icon Label: value" pattern in card rows.
   The fixed-width .icon container makes every row's icon sit in the same
   column regardless of glyph width — emoji glyphs vary by ~2-3px which
   makes the labels jitter horizontally without this. */
.tasks-card-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.tasks-card-row > .icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  line-height: 1;
}
.tasks-card-row > .lbl {
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
  flex-shrink: 0;
}
.tasks-card-row > .val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Card description — full-width block below the meta grid.
   Header (icon + "Description:") on its own line, then the value text
   on the line below, indented to align with the meta-grid label column.
   Border-top visually groups the description as a distinct section
   instead of crowding the meta data. */
.tasks-card-description {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid var(--border-secondary);
  font-size: var(--text-sm);
  line-height: 1.5;
  min-width: 0;
}
.tasks-card-description-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}
.tasks-card-description-header > .icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  line-height: 1;
}
.tasks-card-description-header > .lbl {
  font-weight: var(--weight-medium);
}
.tasks-card-description-value {
  margin: 0;
  /* 18px icon column + 6px gap = 24px — aligns the value text with the
     label text, not the icon. Reads like a labeled paragraph rather
     than a hanging indent. */
  padding-left: 24px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  min-width: 0;
}
