/* Material Symbols (Apache-2.0), served from this app so icons work without Google Fonts. */
@font-face {
  font-family: "Material Symbols Outlined";
  font-style: normal;
  font-weight: 100 700;
  font-display: block;
  src: url("fonts/material-symbols-outlined.woff2") format("woff2");
}
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; overflow: hidden;
  -webkit-font-smoothing: antialiased; font-feature-settings: "liga";
  /* Square from the start: while the font loads the icon's name ("account_tree") is laid out
     invisibly, and without a fixed width the menu text would jump left once the icon appears. */
  width: 1em; height: 1em; flex-shrink: 0;
}
/* ============================================================
   Stylesheet.html  (NGSF v2.10.1)
   Version must match NGSF_VERSION in Code.gs.
   ============================================================ */
:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --border: #e3e5e8;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --radius: 8px;
  --topbar-height: 56px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
}
#app { display: flex; min-height: calc(100vh - var(--topbar-height)); margin-top: var(--topbar-height); }
#sidebar { overflow-y: auto; }
#pageNav { flex: 1; overflow-y: auto; }

.mobile-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  background: none; border: none; border-radius: var(--radius);
  font-size: 18px; cursor: pointer; color: var(--text);
}
.mobile-menu-btn:hover { background: var(--border); }
#sidebarOverlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 65;
}
#sidebarOverlay.visible { display: block; }

#sidebar {
  width: 230px; min-width: 230px;
  flex-shrink: 0;
  background: var(--secondary-tint);
  border-right: 1px solid var(--border);
  padding: 10px 12px 16px; /* role-bar carries its own top padding — no double gap above it */
  display: flex; flex-direction: column;
  transition: width 0.22s ease, min-width 0.22s ease, padding 0.22s ease;
  overflow: hidden;
  position: relative;
}
/* Collapsed state — icon-only rail */
#sidebar.collapsed {
  width: 54px; min-width: 54px;
  padding: 16px 6px;
}
#sidebar.collapsed .nav-link-text,
#sidebar.collapsed .nav-group-label { opacity: 0; pointer-events: none; width: 0; padding: 0; margin: 0; overflow: hidden; white-space: nowrap; }
#sidebar.collapsed #pageNav a { justify-content: center; padding: 9px 4px; }
#sidebar.collapsed #pageNav a .nav-icon { margin-right: 0; }
#sidebar.collapsed .nav-group-summary { justify-content: center; padding: 6px 4px; }
#sidebar.collapsed .nav-group-items { padding-left: 0; }
#sidebar.collapsed #sidebarCollapseBtn { transform: rotate(180deg); }

/* Role bar collapses to just the two icon buttons, stacked */
#sidebar.collapsed .role-bar-label,
#sidebar.collapsed .role-switcher { display: none; }
#sidebar.collapsed .role-bar-row { flex-direction: column; gap: 6px; }
#sidebar.collapsed .role-bar-actions { flex-direction: column; width: 100%; gap: 6px; }
#sidebar.collapsed .sidebar-collapse-btn { width: 100%; height: 30px; }
/* Collapse toggle button */
.sidebar-collapse-btn {
  flex-shrink: 0; opacity: 1; visibility: visible;
  background: var(--panel); border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text); font-size: 18px; line-height: 1;
  width: 28px; height: 28px; min-width: 28px; border-radius: 6px;
  transition: transform 0.22s ease, color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.role-bar-actions { min-width: 68px; } /* reserves room so the label's flex:1 can never crush the buttons to 0 */
.sidebar-collapse-btn:hover { background: var(--border); }
/* Refresh sits left of the toggle: it takes the auto margin, the toggle
   following it drops back to a small fixed gap. Muted until hover, and
   the collapsed rotate (which targets the toggle only) never spins it. */
.nav-refresh-btn { color: var(--muted); font-size: 15px; }
.nav-refresh-btn:hover { color: var(--text); }
#sidebar.collapsed .nav-refresh-btn { transform: none; }
.nav-link-text { transition: opacity 0.18s; overflow-wrap: break-word; min-width: 0; line-height: 1.35; }
.nav-group-label { transition: opacity 0.18s; overflow-wrap: break-word; min-width: 0; line-height: 1.3; }
.nav-icon, .section-title-icon { margin-right: 6px; flex-shrink: 0; }
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  font-size: 16px; line-height: 1;
}
#pageNav a {
  display: flex;
  align-items: center;
  padding: 9px 10px;
  margin-bottom: 2px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}
#pageNav a:hover { background: rgba(0,0,0,.05); }
#pageNav a.active { background: var(--primary); color: white; }

/* ---- Menu groups (collapsible "menu" with "submenu" pages) ----
   Sidebar: a normal accordion — summary toggles indented child links.
   Topbar: the summary becomes a nav item whose children render as a
   floating dropdown instead of pushing the bar taller. */
.nav-group { margin-bottom: 2px; }
.nav-group-summary {
  display: flex; align-items: center;
  padding: 7px 10px; margin: 8px 0 3px;
  border-radius: var(--radius);
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  cursor: pointer; list-style: none; user-select: none;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.nav-group-summary::-webkit-details-marker { display: none; }
.nav-group-summary::before { content: '▸'; display: inline-block; width: 14px; color: var(--primary); flex-shrink: 0; }
.nav-group[open] > .nav-group-summary::before { content: '▾'; }
.nav-group-summary:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); }
.nav-group-items { padding-left: 18px; }
.nav-group-items a { font-size: 13.5px; }

body.nav-topbar .nav-group { position: relative; margin-bottom: 0; }
body.nav-topbar .nav-group-summary { margin-bottom: 0; }
body.nav-topbar .nav-group-summary::before { content: ''; }
body.nav-topbar .nav-group-summary::after { content: ' ▾'; color: var(--muted); font-size: 11px; }
body.nav-topbar .nav-group-items {
  position: absolute; top: 100%; left: 0; z-index: 50; padding-left: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; min-width: 170px; box-shadow: 0 6px 16px rgba(15,23,42,.1);
}
body.nav-topbar .nav-group-items a { display: block; margin-bottom: 1px; }

/* ---- Top-bar layout variant (set via Config_Branding NavStyle) ----
   Reuses the same #sidebar/.brand/#pageNav elements as the default
   sidebar layout — just re-flowed horizontally across the top instead
   of down the left edge. */
/* nav-topbar mode (Config_Branding NavStyle) keeps its own nav-across-
   the-top layout and does NOT use the new fixed #appTopBar — the two
   would visually double up. #appTopBar is hidden in this mode. */
body.nav-topbar #appTopBar { display: none; }
body.nav-topbar #app { flex-direction: column; margin-top: 0; min-height: 100vh; }
body.nav-topbar #sidebar {
  width: 100%; flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center;
  padding: 10px 20px; border-right: none; border-bottom: 1px solid var(--border);
}
body.nav-topbar .role-bar { padding: 0; margin-right: 24px; border: none; }
body.nav-topbar #pageNav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; align-items: flex-start; }
body.nav-topbar #pageNav a { margin-bottom: 0; }

#content { flex: 1; min-width: 0; padding: 28px 36px; max-width: var(--content-max-width, 1000px); }
.muted { color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }

#pageTitle { margin: 0 0 4px; font-size: 22px; }
#pageDescription { margin: 0 0 24px; }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.nav-refresh-btn.spinning { display: inline-block; animation: spin .7s linear infinite; }

/* ---- Fixed top bar ---- */
#appTopBar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-height);
  z-index: 80; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-logo { width: 28px; height: 28px; object-fit: contain; border-radius: 4px; flex-shrink: 0; }
.topbar-title {
  font-weight: 700; font-size: 16px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Notification bell + badge + dropdown panel */
.notif-bell {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; color: var(--text);
}
.notif-bell:hover { background: var(--border); }
.notif-badge {
  position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px;
  border-radius: 8px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
  padding: 0 3px; box-shadow: 0 0 0 2px var(--panel);
}
.notif-panel {
  position: fixed; top: calc(var(--topbar-height) + 6px); right: 18px; z-index: 90;
  width: 300px; max-height: 360px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15,23,42,.14);
}
.notif-panel-header {
  font-weight: 700; font-size: 13px; padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.notif-panel-empty { padding: 24px 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* Account chip in the top bar */
.topbar-account { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
  text-transform: uppercase; user-select: none;
}
.topbar-account-email {
  font-size: 12.5px; color: var(--text); max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logout-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 4px; border-radius: 6px;
  display: flex; align-items: center; flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.logout-btn:hover { color: #d9534f; background: var(--border); }
.logout-btn .material-symbols-outlined { font-size: 18px; }

/* ---- Role bar: current role + switcher, top of sidebar ---- */
.role-bar {
  padding: 8px 8px 9px; margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.role-bar-caption {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 3px; line-height: 1.2;
}
#sidebar.collapsed .role-bar-caption { display: none; }
.role-bar-row { display: flex; align-items: center; gap: 8px; }
.role-bar-label {
  flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3;
}
.role-bar-label .role-bar-active { color: var(--primary); }
.role-bar-actions { display: flex; gap: 6px; flex-shrink: 0; }
.role-switcher { margin-top: 5px; }
.role-switcher-select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  width: 100%; box-sizing: border-box;
  font-family: var(--font-family); font-size: 12.5px; font-weight: 600;
  padding: 5px 24px 5px 9px; border-radius: var(--radius, 6px);
  border: 1px solid var(--border); background-color: var(--panel); color: var(--text);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.role-switcher-select:hover { border-color: var(--primary); }
.role-switcher-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent); }
.role-switcher-select option { font-family: var(--font-family); color: var(--text); }

/* Letter badge — default icon for pages without one configured */
.nav-icon-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0;
  background: var(--secondary, var(--primary)); color: #fff;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  user-select: none; margin-right: 6px;
}
#sidebar.collapsed .nav-icon-letter { margin-right: 0; }
/* Group badge — outlined letter, collapsed rail only. Compound selector
   (.nav-icon-letter.nav-group-badge) outranks the base .nav-icon-letter
   rule regardless of source order. */
.nav-icon-letter.nav-group-badge {
  display: none;
  margin-right: 6px;
  background: transparent; color: var(--primary);
  border: none; font-size: 12px;
}
#sidebar.collapsed .nav-icon-letter.nav-group-badge { display: inline-flex; margin-right: 0; }
#sidebar.collapsed .nav-group-summary::before { display: none; }
/* Safety net: if the badge span isn't present (older JS), keep the ▸
   marker visible so a collapsed group is never a blank row */
#sidebar.collapsed .nav-group-summary:not(:has(.nav-group-badge))::before {
  display: inline-block; width: auto;
}

/* ---- Icon row actions (View / Edit / Delete) ---- */
.row-action {
  background: none; border: none; cursor: pointer;
  color: var(--primary); padding: 3px 4px; border-radius: 5px;
  line-height: 1; vertical-align: middle;
}
.row-action:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.row-action-danger { color: #d9534f; }
.row-action-danger:hover { background: rgba(217, 83, 79, 0.12); }
/* Sized to sit level with the table's 13.5px text */
.row-action .row-action-icon.material-symbols-outlined { font-size: 16px; display: block; }
.row-action .row-action-icon { font-size: 13.5px; }
@media (max-width: 720px) {
  .row-action .row-action-icon.material-symbols-outlined { font-size: 15px; }
}
.btn-add-icon.material-symbols-outlined { font-size: 16px; vertical-align: -3px; margin-right: 2px; }

/* ---- Master-detail line-items grid in the Add form ---- */
.form-lines-block {
  grid-column: 1 / -1; /* #modalFields is a 2-column grid — span it fully */
  margin-top: 16px; padding-top: 12px;
  border-top: 2px solid var(--border);
}
.form-lines-title {
  font-weight: 700; font-size: 13px; color: var(--primary);
  margin-bottom: 8px;
}
/* Horizontal scroll wrapper: many-column grids scroll instead of
   crushing. Deliberately overflow-X only (not the overflow shorthand)
   — overflow-y stays at its default, visible, so a searchable-select
   dropdown opened in the last row can extend below the container
   without being clipped. (An earlier version of this used a large
   padding-bottom + compensating negative margin to fake the same
   effect — that hack rendered inconsistently in Safari, where the
   phantom padding area intercepted clicks on the "+ Add line" button
   sitting right after it. overflow-x-only achieves the same visual
   result with no such risk, in every browser.) */
.form-lines-scroll { overflow-x: auto; margin-bottom: 8px; }
.form-lines-table { width: 100%; border-collapse: collapse; }
.form-lines-table th {
  text-align: left; font-size: 11px; color: var(--muted);
  font-weight: 600; padding: 4px 8px 4px 0; white-space: nowrap;
}
.form-lines-table td { padding: 3px 8px 3px 0; vertical-align: top; }
.form-lines-table input, .form-lines-table select {
  width: 100%; box-sizing: border-box;
  padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); color: var(--text);
}
/* Per-type sizing: numbers and dates stay compact; text stretches.
   Text/select columns share the leftover width via the table layout;
   min-widths stop any column collapsing below usable. */
.form-lines-table input[type="number"]  { min-width: 84px;  max-width: 110px; }
.form-lines-table input[type="date"]    { min-width: 132px; max-width: 150px; }
.form-lines-table input[type="datetime-local"] { min-width: 170px; }
.form-lines-table input[type="time"]    { min-width: 90px;  max-width: 110px; }
.form-lines-table select                { min-width: 110px; }
.form-lines-table input[type="text"],
.form-lines-table input[type="email"]   { min-width: 130px; }
.form-lines-table .line-locked,
.form-lines-table .line-locked:focus {
  background: var(--secondary-tint, #f0f2f5); color: var(--muted);
  cursor: not-allowed; outline: none;
}
.form-lines-remove-cell { width: 28px; }
.form-lines-remove {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; padding: 5px 4px;
  border-radius: 4px; line-height: 1;
}
.form-lines-remove:hover { color: #d9534f; background: var(--border); }
.btn-add-line { font-size: 12.5px; padding: 5px 12px; }

/* Nav tooltip shown beside the collapsed rail */
#navTooltip {
  position: fixed; z-index: 3000;
  background: #1f2328; color: #fff;
  font-size: 12px; line-height: 1; padding: 7px 10px;
  border-radius: 6px; pointer-events: none;
  white-space: nowrap; opacity: 0;
  transition: opacity 0.12s;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
#navTooltip.visible { opacity: 1; }

#loginBackLink { text-decoration: none; align-self: center; }

#appFooter {
  padding: 16px 24px; border-top: 1px solid var(--border); background: var(--panel);
  font-size: 12px; color: var(--muted); text-align: center;
}
#appFooter a { color: var(--primary); }

.section-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.section-tab {
  background: none; border: none; padding: 9px 14px; font-size: 13.5px; font-weight: 500;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.section-tab:hover { color: var(--text); }
.section-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { margin-bottom: 0; }
.tab-group { margin-bottom: 24px; }

.section { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 24px; overflow: hidden; }
.section-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 10px; background: var(--surface-tint); }
.section-header h3 { margin: 0; font-size: 15px; display: flex; align-items: center; }
.section-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Small dropdown menu used by the table header's Export button */
.header-dropdown { position: relative; }
.header-dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 40;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15,23,42,.12);
  min-width: 140px; padding: 4px; display: flex; flex-direction: column;
}
.header-dropdown-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 8px 10px; font-size: 13px; color: var(--text); border-radius: 5px; cursor: pointer;
}
.header-dropdown-item:hover { background: var(--bg); }

.table-toolbar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 10px; row-gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.search-input {
  flex: 1; max-width: 280px; padding: 7px 11px; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: 6px;
}
.search-input:focus { outline: none; border-color: var(--primary); }
.filter-select {
  padding: 6px 9px; font-size: 13px; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); background: var(--panel); cursor: pointer; max-width: 160px;
}
.result-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.result-count-row {
  display: flex; align-items: center; gap: 14px;
  margin-left: auto; flex-wrap: wrap;
}
/* Top pagination bar sits inline on the toolbar's own row — compound
   selector so this reliably beats the base .pagination-bar rule's own
   border/padding regardless of which rule happens to come later in the
   stylesheet (two plain single-class selectors would otherwise just
   depend on source order, which is what let the border leak through). */
.pagination-bar.pagination-bar-top {
  padding: 0; border-top: none; gap: 12px;
  font-size: 12.5px;
}
.pagination-bar-top:empty { display: none; }
.pagination-bar-top .rows-per-page,
.pagination-bar-top .pagination-info { font-size: 12.5px; }

.show-deleted-toggle {
  display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.show-deleted-toggle input { cursor: pointer; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); }
th.sortable.sorted {
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px;
}

.pagination-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); font-size: 13px;
}
.pagination-info { color: var(--muted); white-space: nowrap; }
.pagination-nav { display: flex; align-items: center; gap: 12px; }
.rows-per-page { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.page-size-select {
  padding: 5px 8px; font-size: 13px; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); background: var(--panel); cursor: pointer;
}

tr.row-deleted td { color: var(--muted); background: #fafafa; }
.badge-deleted {
  display: inline-block; font-size: 11px; font-weight: 600; color: var(--danger);
  background: #fde8e8; padding: 1px 7px; border-radius: 999px; margin-left: 6px;
}
.badge-active {
  display: inline-block; font-size: 11px; font-weight: 600; color: #15803d;
  background: #dcfce7; padding: 1px 7px; border-radius: 999px; margin-left: 6px;
}

#detailView { max-width: var(--content-max-width, 1000px); }
.detail-nav-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.detail-nav-row #detailBack { margin-bottom: 0; }
#detailRelatedTables .section { margin-top: 24px; margin-bottom: 0; }
#detailRelatedTables .tab-group { margin-top: 24px; margin-bottom: 0; }
#detailRelatedTables > *:first-child { margin-top: 0; }
.detail-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px;
  margin-bottom: 24px;
}
.detail-card h2 { margin: 0 0 16px; font-size: 18px; }
.detail-deleted-banner {
  background: #fde8e8; color: var(--danger); font-size: 13px; padding: 8px 12px;
  border-radius: 6px; margin-bottom: 14px;
}
.detail-row { padding: 9px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-of-type { border-bottom: none; }
.detail-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; margin-bottom: 3px; }
.detail-value { font-size: 14px; word-break: break-word; }
.detail-empty { color: var(--muted); }
.detail-meta { font-size: 12px; color: var(--muted); margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }

.detail-history-heading { font-size: 13px; margin: 18px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.history-entry { padding: 10px 0; border-bottom: 1px solid var(--border); }
.history-entry:last-child { border-bottom: none; }
.history-entry-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 3px; }
.history-version { font-weight: 600; }
.history-meta { color: var(--muted); margin-left: auto; }
.history-entry-summary { font-size: 13px; color: var(--text); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-container { overflow-x: auto; }
.table-container.table-loading { opacity: .45; pointer-events: none; transition: opacity .15s ease; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
th {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary); font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .02em;
  border-bottom: 2px solid color-mix(in srgb, var(--primary) 20%, var(--border));
}
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; width: 1%; }
.bulk-select-col { width: 1%; padding-left: 16px; padding-right: 6px; text-align: center; }
.bulk-select-col input[type="checkbox"] { cursor: pointer; width: 15px; height: 15px; vertical-align: middle; }

.btn { border: none; border-radius: var(--radius); padding: 7px 13px; font-size: 13.5px; cursor: pointer; font-weight: 500; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #ececef; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { text-decoration: underline; }
.btn-link { background: transparent; color: var(--primary); padding: 4px 6px; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }

.empty-row { color: var(--muted); padding: 18px; font-size: 13.5px; }
.empty-row.error { color: var(--danger); }

#modalOverlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
#modal {
  background: var(--panel); border-radius: 10px;
  width: 560px; max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden;
}
#modal.modal-wide { width: min(940px, 94vw); }
#modal > h2 { padding: 22px 22px 0; margin: 0 0 14px; flex-shrink: 0; }
#modalScrollBody { padding: 0 22px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
#modal .modal-actions {
  padding: 14px 22px; margin-top: 0; flex-shrink: 0;
  border-top: 1px solid var(--border);
}
#modal > h2 { font-size: 17px; }

/* Warehouse visualization */
.wh-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.wh-toolbar select, .wh-toolbar input[type="text"] {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
.wh-toolbar input[type="text"] { min-width: 200px; }
.wh-mode-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.wh-mode-toggle .btn { border: none; border-radius: 0; background: var(--panel); }
.wh-mode-toggle .btn.active { background: var(--primary); color: #fff; }
.wh-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-left: auto; }
.wh-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.15); }
.wh-canvas { padding: 16px; overflow: auto; }

/* ---- Matrix / cross-tab (SectionType: matrix) ---- */
.matrix-scroll { overflow: auto; max-height: 70vh; }
.matrix-table { border-collapse: collapse; font-size: 13.5px; white-space: nowrap; }
.matrix-table th, .matrix-table td {
  border: 1px solid var(--border); padding: 7px 12px; text-align: center;
}
.matrix-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel); font-weight: 700; color: var(--text);
}
.matrix-corner { position: sticky; left: 0; top: 0; z-index: 3; background: var(--panel); }
.matrix-row-header {
  position: sticky; left: 0; z-index: 1;
  background: var(--panel); font-weight: 700; text-align: left; color: var(--text);
}
.matrix-cell { background: var(--panel); }
.matrix-cell-empty { background: var(--bg); color: var(--muted); }
.matrix-header-primary { font-weight: 700; }
.matrix-header-secondary {
  font-weight: 400; font-size: 11px; color: var(--muted);
  margin-top: 1px; white-space: nowrap;
}
.matrix-row-header .matrix-header-primary,
.matrix-row-header .matrix-header-secondary { text-align: left; }
.matrix-cell-clickable { cursor: pointer; transition: background .12s, box-shadow .12s; }
.matrix-cell-clickable:hover { background: color-mix(in srgb, var(--primary) 10%, var(--panel)); box-shadow: inset 0 0 0 1.5px var(--primary); }

/* Route optimization run progress/result modal */
#runRouteOverlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center; z-index: 110;
}
#runRouteModal {
  background: var(--panel); border-radius: 10px; width: 420px; max-width: 92vw;
  padding: 22px; transition: width .15s ease;
}
#runRouteModal.run-route-modal-wide { width: 560px; }
#runRouteModal h2 { margin: 0 0 16px; font-size: 17px; }
.run-route-chart-wrap { height: 220px; margin: 14px 0; }
.run-route-map-wrap { position: relative; margin: 14px 0; }
.run-route-map { width: 100%; height: 320px; border-radius: 8px; border: 1px solid var(--border); }
.run-route-map-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--panel); border-radius: 8px; color: var(--muted); font-size: 13px;
}
.run-route-map-note { font-size: 12px; color: #b45309; margin-top: 6px; }
.run-route-label-tooltip {
  background: rgba(255,255,255,.9) !important; border: none !important; box-shadow: 0 1px 2px rgba(0,0,0,.3) !important;
  font-size: 9px !important; line-height: 1.2 !important; font-weight: 600 !important;
  padding: 0px 4px !important; color: #1e293b !important; white-space: nowrap !important;
  border-radius: 3px !important;
}
.run-route-label-tooltip::before { display: none; } /* hide the default Leaflet tooltip arrow -- looks odd on a permanent label */
.run-route-map-legend {
  position: absolute; bottom: 8px; left: 8px; z-index: 500;
  background: rgba(255,255,255,.95); border-radius: 8px; padding: 6px 10px;
  display: flex; gap: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.2); font-size: 11px;
}
.run-route-map-legend-item { display: flex; align-items: center; gap: 5px; color: #334155; }
.run-route-progress { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.run-route-status { flex: 1; }
.run-route-elapsed { font-size: 12.5px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.run-route-note { font-size: 12.5px; color: var(--muted); margin: 0; }
.run-route-result-row { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.run-route-result-row:last-child { border-bottom: none; }

/* Small floating popup for one matrix cell — deliberately NOT a full
   centered modal; it appears right next to the cell that was clicked. */
#matrixCellPopup {
  position: fixed; z-index: 120;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15,23,42,.16);
  padding: 12px; width: 220px;
}
#matrixCellPopup:has(.matrix-popup-parent-link) { width: 260px; }
.matrix-popup-label {
  font-size: 12px; font-weight: 700; color: var(--muted);
  margin-bottom: 8px; line-height: 1.35;
}
#matrixCellPopupFieldWrap input, #matrixCellPopupFieldWrap select {
  width: 100%; box-sizing: border-box; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px;
}
.matrix-popup-parent-link { margin-bottom: 8px; }
.matrix-popup-parent-link label {
  display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 3px;
}
.matrix-popup-parent-link input:disabled {
  background: var(--bg); color: var(--text); cursor: not-allowed;
  text-overflow: ellipsis;
}
.matrix-popup-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.matrix-popup-loading {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 2px; color: var(--muted); font-size: 13px;
}
.spinner-sm {
  width: 15px; height: 15px; border-width: 2px;
}
/* Visual cue on the cell itself the instant it's clicked — separate
   from the popup's own spinner, so even before the popup fully repaints
   the person sees SOMETHING happened right where they clicked. */
.matrix-cell-loading { opacity: 0.55; cursor: wait; }
@media (max-width: 720px) {
  .matrix-table { font-size: 12.5px; }
  .matrix-table th, .matrix-table td { padding: 5px 8px; }
}
.wh-svg { width: 100%; max-height: 540px; display: block; }
.wh-bay { cursor: pointer; }
.wh-bay:hover rect, .wh-bay:hover polygon { filter: brightness(1.08); }
.wh-bay.wh-dim { opacity: 0.22; }
.wh-bay-label { font-size: 10px; fill: #1f2328; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.wh-label-light { fill: #ffffff; font-weight: 600; }
.wh-flat { cursor: default; }
.wh-flat.wh-dim { opacity: 0.22; }
.wh-detail { border-top: 1px solid var(--border); padding: 14px 16px; }
.wh-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.wh-detail-head .btn { margin-left: auto; }
.wh-shelf-grid { display: grid; gap: 6px; margin-bottom: 12px; }
.wh-lvl-label { display: flex; align-items: center; font-weight: 600; font-size: 12px; color: var(--muted); }
.wh-shelf-cell {
  border: 1px solid rgba(0,0,0,.15); border-radius: 6px; padding: 6px 8px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; font-size: 12px; min-height: 34px;
}
.wh-shelf-cell:hover { filter: brightness(1.08); }
.wh-shelf-qty { font-weight: 600; }
.wh-shelf-items { font-size: 13px; line-height: 1.7; }

#importModalOverlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
#importModal { background: var(--panel); border-radius: 10px; padding: 22px; width: 460px; max-width: 90vw; max-height: 85vh; overflow-y: auto; }
#importModal h2 { margin: 0 0 12px; font-size: 17px; }
#importFileInput { width: 100%; padding: 8px 0; }
.import-template-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.import-template-row select { font-size: 12px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); }
.import-template-link { display: inline-block; font-size: 13px; text-decoration: none; }
.import-template-link:hover { text-decoration: underline; }
.import-template-link.loading { opacity: 0.6; pointer-events: none; }
.import-result-summary { font-size: 14px; margin: 0 0 10px; }
.import-result-errors {
  max-height: 200px; overflow-y: auto; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px; font-size: 12.5px; color: var(--danger, #dc2626);
}
.import-result-errors div { margin-bottom: 4px; }

#printModalOverlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
#printModal { background: var(--panel); border-radius: 10px; padding: 22px; width: 460px; max-width: 90vw; }
#printModal h2 { margin: 0 0 16px; font-size: 17px; }
.print-format-toggle { display: flex; gap: 18px; margin-top: 6px; }
.print-format-option { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.print-success-msg { color: var(--success, #16a34a); font-weight: 600; margin: 0 0 12px; }
.print-result-btn { display: inline-block; margin-bottom: 8px; }
.print-result-filename { margin: 4px 0 0; font-size: 12px; }
.btn-print { display: inline-flex; align-items: center; gap: 5px; }

#guestIdentityOverlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center; z-index: 110;
}
#guestIdentityModal { background: var(--panel); border-radius: 10px; padding: 22px; width: 400px; max-width: 90vw; }
#guestIdentityModal h2 { margin: 0 0 8px; font-size: 17px; }
#guestIdentityModal .muted { margin: 0 0 16px; font-size: 13.5px; }

#relatedViewOverlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center; z-index: 105;
}
#relatedViewModal { background: var(--panel); border-radius: 10px; padding: 22px; width: 560px; max-height: 85vh; overflow-y: auto; }
.related-view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.related-view-header h2 { margin: 0; font-size: 16px; }

.field-locked input, .field-locked select, .field-locked textarea {
  background: var(--bg); color: var(--muted);
}

/* Live {{lookup}} in flight — dims the input and shows a small corner
   spinner so a person waiting on a round-trip has visible feedback
   instead of a field that just silently sits there. */
.field-lookup-loading { position: relative; }
.field-lookup-loading input, .field-lookup-loading select,
.field-lookup-loading .searchable-select-input { opacity: 0.55; }
.field-lookup-loading::after {
  content: ''; position: absolute; top: 50%; right: 8px;
  width: 13px; height: 13px; margin-top: -6.5px;
  border: 2px solid rgba(15,23,42,.15); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
  pointer-events: none;
}
/* Inside a line-grid <td>, the spinner sits right after the input
   rather than absolutely-positioned over it — the cell is narrow and
   an overlaid spinner would sit on top of the text being shown. */
td.field-lookup-loading::after { display: none; }
td.field-lookup-loading { position: relative; padding-right: 22px !important; }
td.field-lookup-loading::before {
  content: ''; position: absolute; top: 50%; right: 6px;
  width: 12px; height: 12px; margin-top: -6px;
  border: 2px solid rgba(15,23,42,.15); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
  pointer-events: none;
}

.inline-form-fields { padding: 18px; max-width: 640px; }
.inline-form-fields .field:last-child { margin-bottom: 0; }
.section-body > .btn { margin: 0 18px 18px; }

/* ---- Two-column layout for fields (Config_Fields Width: half/full) ----
   Shared by the Add/Edit modal, the inline form, the detail view, and
   cards — a 'half' field pairs up with whatever's next to it; a 'full'
   field always takes its own row. Browser grid auto-placement handles
   the wrapping automatically, so no manual row-grouping is needed. */
#modalFields, .inline-form-fields, .detail-fields-grid, .card-fields-grid {
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px;
}
.col-full { grid-column: 1 / -1; }
.col-half { grid-column: span 1; }

.field-group-heading {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--primary); padding: 7px 12px 7px 14px; margin: 20px 0 8px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
}
/* The first heading in a form/detail/card block shouldn't push down from the top. */
#modalFields > .field-group-heading:first-child,
.inline-form-fields > .field-group-heading:first-child,
.detail-fields-grid > .field-group-heading:first-child,
.card-fields-grid > .field-group-heading:first-child { margin-top: 0; }

.field { margin-bottom: 14px; }
.field-hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field-range-hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
/* v2.7.6: field tanggal/waktu - tinggi tetap, ikon kalender, petunjuk saat kosong (iPhone/Safari) */
.date-field-wrap { position: relative; }
.field .date-field-wrap input.date-field-input {
  -webkit-appearance: none; appearance: none; display: block;
  box-sizing: border-box; min-height: 34px; line-height: 18px; padding-right: 38px; text-align: left;
  background-color: var(--panel, #fff); color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px 18px;
}
.date-field-input::-webkit-date-and-time-value { text-align: left; min-height: 20px; }
.date-field-input::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0; width: auto; height: auto; opacity: 0; cursor: pointer;
}
.date-field-hint {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--muted, #6b7280); pointer-events: none; display: none;
}
.date-field-wrap.is-empty .date-field-hint { display: block; }
.date-field-wrap.is-empty input.date-field-input { color: transparent; }
.date-field-wrap.is-empty input.date-field-input:focus { color: var(--text); }
.date-field-wrap.is-empty input.date-field-input:focus + .date-field-hint { display: none; }

/* v2.8.0: daftar pilihan terbuka untuk narasi panjang (rubrik penilaian) */
.long-pick-box { position: relative; border: 1px solid var(--border); border-radius: 8px; padding: 8px 30px 8px 11px;
  font-size: 14px; line-height: 1.45; cursor: pointer; background: var(--panel, #fff); color: var(--muted, #6b7280); min-height: 34px; box-sizing: border-box; }
.long-pick-box.is-set { color: var(--text); }
.long-pick-box.is-locked { cursor: default; opacity: .75; }
.long-pick-box:focus { outline: 2px solid var(--primary, #b91c1c); outline-offset: 1px; }
.long-pick-caret { position: absolute; right: 11px; top: 8px; color: var(--muted, #6b7280); }
.long-pick-list { border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; margin-top: -2px; background: var(--panel, #fff); }
.long-pick-item { padding: 9px 11px; font-size: 13.5px; line-height: 1.45; border-top: 1px solid var(--border); cursor: pointer; white-space: normal; }
.long-pick-item:hover { background: var(--hover, #f3f4f6); }
.long-pick-item.is-on { background: var(--primary-soft, #fde8e8); color: var(--primary, #b91c1c); font-weight: 600; }

/* v2.8.1: pratinjau nilai pada lembar penilaian */
.nilai-preview { margin-top: 16px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--panel, #fff); }
.np-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: 14px; margin-bottom: 8px; gap: 8px; }
.np-count { font-weight: 400; font-size: 12px; color: var(--muted, #6b7280); }
.np-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.np-cell { display: flex; justify-content: space-between; align-items: center; background: var(--hover, #f3f4f6); border-radius: 6px; padding: 6px 9px; font-size: 13px; }
.np-cell small { color: var(--muted, #6b7280); }
.np-cell b { font-variant-numeric: tabular-nums; }
.np-total { background: var(--primary-soft, #fde8e8); color: var(--primary, #b91c1c); }
.np-note { font-size: 11.5px; color: var(--muted, #6b7280); margin-top: 8px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions-spacer { flex: 1; }
#modalReset { font-size: 13px; color: var(--muted); }
.error { color: var(--danger); font-size: 13px; }

.multiselect-options {
  display: flex; flex-direction: column; gap: 6px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; max-height: 160px; overflow-y: auto;
}
.multiselect-option { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 400; cursor: pointer; }
.multiselect-option input[type="checkbox"] { width: auto; cursor: pointer; }
.multiselect-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.multiselect-search { flex: 1; width: auto; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px; }
.multiselect-clear {
  background: none; border: none; color: var(--primary); font-size: 12.5px; font-weight: 500;
  cursor: pointer; padding: 4px 2px; white-space: nowrap;
}
.multiselect-clear:hover { text-decoration: underline; }

.searchable-select { position: relative; }
.searchable-select-input-row { display: flex; align-items: stretch; gap: 0; }
.searchable-select-input { width: 100%; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.searchable-select-unmatched {
  border-color: #e0a800 !important; background: #fff8e1 !important; color: #7a5c00;
}
.select-unmatched-option { color: #7a5c00; }
.searchable-select-clear {
  flex-shrink: 0; width: 32px; border: 1px solid var(--border); border-left: none;
  border-top-right-radius: 6px; border-bottom-right-radius: 6px; background: var(--bg);
  color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1;
}
.searchable-select-clear:hover { color: var(--danger); }
.searchable-select-clear:disabled { cursor: default; opacity: .5; }
.searchable-select-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 40; margin-top: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  max-height: 200px; overflow-y: auto; box-shadow: 0 6px 16px rgba(15,23,42,.1);
}
.searchable-select-option { padding: 8px 11px; font-size: 13.5px; cursor: pointer; }
.searchable-select-option:hover { background: var(--bg); }
.searchable-select-empty { padding: 8px 11px; font-size: 13px; color: var(--muted); }
.searchable-select-other-option { border-top: 1px solid var(--border); color: var(--primary); font-weight: 500; }

.plain-select-wrap select { width: 100%; }
.select-other-input { width: 100%; }
.plain-select-wrap .select-other-input,
.searchable-select .select-other-input { margin-top: 8px; }

.currency-input-wrapper {
  display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.currency-input-wrapper .currency-symbol {
  display: flex; align-items: center; padding: 0 10px; background: var(--bg); color: var(--muted);
  font-size: 14px; border-right: 1px solid var(--border);
}
.currency-input-wrapper input {
  border: none; border-radius: 0; flex: 1; min-width: 0;
}

.upload-field-wrapper { display: flex; flex-direction: column; gap: 8px; }
.upload-current { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-current a { color: var(--primary); text-decoration: none; font-size: 14px; }
.upload-current a:hover { text-decoration: underline; }
.btn-link-remove {
  background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline;
  cursor: pointer; padding: 0;
}
.btn-link-remove:hover { color: #dc2626; }
.upload-picker { font-size: 13px; }
.upload-status { font-size: 12.5px; color: var(--muted); }
.upload-hint { font-size: 11.5px; color: var(--muted); opacity: 0.85; }
.upload-status-error { color: #dc2626; }

/* ---- Progress fields (FieldType: progress) ---- */
.progress-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.progress-bar-track {
  flex: 1; height: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden; min-width: 50px;
}
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.2s ease; }
.progress-bar-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.progress-field-wrapper { display: flex; align-items: center; gap: 10px; }
.progress-field-wrapper input[type="range"] { flex: 1; }
.progress-field-readout {
  font-size: 13px; color: var(--text); min-width: 2.5em; text-align: right; flex-shrink: 0;
}

.color-field-wrapper { display: flex; align-items: center; gap: 10px; }

/* ---- {{lookup}} builder (FieldType: lookup-builder) ---- */
.lookup-builder-wrapper { display: flex; flex-direction: column; gap: 6px; }

/* ---- Location picker (FieldType: location) ---- */
.location-picker-wrapper { display: flex; flex-direction: column; gap: 8px; }
.location-picker-search-row { position: relative; }
.location-picker-search {
  width: 100%; box-sizing: border-box; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px;
}
.location-picker-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 45;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15,23,42,.12); max-height: 220px; overflow-y: auto;
}
.location-picker-result-item {
  padding: 8px 11px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.location-picker-result-item:last-child { border-bottom: none; }
.location-picker-result-item:hover { background: var(--bg); }
.location-picker-result-empty { padding: 8px 11px; font-size: 13px; color: var(--muted); }
.location-picker-coords { font-size: 12.5px; color: var(--muted); }
.location-picker-map { width: 100%; height: 280px; border-radius: 8px; border: 1px solid var(--border); }
.location-picker-loading {
  display: flex; align-items: center; gap: 8px; padding: 14px;
  color: var(--muted); font-size: 13px; border: 1px solid var(--border); border-radius: 8px;
}
.location-picker-error { color: var(--danger); font-size: 13px; }

/* Read-only mini-map thumbnail (table cell + detail view) */
.location-thumb {
  display: inline-block; width: 160px; height: 120px;
  border-radius: 6px; border: 1px solid var(--border);
  overflow: hidden; cursor: pointer; line-height: 0; position: relative;
}
.location-thumb img { display: block; }
.location-thumb-empty { color: var(--muted); font-size: 12.5px; }
.location-thumb-loading {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; background: var(--bg); font-size: 22px;
}
/* The tiny Leaflet map inside a thumbnail is display-only — dragging/
   zooming are already disabled in JS, this just makes sure a click
   anywhere on it still triggers the wrapping <a> link's navigation
   rather than being captured by Leaflet's own click handling. */
.location-thumb .leaflet-container { pointer-events: none; }

/* ---- Column picker (FieldType: column-picker) ---- */
.column-picker-disabled, .column-picker-unconfigured {
  opacity: 0.5; pointer-events: none; position: relative;
}
.column-picker-disabled::after, .column-picker-unconfigured::after {
  content: 'Choose a section above first.';
  display: block; font-size: 12px; color: var(--muted); font-style: italic;
  padding: 6px 2px 0;
}
.lookup-builder-toggle { align-self: flex-start; }
.lookup-builder-panel {
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  background: var(--bg); display: flex; flex-direction: column; gap: 8px;
}
.lookup-builder-loading { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.lookup-builder-row { display: flex; flex-direction: column; gap: 3px; }
.lookup-builder-row label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.lookup-builder-row select, .lookup-builder-row input {
  padding: 6px 8px; font-size: 13px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); color: var(--text);
}
.lookup-builder-preview {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; overflow-x: auto;
}
.lookup-builder-preview code { color: var(--primary); white-space: nowrap; }
.lookup-builder-test-result {
  font-size: 12.5px; padding: 6px 10px; border-radius: 6px;
  background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--text);
}
.lookup-builder-actions { display: flex; justify-content: flex-end; gap: 8px; }
.color-field-wrapper input[type="color"] {
  width: 42px; height: 32px; padding: 2px; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; background: none;
}
.color-field-text-input {
  font-size: 13px; font-family: monospace; color: var(--text); width: 90px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
}
.color-field-text-input.invalid { border-color: var(--danger, #dc2626); color: var(--danger, #dc2626); }
.color-swatch-wrap { display: inline-flex; align-items: center; gap: 6px; }
.color-swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 4px;
  border: 1px solid var(--border); flex-shrink: 0;
}
.color-swatch-code { font-size: 12.5px; color: var(--muted); font-family: monospace; }

#toast {
  position: fixed; bottom: 24px; right: 24px; background: #1f2328; color: white;
  padding: 10px 16px; border-radius: 8px; font-size: 13.5px; z-index: 200;
}
#toast.error-toast { background: var(--danger); }

/* ============== Loading indicators ============== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes skeleton-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.spinner {
  display: inline-block; width: 22px; height: 22px;
  border: 3px solid rgba(15,23,42,.15); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
.btn-spinner {
  display: inline-block; width: 16px; height: 16px; margin-right: 7px; vertical-align: -3px;
  border: 2.5px solid rgba(255,255,255,.5); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.btn-spinner.dark {
  border-color: rgba(37,99,235,.25); border-top-color: var(--primary);
}
.btn[disabled] { opacity: .75; cursor: default; }

.page-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 60px 0; color: var(--muted); font-size: 13.5px;
}
.nav-loading {
  display: flex; align-items: center; gap: 8px; padding: 8px; color: var(--muted); font-size: 13px;
}

.skeleton-bar {
  height: 12px; border-radius: 4px;
  background: linear-gradient(90deg, #ececec 25%, #f6f6f6 37%, #ececec 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.3s ease infinite;
}
.skeleton-search { width: 200px; height: 30px; border-radius: 6px; }
.skeleton-row td { padding: 10px 14px; }
.skeleton-row .skeleton-bar { width: 70%; }
.skeleton-row:nth-child(2n) .skeleton-bar { width: 50%; }

/* ---- Cards layout (SectionType: cards) ----
   Each record top-to-bottom as label/value pairs, stacked vertically,
   repeated once per record — an alternative to the table grid. */
.card-list { padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.record-card {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; background: var(--panel);
}
.record-card-deleted { background: #fafafa; }
.record-card-deleted .card-field-value { color: var(--muted); }
.record-card .badge-deleted { position: absolute; top: 14px; right: 16px; }
.card-field { padding: 6px 0; border-bottom: 1px solid var(--border); }
.card-field:last-of-type { border-bottom: none; }
.card-field-label {
  font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; margin-bottom: 2px;
}
.card-field-value { font-size: 14px; word-break: break-word; }
.card-actions { display: flex; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.skeleton-card { display: block; }

/* ---- Dashboard layout (SectionType: dashboard) ----
   Tiles (single big number) and charts, in a responsive grid driven by
   Config_DashboardItems. col-half pairs up; col-full takes a full row,
   same convention as fields elsewhere in the app. */
.dashboard-grid {
  padding: 18px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px;
}
.dashboard-tile {
  grid-column: 1 / -1; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); padding: 20px; text-align: center;
}
.dashboard-tile-value { font-size: 32px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.dashboard-tile-title { margin-top: 6px; font-size: 13px; color: var(--muted); }
.dashboard-chart-card {
  grid-column: 1 / -1; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); padding: 16px;
}
.dashboard-item-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.dashboard-chart-canvas-wrap { position: relative; height: 240px; }
.dashboard-item-error { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.col-half.dashboard-tile, .col-half.dashboard-chart-card, .col-half.dashboard-item-error { grid-column: span 6; }
/* v2.7.2 compact tiles: Width = third / quarter in Config_DashboardItems */
.col-third.dashboard-tile, .col-third.dashboard-item-error { grid-column: span 4; }
.col-quarter.dashboard-tile, .col-quarter.dashboard-item-error { grid-column: span 3; }
.col-sixth.dashboard-tile, .col-sixth.dashboard-item-error { grid-column: span 2; }
@media (max-width: 900px) {
  .col-sixth.dashboard-tile, .col-sixth.dashboard-item-error { grid-column: span 4; }
}
.dashboard-grid:has(> .dashboard-tile-compact) { gap: 10px; padding: 12px 18px; }
.dashboard-tile.dashboard-tile-compact {
  padding: 10px 14px; text-align: left; display: flex; align-items: baseline; gap: 10px; min-width: 0;
}
.dashboard-tile-compact .dashboard-tile-value { font-size: 22px; flex: none; }
.dashboard-tile-compact .dashboard-tile-title {
  margin-top: 0; font-size: 12px; line-height: 1.3; min-width: 0; overflow-wrap: anywhere;
}

/* ---- Content sections (SectionType: content) — rendered Markdown ---- */
.content-section-body { padding: 18px; line-height: 1.6; color: var(--text); }
.content-section-body h1, .content-section-body h2, .content-section-body h3,
.content-section-body h4, .content-section-body h5, .content-section-body h6 {
  margin: 0.8em 0 0.4em; line-height: 1.25;
}
.content-section-body h1:first-child, .content-section-body h2:first-child,
.content-section-body h3:first-child, .content-section-body > :first-child { margin-top: 0; }
.content-section-body p { margin: 0 0 0.9em; }
.content-section-body ul, .content-section-body ol { margin: 0 0 0.9em; padding-left: 1.5em; }
.content-section-body li { margin-bottom: 0.25em; }
.content-section-body a { color: var(--primary); text-decoration: underline; }
.content-section-body blockquote {
  margin: 0 0 0.9em; padding: 6px 14px; border-left: 3px solid var(--border);
  color: var(--muted); background: var(--bg); border-radius: 0 6px 6px 0;
}
.content-section-body code {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-size: 0.9em;
}
.content-section-body pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 14px; overflow-x: auto; margin: 0 0 0.9em;
}
.content-section-body pre code { background: none; border: none; padding: 0; }
.content-section-body hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.content-img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 0.5em 0; }

@media (max-width: 480px) {
  .dashboard-grid { padding: 14px; }
  .col-half.dashboard-tile, .col-half.dashboard-chart-card { grid-column: 1 / -1; }
  .col-third.dashboard-tile, .col-quarter.dashboard-tile, .col-sixth.dashboard-tile,
  .col-third.dashboard-item-error, .col-quarter.dashboard-item-error, .col-sixth.dashboard-item-error { grid-column: span 6; }
  .dashboard-grid:has(> .dashboard-tile-compact) { padding: 10px 14px; }
}

/* ---- Gantt timeline (SectionType: gantt) ---- */
.gantt-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 14px 18px 0; }
.gantt-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.gantt-legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.gantt-legend-today-mark { width: 14px; height: 0; border-top: 2px dashed #dc2626; display: inline-block; }
.gantt-canvas-wrap { position: relative; padding: 14px 18px 18px; }

/* ============== Responsive / mobile ============== */
@media (max-width: 900px) {
  #content { padding: 24px 20px; max-width: 100%; }
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  body.nav-topbar .mobile-menu-btn { display: none; } /* nav-topbar has its own inline hamburger below */

  /* On mobile, nav-topbar falls back to the slide-out sidebar too —
     there's no room for a horizontal nav bar on a phone screen. */
  body.nav-topbar #appTopBar { display: flex; } /* re-shown: mobile needs the hamburger it contains */
  body.nav-topbar #app { margin-top: var(--topbar-height); min-height: calc(100vh - var(--topbar-height)); }

  #sidebar, body.nav-topbar #sidebar {
    position: fixed; top: var(--topbar-height); left: 0; height: calc(100vh - var(--topbar-height)); width: 240px;
    z-index: 75; transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,.08);
    flex-wrap: nowrap; flex-direction: column; align-items: stretch;
    padding: 16px 12px; border-bottom: none;
  }
  #sidebar.open { transform: translateX(0); }
  body.nav-topbar .role-bar { margin-right: 0; padding: 10px 8px 12px; }
  body.nav-topbar #pageNav { flex-direction: column; gap: 0; }
  body.nav-topbar #pageNav a { margin-bottom: 2px; }
  body.nav-topbar .nav-group { position: static; margin-bottom: 2px; }
  body.nav-topbar .nav-group-summary::before { content: '▸'; }
  body.nav-topbar .nav-group[open] > .nav-group-summary::before { content: '▾'; }
  body.nav-topbar .nav-group-summary::after { content: ''; }
  body.nav-topbar .nav-group-items {
    position: static; box-shadow: none; border: none; padding: 0 0 0 18px; min-width: 0;
  }

  #content { padding: 68px 16px 28px; }

  #modal, #relatedViewModal { width: 92vw; max-width: 420px; padding: 18px; }
  .detail-card { padding: 16px; }

  .table-toolbar { flex-wrap: wrap; row-gap: 8px; }
  .search-input { max-width: none; flex: 1 1 100%; order: 1; }
  .filter-select { order: 1; }
  .show-deleted-toggle { order: 2; }
  .result-count { order: 3; margin-left: auto; }

  .section-header { flex-wrap: wrap; gap: 10px; }

  table { font-size: 12.5px; }
  th, td { padding: 8px 10px; }
  .actions { white-space: nowrap; }
  .pagination-bar { flex-wrap: wrap; gap: 8px; font-size: 12.5px; }
  .pagination-nav { width: 100%; justify-content: space-between; }
}

@media (max-width: 480px) {
  #pageTitle { font-size: 19px; }
  .section-header h3 { font-size: 14px; }
  table { min-width: 460px; } /* let it scroll horizontally instead of squashing columns */
  .inline-form-fields { padding: 14px; max-width: 100%; }
  .detail-card h2 { font-size: 15px; }
  .card-list { padding: 12px 14px; }
  .record-card { padding: 12px 14px; }
  #modalFields, .inline-form-fields, .detail-fields-grid, .card-fields-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   NGSF native PHP additions: the same look, server-rendered.
   ============================================================ */
:root {
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --secondary: var(--primary); --secondary-tint: #eef3fd; --surface-tint: #dfe8fb; --content-max-width: 1000px;
}
a { color: var(--primary); }
h1 { font-size: 22px; }
.material-symbols-outlined { font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal; display: inline-block;
  white-space: nowrap; direction: ltr; -webkit-font-smoothing: antialiased; letter-spacing: normal; text-transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
a.btn { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
a.btn-primary { color: #fff; }
a.btn-secondary { color: var(--text); }
.btn.disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
form.inline { display: inline; margin: 0; }
.topbar-account-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.topbar-account-name { font-weight: 600; font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-account-text .topbar-account-email { font-size: 11.5px; color: var(--muted); }
.notif-bell { text-decoration: none; }
.role-bar-actions a.sidebar-collapse-btn { text-decoration: none; }
#pageNav a .nav-icon.material-symbols-outlined { font-size: 18px; }
.page-header-row .btn { white-space: nowrap; }
.section-header h3 .section-title-icon { font-size: 18px; color: var(--primary); }
.section-header-actions form { margin: 0; }
.section.in-tab { margin-top: 0; }
.tab-group > .section, .tab-group > .detail-card { margin-bottom: 0; }
a.section-tab { text-decoration: none; display: inline-block; }
.header-dropdown > summary { list-style: none; }
.header-dropdown > summary::-webkit-details-marker { display: none; }
a.header-dropdown-item { text-decoration: none; }
th a.sort-link { color: inherit; text-decoration: none; display: block; }
.pagination-nav a { text-decoration: none; }
.pagination-nav .btn.disabled { visibility: hidden; }
.result-count-row .pagination-info { color: var(--muted); }
.row-action { display: inline-flex; text-decoration: none; }
td.actions form { display: inline; }
tr.row-deleted td { text-decoration: none; }
.empty-row a { text-decoration: none; }
.detail-nav-row a.btn, .detail-nav-row form { margin: 0; }
.detail-fields-grid { margin: 0; }
.detail-value { white-space: pre-wrap; }
.detail-value.markdown { white-space: normal; }
.related-blocks > .section, .related-blocks > .tab-group { margin-top: 24px; margin-bottom: 0; }
.history-entry-summary del { color: var(--danger); }
.history-entry-summary ins { color: #15803d; text-decoration: none; }

/* Flash messages as NGSF toasts (bottom right). */
#toast { box-shadow: 0 6px 18px rgba(15,23,42,.2); }
#toast.hidden { display: none; }
.form-error-banner { background: #fde8e8; color: var(--danger); font-size: 13px; padding: 8px 12px; border-radius: 6px; margin-bottom: 14px; }

/* Add/Edit form: the NGSF modal, also as a page when scripts are off. */
.modal-page #modal { margin: 0 auto; max-height: none; width: 100%; max-width: 560px; border: 1px solid var(--border); }
.modal-page #modal.modal-wide { max-width: 940px; }
.modal-page #modalScrollBody { overflow: visible; }
#modalOverlay.hidden { display: none; }
#modalOverlay #modal { max-width: 94vw; }
#modalOverlay .modal-loading { padding: 30px 22px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
body.modal-open { overflow: hidden; }
.field.is-hidden, .form-lines-block.is-hidden { display: none; }
.field .req { color: inherit; }
.field .field-suffix { font-weight: 400; color: var(--muted); }
.field .field-hint p { margin: 0; }
.field .error { margin-top: 4px; }
.field input[type="checkbox"], .field input[type="radio"] { width: auto; }
.field input[readonly], .field .locked-value { background: var(--bg); color: var(--muted); }
.field .locked-value { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; min-height: 36px; }
.field textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.radio-options { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 4px 0; }
.radio-option { display: inline-flex !important; align-items: center; gap: 6px; font-weight: 400 !important; font-size: 13.5px !important; margin: 0 !important; cursor: pointer; }
.switch-wrap { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; margin: 0 !important; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-slider { position: absolute; inset: 0; background: #cbd0d6; border-radius: 22px; transition: background .15s; cursor: pointer; }
.switch-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch-text { font-size: 13.5px; }
.multiselect-option.is-hidden { display: none; }
.searchable-select select.searchable-native { display: none; }
.searchable-select-list.hidden { display: none; }
.searchable-select-option.is-active { background: var(--bg); }
.select-other-input.hidden { display: none; }
.token-helper { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.token-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 12px; cursor: pointer; color: var(--text); font-family: inherit; }
.token-chip:hover { border-color: var(--primary); color: var(--primary); }
.form-lines-block legend { padding: 0; }
.form-lines-table td .error { font-size: 12px; }
.form-lines-status { font-size: 12px; color: var(--muted); margin-left: 8px; }
.inline-form .modal-actions { padding: 0 18px 18px; margin-top: 0; justify-content: flex-start; }
.content-section-body img { max-width: 100%; }

/* Sign-in pages */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 26px 22px; }
.auth-card .auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; margin-bottom: 18px; }
.auth-card h1 { font-size: 17px; margin: 0 0 6px; }
.auth-card .lead { color: var(--muted); margin: 0 0 16px; font-size: 13.5px; }
.auth-card .row { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-size: 13.5px; }
.auth-card .btn-block { width: 100%; margin-top: 6px; padding: 9px 13px; }
input.code { font-size: 22px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; }
.flash { border-radius: 6px; padding: 8px 12px; margin-bottom: 14px; font-size: 13.5px; }
.flash.ok { background: #dcfce7; color: #15803d; }
.flash.err { background: #fde8e8; color: var(--danger); }

/* Simple pages (notifications, import, history, errors) */
.page-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 24px; }
.page-card h2 { margin: 0 0 12px; font-size: 16px; }
.notif-list { padding: 0; }
.notif { display: grid; gap: 2px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--bg); }
.notif.unread { box-shadow: inset 3px 0 0 var(--primary); }
.notif.unread .notif-title { font-weight: 600; }
.notif-msg { color: var(--muted); font-size: 13.5px; }
.errors-list { color: var(--danger); font-size: 13.5px; max-height: 320px; overflow: auto; }
.file-current { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13.5px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.section-body { padding: 18px; }
.section-body > :first-child { margin-top: 0; }
.dashboard-grid .dash-item { border-color: var(--border); background: var(--panel); }
/* Dashboards: categorical palette validated for colour-blind readers, light and dark */
:root { --series-1:#2a78d6; --series-2:#eb6834; --series-3:#1baf7a; --series-4:#eda100;
        --series-5:#e87ba4; --series-6:#008300; --series-7:#6250d6; --series-8:#e34948; }
.s1 { fill:var(--series-1); } .s2 { fill:var(--series-2); } .s3 { fill:var(--series-3); } .s4 { fill:var(--series-4); }
.s5 { fill:var(--series-5); } .s6 { fill:var(--series-6); } .s7 { fill:var(--series-7); } .s8 { fill:var(--series-8); }
.dash-grid { display:grid; grid-template-columns:repeat(12, minmax(0, 1fr)); gap:12px; }
.dash-item { grid-column:span 12; border:1px solid var(--border); border-radius:10px; padding:14px; min-width:0; }
.dash-item h3 { margin:0 0 10px; font-size:14px; font-weight:600; color:var(--muted); }
@media (min-width: 720px) {
  .dash-item.w-half { grid-column:span 6; } .dash-item.w-third { grid-column:span 4; }
  .dash-item.w-quarter { grid-column:span 3; } .dash-item.w-sixth { grid-column:span 2; }
}
.tile-value { font-size:32px; font-weight:600; line-height:1.1; font-variant-numeric:tabular-nums; }
.chart { width:100%; height:auto; display:block; }
.chart text { font-size:13px; fill:var(--muted); font-family:inherit; }
.chart .val { fill:var(--text); font-variant-numeric:tabular-nums; }
.chart .grid { stroke:var(--border); stroke-width:1; }
.chart .hit { fill:transparent; }
.chart g:hover .bar { opacity:.85; }
.chart .series { fill:none; stroke-width:2; stroke-linejoin:round; stroke-linecap:round; }
.chart .s1-line { stroke:var(--series-1); }
.chart .dot { stroke:var(--panel); stroke-width:2; }
.pie { display:flex; gap:20px; align-items:center; flex-wrap:wrap; }
.pie svg { max-width:100%; height:auto; }
.pie .slice { stroke:var(--panel); stroke-width:2; }
.legend { list-style:none; margin:0; padding:0; font-size:14px; display:grid; gap:6px; }
.legend li { display:flex; align-items:center; gap:8px; }
.data-table { margin-top:8px; font-size:13px; }
.data-table summary { cursor:pointer; color:var(--muted); }
.data-table table { margin-top:6px; }
.bars { display:grid; gap:8px; }
.bar-row { display:grid; grid-template-columns:minmax(80px, 34%) 1fr auto; align-items:center; gap:10px; font-size:13px; }
.bar-label { color:var(--muted); text-align:right; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bar-track { width:100%; height:18px; display:block; border-radius:4px; overflow:hidden; }
.bar-val { font-variant-numeric:tabular-nums; min-width:2ch; }
.chart { max-width:640px; }

/* Print templates */
.print-body { background:var(--bg); margin:0; }
.print-bar { display:flex; gap:10px; align-items:center; flex-wrap:wrap; padding:12px 16px; background:var(--panel); border-bottom:1px solid var(--border); position:sticky; top:0; }
.print-doc { max-width:210mm; margin:16px auto; background:#fff; color:#111; padding:18mm 16mm; box-shadow:0 1px 4px rgba(0,0,0,.12); line-height:1.5; }
.print-doc h1, .print-doc h2, .print-doc h3 { color:#111; }
.print-doc a { color:#111; }
.print-table { width:100%; border-collapse:collapse; margin:10px 0; font-size:13px; }
.print-table th, .print-table td { border:1px solid #999; padding:4px 6px; text-align:left; vertical-align:top; color:#111; }
.print-table th { font-weight:600; background:#eee; }
.print-table tr[bgcolor] th { background:transparent; }
.print-img { max-width:100%; height:auto; }
.page-break { break-after:page; height:0; }
@media print {
  .no-print { display:none !important; }
  .print-body { background:#fff; }
  .print-doc { box-shadow:none; margin:0; padding:0; max-width:none; }
  @page { size:A4; margin:16mm; }
}
.print-doc h2 { font-size:22px; margin:0 0 12px; }
.print-doc h3 { font-size:17px; margin:18px 0 8px; }

/* Detail charts: one line style per categorical slot */
.chart .line-s1 { stroke:var(--series-1); } .chart .line-s2 { stroke:var(--series-2); } .chart .line-s3 { stroke:var(--series-3); }
.chart .line-s4 { stroke:var(--series-4); } .chart .line-s5 { stroke:var(--series-5); } .chart .line-s6 { stroke:var(--series-6); }
.chart .line-s7 { stroke:var(--series-7); } .chart .line-s8 { stroke:var(--series-8); }
.legend-row { display:flex; flex-wrap:wrap; gap:6px 16px; margin-top:8px; }

/* Matrix (cross-tab) */
.matrix-wrap { max-height:70vh; overflow:auto; border:1px solid var(--border); border-radius:8px; }
table.matrix { width:auto; min-width:100%; }
table.matrix th, table.matrix td { border-bottom:1px solid var(--border); border-right:1px solid var(--border); padding:6px 10px; text-align:center; white-space:nowrap; }
table.matrix thead th { position:sticky; top:0; background:var(--bg); z-index:2; font-weight:600; }
table.matrix tbody th { position:sticky; left:0; background:var(--bg); z-index:1; text-align:left; font-weight:500; }
table.matrix thead th.mx-corner { left:0; z-index:3; }
table.matrix td { font-variant-numeric:tabular-nums; min-width:64px; }
.mx-sub { display:block; font-size:12px; font-weight:400; color:var(--muted); }
a.mx-cell { display:block; margin:-6px -10px; padding:6px 10px; color:inherit; }
a.mx-cell:hover, a.mx-cell:focus-visible { background:color-mix(in srgb, var(--primary) 12%, var(--panel)); color:var(--primary); }
td.mx-empty a.mx-cell { color:var(--muted); opacity:.55; }
td.mx-empty a.mx-cell:hover { opacity:1; }

/* Gantt */
.gantt-legend { display:flex; flex-wrap:wrap; gap:6px 16px; margin-bottom:10px; }
.gantt { display:grid; grid-template-columns:minmax(120px, 28%) minmax(0, 1fr); border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.gantt-labels { border-right:1px solid var(--border); background:var(--panel); min-width:0; }
.gantt-label-head { height:40px; border-bottom:1px solid var(--border); }
.gantt-label { height:30px; line-height:30px; padding:0 10px; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; border-bottom:1px solid var(--border); }
.gantt-label a { color:var(--text); }
.gantt-label a:hover { color:var(--primary); }
.gantt-label.rollup { font-weight:600; }
.gantt-label.depth-1 { padding-left:24px; } .gantt-label.depth-2 { padding-left:38px; } .gantt-label.depth-3 { padding-left:52px; }
.gantt-label.depth-4 { padding-left:66px; } .gantt-label.depth-5 { padding-left:80px; }
.gantt-scroll { overflow-x:auto; min-width:0; }
.gantt-svg { display:block; }
.gantt-svg text { font-size:12px; fill:var(--muted); font-family:inherit; }
.gantt-svg .gantt-month-label { fill:var(--text); font-weight:600; }
.gantt-weekend { fill:var(--bg); }
.gantt-row { stroke:var(--border); stroke-width:1; }
.gantt-month { stroke:var(--border); stroke-width:1; }
.gantt-axis { stroke:var(--border); stroke-width:1; }
.gantt-today { stroke:var(--text); stroke-width:2; stroke-dasharray:4 3; }
.gantt-bar .hit { fill:transparent; }
.gantt-bar .gantt-track { opacity:.35; }
.gantt-bar.rollup .bar { opacity:.6; }
.gantt-other { fill:#8c959f; }
a:hover .gantt-bar .bar, a:focus-visible .gantt-bar .bar { stroke:var(--text); stroke-width:1.5; }

/* Warehouse floor plan (fill = how full; status colours with text in the legend and tooltips) */
:root { --wh-empty:#d7dbe0; --wh-stored:#5b8ff9; --wh-low:#3fa46a; --wh-mid:#e0a12e; --wh-full:#d9534f;
        --wh-gate:#37474f; --wh-path:#e8ebf0; --wh-staging:#fdf3dd; --wh-edge:#5b6472; }
.wh-tools { display:flex; flex-wrap:wrap; gap:8px 16px; align-items:center; justify-content:space-between; margin-bottom:10px; }
.wh-floors { display:flex; gap:6px; flex-wrap:wrap; }
.wh-search { display:flex; gap:6px; }
.wh-search input { height:30px; width:220px; max-width:60vw; }
.wh-legend { display:flex; flex-wrap:wrap; gap:6px 16px; margin-bottom:10px; }
.wh-swatch { display:inline-block; width:12px; height:12px; border-radius:3px; border:1px solid var(--wh-edge); }
.wh-plan { overflow:auto; border:1px solid var(--border); border-radius:8px; background:var(--panel); }
.wh-svg { display:block; max-width:100%; height:auto; margin:0 auto; }
.wh-bay rect { stroke:var(--wh-edge); stroke-width:1; }
.wh-bay text { font-size:9px; fill:#1f2328; pointer-events:none; font-family:inherit; }
.wh-empty rect, .wh-swatch.wh-empty, td.wh-empty { fill:var(--wh-empty); background:var(--wh-empty); }
.wh-stored rect, .wh-swatch.wh-stored, td.wh-stored { fill:var(--wh-stored); background:var(--wh-stored); }
.wh-low rect, .wh-swatch.wh-low, td.wh-low { fill:var(--wh-low); background:var(--wh-low); }
.wh-mid rect, .wh-swatch.wh-mid, td.wh-mid { fill:var(--wh-mid); background:var(--wh-mid); }
.wh-full rect, .wh-swatch.wh-full, td.wh-full { fill:var(--wh-full); background:var(--wh-full); }
.wh-staging-bay.wh-empty rect { fill:var(--wh-staging); stroke-dasharray:6 3; }
.wh-gate rect { fill:var(--wh-gate); } .wh-gate text { fill:#fff; }
.wh-path rect { fill:var(--wh-path); stroke-dasharray:5 4; stroke:var(--border); }
.wh-stored text, .wh-full text { fill:#fff; }
.wh-dim { opacity:.25; }
a .wh-bay:hover rect, a:focus-visible .wh-bay rect, .wh-selected rect { stroke:var(--text); stroke-width:2.5; }
.wh-detail { margin-top:14px; border-top:1px solid var(--border); padding-top:12px; }
.wh-detail h3 { margin:0; font-size:15px; }
table.wh-shelves { width:auto; border-collapse:separate; border-spacing:4px; }
table.wh-shelves th { font-size:12px; color:var(--muted); padding:0 6px; }
table.wh-shelves td { padding:0; border-radius:6px; min-width:70px; }
table.wh-shelves td a { display:flex; justify-content:space-between; gap:8px; padding:8px 10px; color:#1f2328; font-size:13px; }
table.wh-shelves td.wh-stored a, table.wh-shelves td.wh-full a { color:#fff; }
table.wh-shelves td.wh-selected { outline:2px solid var(--text); }
.wh-shelf-qty { font-variant-numeric:tabular-nums; }
.wh-items { margin-top:10px; font-size:14px; }
.wh-items ul { margin:6px 0 0; padding-left:18px; }

/* In-page anchors (tabs, sections) land below the fixed top bar. */
[id] { scroll-margin-top: 72px; }

/* Colour field: picker + hex box (the box is what's sent; blank allowed). */
.color-field-wrapper { display: flex; align-items: center; gap: 8px; }
.field .color-field-wrapper input[type="color"] { width: 44px; height: 36px; padding: 2px; flex: 0 0 auto; }
.field .color-field-wrapper .color-field-text-input { width: 120px; font-family: monospace; }

/* Progress: bar in tables and detail, slider + number in forms. */
.progress-cell { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.progress-bar { width: 80px; height: 8px; border: 0; border-radius: 999px; background: var(--border); overflow: hidden; -webkit-appearance: none; appearance: none; }
.progress-bar::-webkit-progress-bar { background: var(--border); border-radius: 999px; }
.progress-bar::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
.progress-bar::-moz-progress-bar { background: var(--primary); border-radius: 999px; }
.progress-text { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); }
.progress-input { display: flex; align-items: center; gap: 10px; }
.field .progress-input input[type="range"] { flex: 1 1 auto; padding: 0; accent-color: var(--primary); }
.field .progress-input .progress-number { width: 90px; flex: 0 0 auto; }
.progress-unit { color: var(--muted); }
.color-swatch { display: inline-block; vertical-align: -2px; border: 0; width: 14px; height: 14px; }
.related-view-actions { display: flex; gap: 8px; }

/* Builder helpers: token test, lookup builder, print-template check, column picker. */
.token-tools { display: inline-flex; gap: 6px; margin-left: 4px; }
.lookup-builder-panel { margin-top: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); display: grid; gap: 8px; }
.lookup-builder-row { display: grid; grid-template-columns: 130px 1fr; gap: 8px; align-items: center; font-size: 13px; }
.lookup-builder-row.hidden { display: none; }
.lookup-builder-test-result, .print-check-result { margin-top: 6px; }
.lookup-builder-test-result.is-error, .print-check-result.is-error { background: color-mix(in srgb, #dc2626 10%, transparent); color: #b91c1c; }
.print-check { margin-top: 6px; }
.print-check-result { font-size: 12.5px; padding: 6px 10px; border-radius: 6px; background: color-mix(in srgb, var(--primary) 10%, transparent); }
.column-picker-empty { font-size: 12.5px; }
.md-img { max-width: 100%; height: auto; border-radius: 6px; }
blockquote { margin: 8px 0; padding: 6px 14px; border-left: 3px solid var(--primary); background: var(--bg); color: var(--muted); }
pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; }
.print-table-doc h1 { font-size: 18px; margin: 0 0 4px; }
.print-table .print-num { width: 32px; text-align: right; color: #666; }
@page landscape { size: A4 landscape; margin: 12mm; }
@media print { .print-landscape { page: landscape; } }
.print-table tbody tr:last-child td { border-bottom: 1px solid #999; }
.print-table td, .print-table th { white-space: normal; }

/* Bell panel (NGSF #notifPanel) */
.notif-panel { width: min(340px, calc(100vw - 24px)); max-height: 70vh; text-align: left; }
.notif-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.notif-panel-tools { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.notif-link-btn { background: none; border: none; cursor: pointer; color: var(--primary); font-size: 12.5px; padding: 0; font: inherit; font-size: 12.5px; }
.notif-gear { color: var(--muted); display: flex; }
.notif-gear .material-symbols-outlined { font-size: 18px; }
.notif-panel-item { display: flex; gap: 9px; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; background: var(--panel); }
.notif-panel-item:hover { background: var(--bg); }
.notif-panel-item.unread { background: color-mix(in srgb, var(--primary) 8%, var(--panel)); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: transparent; }
.notif-panel-item.unread .notif-dot { background: var(--primary); }
.notif-panel-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-panel-title { font-size: 13px; font-weight: 500; }
.notif-panel-item.unread .notif-panel-title { font-weight: 700; }
.notif-panel-msg { font-size: 12.5px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-panel-meta { font-size: 11.5px; color: var(--muted); }
.notif-panel-foot { display: block; padding: 9px 14px; font-size: 12.5px; color: var(--primary); text-decoration: none; }
.notif-badge.hidden { display: none; }
.import-plan { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 13px; }
.import-plan th, .import-plan td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.import-run { display: grid; gap: 8px; margin-top: 14px; }
.import-upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0 6px; }
.import-steps { margin: 0 0 6px 18px; padding: 0; line-height: 1.7; }
.import-report { font-size: 13px; line-height: 1.6; }

/* Installer (first visit on a new server) */
.install-card { max-width: 560px; }
.install-card h2 { font-size: 15px; margin: 22px 0 8px; }
.install-form .radio-option { display: flex !important; align-items: flex-start; margin: 0 0 8px !important; }
.install-form .radio-option input { margin-top: 3px; }
.install-more { margin: 0 0 14px; font-size: 13.5px; }
.install-more summary { cursor: pointer; color: var(--primary); margin-bottom: 8px; }
.install-list { padding-left: 20px; font-size: 14px; line-height: 1.6; }
.install-error { margin: 0 0 14px; }
.install-config { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.flash.warn { background: #fef3c7; color: #92400e; }
.install-card a.btn-block { text-align: center; justify-content: center; }

/* Sign-in choices and My account */
.auth-google { display: flex !important; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 12.5px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.auth-note { margin-top: 14px; font-size: 13px; }
.topbar-account-link { display: flex; align-items: center; gap: inherit; color: inherit; text-decoration: none; min-width: 0; }
.topbar-account-link:hover .topbar-account-name { text-decoration: underline; }
.account-section { max-width: 560px; }
.account-section .section-body { padding: 16px 20px; }
.account-form .field input { max-width: 360px; }
