/* EEIS visual language — corporate/operations dashboard style (Outfit type,
   slate neutrals, blue accent). Presentation only: behavior and markup
   stay intact. Primary/accent/bg keep their --clr-* names as the single
   source of truth so the branding settings screen (js/branding-settings.js,
   applyBrandingToDOM) can still override them per company via inline
   custom properties on :root — --coral/--navy/--app-bg below are defined
   IN TERMS OF --clr-primary/--clr-accent/--clr-bg (not the other way
   around) specifically so that override keeps flowing through to every
   component in this file. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Cairo:wght@400;500;600;700&display=swap');

:root {
  --clr-bg: #f8f9fb;
  --clr-surface: #ffffff;
  --clr-surface-2: #f8fafc;
  --clr-surface-3: #e8f1f5;
  --clr-border: #e2e8f0;
  --clr-border-2: #cbd5e1;
  --clr-primary: #003f5a;
  /* Derived from --clr-primary with color-mix(), NOT set as their own
     static hex — a branding override only ever touches --clr-primary
     (see js/branding-settings.js applyBrandingToDOM), so any color that
     was hardcoded here independently would silently stop following a
     company's brand color (this happened once: .page-context's gradient
     used a static --clr-primary-dk and stayed blue regardless of the
     configured brand color). Deriving them keeps every shade of the
     brand color in sync automatically. */
  --clr-primary-dk: color-mix(in srgb, var(--clr-primary) 80%, black);
  --clr-primary-lt: color-mix(in srgb, var(--clr-primary) 18%, white);
  --clr-accent: #841010;
  --clr-text: #1b2a33;
  --clr-text-sub: #494949;
  --clr-text-muted: #94a3b8;
  --clr-text-inv: #fff;
  --success: #059669;
  --warning: #d97706;
  --danger: #b42318;
  --info: #003f5a;
  --radius-control: 10px;
  --radius-card: 12px;
  --radius-large: 16px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-raised: 0 8px 20px rgba(15, 23, 42, .08);

  /* App-level aliases, derived from the --clr-* tokens above so a
     branding override on --clr-primary/--clr-accent/--clr-bg reaches
     every rule below that still reads the older --coral/--navy names. */
  --app-bg: var(--clr-bg);
  --surface: var(--clr-surface);
  --surface-soft: var(--clr-surface-2);
  --surface-blue: var(--clr-surface-3);
  --navy: var(--clr-accent);
  --navy-dark: var(--clr-primary-dk);
  --blue-gray: var(--clr-text-sub);
  --coral: var(--clr-primary);
  --coral-hover: var(--clr-primary-dk);
  --coral-soft: var(--clr-primary-lt);
  --ink: var(--clr-text);
  --ink-soft: var(--clr-text-sub);
  --ink-muted: var(--clr-text-muted);
  --line: var(--clr-border);
  --shadow-sm: var(--shadow-card);
  --shadow-md: var(--shadow-raised);
  --shadow-lg: 0 22px 48px rgba(15, 23, 42, .16);
  --font-base: 'Inter', 'Cairo', system-ui, sans-serif;
  --r-xs: 8px; --r-sm: 10px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px;
  /* Was 60px: taller than any of the branded cards it sits above (the
     filter shell, KPI cards, list rows all read as compact 12–16px-padded
     surfaces), so the header read as a leftover default bar rather than
     part of the same design. 52px matches that density and hands every
     screen ~8px more content height, felt on every scroll. */
  --header-h: 52px; --nav-h: 72px;
}

html, body { background: var(--app-bg); }
body {
  color: var(--ink);
  background: var(--app-bg);
  font-family: var(--font-base);
  letter-spacing: 0;
}
html[lang='ar'] body, html[dir='rtl'] body { font-family: 'Cairo', 'Outfit', sans-serif; }
.screen { background: transparent; }
.screen::before { content: ''; position: absolute; z-index: -1; inset: auto -12% -20% auto; width: 35vw; height: 35vw; border-radius: 50%; background: rgba(255,255,255,.38); pointer-events: none; }

/* App bars */
.app-header {
  background: var(--clr-surface);
  border: 0;
  border-bottom: 1px solid var(--clr-border);
  box-shadow: none;
  backdrop-filter: none;
  padding-inline: max(16px, env(safe-area-inset-left));
}
.header-title { text-align: start; }
.header-title span { color: var(--ink); font-size: 16px; font-weight: 700; }
.header-title small { color: var(--ink-muted); }
.btn-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: var(--radius-control); color: var(--navy); background: transparent; }

/* With the sidebar retired, a header that used to offload its extra icon
   buttons there (see js/app.js's old collectSidebarContextSources) now
   shows all of them inline — on a screen with several (e.g. daily
   checklist run: back, prev/next cycle, export Excel, export PDF,
   refresh) they no longer fit the fixed-height header and were
   overlapping. Let the group scroll horizontally instead of squeezing. */
.header-left, .header-right {
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.header-left::-webkit-scrollbar, .header-right::-webkit-scrollbar { display: none; }
.btn-icon:hover { color: var(--navy-dark); background: var(--surface-blue); }
.btn-icon.primary { background: var(--coral); color: #fff; box-shadow: none; }

/* Controls */
.btn { min-height: 42px; padding: 10px 16px; border-radius: var(--radius-control); font-size: 13.5px; font-weight: 600; box-shadow: none; }
.btn-primary { background: var(--coral); border-color: var(--coral); color: #fff; box-shadow: none; }
.btn-primary:hover { background: var(--coral-hover); border-color: var(--coral-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-blue); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-chip { min-height: 32px; padding: 6px 13px; border-radius: 999px; }

.form-group { gap: 6px; }
.form-group label { color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.form-group input, .form-group select, .form-group textarea,
.filter-select, input:not([type='checkbox']):not([type='radio']), select, textarea {
  min-height: 42px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-control); box-shadow: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus,
input:focus, select:focus, textarea:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(0,63,90,.16); }
::placeholder { color: var(--ink-muted); opacity: 1; }

/* Checkboxes/radios — a plain `accent-color` checkbox renders as whatever
   shape/style the OS gives it (a squircle with a checkmark on some
   platforms, a plain square on others), which reads as foreign next to
   the app's own flat, bordered controls. Draw the box ourselves instead
   so it's the same on every device. */
input[type="checkbox"], input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-height: 0;
  flex-shrink: 0;
  margin: 0;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: background .12s ease, border-color .12s ease;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:checked, input[type="radio"]:checked {
  background: var(--coral);
  border-color: var(--coral);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/70% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/70% no-repeat;
}
input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #fff;
}
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible {
  box-shadow: 0 0 0 3px rgba(37,99,235,.18);
}

/* Selects — same story: the native dropdown arrow is drawn by the OS and
   never matches the app's own icon set, so replace it with one consistent
   chevron and reclaim the padding it needs. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}
html[dir="rtl"] select {
  padding-right: 14px !important;
  padding-left: 34px !important;
  background-position: left 10px center;
}
.search-box { min-height: 40px; background: var(--surface-2, #f8fafc); border: 1px solid var(--line); border-radius: var(--radius-control); box-shadow: none; }
.search-box svg { color: var(--blue-gray); }
.search-box:focus-within { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.filter-toggle-btn { background: var(--surface-blue); border: 0; }

/* Content rhythm, cards, and records */
.pg-tabs { background: transparent; border: 0; padding: 10px 16px 8px; gap: 8px; }
.pg-tab-btn { min-height: 34px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--ink-soft); box-shadow: none; font-weight: 600; }
.pg-tab-btn.active { background: var(--coral); color: #fff; border-color: var(--coral); }
.pg-tab-count { background: rgba(255,255,255,.3); color: inherit; }
.pg-tab-panel, .form-container, .detail-container, .tasks-container, .milestones-container { padding: 12px 16px 24px; gap: 16px; }
.pg-filter-bar, .pg-filter-row { gap: 10px; padding: 4px 0 14px; }
.pg-list { gap: 12px; padding: 0; }
.pg-list-row, .pg-row, .project-card, .task-card, .tool-card, .wh-product-card,
.detail-section, .stat-card, .dashboard-card, .warehouse-card, .q-card, .support-card,
.profile-card, .changelog-card, .kpi-card {
  background: var(--surface); border: 1px solid var(--line); box-shadow: none; color: var(--ink);
}
.pg-list-row, .pg-row, .project-card, .task-card { border-radius: var(--radius-card); padding: 16px; margin: 0; }
.pg-list-row:hover, .pg-row:hover, .project-card:hover, .task-card:hover, .tool-card:hover, .wh-product-card:hover { background: var(--surface-2, #fafbff); border-color: var(--line); box-shadow: none; transform: none; }
.pg-row-title, .project-card-title, .task-card-title, .pg-list-row strong, .detail-field span { color: var(--ink); }
.pg-row-meta, .pg-row-sub, .task-card-meta, .pg-row-note, .pg-stat-lbl { color: var(--ink-soft); }
.pg-dot { box-shadow: none; }
.progress-wrap { background: #e7eef4; box-shadow: none; }
.progress-bar { background: var(--coral); box-shadow: none; }
.status-badge, .badge, .chip, .pg-status { border-radius: 999px; font-weight: 700; }

/* Details and overlays */
.detail-section { border-radius: var(--radius-card); overflow: hidden; }
.detail-section-title { background: var(--surface-blue); border: 0; color: var(--navy); padding: 13px 16px; }
.detail-grid { background: var(--line); gap: 1px; }
.detail-field { background: var(--surface); padding: 14px 16px; }
.detail-field label { color: var(--ink-muted); }
.modal-overlay, .modal-backdrop { background: rgba(52,79,103,.28); backdrop-filter: blur(5px); }
.modal-sheet, .modal, .modal-content, .dialog, .bottom-sheet, .sheet-content { background: var(--surface); border: 0; border-radius: var(--radius-large) var(--radius-large) 0 0; box-shadow: 0 -12px 36px rgba(15,23,42,.14); color: var(--ink); }
.modal-header { background: var(--surface); border-color: var(--line); padding: 20px; }
.modal-header h3 { color: var(--ink); }
.modal-body { padding: 20px; }
.toast { border-radius: 16px; box-shadow: var(--shadow-raised); }

/* Mobile-native navigation */
.bottom-nav:not(.app-sidebar__nav).visible { background: rgba(255,255,255,.96) !important; border-color: var(--line) !important; box-shadow: 0 -8px 24px rgba(47,76,101,.09) !important; }
.bottom-nav:not(.app-sidebar__nav) .nav-tab { color: var(--ink-muted); }
.bottom-nav:not(.app-sidebar__nav) .nav-tab.active { color: var(--coral); }
.bottom-nav:not(.app-sidebar__nav) .nav-tab.active::before { background: var(--coral); }
.nav-profile-avatar-wrap { background: var(--surface-blue); }
.app-fab { background: var(--coral); border-radius: 18px; box-shadow: 0 12px 24px rgba(255,107,87,.28); }
.app-fab:hover { background: var(--coral-hover); box-shadow: 0 16px 28px rgba(255,107,87,.3); }
.mobile-nav-sheet { display: none; }
.mobile-nav-sheet[hidden] { display: none !important; }

/* The five visible tabs stay concise. Less-frequent destinations live in a
   thumb-friendly sheet instead of disappearing with the desktop sidebar. */
@media (max-width: 768px) {
  body.mobile-nav-sheet-open { overflow: hidden; }
  .mobile-nav-sheet {
    position: fixed;
    z-index: 6100;
    inset: 0;
    display: block;
    color: var(--ink);
  }
  .mobile-nav-sheet__backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(35, 55, 73, .36);
    backdrop-filter: blur(4px);
  }
  .mobile-nav-sheet__panel {
    position: absolute;
    inset: auto 0 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: min(88dvh, 680px);
    padding: 14px 16px calc(28px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    background: var(--surface);
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -20px 48px rgba(35, 55, 73, .22);
    overscroll-behavior: contain;
  }
  .mobile-nav-sheet__handle {
    width: 42px;
    height: 4px;
    margin: 0 auto -2px;
    border-radius: 999px;
    background: #cedbe5;
  }
  .mobile-nav-sheet__header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .mobile-nav-sheet__eyebrow { display: block; margin-bottom: 3px; color: var(--coral); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
  .mobile-nav-sheet__title { margin: 0; color: var(--ink); font-size: 20px; font-weight: 800; line-height: 1.2; }
  .mobile-nav-sheet__close { flex: 0 0 44px; color: var(--navy); background: var(--surface-blue); }
  .mobile-nav-sheet__section-label {
    margin: 2px 2px -4px;
    color: var(--ink-muted, #9aa9b6);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
  }
  .mobile-nav-sheet__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mobile-nav-sheet__item {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 74px;
    gap: 10px;
    padding: 11px;
    color: var(--ink);
    background: var(--surface-soft);
    border: 1px solid transparent;
    border-radius: 18px;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
    text-align: start;
  }
  .mobile-nav-sheet__item:active { background: var(--coral-soft); border-color: #ffd0c8; transform: scale(.985); }
  .mobile-nav-sheet__item > :last-child { min-width: 0; overflow-wrap: anywhere; }
  .mobile-nav-sheet__icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    flex: 0 0 34px;
    align-items: center;
    justify-content: center;
    color: var(--coral);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(52,79,103,.07);
  }
  .mobile-nav-sheet__icon svg { width: 18px; height: 18px; }
  .mobile-nav-sheet__icon--amber { color: #d97706; background: #fef3c7; }
  .mobile-nav-sheet__icon--blue  { color: #2563eb; background: #dbeafe; }
  .mobile-nav-sheet__icon--red   { color: var(--clr-danger, #dc453f); background: rgba(220,69,63,.12); }
  .mobile-nav-sheet__icon--purple{ color: #9333ea; background: #f3e8ff; }
  .mobile-nav-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--clr-danger, #dc453f), #c82020);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(220,69,63,.35);
  }
  .mobile-nav-badge--inline { top: 8px; right: 8px; }
  .mobile-nav-sheet__language {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    color: var(--ink-soft);
    background: var(--surface-blue);
    border-radius: 16px;
    font-size: 12px;
    font-weight: 800;
  }
  .mobile-nav-sheet__language select {
    min-height: 38px;
    width: min(132px, 45vw);
    padding: 6px 30px 6px 10px;
    color: var(--ink);
    background-color: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
  }
  .mobile-nav-sheet__logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    margin-top: 8px;
    color: #fff;
    background: linear-gradient(135deg, #ff7369, #dc453f);
    border: none;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(220, 69, 63, 0.2);
    transition: transform 0.1s ease, filter 0.15s ease;
  }
  .mobile-nav-sheet__logout:active {
    transform: scale(0.98);
    filter: brightness(0.9);
  }
  .mobile-nav-sheet__logout svg {
    width: 18px;
    height: 18px;
  }
}
@media (max-width: 360px) {
  .mobile-nav-sheet__panel { gap: 12px; padding-inline: 12px; }
  .mobile-nav-sheet__grid { gap: 8px; }
  .mobile-nav-sheet__item { min-height: 66px; padding: 9px; gap: 8px; font-size: 11px; }
  .mobile-nav-sheet__icon { width: 30px; height: 30px; flex-basis: 30px; border-radius: 10px; }
  .mobile-nav-sheet__page-tools { padding: 10px; gap: 8px; }
  .mobile-nav-sheet__page-tools-title { font-size: 10px; }
  .mobile-page-tools-host { gap: 6px; }
  .mobile-page-tools-host input[type="search"],
  .mobile-page-tools-host input[type="text"],
  .mobile-page-tools-host select {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 13px;
  }
  .mobile-page-tools-host .pg-tabs,
  .mobile-page-tools-host--actions {
    gap: 6px;
  }
  .mobile-page-tools-host .pg-tabs button,
  .mobile-page-tools-host--actions .mobile-header-action-proxy {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
  }
}

/* A page uses either its compact app-bar action or its floating action,
   never both. The FAB remains available only when a desktop sidebar is
   intentionally collapsed and therefore cannot expose the primary action. */
@media (min-width: 769px) {
  body.app-shell-sidebar-active:not(.app-shell-sidebar-collapsed) .app-fab { display: none !important; }
}

/* Desktop rail — dark navy "control room" sidebar, matching the app's
   accent (--clr-primary, branding-driven) for the active state instead of
   a hardcoded color, so a company's own brand color still shows here. */
@media (min-width: 769px) {
  .app-sidebar__panel { background: #0f172a; border: 1px solid #1e293b; box-shadow: 0 18px 45px rgba(15,23,42,.18); }
  .app-sidebar__brand-copy strong, .app-sidebar__title { color: #f1f5f9; }
  .app-sidebar__brand-copy span, .app-sidebar__subtitle, .app-sidebar__eyebrow, .app-sidebar__section-title { color: #64748b; }
  .app-sidebar__screen-summary { background: var(--clr-primary); border: 0; }
  .app-sidebar__screen-summary .app-sidebar__title, .app-sidebar__screen-summary .app-sidebar__subtitle, .app-sidebar__screen-summary .app-sidebar__eyebrow { color: #fff; }
  .app-sidebar__nav .nav-tab { color: #94a3b8; }
  .app-sidebar__nav .nav-tab.active { background: var(--clr-primary); color: #fff; box-shadow: none; }
  .app-sidebar__nav .nav-tab:hover { background: #1e293b; color: #cbd5e1; }
  .app-sidebar__shortcut, .app-sidebar__action { color: #cbd5e1; background: #1e293b; border-color: transparent; }
  .app-sidebar__shortcut:hover, .app-sidebar__action:hover { background: #24344a; border-color: transparent; }
  .app-sidebar__shortcut.active, .app-sidebar__action--primary, .app-sidebar__action--hero { background: var(--clr-primary); border-color: transparent; color: #fff; box-shadow: none; }
  .app-sidebar__toggle, .app-sidebar__reopen { background: #1e293b; border-color: #1e293b; color: #cbd5e1; box-shadow: var(--shadow-card); }
  .app-fab { right: 32px; bottom: 28px; }
}

/* Per-screen search/filter/tab controls relocated into the sidebar (desktop)
   or the mobile "More" sheet (see js/app.js relocateActiveScreenWorkspaceControls).
   Their original containers are left in place empty, so collapse them to
   reclaim the vertical space they used to occupy in the screen content. */
.pg-filter-bar:empty, .pg-tabs:empty,
.wh-filter-bar:empty, .q-filter-bar:empty,
.collection-toolbar:empty, .wh-type-tabs:empty, .collection-tabs:empty,
.dashboard-filter-shell:empty {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  min-height: 0 !important;
}

.app-sidebar__search-host,
.app-sidebar__tabs-host {
  display: grid;
  gap: 8px;
}
.workspace-control-group { display: contents; }
.app-sidebar__search-host .search-box,
.app-sidebar__search-host input,
.app-sidebar__search-host select {
  width: 100%;
}
/* .pg-tabs/.collection-tabs carry a full-width top-bar look (background,
   border-bottom, box-shadow, horizontal scroll) meant for sitting across
   the page. Relocated into the narrow sidebar column that reads as a
   clashing floating strip instead of blending in with the other sidebar
   controls — reset it back to plain wrapped pill buttons here. */
.app-sidebar__tabs-host .pg-tabs,
.app-sidebar__tabs-host .collection-tabs {
  display: flex !important;
  flex-wrap: wrap !important;
  overflow: visible !important;
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  gap: 6px !important;
}

@media (min-width: 769px) {
  .app-sidebar__search-host input[type="search"],
  .app-sidebar__search-host input[type="text"],
  .app-sidebar__search-host select {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    color: var(--ink);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 14px;
    font: inherit;
  }
  .app-sidebar__tabs-host {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .app-sidebar__tabs-host button,
  .app-sidebar__tabs-host .pg-tab {
    color: var(--ink-soft);
    background: var(--surface-soft);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 8px 12px;
  }
  .app-sidebar__tabs-host button.active,
  .app-sidebar__tabs-host .pg-tab.active {
    background: var(--coral-soft);
    color: var(--coral);
  }
}

/* Fingerprint quick-action nav icon (clock in/out in one tap) — bottom bar
   on phone, sidebar nav list on desktop. State comes from data-att-state,
   set by refreshAttendanceQuickState()/applyAttendanceQuickState() in
   js/app.js: "none" (not clocked in), "in" (active), "out" (completed).
   The badge lives entirely on the <svg> itself (padding + border-radius) so
   it can't visually overflow its nav-tab slot in either layout. */
.nav-attendance-fingerprint svg {
  box-sizing: content-box;
  padding: 8px;
  border-radius: 999px;
  border: 2px solid var(--line, #e4ebf1);
  background: var(--surface, #fff);
  color: var(--ink-muted, #9aa9b6);
  transition: color .2s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.nav-attendance-fingerprint[data-att-state="in"] svg {
  color: var(--coral, #ff6b57);
  border-color: var(--coral, #ff6b57);
  background: var(--coral-soft, rgba(255,107,87,.12));
  animation: att-fingerprint-pulse 1.8s ease-out infinite;
}
.nav-attendance-fingerprint[data-att-state="out"] svg {
  color: var(--success, #2e9e6b);
  border-color: var(--success, #2e9e6b);
  background: rgba(46,158,107,.12);
}
.nav-attendance-fingerprint--busy {
  opacity: .55;
  pointer-events: none;
}
@keyframes att-fingerprint-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,107,87,.45); }
  70%  { box-shadow: 0 0 0 8px rgba(255,107,87,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,87,0); }
}
#mobile-bottom-nav .nav-attendance-fingerprint svg {
  width: 22px;
  height: 22px;
}

/* Shared avatar chip used by avatarChipHtml() (js/app.js) wherever a user
   list renders a photo — real upload, gender-based default, or initials. */
.avatar-chip {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 999px;
  object-fit: cover;
  background: var(--surface-blue);
}
.avatar-chip--initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  background: var(--surface-blue);
  font-size: 12px;
  font-weight: 800;
}

.mobile-nav-sheet__page-tools {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin: 0 0 4px;
  background: var(--surface-soft);
  border-radius: 18px;
}
.mobile-nav-sheet__page-tools-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--coral);
}
.mobile-page-tools-host {
  display: grid;
  gap: 8px;
}
.mobile-page-tools-host:empty { display: none; }
.mobile-page-tools-host input[type="search"],
.mobile-page-tools-host input[type="text"],
.mobile-page-tools-host select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  font: inherit;
}
.mobile-page-tools-host .pg-tabs,
.mobile-page-tools-host--actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

table { border-spacing: 0 8px; }
thead th { background: var(--surface-blue); color: var(--ink-soft); }
tbody tr { background: var(--surface); box-shadow: var(--shadow-card); }
td, th { padding: 13px 14px; }

/* Keep utility/legacy surfaces in sync with the new palette. */
[style*='var(--bg-surface)'] { --bg-surface: var(--surface); --bg-surface-2: var(--surface-soft); }
:focus-visible { outline: 3px solid rgba(255,107,87,.45); outline-offset: 2px; }
@media (max-width: 768px) {
  .screen::before { display: none; }
  .form-actions { background: var(--app-bg); border-color: var(--line); box-shadow: 0 -8px 22px rgba(47,76,101,.08); }
  .detail-container, .form-container, .pg-tab-panel { padding-bottom: calc(24px + var(--nav-h)); }
}

/* Collection pages are real workspaces, not vertically stacked rows. */
.screen--sticky-workspace > .app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(18px);
}
.screen--sticky-workspace .pg-tabs,
.screen--sticky-workspace .dashboard-filter-shell,
.screen--sticky-workspace .pg-filter-bar,
.screen--sticky-workspace .collection-toolbar,
.screen--sticky-workspace .wh-filter-bar,
.screen--sticky-workspace .q-filter-bar {
  position: sticky;
  z-index: 20;
  top: calc(var(--header-h) + 8px);
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(16px);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  margin: 8px 0 12px;
}
.screen--sticky-workspace .pg-tabs {
  top: var(--header-h);
  margin: 0;
  padding: 8px 16px 10px;
  border-radius: 0 0 18px 18px;
  background: rgba(255,255,255,.92);
}
.screen--sticky-workspace .dashboard-filter-shell {
  top: var(--header-h);
  /* The base rule sets width: min(100%, 1440px) for the centered desktop
     layout. Adding a 16px left/right margin on top of an already-100%-wide
     box pushed the sticky bar 32px past the viewport at every width — the
     right edge (and its rounded corner) was clipped and a horizontal
     scrollbar appeared under the whole dashboard. width: auto lets the box
     size itself to (container − margins) instead, like every other sticky
     filter bar on this page's sibling screens already does. */
  width: auto;
  margin: 8px 16px 12px;
}
.collection-screen .collection-tabs { margin: 0; padding: 8px 16px; background: transparent; box-shadow: none; }
.collection-screen .collection-panel { display: block; width: min(100%, 1440px); margin-inline: auto; padding: 0 16px calc(24px + var(--nav-h)); overflow-y: auto; }
.collection-screen .collection-toolbar { display: flex; flex-wrap: wrap; align-items: center; padding: 12px; margin: 0 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.collection-screen .collection-toolbar .search-box { flex: 1 1 220px !important; }
.collection-screen .collection-toolbar > .filter-select { flex: 1 1 180px !important; max-width: none !important; }
.collection-screen .collection-filters { padding: 12px; margin: -4px 0 12px; background: var(--surface-blue); border: 0; border-radius: 16px; }
.collection-screen .collection-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 0 12px; }
.collection-list.record-grid { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 0; }
.collection-list.record-grid > .pg-list-row, .collection-list.record-grid > .pg-task-row { width: 100%; margin: 0; }

/* Equipment and project records use a card hierarchy: heading, facts, then progress. */
.record-grid--equipment .pg-list-row, .record-grid--projects .pg-list-row {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  align-content: start;
  min-height: 184px;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-card);
}
.record-grid--equipment .pg-row-top, .record-grid--projects .pg-row-top { align-items: flex-start; }
.record-grid--equipment .pg-row-title, .record-grid--projects .pg-row-title { font-size: 16px; font-weight: 800; line-height: 1.35; }
.record-grid--equipment .pg-row-meta, .record-grid--projects .pg-row-meta { align-content: flex-start; min-height: 38px; padding: 10px; background: var(--surface-soft); border-radius: 12px; font-size: 11px; }
.record-grid--equipment .pg-row-progress, .record-grid--projects .pg-row-progress { align-self: end; padding-top: 4px; color: var(--ink-soft); }
.record-grid--equipment .pg-row-note, .record-grid--projects .pg-row-note { color: var(--ink-soft); font-size: 11px; }
.record-grid--projects .pg-row-progress { order: 4; }
.record-grid--projects .pg-row-meta { order: 3; }

/* Work orders use a tappable two-column card: completion state, content, then actions. */
.record-grid--tasks .pg-task-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: start;
  min-height: 132px;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.record-grid--tasks .pg-task-row:hover { border-color: #d3e0e9; box-shadow: var(--shadow-raised); }
.record-grid--tasks .pg-task-check { width: 28px; height: 28px; margin: 0; border-color: #bfd0dd; border-radius: 10px; }
.record-grid--tasks .pg-task-check.checked { background: var(--success); border-color: var(--success); }
.record-grid--tasks .pg-task-body { display: grid; min-width: 0; gap: 10px; }
.record-grid--tasks .pg-task-heading { color: var(--ink); font-size: 15px; font-weight: 800; line-height: 1.4; }
.record-grid--tasks .pg-task-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; padding: 10px; color: var(--ink-soft); background: var(--surface-soft); border-radius: 12px; font-size: 11px; line-height: 1.4; }
.record-grid--tasks .pg-task-body > .avatar-stack { margin-top: 0; }
.record-grid--tasks .task-delete-btn, .record-grid--tasks .task-return-delete-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--surface-soft); }

@media (min-width: 640px) {
  .collection-screen .collection-panel { padding-inline: 24px; }
  .collection-list.record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .record-grid--tasks { grid-template-columns: 1fr !important; }
}
@media (min-width: 1180px) {
  .record-grid--equipment, .record-grid--projects { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .record-grid--tasks { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 390px) {
  .collection-screen .collection-panel { padding-inline: 12px; }
  .collection-screen .collection-stats { gap: 8px; }
  .collection-screen .collection-stats .pg-stat-cell { padding: 10px 8px; }
  .record-grid--tasks .pg-task-row { grid-template-columns: 28px minmax(0, 1fr); padding: 14px; }
  .record-grid--tasks .task-delete-btn, .record-grid--tasks .task-return-delete-btn { grid-column: 2; justify-self: end; }
}

/* Record details have their own information architecture, not just a list of fields. */
.detail-workspace { display: grid; gap: 16px; }
.detail-hero { position: relative; display: grid; gap: 18px; overflow: hidden; padding: 22px; color: #fff; background: linear-gradient(135deg, var(--navy-dark), var(--navy)); border-radius: var(--radius-large); box-shadow: 0 18px 38px rgba(53,83,111,.2); }
.detail-hero::after { content: ''; position: absolute; inset: -70px -58px auto auto; width: 210px; height: 210px; border: 36px solid rgba(255,255,255,.07); border-radius: 50%; pointer-events: none; }
.detail-hero-main { position: relative; z-index: 1; display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
.detail-hero-icon { width: 48px; height: 48px; display: inline-flex; flex: 0 0 48px; align-items: center; justify-content: center; color: var(--coral); background: #fff; border-radius: 16px; box-shadow: 0 8px 18px rgba(22,44,64,.18); overflow: hidden; }
.detail-hero-icon svg { width: 24px; height: 24px; }
.detail-hero-icon--photo { width: 76px; height: 76px; flex: 0 0 76px; border-radius: 20px; border: 2px solid rgba(255,255,255,.5); }
.detail-hero-icon--photo img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero-copy { min-width: 0; flex: 1; }
.detail-hero-eyebrow { margin: 0 0 5px; color: #cbdde9; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.detail-hero-title { margin: 0; color: #fff; font-size: clamp(22px, 5vw, 30px); font-weight: 800; line-height: 1.2; letter-spacing: -.025em; overflow-wrap: anywhere; }
.detail-hero-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 9px; color: #d5e4ee; font-size: 12px; }
.detail-hero-meta-item { display: inline-flex; align-items: center; gap: 5px; }
.detail-hero-status { position: relative; z-index: 1; align-self: start; margin-inline-start: auto; }
.detail-hero-status .detail-status-chip { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.25); }
.detail-hero-progress { position: relative; z-index: 1; padding: 13px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); border-radius: 16px; }
.detail-hero-progress-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: #dceaf3; font-size: 11px; font-weight: 700; }
.detail-hero-progress-label strong { color: #fff; }
.detail-hero-progress .progress-wrap { height: 6px !important; background: rgba(255,255,255,.22); }
.detail-hero-progress .progress-bar { background: var(--coral); }
.detail-quick-actions { position: relative; inset: auto; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; }
.detail-quick-actions .btn { flex: 1 1 140px; }
.detail-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.detail-summary-card { min-width: 0; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-card); }
.detail-summary-label, .detail-summary-card__label { display: block; margin-bottom: 5px; color: var(--ink-muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.detail-summary-value, .detail-summary-card__value { display: block; overflow: hidden; color: var(--ink); font-size: 16px; font-weight: 800; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.detail-summary-caption, .detail-summary-card__caption { display: block; margin-top: 4px; color: var(--ink-soft); font-size: 11px; line-height: 1.35; }
.detail-main-grid { display: grid; gap: 16px; align-items: start; }
.detail-primary-column, .detail-aside { display: grid; gap: 14px; min-width: 0; }
.detail-section-heading { display: grid; gap: 3px; margin: 2px 0 0; }
.detail-section-heading h2, .detail-section-heading h3 { margin: 0; color: var(--ink); font-size: 16px; font-weight: 800; }
.detail-section-heading p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.detail-section-eyebrow { margin: 0 0 3px !important; color: var(--coral) !important; font-size: 10px !important; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.detail-section-description { margin-top: 4px !important; }
.detail-status-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--detail-status-color, var(--navy)); background: var(--surface-blue); font-size: 11px; font-weight: 800; }
.detail-status-chip::before { content: ''; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: currentColor; }
.detail-status-chip--success { color: #27834f; background: #e6f6ec; border-color: #ccebd8; }
.detail-status-chip--danger { color: #c24a4a; background: #ffe9e7; border-color: #ffd1cd; }
.detail-status-chip--active { color: #3078a9; background: #e7f3fc; border-color: #cfe5f5; }
.detail-status-chip--muted, .detail-status-chip--neutral { color: var(--ink-soft); background: var(--surface-soft); }
.detail-info-field { padding: 13px 0; border-bottom: 1px solid var(--line); }
.detail-info-field:last-child { border-bottom: 0; }
.detail-info-field label { display: block; margin-bottom: 4px; color: var(--ink-muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.detail-info-field span { color: var(--ink); font-size: 13px; font-weight: 650; line-height: 1.5; }
.detail-side-card { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.detail-side-card > h2, .detail-side-card > h3 { margin: 0 0 12px; color: var(--ink); font-size: 14px; font-weight: 800; }
.detail-progress-card { background: var(--surface-blue); border-color: transparent; }
.detail-context-list { display: grid; gap: 10px; margin: 0; }
.detail-context-list > div { display: grid; grid-template-columns: minmax(72px, .7fr) minmax(0, 1.3fr); gap: 12px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.detail-context-list > div:last-child { padding-bottom: 0; border: 0; }
.detail-context-list dt { color: var(--ink-muted); font-size: 11px; font-weight: 700; }
.detail-context-list dd { min-width: 0; margin: 0; color: var(--ink); font-size: 12px; font-weight: 700; overflow-wrap: anywhere; text-align: end; }
.detail-assignee-preview .member-card { box-shadow: none; }
.task-file-upload { display: grid; gap: 9px; padding: 14px; margin-bottom: 12px; background: var(--coral-soft); border-radius: 16px; }
.task-file-upload small { color: var(--ink-soft); font-size: 11px; }
.detail-empty-state { padding: 26px 18px; color: var(--ink-soft); background: var(--surface-soft); border-radius: 16px; text-align: center; }

@media (min-width: 860px) {
  .detail-hero { grid-template-columns: minmax(0, 1fr) 230px; padding: 28px; }
  .detail-hero-main { grid-column: 1; }
  .detail-hero-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .detail-hero-progress { grid-column: 2; grid-row: 2; }
  .detail-quick-actions { grid-column: 1; }
  .detail-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .detail-main-grid { grid-template-columns: minmax(0, 1.55fr) minmax(260px, .7fr); }
}
@media (max-width: 480px) {
  .detail-hero { padding: 18px; border-radius: 22px; }
  .detail-hero-icon { width: 42px; height: 42px; flex-basis: 42px; border-radius: 13px; }
  .detail-hero-icon--photo { width: 60px; height: 60px; flex-basis: 60px; border-radius: 16px; }
  .detail-hero-title { font-size: 21px; }
  .detail-summary-card { padding: 12px; }
  .detail-summary-card__value { font-size: 14px; }
  .detail-quick-actions .btn { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }

/* Dashboard: equal KPI cards, predictable widgets and a phone-first grid. */
#dashboard-content {
  width: min(100%, 1440px);
  margin-inline: auto;
  padding: 16px !important;
  gap: 20px !important;
}
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
  width: 100%;
}
.dashboard-kpi-card {
  appearance: none;
  min-width: 0;
  min-height: 174px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  overflow: hidden;
  text-align: start;
  cursor: pointer;
  border-radius: var(--radius-card);
  transition: transform 180ms cubic-bezier(.2,.8,.2,1), box-shadow 180ms cubic-bezier(.2,.8,.2,1), border-color 180ms cubic-bezier(.2,.8,.2,1);
}
.dashboard-kpi-card:hover { transform: translateY(-3px); border-color: #d5e2eb; box-shadow: var(--shadow-raised); }
.dashboard-kpi-card:active { transform: scale(.98); }
.dashboard-kpi-card__top, .dashboard-kpi-card__value-row, .dashboard-kpi-card__trend { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.dashboard-kpi-card__title { color: var(--ink-soft); font-size: 11px; font-weight: 800; letter-spacing: .06em; line-height: 1.4; text-transform: uppercase; }
.dashboard-kpi-card__marker { width: 18px; height: 18px; flex: 0 0 18px; border: 2px solid var(--coral); border-radius: 50%; }
.dashboard-kpi-card__value { min-width: 0; color: var(--ink); font-size: clamp(27px, 7vw, 34px); font-weight: 800; line-height: 1; overflow: hidden; text-overflow: ellipsis; }
.dashboard-kpi-card__sparkline { flex: 0 1 100px; min-width: 0; color: var(--coral); }
.dashboard-kpi-card__sparkline svg { display: block; width: 100%; height: auto; margin: 0 !important; }
.dashboard-kpi-card__trend { justify-content: flex-start; font-size: 11px; font-weight: 600; }
.dashboard-kpi-card__trend-value { font-weight: 800; white-space: nowrap; }
.dashboard-kpi-card__trend-label { color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dash-widgets-grid { display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 16px; width: 100%; }
.widget-grid-item { min-width: 0; display: flex; }
.dash-widget { width: 100%; min-height: 360px; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.dash-widget-header { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--surface-blue); border-bottom: 1px solid var(--line); }
.dash-widget-header h3 { margin: 0; color: var(--ink); font-size: 14px; font-weight: 800; line-height: 1.35; }
.dash-widget-actions { display: flex; flex: 0 0 auto; gap: 4px; }
.dash-widget-actions .btn-icon { width: 36px; height: 36px; min-height: 36px; border-radius: 10px; }
.dash-widget-body { position: relative; flex: 1; min-height: 0; padding: 16px; }
.dashboard-chart { width: 100%; height: 280px; display: flex; align-items: center; justify-content: center; }
.dash-widget.fullscreen { position: fixed; inset: 16px; z-index: 7000; min-height: 0; }
.dash-widget.fullscreen .dashboard-chart { height: min(70vh, 620px); }

@media (min-width: 600px) {
  #dashboard-content { padding: 20px !important; }
  .dash-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .dash-widgets-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
  .widget-grid-item--small { grid-column: span 4; }
  .widget-grid-item--medium { grid-column: span 6; }
  .widget-grid-item--large { grid-column: span 8; }
  .widget-grid-item--full { grid-column: 1 / -1; }
}
@media (min-width: 1024px) {
  #dashboard-content { padding: 24px !important; }
  .dash-kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .dashboard-kpi-card { min-height: 182px; }
}
@media (max-width: 390px) {
  .dashboard-kpi-card { min-height: 158px; padding: 14px; gap: 12px; }
  .dashboard-kpi-card__sparkline { display: none; }
  .dashboard-kpi-card__title { font-size: 10px; }
  .dashboard-kpi-card__trend-label { display: none; }
  .dash-widget-body { padding: 12px; }
  .dashboard-chart { height: 240px; }
}

/* Shared list, detail, and workflow presentation across every module. */
.pg-tab-panel, .pg-scroll-area, .tasks-container, .milestones-container, .form-container, .detail-container {
  scrollbar-color: #cbd9e4 transparent;
  scrollbar-width: thin;
}
.pg-filter-row { display: flex; flex-wrap: wrap; padding: 0 0 14px; }
.pg-filter-row .filter-select { flex: 1 1 180px; }
.pg-stats-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; padding: 0; background: transparent; border: 0; }
.pg-stat-cell { min-width: 0; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-card); }
.pg-stat-cell + .pg-stat-cell { border-inline-start: 1px solid var(--line); }
.pg-stat-num { color: var(--navy); font-size: 20px; }
.pg-badge, .pg-chip, .rp-status-badge, .att-status-pill, .wh-sku { border-radius: 999px; border: 0; }
.pg-badge { padding: 5px 9px; font-weight: 800; }
.pg-chip { padding: 7px 12px; background: var(--surface-blue); color: var(--navy); }
.pg-empty, .rp-empty, .member-empty, .linked-empty, .task-empty-block, .notif-empty {
  padding: 36px 20px; color: var(--ink-soft); background: var(--surface); border: 1px dashed #cad9e4; border-radius: var(--radius-card); box-shadow: var(--shadow-card); text-align: center;
}
.pg-empty svg, .notif-empty svg { color: var(--coral); }
.pg-empty strong, .notif-empty strong { color: var(--ink); font-size: 15px; }

/* Detail pages retain an open, native-app information layout. */
.detail-container { gap: 16px; padding: 16px; padding-bottom: 108px; }
.detail-tab-host { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detail-tab-bar { display: flex; gap: 8px; padding: 0 2px; overflow-x: auto; scrollbar-width: none; background: transparent; border: 0; }
.detail-tab-bar::-webkit-scrollbar { display: none; }
.detail-tab-btn { min-height: 40px; flex: 0 0 auto; padding: 8px 13px; color: var(--ink-soft); background: var(--surface); border: 1px solid transparent; border-radius: 999px; box-shadow: var(--shadow-card); font-size: 12px; font-weight: 800; }
.detail-tab-btn::after { display: none; }
.detail-tab-btn.active { color: #fff; background: var(--navy); border-color: var(--navy); }
.tab-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; margin-inline-start: 3px; padding-inline: 5px; border-radius: 999px; background: rgba(255,255,255,.22); color: currentColor; font-size: 10px; }
.detail-tab-panel { padding: 0; background: transparent; }
.detail-tab-body { padding: 0; }
.detail-section { box-shadow: var(--shadow-card); }
.detail-section + .detail-section { margin-top: 14px; }
.detail-section-title { display: flex; align-items: center; min-height: 48px; font-size: 12px; letter-spacing: .07em; }
.detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--line); }
.detail-field { min-height: 78px; justify-content: center; gap: 5px; }
.detail-field label { font-size: 10px; line-height: 1.2; letter-spacing: .06em; }
.detail-field span { font-size: 13px; font-weight: 650; line-height: 1.45; }
.detail-actions { position: sticky; inset-block-end: 0; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: rgba(234,241,248,.94); border-top: 1px solid rgba(228,235,241,.8); box-shadow: 0 -8px 22px rgba(47,76,101,.08); backdrop-filter: blur(12px); z-index: 4; }
.detail-actions .btn { flex: 1 1 132px; }
.project-detail-progress { padding: 18px; background: var(--navy); color: #fff; border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.pdp-header { color: #fff; }
.pdp-pct { color: #fff; }
.pdp-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pdp-stat-card { min-width: 0; padding: 12px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.15); border-radius: 16px; color: #fff; }
.pdp-stat-card svg, .pdp-stat-label, .pdp-stat-nums span { color: #d9e8f3; }
.pdp-stat-nums strong { color: #fff; }
.project-detail-progress .progress-wrap { background: rgba(255,255,255,.22); }
.project-detail-progress .progress-bar { background: var(--coral); }

/* Comments, activity, attachments, memberships and tool cards. */
.member-card, .task-comment-card, .task-file-item, .task-note-card, .task-timeline-item, .wh-invoice-card, .wh-project-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-card);
}
.member-card, .task-comment-card, .task-file-item, .task-note-card { padding: 14px; }
.task-comment-form { padding: 14px; background: var(--surface-blue); border: 0; border-radius: var(--radius-card); }
.task-comment-form textarea { min-height: 100px; background: #fff; }
.task-comment-actions { padding-top: 10px; }
.task-timeline-item { padding: 13px 14px 13px 28px; border: 0; box-shadow: none; }
.task-timeline-item::before { inset-inline-start: 13px; background: var(--coral); }
.task-file-item:hover, .member-card:hover, .tool-card:hover, .wh-product-card:hover, .wh-invoice-card:hover, .wh-project-card:hover { border-color: #d6e2eb; }

.add-member-control { display: flex; gap: 8px; margin-bottom: 14px; }
.member-card { position: relative; align-items: center; }
.member-card-remove {
  margin-inline-start: auto;
  width: 28px; height: 28px; flex-shrink: 0;
  color: var(--ink-soft, #718293);
  border-radius: 50%;
}
.member-card-remove:hover { color: var(--clr-danger, #ef4444); background: rgba(239,68,68,.08); }
.tools-grid, .wh-product-grid, .export-format-options { gap: 12px; }
.tool-card { min-height: 84px; border-radius: var(--radius-card); }
.tool-card-icon { background: var(--surface-blue); border-radius: 14px; }
.tool-card-copy strong, .wh-product-card__name, .wh-invoice-card__number { color: var(--ink); }
.tool-card-copy small, .wh-product-card__meta, .wh-invoice-card__meta { color: var(--ink-soft); }
.wh-product-card { border-radius: var(--radius-card); }
.wh-product-card__icon-wrap { background: var(--surface-blue); }

/* Form and desktop behavior stays spacious without stretching content. */
.form-container { width: min(100%, 900px); margin-inline: auto; padding: 16px; }
.form-section-divider { background: var(--line); margin-block: 6px; }
.form-actions { padding-top: 8px; }
.export-section, .import-section, .qr-section, .profile-info-card, .profile-password-card, .profile-admin-card, .att-clock-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.export-format-card, .qr-size-card { background: var(--surface-soft); border-color: transparent; border-radius: 16px; }
.export-format-radio input:checked + .export-format-card { background: var(--coral-soft); border-color: var(--coral); }

/* Form structure was previously undefined beyond two columns. */
.form-row-2, .form-row-3, .form-row-4 { display: grid; align-items: start; gap: 14px; }
.form-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-group { min-width: 0; }
.form-container > .form-section-title, .form-container > h2, .form-container > h3 { color: var(--ink); }
.workflow-form { display: grid; gap: 16px; }
.form-card { display: grid; gap: 16px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.form-card__heading { margin: 0; color: var(--ink); font-size: 16px; font-weight: 800; line-height: 1.3; }
.form-card .form-section-divider { height: auto; margin: 4px 0 0; padding: 6px 0; color: var(--navy); background: transparent; border: 0; border-top: 1px solid var(--line); font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.form-card .form-section-divider .toggle-switch { float: none !important; margin-inline-start: auto !important; }
.form-card .form-section-divider:has(.toggle-switch) { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

@media (min-width: 769px) {
  .pg-tab-panel, .tasks-container, .milestones-container { width: min(100%, 1440px); margin-inline: auto; padding: 20px 24px 30px; }
  .detail-container { width: min(100%, 960px); margin-inline: auto; padding: 24px 24px 32px; }
  .detail-actions { position: static; margin: 4px 0 0; padding: 0; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; }
  .detail-actions .btn { flex: 0 1 auto; }
  .detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .pg-tab-panel, .form-container, .detail-container { padding-inline: 12px; }
  .pg-list-row, .pg-row, .project-card, .task-card { padding: 14px; border-radius: 18px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-field { min-height: 66px; }
  .detail-actions { margin-inline: -12px; padding-inline: 12px; }
  .pdp-stats { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .form-card { padding: 14px; border-radius: 18px; }
}

/* Rebuilt screen hierarchy: compact app bar → contextual hero → controls → results. */
.screen[data-layout-enhanced='true'] .app-header .header-title span { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.screen[data-layout-enhanced='true'] .app-header .header-title small { display: none; }
/* Warehouse and quotation views receive the same compact app-bar treatment
   once their contextual page title has been added by layout-enhancer.js. */
.wh-view-shell[data-layout-enhanced='true'] .app-header .header-title span,
.q-view-shell[data-layout-enhanced='true'] .app-header .header-title span { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.wh-view-shell[data-layout-enhanced='true'] .app-header .header-title small,
.q-view-shell[data-layout-enhanced='true'] .app-header .header-title small { display: none; }
.page-context {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 156px;
  margin-bottom: 16px;
  padding: 24px;
  overflow: hidden;
  border-radius: var(--radius-large);
  color: #fff;
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  box-shadow: 0 16px 34px rgba(53,83,111,.18);
}
.page-context::before { content: ''; position: absolute; z-index: -1; inset: auto -48px -76px auto; width: 190px; height: 190px; border: 38px solid rgba(255,255,255,.08); border-radius: 50%; }
.page-context__copy { position: relative; z-index: 1; max-width: 620px; }
.page-context__eyebrow { display: block; margin-bottom: 6px; color: #c6d7e6; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.page-context__title { margin: 0; color: #fff; font-size: clamp(24px, 4vw, 30px); font-weight: 800; line-height: 1.15; letter-spacing: -.025em; }
.page-context__description { max-width: 570px; margin: 8px 0 0; color: #dfebf4; font-size: 13px; line-height: 1.6; }
.page-context__orb { position: absolute; inset: 20px 28px auto auto; width: 44px; height: 44px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 10px rgba(255,255,255,.08); }
.page-context--compact { min-height: 122px; margin: 0 16px 14px; }
.page-workspace__controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 16px; }
.page-workspace__controls > .pg-filter-bar, .page-workspace__controls > .pg-filter-row, .page-workspace__controls > .pg-stats-strip, .page-workspace__controls > .members-section { margin: 0; }
.page-workspace__results { display: grid; min-width: 0; gap: 14px; }
.page-workspace__results > .pg-list { min-width: 0; }

/* Dedicated layouts for warehouse and quotation screens that have their own views. */
.wh-view-shell, .q-view-shell { background: transparent; }
.wh-view-shell > .pg-filter-bar, .q-view-shell > .pg-filter-bar { margin-inline: 16px; }
.wh-view-shell > .pg-list, .q-view-shell > .pg-list, .wh-view-shell > .pg-empty, .q-view-shell > .pg-empty { margin-inline: 16px; }
.wh-view-shell > .pg-list, .q-view-shell > .pg-list { padding-inline: 0 !important; }
.wh-view-shell > .pg-empty, .q-view-shell > .pg-empty { margin-top: 14px; }

@media (min-width: 769px) {
  .page-context { min-height: 174px; padding: 30px 32px; }
  .page-workspace__controls { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
  .page-workspace__controls > .pg-filter-bar { grid-column: 1 / -1; }
  .page-workspace__controls > .pg-stats-strip { grid-column: 1 / -1; }
  .page-context--compact { margin-inline: 24px; }
  .wh-view-shell > .pg-filter-bar, .q-view-shell > .pg-filter-bar, .wh-view-shell > .pg-list, .q-view-shell > .pg-list, .wh-view-shell > .pg-empty, .q-view-shell > .pg-empty { margin-inline: 24px; }
}

/* Mobile gets its own application chrome instead of a compressed desktop rail. */
@media (max-width: 768px) {
  body.app-shell-sidebar-active .screen:not(#screen-login):not(#screen-splash) { padding: 0 !important; }
  body.app-shell-sidebar-active .screen:not(#screen-login):not(#screen-splash) .app-header { display: flex !important; }
  body.app-shell-sidebar-active .bottom-nav:not(.app-sidebar__nav).visible { display: flex !important; }
  body.app-shell-sidebar-active .app-sidebar { display: none !important; }
  body.app-shell-sidebar-active .app-sidebar__reopen { display: none !important; }
  /* The header action is thumb-safe at this breakpoint; avoid a duplicate
     floating + button over the bottom navigation. */
  .app-fab { display: none !important; }
  .page-context { min-height: 136px; padding: 20px; border-radius: 24px; }
  .page-context__orb { inset: 19px 22px auto auto; width: 34px; height: 34px; }
  .page-context--compact { margin-inline: 12px; }
  .wh-view-shell > .pg-filter-bar, .q-view-shell > .pg-filter-bar, .wh-view-shell > .pg-list, .q-view-shell > .pg-list, .wh-view-shell > .pg-empty, .q-view-shell > .pg-empty { margin-inline: 12px; }
}

/* -------------------------------------------------------------------------
   Subscription lock overlay — admin-tier-only, anti-bypass full-screen
   block shown when the company subscription is genuinely expired (not
   just the softer day-24 renewal-due banner). Navigation is redirected
   back to the Subscription screen structurally in app.js's showScreen(),
   so this overlay is the only thing that can be interacted with besides
   that one screen.
-------------------------------------------------------------------------- */
.subscription-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 28, 38, .82);
  backdrop-filter: blur(6px);
}
.subscription-lock-overlay.show { display: flex; }
.subscription-lock-box {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  background: var(--surface, #fff);
  border-radius: 24px;
  box-shadow: 0 30px 70px rgba(0,0,0,.4);
  text-align: center;
}
.subscription-lock-icon { font-size: 40px; margin-bottom: 10px; }
.subscription-lock-box h2 { margin: 0 0 10px; font-size: 19px; font-weight: 800; color: var(--ink, #1f2d3d); }
.subscription-lock-box p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.6; color: var(--ink-soft, #556170); }
.subscription-lock-note {
  padding: 10px 12px;
  background: var(--surface-blue, #eef5fa);
  border-radius: 12px;
  font-size: 12.5px !important;
}
.subscription-lock-box .btn { width: 100%; margin-top: 6px; min-height: 46px; }

/* Defense-in-depth: hide the nav chrome while locked, even though the
   overlay itself already covers the whole viewport. */
body.subscription-locked .app-sidebar,
body.subscription-locked .bottom-nav,
body.subscription-locked .mobile-nav-sheet {
  display: none !important;
}
