/*
 * DFM UI layer: Tabler-inspired layout, spacing and surfaces with the DFM brand accents.
 * Loaded last (tabler.min.css -> dfm-theme.css -> style.css -> dfm-ui.css). Components restyled here had
 * their legacy selectors removed from style.css, so these rules are the single definition for them.
 */

/* ---------------------------------------------------------------- surfaces & tokens
   One palette in both themes, "loden and cream": an olive (loden) accent on cream surfaces in light
   and deep olive-black in dark. Green, amber and red are reserved for status; everything
   decorative uses the accent or the neutrals. */
html[data-theme="light"] {
  --background: 48 36% 95%;          /* #f6f4ec cream page */
  --foreground: 80 14% 13%;          /* #22251c text */
  --card: 45 100% 98%;               /* #fffdf7 */
  --card-foreground: 80 14% 13%;
  --popover: 45 100% 98%;
  --popover-foreground: 80 14% 13%;
  --secondary: 48 23% 91%;           /* #eeece4 */
  --secondary-foreground: 80 14% 13%;
  --muted: 48 23% 91%;
  --muted-foreground: 74 7% 39%;     /* #676a5d */
  --border: 47 24% 85%;              /* #e3dfd1 */
  --input: 46 21% 80%;               /* #d6d1c0 */
  --primary: 85 25% 28%;             /* #4b5a36 loden */
  --primary-foreground: 45 100% 98%;
  --accent: 85 25% 28%;
  --accent-foreground: 45 100% 98%;
  --ring: 85 25% 34%;
  --status-info: 85 25% 28%;
  --finance-canvas: #f6f4ec;
  --finance-surface: #fffdf7;
  --finance-control: #eeece4;
  --finance-line: #e3dfd1;
  --finance-ink: #22251c;
  --finance-muted: #676a5d;
  --radius: .5rem;
  --card-radius: 8px;
  --shadow: 0 1px 2px rgb(34 37 28 / .06), 0 1px 3px rgb(34 37 28 / .04);
  --soft: 0 1px 2px rgb(34 37 28 / .05);
  --tblr-primary-rgb: 75, 90, 54;
  --tblr-info-rgb: 75, 90, 54;
  --tblr-body-bg-rgb: 246, 244, 236;
  --tblr-body-color-rgb: 34, 37, 28;
  --tblr-secondary-rgb: 103, 106, 93;
}

html[data-theme="dark"] {
  /* Near-neutral charcoal with a faint olive hint; clear steps page < card < inner box < border. */
  --background: 90 6% 8%;            /* #131512 page */
  --foreground: 75 15% 91%;          /* #e9ebe4 text */
  --card: 90 6% 11%;                 /* #1b1d19 */
  --card-foreground: 75 15% 91%;
  --popover: 90 6% 13%;
  --popover-foreground: 75 15% 91%;
  --secondary: 90 6% 15%;            /* inner boxes, hover */
  --secondary-foreground: 75 15% 91%;
  --muted: 90 6% 15%;
  --muted-foreground: 80 6% 64%;     /* #a3a698 */
  --border: 90 6% 20%;               /* #31342e */
  --input: 90 6% 26%;
  /* Accent for text, links, the active menu line and icons: light loden (readable on charcoal). */
  --primary: 82 30% 70%;             /* #b5c697 */
  --primary-foreground: 90 6% 8%;
  --accent: 82 30% 70%;
  --accent-foreground: 90 6% 8%;
  --ring: 82 30% 70%;
  --status-info: 82 30% 74%;
  /* Filled controls (buttons, brand mark, active filter): deep loden with light text, not pastel. */
  --primary-fill: 84 26% 34%;        /* #566b40 */
  --primary-fill-hover: 84 26% 39%;
  --primary-fill-foreground: 75 40% 96%;
  --radius: .5rem;
  --card-radius: 8px;
  --shadow: inset 0 1px 0 rgb(255 255 255 / .035), 0 1px 2px rgb(0 0 0 / .45);
  --soft: 0 1px 2px rgb(0 0 0 / .35);
  --tblr-primary-rgb: 181, 198, 151;
  --tblr-info-rgb: 181, 198, 151;
  --tblr-body-bg-rgb: 19, 21, 18;
  --tblr-body-color-rgb: 233, 235, 228;
  --tblr-secondary-rgb: 163, 166, 152;
}

/* ---------------------------------------------------------------- KPI cards
   One card per figure with even gutters (Tabler "row-cards"), neutral border, one brand-tinted
   icon tile; no per-card colours (one palette across the app). */
.executive-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin: 0 0 20px;
  padding: 0;
}
/* Balanced rows for longer strips on wide screens: 8 -> 4 + 4, 9 -> 5 + 4 (instead of 7 + 1 / 7 + 2). */
@media (min-width: 1200px) {
  .executive-strip:has(> article:nth-child(8):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .executive-strip:has(> article:nth-child(9):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.executive-strip > article {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 18px 20px 16px;
  color: hsl(var(--card-foreground));
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.executive-strip > article > span:not(.kpi-icon) {
  min-height: 32px;
  padding-right: 44px;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
}
.executive-strip > article > strong {
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
  color: hsl(var(--card-foreground));
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.executive-strip > article > small {
  display: block;
  font-size: 13px;
  line-height: 18px;
  color: hsl(var(--muted-foreground));
}
.executive-strip .kpi-empty { color: hsl(var(--muted-foreground)); font-weight: 500; }

.executive-strip .kpi-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: hsl(var(--primary) / .10);
  color: hsl(var(--primary));
}
.executive-strip .kpi-icon .icon { width: 20px; height: 20px; }

@media (max-width: 575.98px) {
  .executive-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .executive-strip > article { padding: 14px 14px 12px; }
  .executive-strip > article > strong { font-size: 20px; line-height: 28px; }
}

/* Page backdrop: a flat neutral canvas (Tabler), replacing the legacy gradients and glows. */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: hsl(var(--background));
}

/* ---------------------------------------------------------------- app shell
   Tabler two-row header: brand, account and theme switch on top; the main menu on its own
   full-width row below. Both rows stay pinned while the page scrolls. */
.dfm-shell { width: 100%; max-width: 1640px; margin: 0 auto; padding: 0 18px; }
.dfm-header { position: sticky; top: 0; z-index: 1020; }
.dfm-navbar,
.dfm-menubar {
  background: hsl(var(--card));
  box-shadow: inset 0 -1px 0 hsl(var(--border));
}
.dfm-navbar { min-height: 56px; padding: 0; }
.dfm-navbar-inner { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.dfm-navbar .navbar-toggler { padding: 6px; border: 0; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin: 0; padding: 0; color: hsl(var(--foreground)); text-decoration: none; }
.brand:hover { color: hsl(var(--foreground)); }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1;
}
.brand small {
  display: block;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 600;
  line-height: 14px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.brand strong { display: block; color: hsl(var(--foreground)); font-size: 15px; font-weight: 600; line-height: 20px; }

.dfm-navbar-tools { gap: 8px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 6px;
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 500;
  text-transform: lowercase;
}
.user-chip:hover,
.user-chip.show { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

.dfm-menubar .navbar { min-height: 0; padding: 0; background: transparent; box-shadow: none; }
.dfm-navbar-menu { gap: 2px; }
.dfm-navbar-menu .nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  font-weight: 500;
}
.dfm-navbar-menu .nav-link-icon { width: 18px; height: 18px; margin: 0; opacity: .85; }
.dfm-navbar-menu .nav-link:hover,
.dfm-navbar-menu .nav-link:focus-visible,
.dfm-navbar-menu .nav-link.show,
.dfm-navbar-menu .nav-item.active > .nav-link { color: hsl(var(--foreground)); }
.dfm-navbar-menu .nav-item.active::after { content: none; }
.dfm-navbar-menu .nav-item.active > .nav-link::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -2px; /* sits on the menu bar's bottom border: one line, not two */
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: hsl(var(--primary));
}

.dfm-header .dropdown-menu {
  min-width: 220px;
  padding: 6px;
  font-size: 14px;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  box-shadow: 0 12px 32px rgb(34 37 28 / .14);
}
html[data-theme="dark"] .dfm-header .dropdown-menu { box-shadow: 0 12px 32px rgb(0 0 0 / .45); }
.dfm-header .dropdown-item { padding: 8px 10px; border-radius: 6px; color: hsl(var(--foreground)); white-space: nowrap; }
.dfm-header .dropdown-item:hover,
.dfm-header .dropdown-item:focus { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
.dfm-header .dropdown-header {
  padding: 8px 10px 4px;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.dfm-header .dropdown-item-icon { width: 16px; height: 16px; margin-right: 8px; }
@media (min-width: 992px) {
  .dfm-workings-menu .dropdown-menu-columns { display: grid; grid-template-columns: repeat(2, minmax(230px, 1fr)); column-gap: 8px; }
  .dfm-workings-menu .dropdown-menu-column { min-width: 0; }
}
@media (max-width: 991.98px) {
  .dfm-navbar .brand small { display: none; }
  .dfm-navbar .theme-toggle-label { display: none; }
  .dfm-navbar .theme-toggle { min-width: 0; padding: 5px 7px; }
  .dfm-menubar .navbar { padding: 4px 0 8px; }
  .dfm-navbar-menu .nav-link { padding: 10px 8px; }
  .dfm-navbar-menu .nav-item.active > .nav-link::before { left: 0; right: auto; top: 8px; bottom: 8px; width: 2px; height: auto; }
  .dfm-header .dropdown-menu { box-shadow: none; border: 0; background: transparent; padding: 0 0 4px 26px; }
  .dfm-header .dropdown-menu-columns { flex-direction: column; }
}
@media (max-width: 575.98px) {
  .dfm-shell { padding: 0 12px; }
  .dfm-navbar-inner { gap: 8px; }
  .user-chip > span { display: none; }
  .dfm-navbar-tools { gap: 4px; }
}

/* ---------------------------------------------------------------- page headers
   Tabler page-header: small uppercase pretitle, title, muted subtitle and actions on the canvas
   itself (no banner box); the status or batch summary sits on the right as a compact card. */
:is(.principal-cover, .module-page-head, .hero) {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 32px;
  margin: 8px 0 24px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
:is(.principal-cover, .module-page-head, .hero) > div:first-child { flex: 1 1 520px; min-width: 0; }
:is(.principal-cover, .module-page-head, .hero) .eyebrow {
  display: block;
  margin: 0 0 4px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
:is(.principal-cover, .module-page-head, .hero) h1 {
  margin: 0;
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
  letter-spacing: -.01em;
}
:is(.principal-cover, .module-page-head, .hero) > div:first-child > p {
  max-width: 82ch;
  margin: 6px 0 0;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  line-height: 20px;
}
:is(.principal-cover, .module-page-head, .hero) .actions,
:is(.principal-cover, .module-page-head, .hero) .page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  background: none;
  border: 0;
}
:is(.principal-cover, .module-page-head, .hero) > .page-actions { margin: 0; align-self: center; }
:is(.principal-cover, .module-page-head, .hero) > aside {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 1 340px;
  min-width: 240px;
  margin: 0;
  padding: 16px 20px;
  color: hsl(var(--card-foreground));
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
}
:is(.principal-cover, .module-page-head, .hero) > aside > span {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
:is(.principal-cover, .module-page-head, .hero) > aside > strong {
  color: hsl(var(--card-foreground));
  font-size: 18px;
  font-weight: 600;
  line-height: 26px;
}
:is(.principal-cover, .module-page-head, .hero) > aside > strong.status-text { align-self: flex-start; font-size: 12px; line-height: 18px; }
:is(.principal-cover, .module-page-head, .hero) > aside > small {
  display: block;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 18px;
}
:is(.principal-cover, .module-page-head, .hero) > aside .btn { align-self: flex-start; }
/* Status cards outside page headers (ERP import) share the compact card look. */
.status-card:not(:is(.principal-cover, .module-page-head, .hero) > *) {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
}
@media (max-width: 767.98px) {
  :is(.principal-cover, .module-page-head, .hero) { margin: 4px 0 16px; gap: 12px; }
  :is(.principal-cover, .module-page-head, .hero) h1 { font-size: 20px; line-height: 28px; }
  :is(.principal-cover, .module-page-head, .hero) > aside { flex: 1 1 100%; min-width: 0; }
  :is(.principal-cover, .module-page-head, .hero) .actions > .btn { flex: 1 1 calc(50% - 4px); }
}

/* ---------------------------------------------------------------- toolbars, card headers, tables */
/* Action rows sit on the canvas like Tabler's page actions instead of inside their own box. */
html[data-theme] .module-toolbar {
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
/* Card headers: 16px semibold title, muted note. */
html[data-theme] .panel-title-row > :is(h2, h3),
html[data-theme] .panel-title-row > div > :is(h2, h3) {
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: 0;
}
html[data-theme] .panel-title-row > small,
html[data-theme] .dashboard-section-title p {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}
html[data-theme] .dashboard-section-title h2 { font-size: 18px; font-weight: 600; line-height: 28px; letter-spacing: 0; }
/* Module card meta rows: the label column fits its word ("Inputs" no longer breaks). */
html[data-theme] .micro-meta { grid-template-columns: max-content minmax(0, 1fr); column-gap: 10px; border-radius: 6px; }
html[data-theme] .micro-meta b { font-size: 11px; font-weight: 600; letter-spacing: .04em; }
/* Tables: Tabler header row (small uppercase muted labels on a subtle band) and roomier cells. */
html[data-theme] .mini-table > thead > tr > th {
  padding: 10px 12px;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / .7);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
html[data-theme] .mini-table > tbody > tr > td { padding: 10px 12px; }
html[data-theme] .mini-table.dense-table > tbody > tr > td { padding: 8px 12px; }

/* Module cards: neutral border and a brand-tinted icon tile, the same for every working. */
html[data-theme] .working-card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--card-radius);
}
.work-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: hsl(var(--primary) / .10);
  color: hsl(var(--primary));
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}
.work-icon .icon { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- status badges
   The only place green / amber / red appear. Pending and other not-started states stay neutral so
   a dashboard of uncalculated workings reads calm; amber is for states that need attention. */
html[data-theme] :is(.dfm-status, .status-text) {
  --st-bg: hsl(var(--muted));
  --st-fg: hsl(var(--muted-foreground));
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  background: var(--st-bg);
  color: var(--st-fg);
  box-shadow: none;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
html[data-theme="light"] :is(.dfm-status, .status-text):is(.ready, .ready-for-calculation, .calculated-snapshot, .extraction_complete, .current, .active, .success, .done) { --st-bg: #e3f5ea; --st-fg: #1e7b45; }
html[data-theme="light"] :is(.dfm-status, .status-text):is(.stale, .partly-ready, .partial, .missing, .missing-files, .needs-source, .incomplete-sources, .review_required, .period-review, .duplicate-review, .source-review, .ready-for-mapping, .queued) { --st-bg: #fdf2dc; --st-fg: #8a5a00; }
html[data-theme="light"] :is(.dfm-status, .status-text):is(.failed, .error, .blocked, .rejected) { --st-bg: #fbe7e7; --st-fg: #a12a2a; }
html[data-theme="light"] :is(.dfm-status, .status-text):is(.in-progress, .running) { --st-bg: #ebeedf; --st-fg: #4b5a36; }
html[data-theme="dark"] :is(.dfm-status, .status-text):is(.ready, .ready-for-calculation, .calculated-snapshot, .extraction_complete, .current, .active, .success, .done) { --st-bg: #163a27; --st-fg: #7fdca5; }
html[data-theme="dark"] :is(.dfm-status, .status-text):is(.stale, .partly-ready, .partial, .missing, .missing-files, .needs-source, .incomplete-sources, .review_required, .period-review, .duplicate-review, .source-review, .ready-for-mapping, .queued) { --st-bg: #3d2f10; --st-fg: #f2c56b; }
html[data-theme="dark"] :is(.dfm-status, .status-text):is(.failed, .error, .blocked, .rejected) { --st-bg: #421c1f; --st-fg: #f29a9a; }
html[data-theme="dark"] :is(.dfm-status, .status-text):is(.in-progress, .running) { --st-bg: #272f1c; --st-fg: #c5d2a9; }

/* Labels stay neutral: the accent is kept for actions, the active menu item and icons. */
html[data-theme] :is(.eyebrow, .micro-meta b, .working-stats span, .panel-title-row > small, .dashboard-section-title p) {
  color: hsl(var(--muted-foreground));
}

/* ---------------------------------------------------------------- sign-in pages (login, two-factor)
   "Ledger backdrop": a faint ruled-paper canvas in the loden tint, one card with a brand strip. */
html[data-theme="light"] body:has(.auth-shell) .page-bg {
  background-color: #ebeedf;
  background-image: repeating-linear-gradient(0deg, transparent 0 27px, #dfe3cf 27px 28px);
}
html[data-theme="dark"] body:has(.auth-shell) .page-bg {
  background-color: #121411;
  background-image:
    radial-gradient(ellipse 60% 55% at 50% 38%, rgb(181 198 151 / .07), transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 27px, rgb(255 255 255 / .045) 27px 28px);
}
/* The body's solid background would paint over the fixed backdrop layer; let it show through here. */
html[data-theme] body:has(.auth-shell) { background: transparent !important; }
body:has(.auth-shell) .dfm-navbar,
body:has(.auth-shell) .dfm-menubar { background: hsl(var(--card) / .92); }
body:has(.auth-shell) .dfm-navbar .brand { visibility: hidden; } /* the card carries the brand */
.auth-shell { display: flex; justify-content: center; padding: 56px 0 32px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  box-shadow: 0 1px 2px rgb(34 37 28 / .06), 0 12px 32px rgb(34 37 28 / .10);
}
html[data-theme="dark"] .auth-card {
  border-color: hsl(90 6% 24%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .04), 0 18px 48px rgb(0 0 0 / .55);
}
.auth-card-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.auth-card-brand .brand-mark { background: hsl(var(--primary-foreground)); color: hsl(var(--primary)); }
.auth-card-brand small { display: block; color: hsl(var(--primary-foreground) / .72); font-size: 11px; font-weight: 600; line-height: 14px; letter-spacing: .06em; text-transform: uppercase; }
.auth-card-brand strong { display: block; color: hsl(var(--primary-foreground)); font-size: 15px; font-weight: 600; line-height: 20px; }
/* Dark: the strip uses the deep loden fill (like the buttons) with light text, mirroring light mode. */
html[data-theme="dark"] .auth-card-brand { background: hsl(var(--primary-fill)); color: hsl(var(--primary-fill-foreground)); }
html[data-theme="dark"] .auth-card-brand .brand-mark { background: hsl(var(--primary-fill-foreground)); border-color: transparent; color: hsl(var(--primary-fill)); }
html[data-theme="dark"] .auth-card-brand small { color: hsl(var(--primary-fill-foreground) / .72); }
html[data-theme="dark"] .auth-card-brand strong { color: hsl(var(--primary-fill-foreground)); }
html[data-theme="dark"] .auth-card-body .form-control {
  background-color: hsl(90 6% 7%);
  border-color: hsl(90 6% 27%);
}
html[data-theme="dark"] .auth-card-body .form-control:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / .18);
}
html[data-theme="dark"] .auth-sso-btn {
  background: hsl(90 6% 14%);
  border: 1px solid hsl(90 6% 27%);
  color: hsl(var(--foreground));
}
html[data-theme="dark"] .auth-sso-btn:hover { background: hsl(90 6% 18%); border-color: hsl(90 6% 33%); color: hsl(var(--foreground)); }
.auth-card-body { padding: 24px 24px 26px; }
.auth-card-body .eyebrow { display: block; margin: 0 0 4px; color: hsl(var(--muted-foreground)); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.auth-card-body h1 { margin: 0 0 6px; color: hsl(var(--foreground)); font-size: 22px; font-weight: 600; line-height: 30px; }
.auth-card-body > p.muted { margin: 0 0 18px; color: hsl(var(--muted-foreground)); font-size: 14px; line-height: 20px; }
.auth-card-body .form { gap: 14px; }
.auth-card-body .btn-lg { width: 100%; margin-top: 2px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; color: hsl(var(--muted-foreground)); font-size: 12px; }
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: hsl(var(--border)); }
.auth-sso { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.auth-sso-btn { justify-content: center; gap: 8px; min-height: 40px; }
.auth-sso-btn .icon { width: 18px; height: 18px; }
.auth-sso-note { margin: 12px 0 0; padding: 8px 10px; border-radius: 6px; background: hsl(var(--secondary)); color: hsl(var(--muted-foreground)); font-size: 13px; line-height: 18px; }
@media (max-width: 575.98px) {
  .auth-shell { padding: 24px 0 16px; }
  .auth-card-body { padding: 20px 18px 22px; }
}

/* ---------------------------------------------------------------- module card footer
   Tabler card-footer: a full-width strip on the card's bottom edge with a divider; the actions share
   the width equally at one height (and wrap evenly when a card has three or four). */
html[data-theme] .working-card { padding: 20px; min-height: 0; }
/* A fixed 18px spacer sits just before the footer (order 1 vs the footer's 2), so the gap holds even
   when a card's later rows are hidden; leftover height goes above the footer, keeping footers aligned. */
html[data-theme] .working-card::after { content: ""; order: 1; flex: 0 0 18px; }
html[data-theme] .working-card > .dfm-card-actions { order: 2; }
html[data-theme] .working-card .dfm-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: auto -20px -20px;
  padding: 12px 20px;
  background: hsl(var(--muted) / .45);
  border-top: 1px solid hsl(var(--border));
  border-radius: 0 0 var(--card-radius) var(--card-radius);
}
html[data-theme] .working-card .dfm-card-actions > :is(a, button, form) { flex: 1 1 200px; min-width: 0; margin: 0; }
html[data-theme] .working-card .dfm-card-actions > form { display: flex; }
html[data-theme] .working-card .dfm-card-actions .btn {
  width: 100%;
  min-height: 36px;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-theme] .working-card .dfm-card-actions .btn .icon { width: 16px; height: 16px; flex: 0 0 auto; }
html[data-theme] .working-card .dfm-card-actions .btn:not(.btn-primary):not(.btn-outline-danger) {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}
html[data-theme] .working-card .dfm-card-actions .btn:not(.btn-primary):not(.btn-outline-danger):hover {
  border-color: hsl(var(--input));
  background: hsl(var(--secondary));
}

/* ---------------------------------------------------------------- dark-mode depth and fills */
html[data-theme="dark"] .btn-primary {
  --tblr-btn-bg: hsl(var(--primary-fill));
  --tblr-btn-border-color: hsl(var(--primary-fill));
  --tblr-btn-color: hsl(var(--primary-fill-foreground));
  --tblr-btn-hover-bg: hsl(var(--primary-fill-hover));
  --tblr-btn-hover-border-color: hsl(var(--primary-fill-hover));
  --tblr-btn-hover-color: hsl(var(--primary-fill-foreground));
  --tblr-btn-active-bg: hsl(var(--primary-fill-hover));
  --tblr-btn-active-color: hsl(var(--primary-fill-foreground));
}
/* Separate rules (not one :is() list) so each keeps its own specificity and the sign-in strip can
   still invert the brand mark. */
html[data-theme="dark"] .brand-mark,
html[data-theme="dark"] .module-filter-bar .btn.active,
html[data-theme="dark"] .close-step.is-current .close-step-index {
  background: hsl(var(--primary-fill));
  border-color: hsl(var(--primary-fill));
  color: hsl(var(--primary-fill-foreground));
}
html[data-theme="dark"] :is(.working-card, .panel, .data-panel, .info-card, .close-step) {
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- info cards (both themes)
   Same neutral card as everything else: no coloured left edges, neutral tags. */
html[data-theme] .info-card {
  padding: 16px 20px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
}
html[data-theme] .info-card em {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-weight: 600;
  letter-spacing: .04em;
}

/* ---------------------------------------------------------------- footer (both themes)
   Same two-line layout in light and dark: the notice, then the legal links centred below. */
html[data-theme] .dfm-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 18px 28px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
html[data-theme] .legal-links { margin: 0; gap: 16px; }
html[data-theme] .legal-links a { color: hsl(var(--primary)); font-weight: 600; text-decoration: none; }
html[data-theme] .legal-links a:hover { text-decoration: underline; }

/* ---- Two-factor setup: QR code ------------------------------------------ */
/* The QR keeps a white quiet zone in both themes so phone cameras can read it. */
.mfa-setup-card .mfa-step { margin: 0 0 12px; color: hsl(var(--foreground)); }
.mfa-qr-frame { display: flex; justify-content: center; margin: 0 0 14px; }
.mfa-qr-frame svg.mfa-qr {
  display: block; width: 200px; height: 200px; background: #fff;
  border: 1px solid hsl(var(--border)); border-radius: 8px;
}
.mfa-manual { margin: 0 0 14px; }
.mfa-manual summary {
  cursor: pointer; color: hsl(var(--muted-foreground)); font-size: 13px; margin-bottom: 8px;
}
.mfa-manual summary:hover { color: hsl(var(--foreground)); }
.mfa-manual label { margin-top: 8px; }
