/* ============================================================================
   Derkonig Logistics — Shared Components CSS
   ========================================================================== */

/* ============================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--dk-spacing-2);
  padding: var(--dk-spacing-3) var(--dk-spacing-4);
  font-size: var(--dk-font-button);
  font-weight: var(--dk-font-button-weight);
  border: none;
  border-radius: var(--dk-radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.btn:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary Button */
.btn-primary {
  background-color: var(--dk-primary);
  color: white;
  box-shadow: var(--dk-shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background-color: #1e40af;
  box-shadow: var(--dk-shadow-md);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:focus {
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

/* Secondary Button */
.btn-secondary {
  background-color: transparent;
  color: var(--dk-primary);
  border: 2px solid var(--dk-primary);
}

.btn-secondary:hover:not(:disabled) {
  background-color: rgba(29, 78, 216, 0.05);
}

.btn-secondary:focus {
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

/* Tertiary Button */
.btn-tertiary {
  background-color: transparent;
  color: var(--dk-primary);
  border: none;
}

.btn-tertiary:hover:not(:disabled) {
  color: var(--dk-secondary);
}

.btn-tertiary:focus {
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

/* Destructive Button */
.btn-destructive {
  background-color: var(--dk-error);
  color: white;
  box-shadow: var(--dk-shadow-sm);
}

.btn-destructive:hover:not(:disabled) {
  background-color: #b91c1c;
  box-shadow: var(--dk-shadow-md);
  transform: translateY(-1px);
}

.btn-destructive:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Button Sizes */
.btn-sm {
  padding: var(--dk-spacing-2) var(--dk-spacing-3);
  font-size: 12px;
  font-weight: var(--dk-font-label-weight);
}

.btn-lg {
  padding: var(--dk-spacing-4) var(--dk-spacing-5);
  font-size: 16px;
}

.btn-block {
  width: 100%;
  display: flex;
}

/* Loading State */
.btn.is-loading {
  position: relative;
  color: transparent;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
  to { transform: rotate(360deg); }
}

/* ============================================================================
   Cards
   ========================================================================== */

.card {
  background-color: var(--dk-surface);
  border: none;
  border-radius: var(--dk-card-radius);
  padding: var(--dk-spacing-5);
  box-shadow: var(--dk-card-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--dk-card-shadow-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--dk-spacing-3);
  padding-bottom: var(--dk-spacing-3);
  border-bottom: 1px solid var(--dk-border);
}

.card-header h2 {
  margin: 0;
  font-size: var(--dk-font-card-heading);
  font-weight: var(--dk-font-card-heading-weight);
  display: flex;
  align-items: center;
}

/* Small outline icon next to a card-header title (e.g. the wallet icon on "Payment Collection")
   — plain, no circular badge behind it, matching how the reference's own card-header icons sit
   directly next to the title with no background treatment. */
.card-header-icon {
  display: inline-flex;
  margin-right: var(--dk-spacing-2);
  color: var(--dk-text-secondary);
}

.card-header-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.25;
}

/* Circular light-gray badge behind a small icon in a list-style stat row (e.g. the Today/This
   Week/This Month/All-Time breakdown) — matches the reference dashboard's Total/Active/New
   Client row treatment, distinct from .card-header-icon's plain (no-badge) style next to a
   card title. */
.stat-badge-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--dk-background);
  color: var(--dk-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-badge-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.25;
}

.card-content {
  margin-bottom: var(--dk-spacing-4);
}

.card-footer {
  display: flex;
  gap: var(--dk-spacing-2);
  padding-top: var(--dk-spacing-3);
  border-top: 1px solid var(--dk-border);
}

.card.compact {
  padding: var(--dk-spacing-3);
}

.card.elevated {
  box-shadow: var(--dk-shadow-lg);
}

/* Summary Card */
.card-summary {
  display: flex;
  flex-direction: column;
  gap: var(--dk-spacing-2);
}

.card-summary-label {
  font-size: var(--dk-font-secondary);
  font-weight: var(--dk-font-secondary-weight);
  color: var(--dk-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-summary-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--dk-text-primary);
}

/* Dashboard KPI stat cards — cleaner, more spacious treatment: generous padding, a bigger clearer
   number, a small uppercase label above it. Scoped to .dashboard-stat-card specifically (added
   alongside .card on the four Dashboard screens' stat cards only) rather than changing the base
   .card-summary every screen uses (e.g. Rider Profile's Status/Outstanding/Fine/Bike cards) — this
   first pass is Dashboard-only by design, so other screens' cards stay exactly as they are. */
.card.dashboard-stat-card {
  padding: var(--dk-spacing-5);
}

.dashboard-stat-card .card-summary {
  gap: var(--dk-spacing-3);
}

.dashboard-stat-card .card-summary-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.dashboard-stat-card .card-summary-value {
  font-size: 32px;
  line-height: 1.1;
}

/* KPI stat-card — Super Admin dashboard's top-row cards only, opted into per-dashboard as each
   one gets its own visual-redesign pass. Replaces .card-summary's stacked label/value with a
   light-gray header band (uppercase label + divider), the number centered in whitespace, and a
   fixed-height comparison row pinned to the bottom — present (though sometimes left empty) on
   every card so they all stay the same height whether or not that card has a real trend to show.
   Fixed (not min-) height plus a max-width, both deliberately tight, so a row of these reads
   closer to the reference's compact proportions instead of stretching to fill the row — pair with
   a capped grid-template-columns track on the row's own wrapper (e.g. minmax(0, 260px)), since
   the max-width here alone wouldn't stop a wider 1fr track from leaving empty space around the
   card. A dashboard that hasn't had this pass yet keeps using bare .dashboard-stat-card /
   .card-summary exactly as before. */
.dashboard-stat-card.stat-card-plain {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 150px;
  max-width: 260px;
  overflow: hidden;
}

/* Fixed height (not auto/min) sized to fit two lines of the label uniformly — Admin's four-card
   row packs narrower per-card widths than Super Admin's three-card row at the same container
   width (both cap at minmax(0,260px), but 4 columns need more total width to stay uncompressed),
   so a label like "Pending inspections" can wrap there where it wouldn't at the full 260px. A
   fixed height means every card's header is the same height regardless of whether ITS OWN label
   wraps to one line or two, so .kpi-card-body (flex:1 below) always starts at the same Y position
   across all cards in a row — no more depending on which specific labels happen to wrap. */
.kpi-card-header {
  background-color: var(--dk-background);
  padding: var(--dk-spacing-2) var(--dk-spacing-4);
  border-bottom: 1px solid var(--dk-border);
  height: 52px;
  display: flex;
  align-items: center;
}
.kpi-card-label {
  font-size: 14px;
  font-weight: var(--dk-font-card-heading-weight);
  color: var(--dk-text-primary);
}

.kpi-card-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--dk-spacing-3) var(--dk-spacing-4);
}

.kpi-card-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--dk-text-primary);
  text-align: center;
}

/* Fixed min-height regardless of content — Pending Inspections leaves this empty (no honest
   baseline to show a trend against) but still needs the same card height as Total Riders / Total
   Collected, which populate it with trendLineHTML()'s real comparison. */
.kpi-card-trend {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--dk-spacing-2);
  padding: var(--dk-spacing-1) var(--dk-spacing-4) var(--dk-spacing-2);
  font-size: 13px;
  color: var(--dk-text-secondary);
}

/* Small colored-dot legend for a chart, sitting above it — e.g. the payment-method breakdown on
   the Payment Collection bar chart. */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--dk-spacing-4);
  margin-bottom: var(--dk-spacing-3);
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--dk-text-secondary);
}

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================================================
   Two-column dashboard layout: a wider main column plus a narrower sidebar card (e.g. a tabbed
   activity feed) that runs the full height of the main column. Generic/reusable — not tied to
   any one dashboard.
   ========================================================================== */

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--dk-spacing-5);
  align-items: start;
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--dk-spacing-5);
}

.dashboard-sidebar .card {
  height: 100%;
}

@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   Segmented Tab Group — a small pill-track control for switching between a few views inside one
   card (e.g. a "Payments / Fines / New Riders" activity feed), without navigating anywhere.
   ========================================================================== */

.tab-group {
  display: inline-flex;
  background-color: var(--dk-background);
  border-radius: var(--dk-radius-lg);
  padding: 4px;
  gap: 4px;
  margin-bottom: var(--dk-spacing-4);
}

.tab-btn {
  padding: var(--dk-spacing-2) var(--dk-spacing-3);
  border: none;
  background: none;
  border-radius: var(--dk-radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--dk-text-secondary);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.tab-btn:hover {
  color: var(--dk-text-primary);
}

.tab-btn.active {
  background-color: var(--dk-surface);
  color: var(--dk-text-primary);
  box-shadow: var(--dk-shadow-sm);
}

/* ============================================================================
   Activity Row — one entry in a feed list: avatar, title/subtitle stacked left, an optional
   amount + date stacked right, all clickable through to the relevant record.
   ========================================================================== */

.activity-row {
  display: flex;
  align-items: center;
  gap: var(--dk-spacing-3);
  padding: var(--dk-spacing-3) 0;
  border-bottom: 1px solid var(--dk-border);
  text-decoration: none;
  color: inherit;
}

.activity-row:last-child {
  border-bottom: none;
}

.activity-row:hover {
  background-color: var(--dk-surface-alt);
}

.activity-row-body {
  flex: 1;
  min-width: 0;
}

.activity-row-title {
  font-size: var(--dk-font-body);
  font-weight: 600;
  color: var(--dk-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-row-subtitle {
  font-size: var(--dk-font-secondary);
  color: var(--dk-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-row-meta {
  text-align: right;
  flex-shrink: 0;
}

.activity-row-amount {
  font-size: var(--dk-font-body);
  font-weight: 700;
  color: var(--dk-text-primary);
}

.activity-row-date {
  font-size: var(--dk-font-secondary);
  color: var(--dk-text-secondary);
}

/* ============================================================================
   Badges
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--dk-spacing-1);
  padding: var(--dk-spacing-1) var(--dk-spacing-2);
  font-size: var(--dk-font-secondary);
  font-weight: var(--dk-font-label-weight);
  border-radius: var(--dk-radius-md);
  white-space: nowrap;
}

.badge-success {
  background-color: rgba(var(--dk-success-rgb), var(--dk-tint-opacity));
  color: var(--dk-success);
  border: 1px solid var(--dk-success);
}

.badge-error {
  background-color: rgba(var(--dk-error-rgb), var(--dk-tint-opacity));
  color: var(--dk-error);
  border: 1px solid var(--dk-error);
}

.badge-warning {
  background-color: rgba(var(--dk-accent-rgb), var(--dk-tint-opacity));
  color: var(--dk-accent);
  border: 1px solid var(--dk-accent);
}

.badge-info {
  background-color: rgba(var(--dk-info-rgb), var(--dk-tint-opacity));
  color: var(--dk-info);
  border: 1px solid var(--dk-info);
}

.badge-primary {
  background-color: rgba(var(--dk-primary-rgb), var(--dk-tint-opacity));
  color: var(--dk-primary);
  border: 1px solid var(--dk-primary);
}

.badge-fine {
  background-color: rgba(var(--dk-fine-rgb), var(--dk-tint-opacity));
  color: var(--dk-fine);
  border: 1px solid var(--dk-fine);
}

.badge-secondary {
  background-color: rgba(var(--dk-info-rgb), var(--dk-tint-opacity));
  color: var(--dk-text-secondary);
  border: 1px solid var(--dk-border);
}

.badge-lg {
  padding: var(--dk-spacing-2) var(--dk-spacing-3);
  font-size: var(--dk-font-body);
}

.badge-with-icon::before {
  content: '●';
  margin-right: var(--dk-spacing-1);
}

/* ============================================================================
   Form Elements
   ========================================================================== */

.form-group {
  margin-bottom: var(--dk-spacing-4);
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: var(--dk-spacing-2);
  font-size: var(--dk-font-label);
  font-weight: var(--dk-font-label-weight);
  color: var(--dk-text-primary);
}

.form-group.required label::after {
  content: '*';
  color: var(--dk-error);
  margin-left: var(--dk-spacing-1);
}

.form-control {
  padding: var(--dk-spacing-3);
  font-size: var(--dk-font-body);
  color: var(--dk-text-primary);
  background-color: var(--dk-surface);
  border: 1px solid var(--dk-border);
  border-radius: var(--dk-radius-lg);
  transition: all 0.2s ease;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--dk-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.form-control:disabled {
  background-color: #f9fafb;
  color: var(--dk-text-secondary);
  cursor: not-allowed;
}

.form-control:invalid {
  border-color: var(--dk-error);
}

.form-control.has-error {
  border-color: var(--dk-error);
  background-color: rgba(220, 38, 38, 0.02);
}

.form-control.has-error:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Password field show/hide toggle */
.password-field-wrap {
  position: relative;
}

.password-field-wrap .form-control {
  padding-right: 60px;
}

.password-toggle-btn {
  position: absolute;
  right: var(--dk-spacing-2);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px var(--dk-spacing-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--dk-primary);
  cursor: pointer;
}

.password-toggle-btn:hover {
  text-decoration: underline;
}

/* Photo/file upload field — native <input type="file"> renders very inconsistently across
   browsers (often just plain unstyled browser chrome, easy to overlook next to styled
   .form-control fields), so it's visually hidden but still fully accessible/keyboard-operable,
   and a real styled button plus a filename readout stand in as the visible control. */
.file-upload-field {
  display: flex;
  align-items: center;
  gap: var(--dk-spacing-3);
  flex-wrap: wrap;
}

.file-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-upload-btn {
  cursor: pointer;
  margin: 0;
  display: inline-flex;
  align-items: center;
}

.file-upload-input:focus-visible + .file-upload-btn {
  outline: 2px solid var(--dk-primary);
  outline-offset: 2px;
}

/* "History" icon button — opens the full change-history modal for one record */
.history-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  margin-left: 4px;
  color: var(--dk-text-secondary);
  vertical-align: middle;
  border-radius: var(--dk-radius-sm, 4px);
}

.history-btn:hover {
  color: var(--dk-primary);
  background-color: rgba(29, 78, 216, 0.08);
}

/* Make Payment's auto-calculated summary figures — visually distinct from the actually-editable
   Payment Amount field below them, so staff don't wonder why they can't click into these. */
.calculated-figure {
  opacity: 0.85;
  position: relative;
}

.calculated-figure-label {
  font-size: 11px;
  color: var(--dk-text-secondary);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

input.form-control,
select.form-control,
textarea.form-control {
  width: 100%;
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
}

.form-control::placeholder {
  color: var(--dk-text-secondary);
}

/* Select Styling */
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231D4ED8' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--dk-spacing-3) center;
  padding-right: var(--dk-spacing-6);
}

/* Checkbox & Radio */
input[type='checkbox'],
input[type='radio'] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--dk-primary);
}

.checkbox-group,
.radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--dk-spacing-2);
}

.checkbox-item,
.radio-item {
  display: flex;
  align-items: center;
  gap: var(--dk-spacing-2);
  cursor: pointer;
}

.checkbox-item label,
.radio-item label {
  margin-bottom: 0;
  cursor: pointer;
}

/* Form Error */
.form-error {
  display: flex;
  align-items: center;
  gap: var(--dk-spacing-1);
  margin-top: var(--dk-spacing-1);
  font-size: var(--dk-font-secondary);
  color: var(--dk-error);
}

.form-error::before {
  content: '⚠';
  flex-shrink: 0;
}

/* Form Help Text */
.form-help {
  margin-top: var(--dk-spacing-1);
  font-size: var(--dk-font-secondary);
  color: var(--dk-text-secondary);
}

/* ============================================================================
   Tables
   ========================================================================== */

.table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  background-color: var(--dk-surface);
}

.table thead {
  background-color: var(--dk-surface-alt);
  border-bottom: 1px solid var(--dk-border);
}

.table-wrapper .table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: var(--dk-surface-alt);
}

.table th {
  padding: var(--dk-spacing-3);
  text-align: left;
  font-size: var(--dk-font-table-heading);
  font-weight: var(--dk-font-table-heading-weight);
  color: var(--dk-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody tr {
  border-bottom: 1px solid var(--dk-border);
  transition: background-color 0.15s ease;
}

.table tbody tr:nth-child(even) {
  background-color: var(--dk-surface-alt);
}

.table tbody tr:hover {
  background-color: rgba(var(--dk-primary-rgb), 0.06);
}

.table td {
  padding: var(--dk-spacing-3);
  font-size: var(--dk-font-body);
  color: var(--dk-text-primary);
}

.table td.text-secondary {
  color: var(--dk-text-secondary);
}

.table-compact td {
  padding: var(--dk-spacing-2);
  font-size: var(--dk-font-secondary);
}

/* Table with Action Buttons */
.table td.action-cell {
  display: flex;
  gap: var(--dk-spacing-2);
  align-items: center;
}

.table td.action-cell .btn {
  padding: var(--dk-spacing-2) var(--dk-spacing-3);
  font-size: 12px;
}

/* Inline field errors (attachFieldValidation() in app.js: phone digits only, email shape). */
.form-control.is-invalid {
  border-color: var(--dk-error);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.field-error {
  margin-top: 6px;
  font-size: 12px;
  color: var(--dk-error);
}

/* A heads-up, not an error: e.g. a rider's details matching the signed-in staff member's own. */
.field-warning {
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--dk-text-primary);
  background-color: rgba(245, 158, 11, 0.12);
  border-left: 3px solid var(--dk-accent);
  border-radius: var(--dk-radius-md);
}

/* Edit + ▾ joined into one control (the ▾ opens the row menu, see openRowMenu() in app.js). */
.split-btn {
  display: inline-flex;
}

.split-btn > .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.split-btn > .split-btn-toggle {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left-width: 0;
  padding-left: var(--dk-spacing-2);
  padding-right: var(--dk-spacing-2);
}

/* Row action menu: lives on <body> with fixed positioning so a scrolling table can't clip it.
   Same look as the "+Create" header dropdown. */
.row-menu {
  position: fixed;
  min-width: 200px;
  padding: var(--dk-spacing-2);
  background-color: var(--dk-surface);
  border: 1px solid var(--dk-border);
  border-radius: var(--dk-radius-lg);
  box-shadow: var(--dk-shadow-lg);
  z-index: var(--dk-z-dropdown);
}

.row-menu-item {
  display: block;
  width: 100%;
  padding: var(--dk-spacing-2) var(--dk-spacing-3);
  border: none;
  border-radius: var(--dk-radius-md);
  background: none;
  color: var(--dk-text-primary);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.row-menu-item:hover,
.row-menu-item:focus-visible {
  background-color: var(--dk-background);
  outline: none;
}

.row-menu-item-destructive {
  color: var(--dk-error);
}

/* Checkbox column and the bar that appears once riders are ticked. */
.table th.select-cell,
.table td.select-cell {
  width: 40px;
}

.select-cell input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.bulk-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--dk-spacing-3);
  margin-bottom: var(--dk-spacing-3);
  padding: var(--dk-spacing-2) var(--dk-spacing-3);
  border: 1px solid var(--dk-primary);
  border-radius: var(--dk-radius-lg);
  background-color: var(--dk-surface);
  background-color: color-mix(in srgb, var(--dk-primary) 8%, var(--dk-surface));
}

.bulk-bar-count {
  font-weight: 600;
}

.bulk-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--dk-spacing-2);
}

/* ============================================================================
   Alerts
   ========================================================================== */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--dk-spacing-3);
  padding: var(--dk-spacing-4);
  border-radius: var(--dk-radius-lg);
  border-left: 4px solid;
  margin-bottom: var(--dk-spacing-4);
}

.alert-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 18px;
  margin-left: auto;
  color: inherit;
  transition: opacity 0.2s ease;
}

.alert-close:hover {
  opacity: 0.7;
}

.alert-title {
  font-weight: 600;
  margin-bottom: var(--dk-spacing-1);
}

.alert-content {
  font-size: var(--dk-font-body);
  line-height: 1.5;
}

.alert-info {
  background-color: rgba(var(--dk-info-rgb), calc(var(--dk-tint-opacity) / 2));
  border-color: var(--dk-info);
  color: var(--dk-alert-info-text);
}

.alert-success {
  background-color: rgba(var(--dk-success-rgb), calc(var(--dk-tint-opacity) / 2));
  border-color: var(--dk-success);
  color: var(--dk-alert-success-text);
}

.alert-warning {
  background-color: rgba(var(--dk-accent-rgb), calc(var(--dk-tint-opacity) / 2));
  border-color: var(--dk-accent);
  color: var(--dk-alert-warning-text);
}

.alert-error,
.alert-danger {
  background-color: rgba(var(--dk-error-rgb), calc(var(--dk-tint-opacity) / 2));
  border-color: var(--dk-error);
  color: var(--dk-alert-error-text);
}

/* ============================================================================
   Loading States
   ========================================================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--dk-border) 25%,
    rgba(229, 231, 235, 0.5) 50%,
    var(--dk-border) 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--dk-border);
  border-radius: 50%;
  border-top-color: var(--dk-primary);
  animation: spinner 0.6s linear infinite;
}

/* ============================================================================
   Empty State
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--dk-spacing-8);
  text-align: center;
  background-color: var(--dk-surface);
  border-radius: var(--dk-radius-lg);
  border: 1px dashed var(--dk-border);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: var(--dk-spacing-4);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--dk-font-section-heading);
  font-weight: var(--dk-font-section-heading-weight);
  margin-bottom: var(--dk-spacing-2);
}

.empty-state-text {
  color: var(--dk-text-secondary);
  margin-bottom: var(--dk-spacing-4);
}

/* ============================================================================
   Search & Filter
   ========================================================================== */

.search-box {
  position: relative;
  width: 100%;
}

.search-box input {
  width: 100%;
  padding-left: var(--dk-spacing-6);
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: var(--dk-spacing-3);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--dk-text-secondary);
}

.filter-group {
  display: flex;
  gap: var(--dk-spacing-2);
  margin-bottom: var(--dk-spacing-4);
  flex-wrap: wrap;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: var(--dk-spacing-2);
}

/* ============================================================================
   Modals & Dropdowns
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--dk-z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background-color: var(--dk-surface);
  border-radius: var(--dk-radius-lg);
  box-shadow: var(--dk-shadow-lg);
  width: 90%;
  max-width: 500px;
  /* Same 100vh -> dvh reasoning as .app-sidebar/.app-main in app.css — on a mobile browser 90vh is
     a static value that can exceed the actually-visible viewport while chrome is showing, letting
     this modal's own bottom edge (and whatever's near it — a footer button, the last form field)
     render below the fold. 90dvh tracks the real visible viewport instead. overflow-y:auto already
     present is the correct second line of defense once the box is sized right. */
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
}

.modal-header {
  padding: var(--dk-spacing-4);
  border-bottom: 1px solid var(--dk-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 24px;
  color: var(--dk-text-secondary);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: var(--dk-spacing-4);
}

.modal-footer {
  padding: var(--dk-spacing-4);
  border-top: 1px solid var(--dk-border);
  display: flex;
  gap: var(--dk-spacing-2);
  justify-content: flex-end;
}

/* ============================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
  position: fixed;
  top: var(--dk-spacing-5);
  right: var(--dk-spacing-5);
  z-index: var(--dk-z-notification);
  display: flex;
  flex-direction: column;
  gap: var(--dk-spacing-2);
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--dk-spacing-2);
  padding: var(--dk-spacing-3) var(--dk-spacing-4);
  background-color: var(--dk-surface);
  border: 1px solid var(--dk-border);
  border-left: 4px solid var(--dk-success);
  border-radius: var(--dk-radius-lg);
  box-shadow: var(--dk-shadow-lg);
  color: var(--dk-text-primary);
  font-size: var(--dk-font-body);
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-success { border-left-color: var(--dk-success); }
.toast-error { border-left-color: var(--dk-error); }
.toast-info { border-left-color: var(--dk-info); }
.toast-warning { border-left-color: var(--dk-accent); }

.toast-icon {
  flex-shrink: 0;
  font-weight: 700;
}

.toast-message {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--dk-text-secondary);
  padding: 0;
  line-height: 1;
}

.toast-close:hover {
  color: var(--dk-text-primary);
}

@media (max-width: 480px) {
  .toast-container {
    left: var(--dk-spacing-3);
    right: var(--dk-spacing-3);
    top: var(--dk-spacing-3);
    max-width: none;
  }
}

/* ============================================================================
   Responsive Tables (Mobile)
   ========================================================================== */

@media (max-width: 768px) {
  .table-responsive {
    overflow-x: auto;
  }

  .table-stacked {
    width: 100%;
    border-collapse: collapse;
  }

  .table-stacked thead {
    display: none;
  }

  .table-stacked tbody tr {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--dk-spacing-2);
    margin-bottom: var(--dk-spacing-3);
    padding: var(--dk-spacing-3);
    border: 1px solid var(--dk-border);
    border-radius: var(--dk-radius-lg);
    background-color: var(--dk-surface);
  }

  .table-stacked td {
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .table-stacked td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--dk-text-primary);
    margin-right: var(--dk-spacing-2);
  }

  .table-stacked td.action-cell {
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
  }

  .table-stacked td.action-cell .btn {
    width: 100%;
  }

  /* Edit + ▾ stays one full-width row on a card. */
  .table-stacked td.action-cell .split-btn {
    width: 100%;
  }

  .table-stacked td.action-cell .split-btn > .btn:first-child {
    flex: 1;
  }

  .table-stacked td.action-cell .split-btn > .split-btn-toggle {
    width: auto;
    padding-left: var(--dk-spacing-4);
    padding-right: var(--dk-spacing-4);
  }

  /* The checkbox leads the card, label on the left as for every other field. */
  .table-stacked td.select-cell {
    width: auto;
  }

  /* On phones the bar sits just above the bottom tab bar, so it's reachable while scrolling. */
  body.mobile-tabbar .bulk-bar {
    position: fixed;
    left: var(--dk-spacing-3);
    right: var(--dk-spacing-3);
    top: auto;
    bottom: calc(var(--dk-bottom-tab-bar-height, 77px) + var(--dk-bottom-tab-bar-margin, 12px) * 2 + env(safe-area-inset-bottom, 0px));
    z-index: 894;
    margin: 0;
    box-shadow: var(--dk-card-shadow-hover);
  }
}

/* ============================================================================
   Helper Classes
   ========================================================================== */

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.italic {
  font-style: italic;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.transition-all {
  transition: all 0.2s ease;
}

.cursor-pointer {
  cursor: pointer;
}

.cursor-not-allowed {
  cursor: not-allowed;
}

/* ============================================================================
   Payment Calendar
   ========================================================================== */

.pay-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--dk-spacing-3);
}

.pay-cal-month-label {
  font-weight: 600;
  font-size: 15px;
}

.pay-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.pay-cal-weekdays {
  margin-bottom: var(--dk-spacing-2);
}

.pay-cal-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--dk-text-secondary);
  padding: 4px 0;
}

.pay-cal-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--dk-radius-md);
  background-color: var(--dk-surface-alt, rgba(0, 0, 0, 0.02));
  border: 1px solid var(--dk-border);
  font-size: 12px;
}

.pay-cal-cell-empty {
  border: none;
  background: transparent;
}

.pay-cal-paid {
  background-color: rgba(var(--dk-success-rgb), var(--dk-tint-opacity));
  border-color: var(--dk-success);
  color: var(--dk-success);
  font-weight: 600;
}

.pay-cal-outstanding {
  background-color: rgba(var(--dk-accent-rgb), var(--dk-tint-opacity));
  border-color: var(--dk-accent);
  color: var(--dk-accent);
  font-weight: 600;
}

.pay-cal-failed {
  background-color: rgba(var(--dk-error-rgb), var(--dk-tint-opacity));
  border-color: var(--dk-error);
  color: var(--dk-error);
  font-weight: 600;
}

.pay-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--dk-spacing-4);
  margin-top: var(--dk-spacing-3);
  font-size: 12px;
  color: var(--dk-text-secondary);
}

.pay-cal-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  border: none;
}

.pay-cal-dot.pay-cal-paid {
  background-color: var(--dk-success);
}

.pay-cal-dot.pay-cal-outstanding {
  background-color: var(--dk-accent);
}

.pay-cal-dot.pay-cal-failed {
  background-color: var(--dk-error);
}


/* ============================================================================
   Contact Footer — templates/partials/contact-footer.php. Shared by every portal page (inside
   app-shell.php's scroll area), the login page, and the public Apply page, so it lives here in
   components.css (the one stylesheet all three documents load) and uses only theme tokens —
   follows light/dark automatically on portal pages; login/apply are always light.
   ========================================================================== */

.dk-contact-footer {
  margin-top: var(--dk-spacing-6);
  padding-top: var(--dk-spacing-4);
  border-top: 1px solid var(--dk-border);
  font-size: var(--dk-font-secondary);
  line-height: 1.5;
  color: var(--dk-text-secondary);
}

.dk-contact-footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--dk-spacing-3) var(--dk-spacing-6);
}

.dk-contact-footer-brand {
  min-width: 0;
  max-width: 420px;
}

.dk-contact-footer-name {
  display: block;
  font-size: var(--dk-font-table-heading);
  font-weight: 600;
  color: var(--dk-text-primary);
  margin-bottom: 2px;
}

.dk-contact-footer-address {
  font-style: normal;
}

.dk-contact-footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--dk-spacing-2) var(--dk-spacing-5);
}

.dk-contact-footer-links li {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dk-contact-footer-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dk-contact-footer-links a {
  color: var(--dk-primary);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.dk-contact-footer-copy {
  margin-top: var(--dk-spacing-3);
  font-size: 11px;
}

@media (max-width: 768px) {
  /* padding-bottom: breathing room so the last line doesn't sit flush against the floating
     bottom tab bar on portal pages (app.css's .app-content clearance already keeps it out from
     under the bar; this just stops it looking cramped). */
  .dk-contact-footer {
    margin-top: var(--dk-spacing-5);
    padding-bottom: var(--dk-spacing-3);
  }

  /* Stacked, one item per row — and each link padded out to a comfortable tap target. */
  .dk-contact-footer-inner,
  .dk-contact-footer-links {
    flex-direction: column;
    gap: var(--dk-spacing-2);
  }

  .dk-contact-footer-links a {
    display: inline-block;
    padding: 6px 0;
  }
}
/* ============================================================================
   Seat header — "Signed in as <name> · <role>" at the top of each staff dashboard
   (seatHeaderHTML() in app.js), plus the Mine / Whole team segmented toggle.
   ========================================================================== */

.seat-header {
  display: flex;
  align-items: center;
  gap: var(--dk-spacing-3);
  margin-bottom: var(--dk-spacing-5);
}

.seat-header-text {
  min-width: 0;
}

.seat-header-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dk-text-secondary);
}

.seat-header-name {
  font-size: var(--dk-font-page-title);
  font-weight: var(--dk-font-page-title-weight);
  color: var(--dk-text-primary);
  line-height: 1.25;
  margin: 0;
}

.seat-header-role {
  font-size: 13px;
  color: var(--dk-text-secondary);
}

.seat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--dk-spacing-3);
  margin-bottom: var(--dk-spacing-5);
}

.seat-header-row .seat-header {
  margin-bottom: 0;
}

.seg-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background-color: var(--dk-surface-alt);
  border: 1px solid var(--dk-border);
}

.seg-toggle button {
  border: none;
  background: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--dk-text-secondary);
  cursor: pointer;
}

.seg-toggle button.active {
  background-color: var(--dk-primary);
  color: #fff;
}

.kpi-team-note {
  font-size: 12px;
  color: var(--dk-text-secondary);
}

.my-work-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--dk-spacing-3);
  margin-bottom: var(--dk-spacing-4);
}

.my-work-stat {
  border: 1px solid var(--dk-border);
  border-radius: var(--dk-radius-lg);
  padding: var(--dk-spacing-3);
}

.my-work-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--dk-text-primary);
  line-height: 1.2;
}

.my-work-stat-label {
  font-size: 12px;
  color: var(--dk-text-secondary);
}