:root {
  --bg-dark: #08100c;
  --bg-page: #eef4f0;
  --surface: #ffffff;
  --surface-2: #f6f9f7;
  --surface-hover: #f7fbf8;
  --panel: #ffffff;
  --panel-muted: #f4f7f5;
  --ink: #15201a;
  --text: #15201a;
  --on-secondary: #17341f;
  --heading: #0d1814;
  --muted: #65736b;
  --line: #dce5df;
  --line-soft: #e8efea;
  --line-strong: #cbd6cf;
  --ace: #22e340;
  --ace-dark: #087f24;
  --ace-deep: #0b3418;
  --accent: #087f24;
  --warning: #e9a21d;
  --danger: #c63d32;
  --shadow-sm: 0 1px 2px rgba(3, 13, 7, 0.05), 0 1px 3px rgba(3, 13, 7, 0.06);
  --shadow: 0 6px 18px rgba(3, 13, 7, 0.08), 0 2px 5px rgba(3, 13, 7, 0.05);
  --shadow-lg: 0 18px 45px rgba(3, 13, 7, 0.18);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --body-gradient:
    linear-gradient(135deg, rgba(34, 227, 64, 0.08), transparent 42%),
    linear-gradient(180deg, #101b15 0%, var(--bg-page) 34%, var(--bg-page) 100%);
  --dropzone-bg: linear-gradient(180deg, var(--panel-muted), #f9fcfa);
  --dropzone-bg-hover: linear-gradient(180deg, #eef7f1, #f6fbf8);
}

[data-theme="dark"] {
  --bg-dark: #050a08;
  --bg-page: #0d1410;
  --surface: #1a2520;
  --surface-2: #15201b;
  --surface-hover: #243029;
  --panel: #1a2520;
  --panel-muted: #131c17;
  --ink: #e6efe9;
  --text: #e6efe9;
  --on-secondary: #d9ebdf;
  --heading: #f3faf5;
  --muted: #8fa297;
  --line: #2a3830;
  --line-soft: #1f2c25;
  --line-strong: #3a4d42;
  --accent: #22e340;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.32);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.45), 0 2px 5px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 18px 45px rgba(0, 0, 0, 0.55);

  --body-gradient:
    linear-gradient(135deg, rgba(34, 227, 64, 0.06), transparent 42%),
    linear-gradient(180deg, #0a120e 0%, var(--bg-page) 100%);
  --dropzone-bg: linear-gradient(180deg, var(--panel-muted), var(--surface-2));
  --dropzone-bg-hover: linear-gradient(180deg, #1c2922, #1a2520);

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--body-gradient);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  transition: background-color 200ms var(--ease), color 200ms var(--ease);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(34, 227, 64, 0.1), transparent 46%),
    #101b15;
}

.login-screen[hidden] {
  display: none;
}

.login-panel {
  display: grid;
  gap: 20px;
  width: min(420px, 100%);
  padding: 32px 30px 28px;
  border: 1px solid rgba(34, 227, 64, 0.22);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04);
  animation: panel-in 360ms var(--ease) both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.login-panel img {
  width: 190px;
  max-width: 100%;
  margin: 4px auto 0;
  display: block;
}

.login-panel .primary-action {
  margin-top: 8px;
}

.login-error {
  margin: -4px 0 0;
  padding: 8px 10px;
  border: 1px solid rgba(225, 29, 72, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(225, 29, 72, 0.08);
  color: #b91c1c;
  font-size: 0.86rem;
}

input[aria-invalid="true"] {
  border-color: #e11d48;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.14);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 86px;
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand img {
  width: clamp(128px, 22vw, 190px);
  height: auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: var(--ace);
}

/* The topbar sits on the dark-green brand background in both themes, so the
   title must stay white — the global h1 { color: var(--heading) } rule would
   otherwise make it dark (and unreadable) in light mode. */
.topbar h1 {
  color: #fff;
}

/* ── Test-mode banner ────────────────────────────────────────────────────────── */

.test-mode-banner {
  background: linear-gradient(180deg, #9a3a18, #7c2d12);
  color: #fef2f2;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  padding: 10px 18px;
  letter-spacing: 0.01em;
  border-radius: var(--radius-sm);
  margin: 4px 0 10px;
  box-shadow: 0 2px 6px rgba(124, 45, 18, 0.32);
}

.test-mode-banner code {
  background: rgba(255 255 255 / 0.18);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.82rem;
  font-family: "Courier New", monospace;
}

.test-mode-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
}

.test-mode-label input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: #dc2626;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--heading);
  line-height: 1.25;
}

h1 {
  font-size: clamp(1.45rem, 4vw, 2.35rem);
  font-weight: 700;
}

h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.sync-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid rgba(34, 227, 64, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  color: #eaffed;
  font-size: 0.86rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 0.86rem;
}

.text-button.light {
  color: #eaffed;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ace);
  box-shadow: 0 0 12px var(--ace);
}

/* ── Topbar stat pills (Receipts uploaded / To approve) ──────────────────────── */
.topbar-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  flex: 0 0 auto;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.1;
  white-space: nowrap;
}

.stat-pill-num {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ace);
}

.stat-pill-label {
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0.92;
}

/* Anchor pills (e.g. Pricing) — same look as the stat pills, plus link affordance. */
a.stat-pill {
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}
a.stat-pill:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-1px); }

/* "To approve" is a call to action — amber tint + clickable affordance. */
.stat-pill-action {
  cursor: pointer;
  border-color: rgba(251, 191, 36, 0.7);
  background: rgba(251, 191, 36, 0.22);
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}
.stat-pill-action .stat-pill-num { color: #fde68a; }
.stat-pill-action:hover { background: rgba(251, 191, 36, 0.34); transform: translateY(-1px); }

/* ── Collapsible sections ────────────────────────────────────────────────────── */
.collapsible-heading {
  cursor: pointer;
  user-select: none;
}
/* Headings without right-side controls get an absolutely-positioned chevron. */
.collapsible-heading-right {
  position: relative;
  padding-right: 42px;
}

.collapse-toggle {
  position: relative;          /* anchors the ::before chevron */
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.collapsible-heading-right .collapse-toggle {
  position: absolute;
  top: 0;
  right: 0;
}
.collapsible-heading:hover .collapse-toggle {
  color: var(--ink);
  background: var(--dropzone-bg);
}

/* Chevron drawn from two borders: ▼ when expanded, ▶ when collapsed. */
.collapse-toggle::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s var(--ease);
}
.collapsed .collapse-toggle::before {
  transform: translateX(-2px) rotate(-45deg);
}

.collapsed .collapsible-body { display: none; }
.collapsed .section-heading,
.collapsed .console-header { margin-bottom: 0; }

/* Left-chevron variant — used for the management console bars so every bar
   lines up the same way (chevron, then title). */
.collapsible-heading-left {
  position: relative;
  padding-left: 56px;
}
.collapsible-heading-left .collapse-toggle {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

/* ── Management console: uniform collapsible bars ───────────────────────────── */
/* Every collapsible section in the console renders as the same boxed bar,
   regardless of whether it started as a config card or a section heading. */
#managementPanel > [data-collapsible] {
  margin: 0 0 10px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
  overflow: hidden;
}
#managementPanel > [data-collapsible] > .collapsible-heading {
  margin: 0;
  min-height: 56px;
  padding: 12px 16px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.15s var(--ease);
}
#managementPanel > [data-collapsible] > .collapsible-heading:hover {
  background: var(--surface-hover);
}
/* config-card bars: title hugs the chevron on the left, actions go right. */
#managementPanel > [data-collapsible] > .config-card-header {
  justify-content: flex-start;
}
#managementPanel > .config-card > .config-card-header > button:not(.collapse-toggle),
#managementPanel > .config-card > .config-card-header > .agent-auth-actions {
  margin-left: auto;
}
/* section-heading bars: keep eyebrow stacked over the title; the chevron is
   absolutely placed by .collapsible-heading-left. */
#managementPanel > [data-collapsible] > .section-heading.collapsible-heading {
  display: block;
  padding-left: 56px;     /* room for the absolute chevron (beats the shorthand above) */
}
#managementPanel > [data-collapsible] > .section-heading .eyebrow { margin-bottom: 2px; }
#managementPanel > [data-collapsible] > .section-heading h2 { font-size: 1.05rem; }
/* non-config bodies need their own padding (config-card-body brings its own). */
#managementPanel > [data-collapsible]:not(.config-card) > .collapsible-body {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

/* Submission time under the date in tables / history */
.cell-time {
  font-size: 0.78rem;
  color: var(--muted);
}

/* "To approve" pill flashes while approvals wait on this user. */
@keyframes approvePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.55); }
  70%      { box-shadow: 0 0 0 7px rgba(251, 191, 36, 0); }
}
.stat-pill-flash { animation: approvePulse 1.5s ease-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .stat-pill-flash { animation: none; }
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.35fr) minmax(280px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.intake-panel,
.form-panel,
.review-panel,
.management-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.management-panel {
  margin-top: 16px;
  padding: 24px;
}

/* ── Console header (title + pending badge) ──────────────────────────────────── */
.console-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.console-header .eyebrow { margin-bottom: 2px; }
.console-header h2 { margin: 0; }

.pending-approval-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #92400e;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  margin-top: 6px;
}

.pending-approval-badge #pendingApprovalCount {
  font-size: 1.1em;
}

/* ── Routing badge (on work ticket field header) ─────────────────────────────── */
.ticket-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.ticket-field-header label {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0;
  color: var(--ink);
}

.routing-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.routing-badge[data-class="direct"]   { background: #dcfce7; color: #166534; }
.routing-badge[data-class="indirect"] { background: #dbeafe; color: #1e40af; }
.routing-badge[data-class="pending"]  { background: #fef9c3; color: #854d0e; }

/* ── Work Ticket N/A checkbox ────────────────────────────────────────────────── */
.na-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--muted);
}

.na-checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: #2563eb;
  cursor: pointer;
}

.na-checkbox-label:hover { color: var(--ink); }

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 { margin-top: 2px; }

.dropzone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 220px;
  padding: 28px 24px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--dropzone-bg);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms var(--ease), background 160ms var(--ease), transform 160ms var(--ease);
}

.dropzone:hover {
  border-color: var(--ace-dark);
  background: var(--dropzone-bg-hover);
}

.dropzone:active {
  transform: scale(0.998);
}

.dropzone.dragover {
  border-color: var(--ace-dark);
  border-style: solid;
  background: var(--dropzone-bg-hover);
  box-shadow: 0 0 0 4px rgba(34, 227, 64, 0.16);
}

/* Locked until a receipt type is chosen (Step 1 gate). */
.dropzone.locked {
  opacity: 0.55;
  filter: grayscale(0.4);
  cursor: not-allowed;
}
.dropzone.locked:hover {
  border-color: var(--line-strong);
  background: var(--dropzone-bg);
}

.capture-lock-hint {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-muted);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* Brief highlight when the user tries to capture before picking a type. */
@keyframes flashAttention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 227, 64, 0); }
  30%      { box-shadow: 0 0 0 4px rgba(34, 227, 64, 0.35); }
}
.receipt-type-group.flash-attention {
  border-radius: var(--radius);
  animation: flashAttention 0.9s var(--ease) 2;
}
@media (prefers-reduced-motion: reduce) {
  .receipt-type-group.flash-attention { animation: none; }
}

.itemized-unclassified-hint {
  margin: 8px 0 0;
  font-size: 0.85rem;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.compact-action {
  min-height: 38px;
  margin-top: 8px;
  padding: 0 12px;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ace-deep), #105c2a);
  color: var(--ace);
  font-size: 2rem;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(11, 52, 24, 0.28), inset 0 0 0 1px rgba(34, 227, 64, 0.18);
}

small,
.muted {
  color: var(--muted);
}

.preview-wrap {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fafcfb;
}

.preview-meta,
.payload-header,
.submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-meta {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

/* Ensure the HTML hidden attribute wins over any explicit display rules. */
[hidden] { display: none !important; }

#receiptPreview {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #111;
}

.pdf-preview {
  display: block;
  width: 100%;
  height: min(520px, 70vh);
  border: 0;
  background: #fafcfb;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
}

label.disabled-field {
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease), background 140ms var(--ease);
}

input:hover:not(:focus):not(:disabled),
select:hover:not(:focus):not(:disabled),
textarea:hover:not(:focus):not(:disabled) {
  border-color: var(--muted);
}

label.disabled-field input,
label.disabled-field select {
  background: var(--panel-muted);
  color: var(--muted);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ace-dark);
  box-shadow: 0 0 0 3px rgba(34, 227, 64, 0.18);
}

::placeholder { color: var(--muted); opacity: 0.85; }

.wide {
  grid-column: 1 / -1;
}

.primary-action,
.secondary-action,
.text-button {
  border: 0;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.005em;
  transition: background 160ms var(--ease), border-color 160ms var(--ease),
              color 160ms var(--ease), transform 80ms var(--ease),
              box-shadow 160ms var(--ease);
}

.primary-action,
.secondary-action {
  min-height: 46px;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  font-size: 0.92rem;
}

.primary-action {
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(180deg, #0f4a22, var(--ace-deep));
  color: #eaffed;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.primary-action:hover {
  background: linear-gradient(180deg, #145a2a, #0e3f1f);
  box-shadow: 0 4px 10px rgba(11, 52, 24, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.primary-action:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(0, 0, 0, 0.04);
}

.primary-action:focus-visible {
  outline: 3px solid rgba(34, 227, 64, 0.45);
  outline-offset: 2px;
}

.primary-action:disabled {
  cursor: not-allowed;
  background: #a6b2aa;
  box-shadow: none;
}

.is-loading {
  position: relative;
  pointer-events: none;
}

.is-loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 9px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.primary-action.is-loading:disabled {
  background: linear-gradient(180deg, #0f4a22, var(--ace-deep));
  opacity: 0.92;
  color: #eaffed;
}

.secondary-action {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--on-secondary);
  box-shadow: var(--shadow-sm);
}

.secondary-action:hover {
  border-color: var(--ace-dark);
  background: var(--surface-hover);
}

.secondary-action:active {
  transform: translateY(1px);
}

.secondary-action:focus-visible {
  outline: 3px solid rgba(34, 227, 64, 0.35);
  outline-offset: 2px;
}

.link-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.submit-row .primary-action {
  width: auto;
  margin: 0;
}

.submit-row {
  justify-content: flex-end;
}

.text-button {
  background: transparent;
  color: var(--ace-dark);
  padding: 4px 6px;
  border-radius: 4px;
}

.text-button:hover {
  background: rgba(34, 227, 64, 0.08);
}

.status-stack {
  display: grid;
  gap: 10px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-muted);
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.status-item span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #aab8b0;
  box-shadow: 0 0 0 3px rgba(170, 184, 176, 0.18);
  flex-shrink: 0;
}

.status-item.complete {
  color: var(--complete-text, #1a4a2a);
  background: var(--complete-bg, #f0fdf4);
  border-color: var(--complete-border, #c4ecd1);
}

.status-item.complete span {
  background: var(--ace-dark);
  box-shadow: 0 0 0 3px rgba(8, 127, 36, 0.18);
}

.status-item.warn span {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(233, 162, 29, 0.2);
}

.payload-box,
.history {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.payload-header {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-muted);
}

pre {
  max-height: 420px;
  margin: 0;
  overflow: auto;
  padding: 14px 16px;
  background: #0d1510;
  color: #dfffe6;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.history-list {
  display: grid;
  gap: 1px;
  background: var(--line-soft);
}

.history-item {
  padding: 12px 14px;
  background: var(--surface);
  transition: background 140ms var(--ease);
}

.history-item:hover {
  background: var(--surface-hover);
}

.history-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--heading);
}

.management-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

/* Filters row: selects + date range take the available space */
.management-toolbar select {
  flex: 1 1 140px;
  min-width: 120px;
  max-width: 220px;
}

/* Date range group */
.toolbar-date-range {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-date-range input[type="date"] {
  padding: 7px 10px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  width: 140px;
}

.toolbar-date-range input[type="date"]:focus {
  outline: none;
  border-color: var(--ace-dark);
  box-shadow: 0 0 0 3px rgba(34, 227, 64, 0.18);
}

.date-range-sep {
  color: var(--muted);
  font-size: 0.85rem;
  user-select: none;
}

/* Action buttons pushed to end */
.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.agent-auth-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
}

.agent-auth-panel p {
  margin: 4px 0 0;
}

.agent-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

/* (select width is handled in the toolbar block above) */

.management-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.management-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--surface);
}

.management-table th,
.management-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  font-size: 0.88rem;
}

.management-table th {
  background: var(--panel-muted);
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 0.78rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

.management-table tr:last-child td {
  border-bottom: none;
}

.management-table tbody tr:nth-child(even):not(:hover) td {
  background: var(--surface-2);
}

.management-table tbody tr:hover td {
  background: var(--surface-hover);
}

.col-vendor strong { display: block; }
.invoice-hint { font-size: 0.78rem; color: var(--muted); }
.ticket-ref { font-family: monospace; font-size: 0.85rem; color: #2c5aa0; }
.table-empty { padding: 20px !important; text-align: center; }

/* ── Type badges ─────────────────────────────────────────────────────────────── */
.type-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.type-direct   { background: #dcfce7; color: #166534; }
.type-indirect { background: #dbeafe; color: #1e40af; }
.type-pending  { background: #fef9c3; color: #854d0e; }

/* ── Approval chips ──────────────────────────────────────────────────────────── */
.approval-cell {
  min-width: 190px;
  white-space: normal;
}
.approval-na   { color: var(--muted); }

.qb-cell {
  min-width: 140px;
  white-space: normal;
}

.qb-cell .muted {
  display: block;
  font-size: 0.76rem;
  line-height: 1.25;
}

.approval-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  margin: 2px 4px 2px 0;
}
.chip-approved { background: #dcfce7; color: #15803d; }
.chip-rejected { background: #fee2e2; color: #991b1b; }
.chip-pending  { background: #fef9c3; color: #92400e; }

/* ── Icon action buttons (approve / reject / delete) ─────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: none;
  transition: background 0.15s, color 0.15s;
  vertical-align: middle;
  margin-left: 2px;
}
.approve-btn { color: #15803d; border-color: #86efac; }
.approve-btn:hover { background: #dcfce7; border-color: #4ade80; }
.reject-btn  { color: #991b1b; border-color: #fca5a5; }
.reject-btn:hover  { background: #fee2e2; border-color: #f87171; }
.delete-btn  { color: var(--muted); border-color: var(--line); }
.delete-btn:hover  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.config-card {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
  overflow: hidden;
}

.config-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
}

.config-card-header p {
  margin: 4px 0 0;
}

.config-card-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: white;
}

.data-sync-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.data-sync-row p { margin: 4px 0 0; }
.data-sync-row strong { color: var(--heading); }

@media (max-width: 760px) {
  .data-sync-row { flex-direction: column; align-items: stretch; }
}

/* ── Branch / inventory mapping table ────────────────────────────────────────── */
.branch-map-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  background: var(--surface);
}

.branch-map-table th {
  text-align: left;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--line-soft);
}

.branch-map-table td {
  padding: 5px 6px;
  vertical-align: middle;
}

.branch-map-table td:first-child,
.branch-map-table td:nth-child(2) { width: 45%; }
.branch-map-table td:last-child   { width: 10%; text-align: right; }

.branch-map-table input {
  min-height: 36px;
  padding: 6px 9px;
  font-size: 0.88rem;
}

.branch-map-table .delete-btn { width: 28px; height: 28px; }

.provider-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.provider-fields-wide {
  grid-column: 1 / -1;
}

/* Ollama inherits provider-fields layout; keep alias for the info paragraph */
.ollama-fields-wide {
  grid-column: 1 / -1;
}

.label-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.82rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
  padding-top: 6px;
}

.checkbox-label input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
}

.checkbox-label small.label-hint {
  display: block;
  margin-top: 2px;
}

/* ── Work ticket validation ──────────────────────────────────────────────────── */

.validate-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.validate-row input {
  flex: 1;
  min-width: 0;
}

.ticket-status {
  margin: 4px 0 0;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.ticket-valid {
  color: #16a34a;
  font-weight: 500;
}

.ticket-invalid {
  color: #dc2626;
  font-weight: 500;
}

/* Vendor "possible matches" helper under the intake Vendor field. */
.vendor-match-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 2px;
}
.vendor-match-row .ticket-status { margin: 0; flex: 1 1 100%; }
.vendor-match-results {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.vendor-match-chip {
  border: 1px solid var(--border, #cbd5e1);
  background: var(--surface, #fff);
  color: inherit;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}
.vendor-match-chip:hover { border-color: #2563eb; color: #2563eb; }

/* Multi-page receipt extras. */
.extra-pages { margin: 8px 0 4px; }
.extra-page-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 2px 0;
}
.add-page-btn { display: inline-block; cursor: pointer; }

/* Edit-held-receipt dialog: two-column field grid. */
.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.edit-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}
.edit-grid label.wide { grid-column: 1 / -1; }
.edit-grid input,
.edit-grid select,
.edit-grid textarea { width: 100%; box-sizing: border-box; }
.edit-grid .ticket-status { font-size: 0.78rem; }

/* Edit-dialog free-text mode toggle + warning */
.edit-freetext-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.edit-freetext-toggle input { width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; }
.edit-freetext-warning {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid #fbbf24;
  border-radius: var(--radius-sm);
  background: #fef3c7;
  color: #92400e;
  font-size: 0.82rem;
}
.edit-history-badge {
  font-size: 0.72rem;
  color: var(--muted, #6b7280);
  margin-left: 6px;
  white-space: nowrap;
}
@media (max-width: 560px) { .edit-grid { grid-template-columns: 1fr; } }

/* Camera multi-page capture review. */
.camera-review { display: flex; flex-direction: column; gap: 12px; max-width: 92vw; }
.camera-review img {
  max-width: 100%;
  max-height: 58vh;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border, #cbd5e1);
  background: #000;
}
.camera-review-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.camera-review-actions button { flex: 1 1 auto; }

/* Single-ticket allocation hints (whole line → one ticket). */
.alloc-single-hint { font-size: 0.8rem; font-weight: 600; color: var(--ace-dark, #0a6b2b); }
.alloc-whole-line  { font-size: 0.85rem; align-self: center; }

/* My submissions list: reference + live status badge on one row. */
.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

/* App kill-switch banners (submissions paused / AI off). */
.paused-banner {
  background: linear-gradient(180deg, #b91c1c, #7f1d1d);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  margin: 4px 0 10px;
  box-shadow: 0 2px 6px rgba(127, 29, 29, 0.32);
}
#aiPausedBanner { background: linear-gradient(180deg, #b45309, #7c2d12); }

/* App-controls toggle rows. */
.toggle-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-top: 1px solid var(--border, #e5e7eb);
}
.toggle-row:first-child { border-top: 0; }
.toggle-row input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; flex: 0 0 auto; }

.field-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
}

.log-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.log-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-muted);
}

.log-controls select,
.log-controls input {
  width: auto;
  min-height: 38px;
}

.log-controls input {
  min-width: 160px;
  flex: 1 1 160px;
}

.log-table-wrap {
  overflow: auto;
  max-height: 440px;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: #0d1510;
  color: #dfffe6;
}

.log-table th {
  padding: 8px 10px;
  background: #1a2e1f;
  color: #9dccaa;
  font-size: 0.8rem;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
}

.log-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #1a2e1f;
  font-size: 0.77rem;
  font-family: "Courier New", Courier, monospace;
  vertical-align: top;
  word-break: break-word;
}

.log-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.log-badge.info  { background: #0d3020; color: var(--ace); }
.log-badge.warn  { background: #2e1e00; color: var(--warning); }
.log-badge.error { background: #2e0d0a; color: #ff7b72; }

.log-meta {
  display: block;
  padding: 8px 12px;
  margin: 0;
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
  background: var(--panel-muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 16px;
  border-radius: var(--radius);
  background: #102416;
  color: white;
  font-size: 0.92rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(34, 227, 64, 0.18);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Toast variants — colored accent edge for success / error feedback */
.toast {
  border-left: 4px solid rgba(255, 255, 255, 0.25);
}

.toast.toast-success {
  border-left-color: var(--ace);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(34, 227, 64, 0.30);
}

.toast.toast-error {
  border-left-color: #ff7b72;
  background: #2a1311;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(255, 123, 114, 0.28);
}

@media (max-width: 1040px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .review-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .agent-auth-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .agent-auth-actions {
    justify-content: stretch;
  }

  .validate-row {
    flex-direction: column;
    align-items: stretch;
  }

  .submit-row .primary-action,
  .secondary-action {
    width: 100%;
  }
}

/* ── Executive role — hide technical panels ──────────────────────────────────── */
#managementPanel[data-user-role="executive"] #agentAuthPanel,
#managementPanel[data-user-role="executive"] #providerConfigCard,
#managementPanel[data-user-role="executive"] #aspireConfigCard,
#managementPanel[data-user-role="executive"] #logPanel {
  display: none;
}

/* ── Status text cleanup ─────────────────────────────────────────────────────── */
.status-text {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: var(--panel-muted);
  color: var(--muted);
}

.status-text.status-synced_to_aspire     { background: #dcfce7; color: #166534; }
.status-text.status-approved             { background: #dcfce7; color: #15803d; }
.status-text.status-ready_for_approval   { background: #fef9c3; color: #854d0e; }
.status-text.status-pending_ops_approval,
.status-text.status-pending_controller_approval { background: #fef9c3; color: #854d0e; }
.status-text.status-awaiting_classification { background: #fef9c3; color: #854d0e; }
.status-text.status-ready_for_manual_credit_entry { background: #ede9fe; color: #4c1d95; }
.status-text.status-waiting_for_vendor   { background: #fee2e2; color: #991b1b; }
.status-text.status-waiting_for_ticket   { background: #fee2e2; color: #991b1b; }
.status-text.status-denied               { background: #fee2e2; color: #991b1b; }
.status-text.status-missing_receipt      { background: #fee2e2; color: #991b1b; }
.status-text.status-match_exception      { background: #fef2f2; color: #b91c1c; }
.status-text.status-error                { background: #fee2e2; color: #991b1b; }

[data-theme="dark"] .status-text.status-synced_to_aspire,
[data-theme="dark"] .status-text.status-approved             { background: rgba(34, 197, 94, 0.18); color: #6be087; }
[data-theme="dark"] .status-text.status-ready_for_approval,
[data-theme="dark"] .status-text.status-pending_ops_approval,
[data-theme="dark"] .status-text.status-pending_controller_approval,
[data-theme="dark"] .status-text.status-awaiting_classification { background: rgba(234, 179, 8, 0.20); color: #fbcb52; }
[data-theme="dark"] .status-text.status-ready_for_manual_credit_entry { background: rgba(167, 139, 250, 0.20); color: #c4b5fd; }
[data-theme="dark"] .status-text.status-waiting_for_vendor,
[data-theme="dark"] .status-text.status-waiting_for_ticket,
[data-theme="dark"] .status-text.status-denied,
[data-theme="dark"] .status-text.status-missing_receipt,
[data-theme="dark"] .status-text.status-match_exception,
[data-theme="dark"] .status-text.status-error                { background: rgba(248, 113, 113, 0.22); color: #fca5a5; }

.retry-vendor-btn,
.retry-ticket-btn {
  color: var(--ace-dark);
  border-color: rgba(34, 227, 64, 0.45);
  font-size: 1.05rem;
  line-height: 1;
}
.retry-vendor-btn:hover,
.retry-ticket-btn:hover {
  background: rgba(34, 227, 64, 0.12);
  border-color: var(--ace-dark);
}
[data-theme="dark"] .retry-vendor-btn,
[data-theme="dark"] .retry-ticket-btn        { color: #6be087; border-color: rgba(34, 197, 94, 0.45); }
[data-theme="dark"] .retry-vendor-btn:hover,
[data-theme="dark"] .retry-ticket-btn:hover  { background: rgba(34, 197, 94, 0.18); border-color: rgba(34, 197, 94, 0.70); }

/* ── Work ticket field wide span in field-grid ───────────────────────────────── */
#workTicketField.wide {
  grid-column: 1 / -1;
}

/* ── Na checkbox inside field-group ─────────────────────────────────────────── */
.field-group .na-checkbox-label {
  margin-top: 10px;
}

/* ── Reconciliation panel ────────────────────────────────────────────────────── */
.recon-panel { padding-top: 8px; }

.recon-upload-card .config-card-body.recon-controls {
  display: grid;
  gap: 14px;
}

.recon-date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.recon-run-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.recon-summary {
  display: flex;
  gap: 16px;
  margin: 18px 0;
  flex-wrap: wrap;
}

.recon-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  min-width: 110px;
  text-align: center;
}

.recon-stat span {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--heading);
  letter-spacing: -0.02em;
}

.recon-stat small {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.recon-stat-ok  { border-color: #86efac; background: #f0fdf4; }
.recon-stat-ok span { color: #166534; }
.recon-stat-warn { border-color: #fca5a5; background: #fef2f2; }
.recon-stat-warn span { color: #b91c1c; }

.recon-section-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 18px 0 8px;
}

.recon-section-header small { font-size: 0.82rem; }

/* ── User management panel ───────────────────────────────────────────────────── */
.user-mgmt-panel {
  padding-top: 8px;
}

.user-mgmt-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.user-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 24px;
}

/* Role colour chips */
.role-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.role-superadmin { background: #fce7f3; color: #9d174d; }
.role-controller  { background: #ede9fe; color: #4c1d95; }
.role-executive   { background: #dbeafe; color: #1e40af; }
.role-manager     { background: #dcfce7; color: #166534; }
.role-sales       { background: #fef3c7; color: #92400e; }
.role-admin, .role-office { background: #f0f9ff; color: #0369a1; }
.role-employee    { background: #f3f4f6; color: #374151; }

.user-inactive-row td { opacity: 0.55; }
.user-inactive-row td:last-child { opacity: 1; }

.card-mono {
  font-family: monospace;
  font-size: 0.88rem;
  letter-spacing: 0.06em;
  color: #2c5aa0;
}

/* ── User add / edit dialog ──────────────────────────────────────────────────── */
dialog#userDialog {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  padding: 0;
  width: min(500px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
}

dialog#userDialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(3px);
}

dialog#userDialog form {
  padding: 28px 28px 24px;
}

dialog#userDialog h3 {
  margin: 0 0 22px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--heading);
}

.dialog-fields {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.dialog-fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.dialog-fields input,
.dialog-fields select {
  padding: 10px 12px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 400;
  background: var(--surface);
  color: var(--text);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}

.dialog-fields input:focus,
.dialog-fields select:focus {
  outline: none;
  border-color: var(--ace-dark);
  box-shadow: 0 0 0 3px rgba(34, 227, 64, 0.18);
}

.dialog-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.dialog-fieldset legend {
  padding: 0 6px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
}

.dialog-fieldset .test-mode-label {
  margin-top: 8px;
}

.dialog-active-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  cursor: pointer;
  padding: 10px 12px;
  background: var(--panel-muted);
  border-radius: 8px;
}

.required-star { color: #e11d48; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

/* ── Report panel ────────────────────────────────────────────────────────────── */
.report-panel {
  padding: 0 0 28px;
  border-top: 1px solid var(--line);
  margin-top: 28px;
}

.report-controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.report-period-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.control-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.period-btn-group {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.period-btn {
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--line);
  padding: 8px 14px;
  min-height: 0;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  transition: background 140ms var(--ease), color 140ms var(--ease);
}

.period-btn:last-child {
  border-right: none;
}

.period-btn:hover {
  background: var(--surface-hover);
  color: var(--ace-dark);
}

.period-btn.active {
  background: var(--ace-deep);
  color: #eaffed;
  font-weight: 600;
}

.report-custom-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-custom-range input[type="date"] {
  font-size: 0.85rem;
  padding: 6px 10px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: auto;
}

.report-filter-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.report-filter-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.report-filter-row select {
  font-size: 0.9rem;
  font-weight: 400;
  padding: 8px 10px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 180px;
  text-transform: none;
  letter-spacing: 0;
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.report-actions .primary-action {
  width: auto;
  margin: 0;
  min-width: 180px;
}

/* ── Transaction-type toggle (Receipt vs Credit) ─────────────────────────────── */
.transaction-type-group {
  border: none;
  padding: 0;
  margin: 0 0 14px;
}

.transaction-type-group legend {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.transaction-type-buttons {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.transaction-type-option {
  position: relative;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border-right: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: background 140ms var(--ease), color 140ms var(--ease);
  min-width: 140px;
}

.transaction-type-option:last-child { border-right: none; }

.transaction-type-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0; margin: 0; min-height: 0;
}

.transaction-type-option strong {
  display: block;
  font-weight: 600;
  line-height: 1.2;
}
.transaction-type-option small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.15;
}

.transaction-type-option:has(input:checked) {
  background: var(--ace-deep);
  color: #eaffed;
}
.transaction-type-option:has(input:checked) small { color: rgba(234, 255, 237, 0.78); }

.credit-hint {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 8px 10px;
  border-left: 3px solid #a78bfa;
  background: #f5f3ff;
  border-radius: 4px;
}
[data-theme="dark"] .credit-hint {
  background: rgba(167, 139, 250, 0.10);
  border-left-color: #a78bfa;
  color: #d4c8fb;
}

/* ── Link-credit dialog ─────────────────────────────────────────────────────── */
.link-credit-mismatch {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  font-size: 0.88rem;
}

.link-credit-mismatch strong { display: block; margin-bottom: 6px; }
.link-credit-mismatch ul { margin: 0 0 10px; padding-left: 20px; }
.link-credit-mismatch li { margin: 2px 0; }

.link-credit-mismatch #linkCreditAspirePreview {
  margin: 8px 0;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
}

.link-credit-mismatch #linkCreditAspirePreview dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 10px;
  margin: 0;
}
.link-credit-mismatch #linkCreditAspirePreview dt { color: var(--muted); font-weight: 600; }
.link-credit-mismatch #linkCreditAspirePreview dd { margin: 0; word-break: break-word; }

.link-credit-override-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.link-credit-override-label input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: #dc2626;
}

[data-theme="dark"] .link-credit-mismatch {
  background: rgba(248, 113, 113, 0.10);
  border-color: rgba(248, 113, 113, 0.32);
  color: #fca5a5;
}

.credit-badge {
  display: inline-block;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 4px;
  background: #ede9fe;
  color: #4c1d95;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: 2px;
}
[data-theme="dark"] .credit-badge { background: rgba(167, 139, 250, 0.20); color: #c4b5fd; }

.link-credit-btn {
  color: #4c1d95;
  border-color: #c4b5fd;
  font-size: 0.95rem;
  line-height: 1;
}
.link-credit-btn:hover {
  background: #ede9fe;
  border-color: #a78bfa;
}
[data-theme="dark"] .link-credit-btn        { color: #c4b5fd; border-color: rgba(167, 139, 250, 0.45); }
[data-theme="dark"] .link-credit-btn:hover  { background: rgba(167, 139, 250, 0.18); border-color: rgba(167, 139, 250, 0.70); }

/* ── Receipt Type selector (Step 2 — Review & Classify) ─────────────────────── */
.receipt-type-group {
  border: none;
  padding: 0;
  margin: 0 0 18px;
}

.receipt-type-group legend {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  padding: 0;
}

.receipt-type-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.receipt-type-option {
  position: relative;
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line-strong, #cbd6cf);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color 140ms var(--ease), background 140ms var(--ease), box-shadow 140ms var(--ease);
}

.receipt-type-option:hover { border-color: var(--ace-dark); }

.receipt-type-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  margin: 0;
  min-height: 0;
}

.receipt-type-option:has(input:checked) {
  border-color: var(--ace-dark);
  background: linear-gradient(180deg, #eef7f1, var(--surface));
  box-shadow: 0 0 0 3px rgba(34, 227, 64, 0.18);
}

[data-theme="dark"] .receipt-type-option:has(input:checked) {
  background: linear-gradient(180deg, rgba(34, 227, 64, 0.10), var(--surface));
  box-shadow: 0 0 0 3px rgba(34, 227, 64, 0.22);
}

.receipt-type-label strong {
  display: block;
  font-size: 0.95rem;
  color: var(--heading);
  margin-bottom: 2px;
}

.receipt-type-label small {
  color: var(--muted);
  font-size: 0.78rem;
  display: block;
}

@media (max-width: 600px) {
  .receipt-type-buttons { grid-template-columns: 1fr; }
}

/* ── Branch / Inventory readout (auto-populated, read-only) ──────────────────── */
.branch-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel-muted);
  border: 1px solid var(--line-soft);
}

.branch-readout .readout-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.branch-readout .readout-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--heading);
}

/* ── User CSV import label ───────────────────────────────────────────────────── */
.import-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.import-status {
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-muted);
  border: 1px solid var(--line);
  color: var(--muted);
  margin-bottom: 12px;
}

.import-status-ok   { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.import-status-warn { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }

.import-error-list {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 0.82rem;
}
.import-error-list li { margin: 2px 0; }

.import-hint {
  font-size: 0.8rem;
  margin: 8px 0 0;
}
.import-hint code {
  background: var(--panel-muted);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Theme toggle button ─────────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #eaffed;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  transition: background 160ms var(--ease), border-color 160ms var(--ease), transform 80ms var(--ease);
}

.theme-toggle:hover {
  background: rgba(34, 227, 64, 0.15);
  border-color: rgba(34, 227, 64, 0.45);
}

.theme-toggle:active { transform: scale(0.94); }

.theme-toggle:focus-visible {
  outline: 3px solid rgba(34, 227, 64, 0.45);
  outline-offset: 2px;
}

.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }

[data-theme="dark"] .theme-toggle .sun  { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ── Dark theme — component polish ───────────────────────────────────────────── */

[data-theme="dark"] .status-item.complete {
  --complete-bg: rgba(34, 227, 64, 0.10);
  --complete-border: rgba(34, 227, 64, 0.30);
  --complete-text: #9be8b1;
}

[data-theme="dark"] .test-mode-banner {
  background: linear-gradient(180deg, #a23a18, #7a2c10);
}

[data-theme="dark"] .dropzone {
  border-color: var(--line-strong);
}

[data-theme="dark"] .login-panel {
  border-color: rgba(34, 227, 64, 0.30);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(34, 227, 64, 0.06);
}

[data-theme="dark"] .agent-auth-panel,
[data-theme="dark"] .config-card {
  border-color: var(--line);
}

[data-theme="dark"] .config-card-body { background: var(--surface); }

[data-theme="dark"] .preview-wrap { background: var(--surface-2); }
[data-theme="dark"] .pdf-preview  { background: var(--surface-2); }

[data-theme="dark"] .period-btn.active {
  background: var(--ace-dark);
  color: #f3faf5;
}

/* Type badges — dark variants */
[data-theme="dark"] .type-direct,
[data-theme="dark"] .chip-approved   { background: rgba(34, 197, 94, 0.18); color: #6be087; }
[data-theme="dark"] .type-indirect    { background: rgba(96, 165, 250, 0.20); color: #93c5fd; }
[data-theme="dark"] .type-pending,
[data-theme="dark"] .chip-pending,
[data-theme="dark"] .routing-badge[data-class="pending"] { background: rgba(234, 179, 8, 0.20); color: #fbcb52; }
[data-theme="dark"] .routing-badge[data-class="direct"]   { background: rgba(34, 197, 94, 0.18); color: #6be087; }
[data-theme="dark"] .routing-badge[data-class="indirect"] { background: rgba(96, 165, 250, 0.20); color: #93c5fd; }
[data-theme="dark"] .chip-rejected    { background: rgba(248, 113, 113, 0.22); color: #fca5a5; }

[data-theme="dark"] .pending-approval-badge {
  background: rgba(234, 179, 8, 0.18);
  border-color: rgba(234, 179, 8, 0.40);
  color: #fcd34d;
}

/* Role chips — dark variants */
[data-theme="dark"] .role-superadmin { background: rgba(244, 114, 182, 0.18); color: #f9a8d4; }
[data-theme="dark"] .role-controller { background: rgba(167, 139, 250, 0.20); color: #c4b5fd; }
[data-theme="dark"] .role-executive  { background: rgba(96, 165, 250, 0.20); color: #93c5fd; }
[data-theme="dark"] .role-manager    { background: rgba(34, 197, 94, 0.18); color: #6be087; }
[data-theme="dark"] .role-sales      { background: rgba(245, 158, 11, 0.20); color: #fcd34d; }
[data-theme="dark"] .role-admin,
[data-theme="dark"] .role-office     { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; }
[data-theme="dark"] .role-employee   { background: rgba(156, 163, 175, 0.20); color: #d1d5db; }

/* Icon action button hovers — keep red/green but slightly muted */
[data-theme="dark"] .approve-btn { color: #6be087; border-color: rgba(34, 197, 94, 0.45); }
[data-theme="dark"] .approve-btn:hover { background: rgba(34, 197, 94, 0.18); border-color: rgba(34, 197, 94, 0.70); }
[data-theme="dark"] .reject-btn  { color: #fca5a5; border-color: rgba(248, 113, 113, 0.45); }
[data-theme="dark"] .reject-btn:hover { background: rgba(248, 113, 113, 0.18); border-color: rgba(248, 113, 113, 0.70); }
[data-theme="dark"] .delete-btn:hover { background: rgba(248, 113, 113, 0.18); color: #fca5a5; border-color: rgba(248, 113, 113, 0.45); }

/* Recon stat cards — dark tints */
[data-theme="dark"] .recon-stat-ok   { background: rgba(34, 197, 94, 0.08); border-color: rgba(34, 197, 94, 0.30); }
[data-theme="dark"] .recon-stat-ok span { color: #6be087; }
[data-theme="dark"] .recon-stat-warn { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.30); }
[data-theme="dark"] .recon-stat-warn span { color: #fca5a5; }

/* Import status — dark variants */
[data-theme="dark"] .import-status-ok   { background: rgba(34, 197, 94, 0.10); border-color: rgba(34, 197, 94, 0.32); color: #9be8b1; }
[data-theme="dark"] .import-status-warn { background: rgba(248, 113, 113, 0.10); border-color: rgba(248, 113, 113, 0.32); color: #fca5a5; }

[data-theme="dark"] .ticket-valid   { color: #6be087; }
[data-theme="dark"] .ticket-invalid { color: #fca5a5; }

[data-theme="dark"] .ticket-ref { color: #7eb6ff; }
[data-theme="dark"] .card-mono  { color: #7eb6ff; }

/* Inputs glow ring in dark */
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] .dialog-fields input:focus,
[data-theme="dark"] .dialog-fields select:focus,
[data-theme="dark"] .toolbar-date-range input[type="date"]:focus {
  border-color: var(--ace);
  box-shadow: 0 0 0 3px rgba(34, 227, 64, 0.22);
}

/* Log table reads well as-is (already dark), no override needed. */

/* ── Polish: scrollbars, focus rings, reduced motion ─────────────────────────── */

.management-table-wrap,
.log-table-wrap,
.user-table-wrap,
pre {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.management-table-wrap::-webkit-scrollbar,
.log-table-wrap::-webkit-scrollbar,
.user-table-wrap::-webkit-scrollbar,
pre::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.management-table-wrap::-webkit-scrollbar-thumb,
.log-table-wrap::-webkit-scrollbar-thumb,
.user-table-wrap::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.text-button:focus-visible,
.icon-btn:focus-visible,
.period-btn:focus-visible,
.theme-toggle:focus-visible,
.dropzone:focus-within {
  outline: 2px solid rgba(34, 227, 64, 0.55);
  outline-offset: 2px;
}

.receipt-cell {
  white-space: nowrap;
}

.receipt-link {
  display: inline-block;
  margin-right: 8px;
  color: var(--ace-dark);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

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

[data-theme="dark"] .receipt-link {
  color: #6be087;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Sortable table headers ──────────────────────────────────────────────── */
.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sortable-th:hover { color: var(--accent, #2e7d32); }
.sortable-th.sorted-asc::after  { content: " \25B2"; font-size: 0.7em; opacity: 0.8; }
.sortable-th.sorted-desc::after { content: " \25BC"; font-size: 0.7em; opacity: 0.8; }

/* ── Aspire payload preview toggle ───────────────────────────────────────── */
.payload-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  margin: 14px 0 0;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  transition: border-color 160ms var(--ease), background 160ms var(--ease), box-shadow 160ms var(--ease);
}

.payload-toggle:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.payload-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--line);
  transition: background 160ms var(--ease), border-color 160ms var(--ease);
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(3, 13, 7, 0.22);
  transition: transform 160ms var(--ease), background 160ms var(--ease);
}

.payload-toggle:has(input:checked) {
  border-color: rgba(8, 127, 36, 0.34);
  background: rgba(34, 227, 64, 0.08);
}

.payload-toggle:has(input:checked) .toggle-track {
  border-color: var(--ace-dark);
  background: var(--ace-deep);
}

.payload-toggle:has(input:checked) .toggle-knob {
  transform: translateX(22px);
}

.payload-toggle:has(input:focus-visible) {
  box-shadow: 0 0 0 3px rgba(34, 227, 64, 0.22);
}

/* ── Itemized editor (job/indirect per line) ─────────────────────────────── */
.allocation-line-head .iz-class {
  margin-left: auto;
  max-width: 190px;
}
.itemized-method {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.itemized-method select,
.itemized-method input { max-width: 140px; }
.itemized-indirect {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 720px) {
  .itemized-indirect { grid-template-columns: 1fr; }
}

/* ── First-boot setup hint ───────────────────────────────────────────────── */
.setup-hint {
  font-size: 0.85rem;
  color: var(--muted, #666);
  margin: 0 0 6px;
  line-height: 1.4;
}

/* ── Multi-work-ticket allocation editor ─────────────────────────────────── */
.allocation-mode-group {
  border: none;
  padding: 0;
  margin: 0 0 6px;
}

.allocation-mode-group legend {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  padding: 0;
}

.allocation-mode-group .receipt-type-buttons,
#paidStatusGroup .receipt-type-buttons {
  grid-template-columns: repeat(2, 1fr);
}

.allocation-editor {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface-2, rgba(0, 0, 0, 0.02));
}

.allocation-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.allocation-line {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.allocation-line-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.allocation-line-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.allocation-line-head .alloc-method {
  margin-left: auto;
  max-width: 200px;
}

.allocation-line-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  gap: 10px;
  margin-bottom: 8px;
}

.allocation-tickets .alloc-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto 2fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.alloc-ticket-status {
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.allocation-tax-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin: 10px 0 4px;
}

.allocation-tax-row label {
  flex: 0 0 160px;
}

.allocation-hint {
  font-size: 0.8rem;
  margin: 6px 0 10px;
}

.alloc-ticket-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.alloc-ticket-table th,
.alloc-ticket-table td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}

.alloc-recon {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.recon-ok  { background: #dcfce7; color: #166534; }
.recon-bad { background: #fee2e2; color: #991b1b; }

[data-theme="dark"] .recon-ok  { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .recon-bad { background: #7f1d1d; color: #fecaca; }

.alloc-errors,
.alloc-blockers {
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.alloc-errors  { color: #b91c1c; }
.alloc-blockers { color: #92400e; }

[data-theme="dark"] .alloc-errors   { color: #fca5a5; }
[data-theme="dark"] .alloc-blockers { color: #fcd34d; }

@media (max-width: 720px) {
  .allocation-line-fields { grid-template-columns: 1fr 1fr; }
  .allocation-tickets .alloc-row { grid-template-columns: 1fr 1fr auto; }
  .alloc-ticket-status { grid-column: 1 / -1; }
}

/* ── Receipt storage lifecycle ─────────────────────────────────────────────── */
.storage-meter-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.storage-meter-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.storage-meter-head strong { font-size: 1.05rem; color: var(--heading); }
.storage-meter {
  height: 12px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.storage-meter-fill {
  height: 100%;
  width: 0;
  background: var(--ace);
  border-radius: 999px;
  transition: width 0.3s var(--ease), background 0.2s var(--ease);
}
.storage-meter-fill.warn   { background: #f59e0b; }
.storage-meter-fill.danger { background: #dc2626; }
.storage-meter-note { margin: 10px 0 0; font-size: 0.82rem; }

.storage-months { display: flex; flex-direction: column; gap: 8px; }
.storage-month {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
}
.storage-month.is-archivable { border-color: var(--line-strong); }
.storage-month-info { display: flex; flex-direction: column; gap: 2px; }
.storage-month-info strong { color: var(--heading); font-size: 0.95rem; }
.storage-month-info .muted { font-size: 0.8rem; }
.storage-month-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.storage-export {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-muted);
}
.storage-export-info { display: flex; flex-direction: column; gap: 2px; }
.storage-export-info strong { color: var(--heading); font-size: 0.95rem; }
.storage-export-info .muted { font-size: 0.8rem; }
#exportAllBtn { flex-shrink: 0; }

@media (max-width: 560px) {
  .storage-month { flex-direction: column; align-items: stretch; }
  .storage-month-actions { justify-content: flex-end; }
  .storage-export { flex-direction: column; align-items: stretch; }
}
/* Custom searchable dropdown */
.searchable-dropdown {
  position: relative;
  display: inline-block;
  min-width: 200px;
}

.toolbar-checkbox {
  display: flex;
  align-items: center;
  align-self: center;
  margin: 0 12px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
}
.dropdown-options div.option.inactive {
  color: var(--muted);
  font-style: italic;
}
.dropdown-options div.option.inactive:hover {
  background: var(--surface-2);
  color: var(--muted);
  font-style: italic;
}
.searchable-dropdown input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
}
.searchable-dropdown input[type="text"]:focus {
  outline: none;
  border-color: var(--ace);
}
.dropdown-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface);
  z-index: 1000;
  margin-top: -1px;
  display: none;
}
.dropdown-options.show {
  display: block;
}
.dropdown-options div.option {
  padding: 8px 12px;
  cursor: pointer;
}
.dropdown-options div.option:hover,
.dropdown-options div.option.focus {
  background: var(--surface-2);
}
.dropdown-options div.option.selected {
  background: var(--surface-2);
  font-weight: bold;
}
