/* ==========================================================================
   KerjaKu Admin Portal — Modern Design System
   ========================================================================== */

/* ---- Design tokens ---- */
:root {
  color-scheme: light;

  /* Color palette */
  --color-bg: #f5f8f7;
  --color-surface: #ffffff;
  --color-surface-hover: #eef5f3;
  --color-border: #dbe7e3;
  --color-border-focus: #0b8f73;

  --color-text: #142522;
  --color-text-secondary: #58706b;
  --color-text-muted: #758a85;

  --color-primary: #087f68;
  --color-primary-hover: #066852;
  --color-primary-light: #e2f4ee;
  --color-on-primary: #ffffff;

  --color-success: #047857;
  --color-success-light: #d1fae5;
  --color-warning: #b45309;
  --color-warning-light: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-info: #2563eb;
  --color-info-light: #dbeafe;

  /* Secondary (blue) accent — charts, links inside panels, chart legend, focus glow. */
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-light: #dbeafe;
  --color-surface-muted: #eef5f3;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Border & radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Shadows — layered and low-spread so cards read as elevated, not heavy. */
  --shadow-sm: 0 1px 2px 0 rgb(16 40 34 / 0.05), 0 1px 1px -1px rgb(16 40 34 / 0.04);
  --shadow-md: 0 4px 10px -3px rgb(16 40 34 / 0.10), 0 2px 4px -3px rgb(16 40 34 / 0.06);
  --shadow-lg: 0 16px 32px -12px rgb(16 40 34 / 0.18), 0 4px 10px -6px rgb(16 40 34 / 0.10);
  --ring: 0 0 0 3px color-mix(in srgb, var(--color-primary) 22%, transparent);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 250ms ease;

  /* Layout */
  --sidebar-width: 248px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --content-max: 1440px;

  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Dark theme is applied exclusively through [data-theme="dark"], which theme-boot.js
   sets before first paint from the saved choice (falling back to the OS preference).
   A prefers-color-scheme media query is deliberately absent here: it would override an
   explicit "light" choice on a dark-OS device, so the toggle would appear broken. */
[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #0b1418;
  --color-surface: #13201f;
  --color-surface-hover: #1c2c2a;
  --color-surface-muted: #16241f;
  --color-border: #29403c;
  --color-text: #f1f6f4;
  --color-text-secondary: #b6cbc6;
  --color-text-muted: #8aa39d;
  --color-primary: #2dd4a7;
  --color-primary-hover: #5eead4;
  --color-primary-light: rgb(13 148 116 / 0.22);
  --color-on-primary: #052e26;
  --color-accent: #60a5fa;
  --color-accent-hover: #93c5fd;
  --color-accent-light: rgb(37 99 235 / 0.20);
  --color-success: #34d399;
  --color-warning: #fbbf24;
  --color-danger: #f87171;
  --color-info: #60a5fa;
  --color-success-light: rgb(5 150 105 / 0.18);
  --color-warning-light: rgb(217 119 6 / 0.18);
  --color-danger-light: rgb(220 38 38 / 0.18);
  --color-info-light: rgb(37 99 235 / 0.18);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 12px -3px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 18px 40px -16px rgb(0 0 0 / 0.65);
  --ring: 0 0 0 3px color-mix(in srgb, var(--color-primary) 30%, transparent);
}

/* ---- Reset & base ---- */
[hidden] { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  color: var(--color-text);
  background: var(--color-bg);
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; font-family: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: none; background: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
img { max-width: 100%; height: auto; display: block; }

/* ---- Accessibility ---- */
.skip {
  position: fixed;
  top: -100%;
  left: 0.5rem;
  z-index: 10000;
  background: var(--color-primary);
  color: var(--color-on-primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  transition: top var(--transition-fast);
}
.skip:focus { top: 0.5rem; }

/* ---- Layout ---- */
.admin-portal {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
  transition: transform var(--transition-base);
  transform: translateX(0);
}

.admin-sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-height);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.sidebar-brand-mark .admin-icon {
  width: 20px;
  height: 20px;
}

.sidebar-brand-text {
  min-width: 0;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-text small {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section-label {
  flex: none;
  padding: var(--space-4) var(--space-5) var(--space-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.admin-sidebar nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-1) var(--space-3) var(--space-4);
}

.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.admin-sidebar nav a .admin-icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.admin-sidebar nav a:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  text-decoration: none;
}

.admin-sidebar nav a:hover .admin-icon {
  color: var(--color-text-secondary);
}

.admin-sidebar nav a.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.admin-sidebar nav a.active .admin-icon {
  color: var(--color-primary);
}

.sidebar-help {
  flex: none;
  margin: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-hover);
  font-size: 11px;
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.sidebar-help .admin-icon {
  display: block;
  color: var(--color-success);
  margin-bottom: 6px;
}

.sidebar-help strong {
  display: block;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--color-text);
}

.sidebar-help p {
  margin: 3px 0 0;
  color: var(--color-text-muted);
}

/* Collapsed rail — icons only, centered */
.admin-sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
.admin-sidebar.collapsed .sidebar-brand-text,
.admin-sidebar.collapsed .sidebar-section-label,
.admin-sidebar.collapsed .sidebar-help,
.admin-sidebar.collapsed nav a span:not(.admin-icon) {
  display: none;
}
.admin-sidebar.collapsed nav {
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}
.admin-sidebar.collapsed nav a {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(18 40 76 / 0.35);
  display: none;
}

.admin-workspace {
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.admin-sidebar.collapsed ~ .admin-workspace {
  margin-left: var(--sidebar-collapsed);
}

/* Animate layout only on desktop, where the sidebar shares the flow.
   On mobile the sidebar is a fixed drawer, so no margin race on resize. */
@media (min-width: 901px) {
  .admin-sidebar { transition: transform var(--transition-base), width var(--transition-base); }
  .admin-workspace { transition: margin-left var(--transition-base); }
}

.admin-topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 25;
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
}

.menu-toggle:hover {
  background: var(--color-surface-hover);
}

.menu-toggle .admin-icon {
  width: 18px;
  height: 18px;
}

.topbar-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.topbar-title .slash {
  margin: 0 8px;
  color: var(--color-text-muted);
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-time {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
}

.account-menu {
  position: relative;
}

.account-menu > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 0;
  color: var(--color-text);
  list-style: none;
  min-height: 44px;
  cursor: pointer;
}

.account-menu > summary::-webkit-details-marker { display: none; }

.account-menu .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}

.account-name {
  display: block;
  line-height: 1.5;
  max-width: 160px;
  overflow-wrap: anywhere;
}

.account-name strong {
  font-size: 12px;
  font-weight: 600;
  display: block;
}

.account-name small {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: capitalize;
}

.account-popover {
  position: absolute;
  right: 0;
  top: 100%;
  width: 230px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 30;
}

.account-menu[open] .account-popover {
  display: block;
}

.account-popover > strong {
  font-size: 12px;
  display: block;
  margin-bottom: 4px;
}

.account-popover p {
  font-size: 10px;
  color: var(--color-text-muted);
  margin: 0 0 12px;
}

.admin-main {
  padding: clamp(var(--space-4), 3vw, var(--space-8));
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: var(--space-6);
}

.page-heading > div {
  flex: 1;
  min-width: 0;
}

.page-heading h1 {
  font-size: clamp(23px, 2vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

/* ---- Components ---- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.button:active { transform: scale(0.98); }

.button.primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-sm);
}

.button.primary:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-md); }

.button.secondary {
  background: var(--color-surface-hover);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.button.secondary:hover { background: var(--color-border); }

.button.danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.button.danger:hover { background: var(--color-danger); color: var(--color-on-primary); }

.button.small {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 11px;
}

.button.icon {
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
  border-radius: var(--radius-md);
}

.button.icon .admin-icon {
  width: 16px;
  height: 16px;
}

.button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- Form components ---- */

.field {
  margin-bottom: var(--space-4);
}

label.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; }
label.field small { font-size: 12px; font-weight: 400; color: var(--color-text-secondary); line-height: 1.5; }
label.field input, label.field select, label.field textarea { font-weight: 400; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.field label small {
  display: block;
  font-size: 11px;
  font-weight: 450;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 11px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--color-text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--color-primary);
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}

.field textarea {
  resize: vertical;
  min-height: 100px;
}

.field.error input,
.field.error select,
.field.error textarea {
  border-color: var(--color-danger);
}

.field-error {
  font-size: 11px;
  color: var(--color-danger);
  margin-top: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.one { grid-template-columns: minmax(0, 1fr); }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

/* ---- Panels & cards ---- */

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-6);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-hover);
}

.panel-head > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-head h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-head .lede {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 0;
}

.panel-body {
  padding: var(--space-6);
}

.panel-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
}

.panel-link .admin-icon {
  width: 14px;
  height: 14px;
}

.panel-link:hover { text-decoration: underline; }

/* ---- Tables ---- */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-hover);
  position: sticky;
  top: 0;
  z-index: 2;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

tr:hover { background: var(--color-surface-hover); }

/* ---- Badges & pills ---- */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge.success { background: var(--color-success-light); color: var(--color-success); }
.badge.warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge.danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge.info { background: var(--color-info-light); color: var(--color-info); }
.badge.neutral { background: var(--color-surface-hover); color: var(--color-text-secondary); }

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.pill.active { background: var(--color-success-light); color: var(--color-success); }
.pill.pending { background: var(--color-warning-light); color: var(--color-warning); }
.pill.closing { background: var(--color-warning-light); color: var(--color-warning); }
.pill.completed { background: var(--color-success-light); color: var(--color-success); }
.pill.review_required { background: var(--color-warning-light); color: var(--color-warning); }
.pill.rejected { background: var(--color-danger-light); color: var(--color-danger); }
.pill.local { background: var(--color-success-light); color: var(--color-success); }
.pill.staged { background: var(--color-surface-hover); color: var(--color-text-secondary); }
.pill.failed { background: var(--color-danger-light); color: var(--color-danger); }
.pill.paid { background: var(--color-success-light); color: var(--color-success); }

/* ---- Person cell ---- */

.person-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
}

.person-cell > div { min-width: 0; }

.person-cell .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-surface-hover);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.person-cell strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.person-cell small {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

/* Secondary line under a primary value inside a table cell
   (department/position, dates, employee codes, etc.). */
td small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

/* ---- Notices & alerts ---- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: var(--space-4);
}

.notice .admin-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.notice.info {
  background: var(--color-info-light);
  color: var(--color-info);
  border: 1px solid #bfdbfe;
}

.notice.success {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid #a7f3d0;
}

.notice.warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
  border: 1px solid #fde68a;
}

.notice.error {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

/* ---- Empty states ---- */

.empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
}

.empty .admin-icon {
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  color: var(--color-text-muted);
}

.empty > strong {
  display: block;
  font-size: 13px;
  color: var(--color-text);
  margin-bottom: 4px;
}

.empty > p {
  font-size: 12px;
  margin-bottom: 0;
}

/* ---- Pagination ---- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: var(--space-4);
}

.pagination a,
.pagination span {
  display: flex;
  align-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--color-text);
  text-decoration: none;
}

.pagination a:hover { background: var(--color-surface-hover); }

/* ---- Metrics ---- */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.metric {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  gap: 12px;
  align-items: center;
}

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.metric-info strong {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.metric-label {
  font-size: 11px;
  color: var(--color-text-secondary);
  display: block;
  margin-top: 4px;
}

/* ---- Dashboard grid ---- */

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 285px;
  gap: var(--space-6);
}

/* ---- Modals & drawers ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgb(15 23 42 / 0.4);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(600px, 92vw);
  max-height: 90vh;
  overflow: auto;
  animation: modal-in var(--transition-base);
}

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

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.modal-head h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-close {
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
}

.modal-close:hover {
  background: var(--color-surface-hover);
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-hover);
}

/* ---- Drawers ---- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgb(15 23 42 / 0.3);
  display: none;
}

.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--transition-base);
  z-index: 110;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.drawer-head h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.drawer-body {
  flex: 1;
  overflow: auto;
  padding: var(--space-6);
}

.drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-hover);
}

/* ---- Tables with images ---- */

.evidence-photo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--color-border);
}

/* ---- Responsive ---- */

@media (max-width: 1180px) {
  .admin-sidebar { width: 224px; }
  .admin-workspace { margin-left: 224px; }
  .admin-sidebar.collapsed { width: var(--sidebar-collapsed); }
  .admin-sidebar.collapsed ~ .admin-workspace { margin-left: var(--sidebar-collapsed); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .admin-sidebar {
    width: min(288px, 86vw);
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-workspace { margin-left: 0; }
  .admin-main { padding: var(--space-5); }
  .menu-toggle { display: flex; }
  .sidebar-backdrop { display: block; }
  .dashboard-date { display: none; }
}

@media (max-width: 720px) {
  .form-grid,
  .form-grid.three,
  .form-grid.two { grid-template-columns: 1fr; }
  .topbar-end { gap: 8px; }
  .account-name { max-width: 140px; }
}

@media (max-width: 560px) {
  .admin-topbar { padding: 0 var(--space-3); gap: 8px; }
  .topbar-end { gap: 6px; }
  .topbar-time,
  .topbar-divider { display: none; }
  .account-name { display: none; }
  .account-menu > summary { padding: 6px; gap: 4px; }
  .topbar-start { min-width: 0; flex: 1; }
  .topbar-title { max-width: 36vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Auth page (keep separate) ---- */

.auth-layout {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.auth-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  padding: clamp(32px, 6vw, 96px);
  background: var(--color-surface-hover);
  border-right: 1px solid var(--color-border);
}
.auth-intro-copy { max-width: 480px; }
.auth-intro-copy h2 { font-size: clamp(28px, 3vw, 44px); line-height: 1.2; margin: 16px 0 24px; }
.auth-intro-copy p, .auth-intro-foot { color: var(--color-text-secondary); line-height: 1.7; }
.auth-brand { color: var(--color-text); font-weight: 700; flex-wrap: wrap; }
.auth-brand-tag { font-size: 12px; color: var(--color-text-secondary); }
.auth-form-panel { display: grid; place-items: center; padding: 48px 32px; background: var(--color-surface); min-width: 0; }
.auth-form-content { width: 100%; max-width: 420px; }
.auth-form-content h1 { font-size: 28px; line-height: 1.25; margin: 12px 0; }
.auth-form-content .eyebrow { color: var(--color-text-secondary); font-size: 12px; }
.auth-password { position: relative; }
.auth-password input { padding-right: 76px; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-width: 64px; min-height: 44px; border: 0; border-radius: 6px; background: transparent; color: var(--color-text); cursor: pointer; }
.password-toggle:hover { background: var(--color-surface-hover); }
.auth-form .field input { min-height: 52px; font-size: 16px; }
.auth-caps { color: var(--color-warning); margin-top: 8px; }
.auth-submit { background: var(--color-primary); color: var(--color-on-primary); }
.auth-submit:hover { background: var(--color-primary-hover); }

/* Direct-content panels need the same inset as panels using .panel-body. */
.panel:has(> h2), .panel:has(> .branding-group-title) { padding: clamp(16px, 2.5vw, 28px); }
.panel > h2 { font-size: 20px; line-height: 1.35; margin-bottom: 8px; }
.panel > .lede { margin-bottom: 24px; }
.branding-dim { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .auth-intro { padding: 24px; border-right: 0; border-bottom: 1px solid var(--color-border); gap: 0; }
  .auth-intro .auth-brand { margin-bottom: 0; }
  .auth-intro-copy, .auth-intro-foot { display: none; }
  .auth-form-panel { padding: 24px 20px 40px; align-items: start; }
}

.auth-card {
  width: min(420px, 100%);
  max-width: 420px;
  margin: auto;
  padding: var(--space-8);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-6);
}

.auth-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
  display: grid;
  place-items: center;
  font-size: 20px;
}

.auth-brand-text {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.auth-brand-text small {
  display: block;
  font-size: 10px;
  font-weight: 450;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.auth-eyebrow {
  color: var(--color-primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.auth-card h1 {
  font-size: 25px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
}

.auth-description {
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: var(--space-6);
}

.auth-form {
  display: grid;
  gap: var(--space-4);
}

.auth-submit {
  width: 100%;
  min-height: 48px;
  font-size: 14px;
  border-radius: var(--radius-md);
  justify-content: space-between;
  padding: 12px 16px;
  margin-top: 4px;
}

.auth-help {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-4);
  margin-top: var(--space-6);
  font-size: 12px;
}

.auth-privacy {
  font-size: 10px;
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-top: var(--space-6);
}

/* ---- Focus visible for keyboard nav ---- */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ---- Utility ---- */
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.w-full { width: 100%; }
.block { display: block; }
.hidden { display: none !important; }

/* ---- Screen reader only ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ---- Icons in tables ---- */
.admin-portal .admin-icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ---- Legend dots ---- */
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot.success { background: var(--color-success); }
.legend-dot.warning { background: var(--color-warning); }
.legend-dot.info { background: var(--color-info); }
.legend-dot.danger { background: var(--color-danger); }

/* ---- Details summary styling ---- */
.details {
  margin-top: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}
.details summary {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
  background: var(--color-surface-hover);
}
.details summary::-webkit-details-marker { display: none; }
.details > div, .details > form, .details > p {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
}

/* ---- Component list for payroll ---- */
.component-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  font-size: 12px;
}
.component-list dt { color: var(--color-text-muted); font-size: 11px; }
.component-list dd { margin: 0; font-weight: 600; }

/* ==========================================================================
   Extended components (2026 UI rebuild)
   ========================================================================== */

/* Icon-only buttons */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.icon-button:hover { background: var(--color-surface-hover); color: var(--color-text); }
.icon-button .admin-icon { width: 18px; height: 18px; }

/* Theme toggle icon swap */
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline-flex; }

/* Buttons: ghost variant */
.button.ghost { background: transparent; color: var(--color-text-secondary); }
.button.ghost:hover { background: var(--color-surface-hover); color: var(--color-text); }

/* Filter/search bar */
.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.filter label { font-size: 12px; font-weight: 600; color: var(--color-text-secondary); }
.filter input,
.filter select {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  min-height: 40px;
}
.search-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 0;
}
.search-field .admin-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.search-field input {
  width: 100%;
  padding-left: 36px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-height: 40px;
  font-size: 13px;
}

/* Table toolbar for batch actions */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: var(--space-3);
  border: 1px solid var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-md);
  font-size: 12px;
}
[data-theme="dark"] .table-toolbar { background: rgb(14 165 233 / 0.12); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Row action buttons */
.row-actions { display: flex; gap: 6px; }

/* Table checkbox column */
td input[type="checkbox"],
th input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-primary); }

/* Drawer form layout */
.drawer-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.field.wide { grid-column: 1 / -1; }
.form-grid .field { margin-bottom: 0; }

/* Footer */
.admin-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 11px;
}
.admin-footer .admin-icon { width: 14px; height: 14px; }

/* Sidebar single-link stacking safety */
.admin-sidebar nav a span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Lightbox for evidence photos */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgb(15 23 42 / 0.85);
  padding: var(--space-6);
  animation: fade-in var(--transition-base);
}
.lightbox img { max-width: 92vw; max-height: 90vh; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgb(255 255 255 / 0.15);
  color: var(--color-on-primary);
  font-size: 26px;
  line-height: 1;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Evidence gallery in attendance drawer */
.evidence { display: grid; gap: var(--space-4); }
.evidence-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--color-surface);
}
.evidence-card-heading { display: flex; gap: 8px; margin-bottom: var(--space-3); flex-wrap: wrap; }
.evidence-layout { display: grid; grid-template-columns: 180px 1fr; gap: var(--space-4); }
.evidence-image img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  cursor: zoom-in;
  object-fit: cover;
  aspect-ratio: 3 / 4;
}
.evidence-waiting {
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  min-height: 200px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 11px;
  padding: var(--space-4);
}
.evidence-location h3 { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 8px; }
.evidence-address { font-size: 12px; color: var(--color-text-secondary); margin-bottom: var(--space-3); }
.evidence-location dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; margin: 0; }
.evidence-location dt { color: var(--color-text-muted); }
.evidence-location dd { margin: 0; }

/* Compact metric grid responsive already; add value alignment */
.metric > div { min-width: 0; }
.metric strong { overflow-wrap: anywhere; }

/* Settings tabs (pill style) */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-5);
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.settings-tabs a {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.settings-tabs a:hover { background: var(--color-surface-hover); text-decoration: none; color: var(--color-text); }
.settings-tabs a.active { background: var(--color-primary); color: var(--color-on-primary); }

/* Ratio / stat cards for analytics */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.stat-card strong { display: block; font-size: 22px; font-weight: 700; }
.stat-card span { font-size: 11px; color: var(--color-text-secondary); }

/* Dark mode: soften fixed light surfaces on alerts/badges */
[data-theme="dark"] .notice.info { background: rgb(37 99 235 / 0.16); border-color: rgb(37 99 235 / 0.35); }
[data-theme="dark"] .notice.success { background: rgb(5 150 105 / 0.16); border-color: rgb(5 150 105 / 0.35); }
[data-theme="dark"] .notice.warning { background: rgb(217 119 6 / 0.16); border-color: rgb(217 119 6 / 0.35); }
[data-theme="dark"] .notice.error { background: rgb(220 38 38 / 0.16); border-color: rgb(220 38 38 / 0.35); }
[data-theme="dark"] .badge.success,
[data-theme="dark"] .pill.active,
[data-theme="dark"] .pill.completed,
[data-theme="dark"] .pill.local,
[data-theme="dark"] .pill.paid { background: rgb(5 150 105 / 0.18); }
[data-theme="dark"] .badge.warning,
[data-theme="dark"] .pill.pending,
[data-theme="dark"] .pill.closing,
[data-theme="dark"] .pill.review_required { background: rgb(217 119 6 / 0.18); }
[data-theme="dark"] .badge.danger,
[data-theme="dark"] .pill.rejected,
[data-theme="dark"] .pill.failed { background: rgb(220 38 38 / 0.18); }
[data-theme="dark"] .badge.info { background: rgb(37 99 235 / 0.18); }
[data-theme="dark"] .badge.neutral,
[data-theme="dark"] .pill.staged { background: var(--color-surface-hover); }
[data-theme="dark"] .button.secondary { background: var(--color-surface-hover); }

/* Drawer layer: overlay above workspace, drawer above overlay; native dialogs
   use the browser top layer regardless of these values (--z-* documents intent). */
.drawer-overlay { z-index: 90; }
.drawer { z-index: 95; }
body.drawer-open { overflow: hidden; }
body.nav-open { overflow: hidden; }

/* Map containers must not overflow */
.leaflet-container, #site-map { max-width: 100%; border-radius: var(--radius-md); }

/* Mobile refinements */
@media (max-width: 720px) {
  .page-heading { flex-direction: column; align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions .button { flex: 1; }
  .evidence-layout { grid-template-columns: 1fr; }
  .evidence-image img { aspect-ratio: 4 / 5; }
  .admin-main { padding: var(--space-4); }
}

/* ==========================================================================
   Utility layer (used across views; previously undefined)
   ========================================================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: var(--space-5);
}
.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.2px;
}
.lede {
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.55;
}
.section-gap { margin-top: var(--space-5); }

.form-grid .wide,
.form-grid > .wide { grid-column: 1 / -1; }

/* Generic avatar token (was only defined inside .person-cell / .account-menu) */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
}
[data-theme="dark"] .avatar { background: rgb(14 165 233 / 0.18); }

/* Checkbox group (used by schedule day picker) */
.checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: 12px;
  cursor: pointer;
  min-height: 38px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.checkboxes label:hover { border-color: var(--color-border-focus); }
.checkboxes input[type="checkbox"] { accent-color: var(--color-primary); }

/* Compact record rows for card-style lists */
.record {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.record + .record { margin-top: var(--space-3); }
.record:hover { border-color: var(--color-border-focus); box-shadow: var(--shadow-sm); }
.record-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.record-main strong { font-size: 13px; }
.record-main small { color: var(--color-text-muted); font-size: 11px; overflow-wrap: anywhere; }
.record > .badge { flex: none; }
.record > .button { flex: none; }
.site-minimap-wrap {
  flex: 0 0 100%;
  display: grid;
  gap: 6px;
  max-width: 420px;
}
.site-minimap {
  width: 100%;
  min-height: 180px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
}
.site-minimap .leaflet-container { min-height: 180px; border-radius: inherit; }
.site-minimap-wrap > small { color: var(--color-text-muted); font-size: 11px; }
.mini-map-fallback { color: var(--color-text-muted); font-size: 12px; }
.pay-focus { border-color: var(--color-primary) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent); }
/* Layer scale: ordinary content 0, sticky/sidebar controls 10, drawer 20, dialog 30.
   Native modal dialogs use the browser top layer, above all z-index stacking contexts. */
:root { --z-content: 0; --z-sidebar: 10; --z-drawer: 20; --z-dialog: 30; }
/* Mini in-page confirmation popup for routine deletes and bulk actions. */
.confirm-dialog { position: fixed; inset: 0; margin: auto; width: min(420px, calc(100% - 32px)); max-width: 100%; max-height: calc(100dvh - 2rem); overflow: auto; padding: 24px; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-lg); }
.confirm-dialog::backdrop { background: rgb(15 23 42 / 0.45); }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 18px; }
.confirm-dialog p { margin: 0; color: var(--color-text-secondary); line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
body.dialog-open { overflow: hidden; }
@media (max-width: 520px) { .confirm-actions { flex-direction: column-reverse; } .confirm-actions .button { width: 100%; } }

/* Sticky table headers inside scrollable wrappers */
.table-wrap { overflow: auto; max-height: min(72vh, 900px); }
.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-surface);
  box-shadow: inset 0 -1px 0 var(--color-border);
}
.table-wrap thead a { color: inherit; }
.table-wrap thead a:hover { color: var(--color-primary); text-decoration: none; }

/* Drawer body must scroll while head/footer stay fixed */
.drawer-body { overflow-y: auto; flex: 1; min-height: 0; }

/* ==========================================================================
   Dashboard analytics components
   ========================================================================== */
.metric-info { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.metric-info strong { display: block; font-size: 24px; font-weight: 700; line-height: 1.15; }
.metric-label { font-size: 11px; color: var(--color-text-secondary); display: block; margin-top: 3px; }
.activity-panel, .team-overview { min-width: 0; }

.dashboard-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
}
.dashboard-date .admin-icon { width: 15px; height: 15px; }

.team-stat {
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
  text-align: center;
}
.team-stat strong { display: block; font-size: 34px; font-weight: 700; color: var(--color-primary); line-height: 1; }
.team-stat span { font-size: 12px; color: var(--color-text-secondary); }

.operational-legend { list-style: none; padding: var(--space-4) var(--space-5); display: grid; gap: var(--space-3); }
.operational-legend li { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--color-text-secondary); }
.operational-legend strong { margin-left: auto; color: var(--color-text); font-size: 14px; }

.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-3); font-size: 11px; color: var(--color-text-secondary); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Chart.js needs a height-constrained, relatively positioned wrapper, otherwise
   responsive + maintainAspectRatio:false grows the canvas on every resize. */
.chart-wrap { position: relative; width: 100%; height: 280px; }

@media (max-width: 1080px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
}

/* Employee drawer summary header */
.employee-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-hover);
}
.employee-summary-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.employee-summary-text strong { font-size: 13.5px; }
.employee-summary-text small { color: var(--color-text-muted); font-size: 11.5px; overflow-wrap: anywhere; }
.employee-summary .badge { flex: none; }

/* ==========================================================================
   Branding asset uploader (logo / ikon / favicon)
   ========================================================================== */
.branding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 248px), 1fr));
  gap: var(--space-4);
}
.branding-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.branding-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.branding-card-head strong { font-size: 13px; }
.branding-card-hint {
  font-size: 11px;
  line-height: 1.5;
  color: var(--color-text-muted);
}
.branding-dim {
  font-size: 11px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}
.branding-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 148px;
  padding: 12px;
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-hover);
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.branding-zone:hover,
.branding-zone:focus-within { border-color: var(--color-primary); }
.branding-zone.is-dragover { border-color: var(--color-primary); background: var(--color-primary-light); }
.branding-zone img { max-width: 128px; max-height: 128px; object-fit: contain; }
.branding-zone .branding-placeholder {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.5;
}
.branding-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.branding-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.branding-actions .button { flex: 1; justify-content: center; }
.branding-card .branding-reset { margin: 0; }

/* Tab link rendered as a plain anchor inside settings-tabs */
.settings-tabs a[aria-current="page"] { background: var(--color-primary); color: var(--color-on-primary); }

/* Branding asset group heading */
.branding-group-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  margin: var(--space-5) 0 var(--space-3);
}
.branding-group-title:first-of-type { margin-top: var(--space-4); }

/* Theme toggle on the login screen */
.auth-theme-row { display: flex; justify-content: flex-end; margin-bottom: var(--space-2); }
.auth-theme-row .icon-button { color: var(--color-text-secondary); }

.button.primary { background: var(--color-primary); color: var(--color-on-primary); }
.button.primary:hover { background: var(--color-primary-hover); }

/* Touch navigation stays compact so the active form remains above the fold. */
@media (max-width: 720px) {
  .settings-tabs { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; }
  .settings-tabs a { flex: 0 0 auto; white-space: nowrap; }
  .field input, .field select, .field textarea { font-size: 16px; }
  .button.small, .button.icon, .icon-button { min-height: 44px; min-width: 44px; }
}

@media (prefers-reduced-motion: no-preference) {
  .settings-tabs a, .field input, .field select, .field textarea {
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
  }
}

/* ==========================================================================
   Shell finish: shared baseline for all admin screens
   ========================================================================== */
.admin-sidebar {
  background: color-mix(in srgb, var(--color-surface) 94%, var(--color-primary-light));
  box-shadow: 4px 0 18px rgb(16 40 34 / 0.035);
}
.sidebar-brand { min-height: 72px; }
.sidebar-brand-mark {
  background: var(--color-primary);
  box-shadow: 0 5px 12px color-mix(in srgb, var(--color-primary) 22%, transparent);
}
.admin-sidebar nav a {
  position: relative;
  min-height: 44px;
}
.admin-sidebar nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  background: var(--color-primary);
}
.admin-topbar {
  background: color-mix(in srgb, var(--color-surface) 94%, transparent);
  backdrop-filter: blur(12px);
}
.topbar-title { color: var(--color-text-secondary); }
.topbar-title .slash { color: var(--color-border); }
.icon-button:hover { box-shadow: inset 0 0 0 1px var(--color-border); }
.admin-main > .page-heading { max-width: 100%; }
.page-heading h1 { font-size: clamp(24px, 2vw, 30px); }
.page-actions { align-items: center; }
.panel, .metric, .stat-card, .record {
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.panel:hover, .metric:hover, .stat-card:hover { box-shadow: var(--shadow-md); }
.metric { padding: var(--space-5) var(--space-4); }
.metric-icon { border-radius: 10px; }
.panel-head { background: var(--color-surface); padding-block: 18px; }
.panel-body { padding: clamp(var(--space-4), 2vw, var(--space-6)); }
.panel-link, a { transition: color var(--transition-fast); }
.button, .icon-button, .settings-tabs a, .admin-sidebar nav a,
.field input, .field select, .field textarea, .filter input, .filter select {
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.button.secondary { box-shadow: 0 1px 1px rgb(16 40 34 / 0.04); }
.button.secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }
.field input:hover, .field select:hover, .field textarea:hover,
.filter input:hover, .filter select:hover, .search-field input:hover { border-color: var(--color-text-muted); }
.field input:focus, .field select:focus, .field textarea:focus,
.search-field input:focus { box-shadow: var(--ring); }
.table-wrap { box-shadow: var(--shadow-sm); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color var(--transition-fast); }
.admin-footer { max-width: var(--content-max); width: 100%; margin-inline: auto; }

/* Shared map/form hooks used by schedule pages. */
.site-map-picker {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-muted);
}
.site-map-intro { display: grid; gap: 4px; }
.site-map-intro strong { font-size: 13px; }
.site-map-intro p, .site-map-provider, .site-map-summary, .site-map-error { font-size: 12px; color: var(--color-text-secondary); }
.site-map-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.site-map { min-height: 280px; overflow: hidden; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.site-map-summary { padding: 10px 12px; border-radius: var(--radius-md); background: var(--color-surface); }
.site-map-error { color: var(--color-danger); }

/* Legacy auth/password hooks share same tokens as login and portal shell. */
.auth-page { min-height: 100svh; display: grid; place-items: center; padding: var(--space-4); background: var(--color-bg); }
.auth-page .auth-card { margin: 0; }
.auth-page .brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-6); color: var(--color-text); font-size: 18px; font-weight: 700; }
.auth-page .brand::first-letter { color: var(--color-primary); }
.auth-page form { display: grid; gap: var(--space-4); }
.auth-page form > label { display: grid; gap: var(--space-2); color: var(--color-text-secondary); font-size: 12px; font-weight: 600; }
.auth-page form input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.auth-page form button { min-height: 44px; padding: 10px 16px; border-radius: var(--radius-md); background: var(--color-primary); color: var(--color-on-primary); font-weight: 600; }
.auth-page .alert { padding: 12px; border-radius: var(--radius-md); margin-bottom: var(--space-4); }
.auth-page .alert.error { color: var(--color-danger); background: var(--color-danger-light); }
.auth-kicker { color: var(--color-primary); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }

@media (max-width: 900px) {
  .admin-main { max-width: none; }
  .admin-footer { max-width: none; }
}
@media (max-width: 420px) {
  .page-heading h1 { font-size: 22px; }
  .page-actions { display: grid; grid-template-columns: 1fr; }
  .page-actions .button { width: 100%; }
  .panel-head { align-items: flex-start; flex-direction: column; gap: var(--space-3); }
  .panel-head .toolbar { width: 100%; }
  .panel-head .toolbar .button { flex: 1; }
  .metric { padding: var(--space-4); }
}
