/* =========================================================================
   HT-OPS UI refresh — typography + colour calm-down.
   Loaded AFTER MudBlazor.min.css (see App.razor) so these win.
   Display-layer only: font, softer text colours, lighter heading weights.
   ========================================================================= */

:root {
  --ht-font: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;

  /* ── Semantic tokens (LIGHT, default) ───────────────────────────────── */
  --ht-bg:        #F6F7F9;     /* app canvas */
  --ht-surface:   #ffffff;     /* cards / papers */
  --ht-surface-2: #f3f5f8;     /* inset (tiles) */
  --ht-line:      #E7EBF0;     /* hairline border */
  --ht-card-border: var(--ht-line);
  --ht-ink:       #1f2733;     /* primary text — dark grey, not black */
  --ht-muted:     #6b7785;     /* secondary text / labels */
  --ht-faint:     #97a2b0;     /* hints, placeholders */
  --ht-accent:    #3b6ef5;     /* actions / links / active */
  --ht-chip-bg:   #EEF1F5;     /* neutral chip background */
  --ht-btn-ink:   #41506a;     /* neutral outlined-button text */
  --ht-appbar:    #ffffff;     /* top bar */
  --ht-drawer:    #ffffff;     /* sidebar */

  /* ── Map MudBlazor's own variables onto our tokens ──────────────────── */
  --mud-typography-default-family: var(--ht-font);
  --mud-default-borderradius: 10px;
  --mud-palette-background:     var(--ht-bg);
  --mud-palette-surface:        var(--ht-surface);
  --mud-palette-text-primary:   var(--ht-ink);
  --mud-palette-text-secondary: var(--ht-muted);
  --mud-palette-text-disabled:  var(--ht-faint);
  --mud-palette-lines-inputs:   var(--ht-line);
  --mud-palette-lines-default:  var(--ht-line);
  --mud-palette-divider:        var(--ht-line);
}

/* ── DARK THEME — cool dark-grey (driven by <html data-theme="dark">) ──── */
:root[data-theme="dark"] {
  color-scheme: dark;                 /* native scrollbars / date pickers go dark */
  --ht-bg:        #1a1d21;
  --ht-surface:   #23272d;
  --ht-surface-2: #2b3037;
  --ht-line:      #373c44;
  --ht-ink:       #e7e9ed;
  --ht-muted:     #a2a8b2;
  --ht-faint:     #757b86;
  --ht-accent:    #7aa2ff;
  --ht-chip-bg:   #2f343c;
  --ht-btn-ink:   #cfcfd2;
  --ht-appbar:    #1f2329;
  --ht-drawer:    #1f2329;

  --mud-palette-primary:           #7aa2ff;
  --mud-palette-drawer-background: var(--ht-drawer);
  --mud-palette-drawer-text:       #cfcfd2;
  --mud-palette-drawer-icon:       var(--ht-muted);
  --mud-palette-appbar-background: var(--ht-appbar);
  --mud-palette-appbar-text:       var(--ht-ink);
  --mud-palette-action-default:    var(--ht-muted);
  --mud-palette-action-disabled:   #5a606b;
  --mud-palette-surface:           var(--ht-surface);
}

/* App canvas + main scroll regions follow the theme token. */
html, body { background-color: var(--ht-bg); }
.mud-layout, .mud-main-content { background-color: var(--ht-bg); }

/* Top bar + drawer follow the theme (AppBar inline style is overridden). */
.mud-appbar.ht-appbar { background: var(--ht-appbar) !important; border-bottom: 1px solid var(--ht-line) !important; }
.mud-drawer { background: var(--ht-drawer) !important; }

/* Outlined text fields / selects — rounder corners + card-hairline border. */
.mud-input.mud-input-outlined,
.mud-input-outlined-border { border-radius: 10px !important; }
.mud-input-outlined-border { border-color: var(--ht-card-border) !important; }
/* Keep the accent on hover/focus so the field still signals interaction. */
.mud-input-outlined:hover:not(.mud-disabled) .mud-input-outlined-border,
.mud-input-outlined.mud-focused .mud-input-outlined-border {
  border-color: var(--mud-palette-primary) !important;
}

/* Neutral outlined buttons (Edit / Set) — border = card hairline, calm grey text. */
.mud-button-outlined-default {
  border-color: var(--ht-card-border) !important;
  color: var(--ht-btn-ink);
}

/* Rounder corners + a light hairline border so cards read as crisp surfaces
   on the grey canvas (matches the reference). Soften the default shadow. */
.mud-paper {
  border-radius: 12px;
  border: 1px solid var(--ht-card-border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

/* Task detail title card — clean white with a per-type colour accent. */
.ht-title-card {
  position: relative;
  border-radius: 14px;
  padding: 18px 22px 18px 24px;
  background: var(--ht-surface);
  border: 1px solid var(--ht-card-border);
  overflow: hidden;
}
/* Left accent bar in the task-type colour (set via --ht-accent inline). */
.ht-title-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--ht-accent, #3b6ef5);
}
.ht-title-row { display: flex; align-items: flex-start; gap: 16px; }
.ht-title-badge {
  width: 52px; height: 52px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.ht-title-crumb {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ht-faint); margin-bottom: 3px;
}
.ht-title-text { font-weight: 650; line-height: 1.2; color: var(--ht-ink); }
.ht-title-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.ht-title-actions .mud-icon-button:hover { background: rgba(16,24,40,0.05); }

.ht-crumb {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--ht-chip-bg); color: var(--ht-btn-ink);
  border-radius: 7px; padding: 3px 9px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  font-family: "SFMono-Regular", ui-monospace, Consolas, monospace;
}
.ht-crumb.ht-crumb--type { font-family: var(--ht-font); }
.ht-crumb.ht-crumb--soft { background: var(--ht-chip-bg); color: var(--ht-muted); }

/* Task detail: narrow the right (Fields) pane ~15% on desktop; mobile still stacks.
   The right pane also becomes its own sticky scroll area so it scrolls independently
   of the left column. */
@media (min-width: 960px) {
  .ht-task-main { flex: 0 0 72% !important; max-width: 72% !important; }
  .ht-task-side {
    flex: 0 0 28% !important; max-width: 28% !important;
    position: sticky; top: 84px; align-self: flex-start;
    max-height: calc(100vh - 100px); overflow-y: auto;
  }
}

/* Auto-hiding scrollbar on the right pane: invisible at rest; visible while
   scrolling (JS adds .scrolling) or on hover. */
.ht-task-side { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.ht-task-side:hover, .ht-task-side.scrolling { scrollbar-color: rgba(100,110,130,0.40) transparent; }
.ht-task-side::-webkit-scrollbar { width: 10px; }
.ht-task-side::-webkit-scrollbar-thumb {
  background: transparent; border-radius: 6px;
  border: 2px solid transparent; background-clip: padding-box;
}
.ht-task-side:hover::-webkit-scrollbar-thumb,
.ht-task-side.scrolling::-webkit-scrollbar-thumb {
  background: rgba(100,110,130,0.40); background-clip: padding-box;
}

/* Sidebar: keep icons on level-1 items, drop them on sub-menu (group child) links —
   children are an indented text list with a vertical guide-line; the active child
   paints an accent segment onto that line. */
.ht-nav .mud-nav-group .mud-collapse-container .mud-nav-link .mud-nav-link-icon { display: none; }
.ht-nav .mud-nav-group .mud-collapse-container {
  margin-left: 28px;                       /* line indented (sits under the parent label) */
  border-left: 1px solid #CBD3DD;          /* darker guide line */
}
.ht-nav .mud-nav-group .mud-collapse-container .mud-nav-link {
  margin-left: 0;                          /* meet the guide line */
  padding-left: 6px;                       /* text hugs the line (small gap) */
  border-radius: 0 8px 8px 0;
}
.ht-nav .mud-nav-group .mud-collapse-container .mud-nav-link.active {
  box-shadow: inset 2px 0 0 0 var(--ht-accent);     /* active segment turns the line accent */
}
.ht-nav .mud-nav-group .mud-collapse-container .mud-nav-link.active::before { display: none; }

/* Base font everywhere (fixes the body=Helvetica vs Mud=Roboto mismatch). */
html, body, .mud-typography, .mud-input, .mud-input-control,
button, input, select, textarea, .mud-button-root {
  font-family: var(--ht-font);
}

body {
  color: var(--ht-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings: semibold (600), not 700 bold; a touch more air. */
.mud-typography-h1 { font-weight: 600; letter-spacing: -0.02em; }
.mud-typography-h2 { font-weight: 600; letter-spacing: -0.02em; }
.mud-typography-h3 { font-weight: 600; letter-spacing: -0.01em; }
.mud-typography-h4 { font-weight: 600; letter-spacing: -0.01em; }
.mud-typography-h5 { font-weight: 600; }
.mud-typography-h6 { font-weight: 600; }

/* Body copy: comfortable line-height, soft colour. */
.mud-typography-body1, .mud-typography-body2 { color: var(--ht-ink); line-height: 1.55; }
.mud-typography-subtitle1, .mud-typography-subtitle2 { color: var(--ht-ink); }
.mud-typography-caption { color: var(--ht-muted); }

/* MudText Color="Secondary" maps to the brand cyan, but it's almost always used
   for muted *labels/hints* (field labels, "No comments yet", etc.). Grey it so
   blue is reserved for actions/links. Chips/buttons use other classes, untouched. */
.mud-secondary-text, .mud-text-secondary { color: var(--ht-muted) !important; }

/* Tables: lighter header weight, softer text — less "database" feel. */
.mud-table-root { color: var(--ht-ink); }
.mud-table-head .mud-table-cell { font-weight: 600; color: var(--ht-muted); }

/* Buttons: medium weight reads calmer than bold. */
.mud-button-root { font-weight: 500; letter-spacing: 0; text-transform: none; }

/* SectionCard "Subtle" header — force surface bg + hairline so it themes in dark too
   (overrides the inline #fff some pages, incl. custom-header pages, hard-coded). */
.ht-section-head-subtle {
  background: var(--ht-surface) !important;
  border-bottom-color: var(--ht-line) !important;
}
/* Neutralise action buttons callers styled white (they sat on a coloured bar before). */
.ht-section-head-subtle .mud-icon-button .mud-icon-root { color: var(--ht-muted) !important; }
.ht-section-head-subtle .mud-button-root,
.ht-section-head-subtle .mud-button-root .mud-button-label { color: var(--ht-muted) !important; }

/* Safety net: callers across modules styled header text/badges WHITE (on a colour bar).
   Now the header is light/dark surface, so neutralise white inline text and retint the
   translucent-white count badges. !important overrides inline styles — no per-page edits. */
.ht-section-head-subtle [style*="color:white"],
.ht-section-head-subtle [style*="color: white"],
.ht-section-head-subtle [style*="rgba(255,255,255"] { color: var(--ht-btn-ink) !important; }
.ht-section-head-subtle [style*="background:rgba(255,255,255"],
.ht-section-head-subtle [style*="background: rgba(255,255,255"] {
  background: var(--ht-chip-bg) !important; color: var(--ht-muted) !important;
}
/* In dark, force ALL subtle-header text (incl. the SectionCard title span, which is
   inline-coloured ink) to the light ink token; the module-colour icon stays. */
:root[data-theme="dark"] .ht-section-head-subtle span,
:root[data-theme="dark"] .ht-section-head-subtle .mud-typography { color: var(--ht-ink) !important; }

/* ── Theme toggle button (top bar) ─────────────────────────────────────── */
.ht-theme-toggle {
  width: 38px; height: 38px; border-radius: 9px;
  border: 1px solid var(--ht-line); background: transparent;
  color: var(--ht-muted); font-size: 1rem; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: 8px; transition: background .12s, color .12s;
}
.ht-theme-toggle:hover { background: rgba(127,140,160,0.12); color: var(--ht-ink); }

/* ── Dark-mode polish for surfaces MudBlazor paints from its palette ────── */
:root[data-theme="dark"] .mud-paper { box-shadow: 0 1px 2px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.30); }
:root[data-theme="dark"] .ht-appbar .ht-user-email { color: var(--ht-muted); }
/* Inset surfaces (date/number fields, tiles) read slightly lighter than cards. */
:root[data-theme="dark"] .mud-input-outlined .mud-input-slot { background: transparent; }
/* Menus / dialogs / popovers on dark surface. */
:root[data-theme="dark"] .mud-popover, :root[data-theme="dark"] .mud-list { background: var(--ht-surface); }

/* ── DARK inline safety net ─────────────────────────────────────────────
   Many pages hard-code light inline backgrounds (#FAFAFA, #fff, #F5F7FA…) for
   inset boxes/tiles. Under dark, remap those to dark surfaces so the whole app
   themes without editing every page. Attribute selectors + !important beat the
   inline style. Semantic tint boxes (amber/info) map to dark tints. */
:root[data-theme="dark"] [style*="background:#FAFAFA"],
:root[data-theme="dark"] [style*="background: #FAFAFA"],
:root[data-theme="dark"] [style*="background:#fff"],
:root[data-theme="dark"] [style*="background: #fff"],
:root[data-theme="dark"] [style*="background:#FFF"],
:root[data-theme="dark"] [style*="background:#F5F7FA"],
:root[data-theme="dark"] [style*="background: #F5F7FA"],
:root[data-theme="dark"] [style*="background:#F5F5F5"],
:root[data-theme="dark"] [style*="background:#F0F0F0"],
:root[data-theme="dark"] [style*="background:#FAFBFC"],
:root[data-theme="dark"] [style*="background:#EEEEEE"] {
  background-color: var(--ht-surface-2) !important;
}
/* Semantic tint boxes → dark tints (keep the hue, drop the glare). */
:root[data-theme="dark"] [style*="background:#FFF8E1"],
:root[data-theme="dark"] [style*="background:#FFFDE7"] { background-color: #2c281d !important; }
:root[data-theme="dark"] [style*="background:#E3F2FD"] { background-color: #1b2a3a !important; }
/* Light inline borders → hairline token. */
:root[data-theme="dark"] [style*="border:1px solid #E0E0E0"],
:root[data-theme="dark"] [style*="border:1px solid #EEE"],
:root[data-theme="dark"] [style*="border:1px solid #F0F0F0"],
:root[data-theme="dark"] [style*="border-top:1px solid #F0F0F0"],
:root[data-theme="dark"] [style*="border:1px solid #E0E5EA"] { border-color: var(--ht-line) !important; }

/* ── DARK fixes for components with hardcoded light/dark values ─────────── */

/* Sidebar: NavMenu's own <style> hardcodes dark link/title colours (#37474F /
   #263238) — invisible on the dark drawer. Force themed colours in dark. */
:root[data-theme="dark"] .ht-nav .mud-nav-link,
:root[data-theme="dark"] .ht-nav .mud-nav-group > .mud-nav-link { color: var(--ht-ink) !important; }
:root[data-theme="dark"] .ht-nav .mud-nav-link .mud-nav-link-icon,
:root[data-theme="dark"] .ht-nav .mud-nav-link .mud-icon-root { color: var(--ht-muted) !important; }
:root[data-theme="dark"] .ht-nav .mud-nav-link.active,
:root[data-theme="dark"] .ht-nav .mud-nav-link.mud-active { color: var(--ht-accent) !important; }
:root[data-theme="dark"] .ht-nav .mud-nav-link.active .mud-icon-root,
:root[data-theme="dark"] .ht-nav .mud-nav-link.mud-active .mud-icon-root { color: var(--ht-accent) !important; }
:root[data-theme="dark"] .ht-nav .mud-nav-link:hover { background: rgba(255,255,255,0.06) !important; }

/* Inputs: ensure the typed/selected value text is the light ink in dark. */
:root[data-theme="dark"] .mud-input-root,
:root[data-theme="dark"] .mud-input-slot,
:root[data-theme="dark"] .mud-input-slot input,
:root[data-theme="dark"] .mud-input-slot textarea,
:root[data-theme="dark"] .mud-select .mud-select-input { color: var(--ht-ink) !important; }
:root[data-theme="dark"] .mud-input-slot input::placeholder,
:root[data-theme="dark"] .mud-input-slot textarea::placeholder { color: var(--ht-faint) !important; }

/* Light count badges / chips set with #EEF1F5 inline (task badges) → dark chip. */
:root[data-theme="dark"] [style*="background:#EEF1F5"],
:root[data-theme="dark"] [style*="background: #EEF1F5"],
:root[data-theme="dark"] [style*="background:#E4ECFB"],
:root[data-theme="dark"] [style*="background:#EAF0FF"] { background-color: var(--ht-chip-bg) !important; }

/* ── Logo swap: light wordmark in light theme, dark-theme wordmark in dark.
   Hide-only (no display value forced on the visible one, so its layout holds). */
:root:not([data-theme="dark"]) img.logo-dark { display: none; }
:root[data-theme="dark"] img.logo-light { display: none; }

/* Broaden dark inline safety net: also catch background-color / #FFFFFF / white
   and spaced variants (covers Home widgets and similar). */
:root[data-theme="dark"] [style*="background-color:#fff"],
:root[data-theme="dark"] [style*="background-color: #fff"],
:root[data-theme="dark"] [style*="background:#FFFFFF"],
:root[data-theme="dark"] [style*="background: #FFFFFF"],
:root[data-theme="dark"] [style*="background-color:#FFFFFF"],
:root[data-theme="dark"] [style*="background:white"],
:root[data-theme="dark"] [style*="background: white"],
:root[data-theme="dark"] [style*="background-color:#FAFAFA"],
:root[data-theme="dark"] [style*="background-color:#F5F7FA"],
:root[data-theme="dark"] [style*="background-color:#F5F5F5"] {
  background-color: var(--ht-surface-2) !important;
}

/* DARK: hardcoded dark TEXT colours (tiles/widgets/labels) → themed ink/muted so
   they're readable on dark surfaces. Covers Home shortcut tiles (color:#212121),
   KPI labels, empty-state text, etc. across the app. */
:root[data-theme="dark"] [style*="color:#212121"],
:root[data-theme="dark"] [style*="color: #212121"],
:root[data-theme="dark"] [style*="color:#424242"],
:root[data-theme="dark"] [style*="color:#263238"],
:root[data-theme="dark"] [style*="color:#37474F"],
:root[data-theme="dark"] [style*="color:#1F2733"],
:root[data-theme="dark"] [style*="color:#1f2733"] { color: var(--ht-ink) !important; }
:root[data-theme="dark"] [style*="color:#616161"],
:root[data-theme="dark"] [style*="color: #616161"],
:root[data-theme="dark"] [style*="color:#757575"],
:root[data-theme="dark"] [style*="color:#9E9E9E"],
:root[data-theme="dark"] [style*="color:#6D4C41"],
:root[data-theme="dark"] [style*="color:#90A4AE"] { color: var(--ht-muted) !important; }

/* DARK: MudTable header cells + input/select labels were too dim (Mud's own colours
   win over the light rule). Force readable themed colours. */
:root[data-theme="dark"] .mud-table-head .mud-table-cell,
:root[data-theme="dark"] .mud-table-head th { color: var(--ht-ink) !important; }

/* Uniform form-label colour. MudBlazor renders some labels (e.g. required fields)
   a different/darker tone than others; force a single muted tone so every field
   label matches — in BOTH light and dark (the var is theme-aware). */
.mud-input-label,
label.mud-input-label { color: var(--ht-muted) !important; }

/* DARK: input adornment icons (select dropdown arrow, date-picker calendar, clear X)
   were dark-on-dark — make them muted/visible. */
:root[data-theme="dark"] .mud-input-adornment .mud-icon-root,
:root[data-theme="dark"] .mud-select .mud-input-adornment-end .mud-icon-root,
:root[data-theme="dark"] .mud-input .mud-input-adornment-end .mud-icon-root { color: var(--ht-muted) !important; }

/* =========================================================================
   DARK — comprehensive inline-colour coverage (case-insensitive [... i]).
   Catches the remaining hardcoded colours found across all screens so the
   whole app themes without per-page edits.
   ========================================================================= */

/* Neutral light backgrounds → dark inset surface. */
:root[data-theme="dark"] [style*="background:#eceff1" i],
:root[data-theme="dark"] [style*="background-color:#eceff1" i],
:root[data-theme="dark"] [style*="background:#f9f9f9" i],
:root[data-theme="dark"] [style*="background-color:#f9f9f9" i],
:root[data-theme="dark"] [style*="background:#f8f9fa" i],
:root[data-theme="dark"] [style*="background-color:#f8f9fa" i],
:root[data-theme="dark"] [style*="background:#f7f8fb" i],
:root[data-theme="dark"] [style*="background:#f7f7f7" i],
:root[data-theme="dark"] [style*="background:#f5f5f7" i],
:root[data-theme="dark"] [style*="background:#f5f9ff" i],
:root[data-theme="dark"] [style*="background:#cfd8dc" i],
:root[data-theme="dark"] [style*="background-color:#cfd8dc" i] {
  background-color: var(--ht-surface-2) !important;
}

/* Semantic tint boxes → dark tints (keep the hue, drop the glare). */
:root[data-theme="dark"] [style*="background:#e8f5e9" i],
:root[data-theme="dark"] [style*="background-color:#e8f5e9" i],
:root[data-theme="dark"] [style*="background:#e0f2f1" i] { background-color: #1e2c24 !important; }
:root[data-theme="dark"] [style*="background:#fff3e0" i],
:root[data-theme="dark"] [style*="background-color:#fff3e0" i] { background-color: #2c2419 !important; }
:root[data-theme="dark"] [style*="background:#ffcdd2" i],
:root[data-theme="dark"] [style*="background-color:#ffcdd2" i] { background-color: #321f22 !important; }

/* Dark SEMANTIC text colours → lighter, readable variants on dark surfaces.
   (Solid coloured backgrounds keep their hue — these target `color:` only.) */
:root[data-theme="dark"] [style*="color:#1b5e20" i],
:root[data-theme="dark"] [style*="color:#2e7d32" i],
:root[data-theme="dark"] [style*="color:#388e3c" i] { color: #66bb6a !important; }
:root[data-theme="dark"] [style*="color:#c62828" i],
:root[data-theme="dark"] [style*="color:#b71c1c" i],
:root[data-theme="dark"] [style*="color:#d32f2f" i] { color: #ef5350 !important; }
:root[data-theme="dark"] [style*="color:#e65100" i],
:root[data-theme="dark"] [style*="color:#bf360c" i],
:root[data-theme="dark"] [style*="color:#ef6c00" i] { color: #ffa040 !important; }
:root[data-theme="dark"] [style*="color:#00695c" i],
:root[data-theme="dark"] [style*="color:#00897b" i] { color: #4db6ac !important; }
:root[data-theme="dark"] [style*="color:#6a1b9a" i],
:root[data-theme="dark"] [style*="color:#4a148c" i] { color: #ba68c8 !important; }
:root[data-theme="dark"] [style*="color:#1565c0" i],
:root[data-theme="dark"] [style*="color:#1976d2" i],
:root[data-theme="dark"] [style*="color:#0277bd" i],
:root[data-theme="dark"] [style*="color:#1e6be0" i] { color: #6a9bff !important; }

/* =========================================================================
   DARK — overrides for shared components that use page-scoped <style> classes
   (the inline safety-net can't reach class rules). Centralised here so we don't
   touch each component or its print styles. :root[data-theme=dark] .x + !important
   beats the component's own <style>.
   ========================================================================= */

/* KPI tiles (dashboards). */
:root[data-theme="dark"] .ht-kpi-tile { background: var(--ht-surface) !important; }
:root[data-theme="dark"] .ht-kpi-label { color: var(--ht-muted) !important; }

/* Email-notification groups (Settings). */
:root[data-theme="dark"] .ht-email-group { background: var(--ht-surface) !important; border-color: var(--ht-line) !important; }
:root[data-theme="dark"] .ht-email-group[open] { border-color: var(--ht-line) !important; }
:root[data-theme="dark"] .ht-email-group-header { background: var(--ht-surface-2) !important; color: var(--ht-muted) !important; }
:root[data-theme="dark"] .ht-email-group-header:hover { background: var(--ht-surface-2) !important; }
:root[data-theme="dark"] .ht-email-group[open] .ht-email-group-header { border-bottom-color: var(--ht-line) !important; }
:root[data-theme="dark"] .ht-email-group-header .mud-icon-root { color: var(--ht-muted) !important; }

/* Linked-items panels (task/asset detail). */
:root[data-theme="dark"] .ht-linked-panel { background: var(--ht-surface) !important; border-color: var(--ht-line) !important; }
:root[data-theme="dark"] .ht-linked-panel--empty,
:root[data-theme="dark"] .ht-linked-panel-header,
:root[data-theme="dark"] .ht-linked-panel-table thead,
:root[data-theme="dark"] .ht-linked-panel-row--clickable { background: var(--ht-surface-2) !important; }
:root[data-theme="dark"] .ht-linked-panel-title { color: var(--ht-ink) !important; }
:root[data-theme="dark"] .ht-linked-panel-table { color: var(--ht-muted) !important; }
:root[data-theme="dark"] .ht-linked-panel-badge { background: rgba(255,255,255,0.10) !important; color: var(--ht-ink) !important; }
:root[data-theme="dark"] .ht-linked-panel-empty { color: var(--ht-muted) !important; }

/* Workflow diagram (help pages). */
:root[data-theme="dark"] .ht-workflow-step { background: var(--ht-surface) !important; }
:root[data-theme="dark"] .ht-workflow-step-optional,
:root[data-theme="dark"] .ht-workflow-optional-tag { background: var(--ht-surface-2) !important; }
:root[data-theme="dark"] .ht-workflow-desc { color: var(--ht-muted) !important; }
:root[data-theme="dark"] .ht-workflow-arrow { color: var(--ht-faint) !important; }

/* Feedback widget thumbnails (FAB itself stays brand blue). */
:root[data-theme="dark"] .ht-feedback-thumb { background: var(--ht-surface-2) !important; border-color: var(--ht-line) !important; }

/* =========================================================================
   DARK — pure-CSS fallback for MudBlazor built-in colours (works even before
   IsDarkMode applies / right after toggling on the same page).
   ========================================================================= */
:root[data-theme="dark"] {
  --mud-palette-action-default: rgba(255,255,255,0.70);
  --mud-palette-action-default-hover: rgba(255,255,255,0.08);
  --mud-palette-action-disabled: rgba(255,255,255,0.30);
  --mud-palette-action-disabled-background: rgba(255,255,255,0.08);
  --mud-palette-table-lines: var(--ht-line);
  --mud-palette-table-striped: rgba(255,255,255,0.03);
  --mud-palette-table-hover: rgba(255,255,255,0.05);
}
/* Table body text → light ink (was near-black light-palette value). Chips/links
   inside cells set their own colour, so they're unaffected. */
:root[data-theme="dark"] .mud-table-cell { color: var(--ht-ink); }
:root[data-theme="dark"] .mud-table-cell .mud-typography { color: inherit; }
/* Default-colour icons (empty-state clock/search/check, sort arrows) → muted. */
:root[data-theme="dark"] .mud-icon-root.mud-default-text,
:root[data-theme="dark"] .mud-table .mud-icon-root.mud-default-text { color: var(--ht-muted) !important; }
/* Pagination caption / arrows. */
:root[data-theme="dark"] .mud-table-pagination,
:root[data-theme="dark"] .mud-table-pagination .mud-icon-button .mud-icon-root { color: var(--ht-muted) !important; }

/* DARK: default-colour TEXT buttons (e.g. "Link", "Cancel") were dark-on-dark. */
:root[data-theme="dark"] .mud-button-text-default,
:root[data-theme="dark"] .mud-button-text-default .mud-button-label,
:root[data-theme="dark"] .mud-button-text-default .mud-icon-root { color: var(--ht-muted) !important; }

/* DARK (screen only) — Statement of Applicability renders as a white print-doc.
   Theme the on-screen view; @media print keeps it white for export. */
@media screen {
  :root[data-theme="dark"] .ht-soa { background: var(--ht-surface) !important; color: var(--ht-ink) !important; }
  :root[data-theme="dark"] .ht-soa-subtitle,
  :root[data-theme="dark"] .ht-soa-stat-label,
  :root[data-theme="dark"] .ht-soa-impl-note,
  :root[data-theme="dark"] .ht-soa-footer { color: var(--ht-muted) !important; }
  :root[data-theme="dark"] .ht-soa-header { border-bottom-color: var(--ht-line) !important; }
  :root[data-theme="dark"] .ht-soa-summary { background: var(--ht-surface-2) !important; }
  :root[data-theme="dark"] .ht-soa-scope { background: #2c281d !important; }
  :root[data-theme="dark"] .ht-soa-section { color: var(--ht-ink) !important; border-bottom-color: var(--ht-line) !important; }
  :root[data-theme="dark"] .ht-soa-table th { background: var(--ht-surface-2) !important; border-color: var(--ht-line) !important; color: var(--ht-ink) !important; }
  :root[data-theme="dark"] .ht-soa-table td { border-color: var(--ht-line) !important; }
  :root[data-theme="dark"] .ht-soa-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.03) !important; }
  :root[data-theme="dark"] .ht-soa-evidence { color: var(--ht-accent) !important; }
}

/* DARK — Help guide pages (shared .ht-help-* classes hardcode dark text). */
:root[data-theme="dark"] .ht-help-h4 { color: var(--ht-muted) !important; }
:root[data-theme="dark"] .ht-help-ol,
:root[data-theme="dark"] .ht-help-ul,
:root[data-theme="dark"] .ht-help-ol li,
:root[data-theme="dark"] .ht-help-ul li { color: var(--ht-ink) !important; }

/* DARK — category-list item dividers (#F5F5F5 inline borders): a darker groove so
   the rows separate clearly on the dark surface. */
:root[data-theme="dark"] [style*="border-bottom:1px solid #F5F5F5" i],
:root[data-theme="dark"] [style*="border-bottom: 1px solid #F5F5F5" i] { border-bottom-color: #373C44 !important; }

/* DARK — field-row dividers (#EEF1F5 / #F5F7FA inline borders) + email-row class:
   darker groove for clear separation on dark cards (same as category list). */
:root[data-theme="dark"] [style*="border-bottom:1px solid #EEF1F5" i],
:root[data-theme="dark"] [style*="border-bottom: 1px solid #EEF1F5" i],
:root[data-theme="dark"] [style*="border-bottom:1px solid #F5F7FA" i] { border-bottom-color: #373C44 !important; }
:root[data-theme="dark"] .ht-email-row { border-bottom-color: #373C44 !important; }

/* DARK — Account/Login (and sibling auth pages sharing .ht-login-*/.ht-field-*).
   The slate hero + dark Sign-in button look fine in both themes; theme the page
   background, card, fields and labels. */
html[data-theme="dark"] .ht-login-shell,
:root[data-theme="dark"] .ht-login-shell,
[data-theme="dark"] .ht-login-shell {
  background: #15181c !important;
  background-image: linear-gradient(135deg, #20242a 0%, #15181c 100%) !important;
}
:root[data-theme="dark"] .ht-login-card { background: var(--ht-surface) !important; box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.4) !important; }
:root[data-theme="dark"] .ht-field-label { color: var(--ht-muted) !important; }
:root[data-theme="dark"] .ht-field-input { background: var(--ht-surface-2) !important; border-color: var(--ht-line) !important; color: var(--ht-ink) !important; }
:root[data-theme="dark"] .ht-field-input::placeholder { color: var(--ht-faint) !important; }
:root[data-theme="dark"] .ht-field-error { color: #ef5350 !important; }

/* ─────────────────────────────────────────────────────────────────────────
   Account management (Identity /Account/Manage/*) — Calm theme.
   These pages are static-rendered Identity scaffolds; we style them with the
   app tokens so they match the rest of the product in both light + dark.
   ───────────────────────────────────────────────────────────────────────── */
.ht-account { max-width: 920px; margin: 0 auto; padding: 4px 0 32px; }
.ht-account-head { margin-bottom: 20px; }
.ht-account-head h1 { font-size: 1.5rem; font-weight: 700; color: var(--ht-ink); margin: 0; letter-spacing: .2px; }
.ht-account-head p { font-size: .9rem; color: var(--ht-muted); margin: 4px 0 0; }

.ht-account-grid { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
@media (max-width: 720px) { .ht-account-grid { grid-template-columns: 1fr; } }

/* Left nav */
.ht-account-menu { display: flex; flex-direction: column; gap: 2px; background: var(--ht-surface); border: 1px solid var(--ht-line); border-radius: 12px; padding: 8px; }
@media (max-width: 720px) { .ht-account-menu { flex-direction: row; flex-wrap: wrap; } }
.ht-account-menu-link { display: block; padding: 9px 12px; border-radius: 8px; font-size: .88rem; font-weight: 500; color: var(--ht-muted); text-decoration: none; transition: background .12s, color .12s; }
.ht-account-menu-link:hover { background: var(--ht-surface-2); color: var(--ht-ink); }
.ht-account-menu-link.active { background: var(--ht-accent); color: #fff; }

/* Content card */
.ht-account-body .ht-card { background: var(--ht-surface); border: 1px solid var(--ht-line); border-radius: 12px; overflow: hidden; }
.ht-account-body .ht-card-head { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--ht-line); font-size: 1rem; font-weight: 600; color: var(--ht-ink); }
.ht-account-body .ht-card-body { padding: 20px; }
.ht-account-body .ht-card-body p { font-size: .9rem; line-height: 1.55; color: var(--ht-muted); margin: 0 0 14px; }

/* Callouts */
.ht-callout { border-radius: 10px; padding: 12px 14px; font-size: .86rem; line-height: 1.5; margin: 0 0 18px; border: 1px solid var(--ht-line); }
.ht-callout-danger { background: rgba(211,47,47,.06); border-color: rgba(211,47,47,.35); color: #b3261e; }
:root[data-theme="dark"] .ht-callout-danger { background: rgba(239,83,80,.10); border-color: rgba(239,83,80,.40); color: #ef9a9a; }

/* Action buttons (work for <button> and <a>) */
.ht-account-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ht-account-actions form { margin: 0; }
.ht-btn { display: inline-block; padding: 9px 18px; border-radius: 8px; font-size: .88rem; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid transparent; line-height: 1.2; transition: filter .12s, background .12s; }
.ht-btn-primary { background: var(--ht-accent); color: #fff; }
.ht-btn-primary:hover { filter: brightness(1.06); }
.ht-btn-danger { background: #d32f2f; color: #fff; }
.ht-btn-danger:hover { filter: brightness(1.06); }
.ht-btn-ghost { background: transparent; border-color: var(--ht-line); color: var(--ht-ink); }
.ht-btn-ghost:hover { background: var(--ht-surface-2); }
.ht-btn:disabled, .ht-btn[disabled] { opacity: .5; cursor: not-allowed; filter: none; }

/* Account form fields */
.ht-form-step { margin: 16px 0; }
.ht-form-label { display: block; font-size: .84rem; font-weight: 600; color: var(--ht-ink); margin-bottom: 6px; }
.ht-input { width: 100%; padding: 9px 12px; border: 1px solid var(--ht-line); border-radius: 8px; background: var(--ht-surface); color: var(--ht-ink); font-size: .9rem; box-sizing: border-box; }
.ht-input:focus { outline: none; border-color: var(--ht-accent); box-shadow: 0 0 0 3px rgba(59,110,245,.12); }
.ht-check { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--ht-ink); line-height: 1.5; cursor: pointer; }
.ht-check input { margin-top: 3px; flex: 0 0 auto; }
.ht-form-error { color: #b3261e; font-size: .8rem; margin-top: 4px; }
:root[data-theme="dark"] .ht-form-error { color: #ef9a9a; }

/* ─────────────────────────────────────────────────────────────────────────
   Task lists on mobile — render each MudTable row as a clean card
   (My Summit tasks / All Summit tasks; tables tagged .ht-task-cards).
   Desktop keeps the normal dense table; this only kicks in on phones.
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ht-task-cards .mud-table-root > tbody > tr {
    display: block;
    background: var(--ht-surface) !important;
    border: 1px solid var(--ht-line);
    border-radius: 12px;
    margin: 10px 8px;
    padding: 8px 14px 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
  }
  .ht-task-cards .mud-table-root > tbody > tr > td {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0 !important;
    border: none !important;
    height: auto !important;
    text-align: right;
  }
  .ht-task-cards .mud-table-root > tbody > tr > td[data-label]::before {
    content: attr(data-label);
    color: var(--ht-muted);
    font-weight: 600;
    font-size: .76rem;
    text-transform: none;
    white-space: nowrap;
  }
  /* Title gets prominence: full-width heading, no inline label colour clash. */
  .ht-task-cards td[data-label="Title"] { font-weight: 600; font-size: .95rem; }
  .ht-task-cards td[data-label="Title"] a { color: var(--ht-ink) !important; }
  /* Decorative / action cells (type icon, hierarchy) carry no label — drop the
     empty pseudo-label and let them sit quietly to the right. */
  .ht-task-cards .mud-table-root > tbody > tr > td:not([data-label]) { justify-content: flex-end; }
  .ht-task-cards .mud-table-root > tbody > tr > td:not([data-label])::before { content: none !important; }
}

/* ─────────────────────────────────────────────────────────────────────────
   Side drawer — collapse to hidden (data-nav="mini"), desktop only.
   Pure-CSS collapse driven by window.htDrawer + the ht-nav cookie; the static
   layout never has to manage drawer state. On phones (<960px) the drawer is an
   overlay (MudDrawer Responsive) so we leave it alone.
   NOTE: targets MudBlazor 7.x drawer classes — verify in DevTools.
   ───────────────────────────────────────────────────────────────────────── */
.ht-drawer-toggle { background: none; border: none; cursor: pointer; font-size: 1.2rem; line-height: 1; color: var(--ht-ink); padding: 6px 10px; margin-right: 4px; border-radius: 8px; }
.ht-drawer-toggle:hover { background: var(--ht-surface-2); }

@media (min-width: 960px) {
  /* Collapsed = drawer fully hidden, content reclaims the full width.
     The ☰ button (htDrawer.toggle) brings it back. */
  :root[data-nav="mini"] { --mud-drawer-width: 0px !important; --mud-drawer-width-left: 0px !important; }
  :root[data-nav="mini"] .mud-drawer-pos-left {
      width: 0 !important;
      min-width: 0 !important;
      border: none !important;
      overflow: hidden !important;
      transition: width .15s ease;
  }
}

/* ── Rendered markdown (task descriptions, comments) ─────────────────── */
.ht-md { font-size: 0.875rem; line-height: 1.5; color: var(--ht-ink, #1F2733); word-break: break-word; }
.ht-md > *:first-child { margin-top: 0; }
.ht-md > *:last-child  { margin-bottom: 0; }
.ht-md p { margin: 0 0 0.6em; }
.ht-md h1, .ht-md h2, .ht-md h3, .ht-md h4 { margin: 0.8em 0 0.4em; line-height: 1.25; font-weight: 600; }
.ht-md h1 { font-size: 1.25rem; } .ht-md h2 { font-size: 1.12rem; } .ht-md h3 { font-size: 1rem; }
.ht-md ul, .ht-md ol { margin: 0 0 0.6em; padding-left: 1.4em; }
.ht-md li { margin: 0.15em 0; }
.ht-md a { color: var(--ht-accent, #3B6EF5); text-decoration: none; }
.ht-md a:hover { text-decoration: underline; }
.ht-md code { background: var(--ht-surface-2, #EEF1F5); border: 1px solid var(--ht-line, #E7EBF0);
  border-radius: 4px; padding: 0.05em 0.35em; font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ht-md pre { background: var(--ht-surface-2, #EEF1F5); border: 1px solid var(--ht-line, #E7EBF0);
  border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 0 0 0.6em; }
.ht-md pre code { background: none; border: 0; padding: 0; font-size: 0.82rem; line-height: 1.45; }
.ht-md blockquote { margin: 0 0 0.6em; padding: 0.2em 0.9em; border-left: 3px solid var(--ht-line, #E7EBF0);
  color: var(--ht-muted, #6B7785); }
.ht-md table { border-collapse: collapse; margin: 0 0 0.6em; font-size: 0.84rem; }
.ht-md th, .ht-md td { border: 1px solid var(--ht-line, #E7EBF0); padding: 4px 8px; text-align: left; }
.ht-md th { background: var(--ht-surface-2, #EEF1F5); font-weight: 600; }
.ht-md img { max-width: 100%; border-radius: 6px; }
.ht-md hr { border: 0; border-top: 1px solid var(--ht-line, #E7EBF0); margin: 0.8em 0; }
