/* ------------------------------------------------------------------ Colour themes (18 November 2026)
   Holly Crowe does not like the black bar; Zak the same day: the whole look, background
   included, picked per person under Profile, today's look kept as Classic (no attribute).
   base.html sets body[data-flow-theme] from users.theme (app/core/themes.py). Each theme
   below only sets tokens; the shared block after them draws the bar, the page, the cards
   and the Home buttons from those tokens. Status colours (overdue, new, signed) are not
   touched, so red means the same thing on every screen. Text on orange sits on #bf550a
   or darker (4.6:1 with white) and links #b8520a (4.9:1 on white), not the lighter orange
   of the mock-ups. --panel stays opaque (sticky columns such as
   the training matrix sit on it); only Home's cards take --th-card, the glassy look. */
body[data-flow-theme="mist"] {
  --ground: #eef3f0;
  --ground-warm: #f3f6f4;
  --panel: #ffffff;
  --th-card: rgba(255, 255, 255, 0.92);
  --line: #dfe7e3;
  --line-strong: #cbd8d2;
  --ink: #1d4639;
  --ink-soft: #4f625b;
  --brand-700: #2c5a4b;
  --brand-100: #e9f0ec;
  --radius: 14px;
  --radius-lg: 16px;
  --shadow-sm: 0 6px 18px rgba(29, 70, 57, 0.06);
  --shadow: 0 10px 26px rgba(29, 70, 57, 0.09);
  --th-hdr: rgba(255, 255, 255, 0.78);
  --th-hdr-line: #dfe7e3;
  --th-hdr-mark: none;
  --th-brand: #1d4639;
  --th-arrows: #c25e0c;
  --th-nav: #1d4639;
  --th-nav-line: #9fb5ac;
  --th-nav-hover-bg: rgba(29, 70, 57, 0.06);
  --th-sw-ink: #1d4639;
  --th-sw-line: #dfe7e3;
  --th-sw-bg: #ffffff;
  --th-pill: linear-gradient(#fde3c8, #fbcf9f);
  --th-pill-ink: #8a3e06;
  --th-pill-line: #f2b27a;
  --th-ctx: rgba(255, 255, 255, 0.85);
  --th-accent: #e2711c;
  --th-deco:
    radial-gradient(70% 50% at 0% 0%, rgba(255, 255, 255, 0.9), transparent 60%),
    radial-gradient(60% 45% at 100% 100%, rgba(186, 212, 200, 0.55), transparent 65%),
    radial-gradient(40% 30% at 92% 96%, rgba(255, 255, 255, 0.7), transparent 70%);
  --th-test-bg: rgba(251, 236, 222, 0.85);
  --th-test-line: #f1dcc8;
  --th-eyebrow: #2f5a4c;
  --th-link: #b8520a;
  --th-icon-bg: #e9f0ec;
  --th-icon: #2c5a4b;
  --th-hz-bg: linear-gradient(#feead6, #fcd9b4);
  --th-hz-ink: #8a3e06;
  --th-hz-line: #f2b27a;
  --th-inc-bg: #e4ece8;
  --th-primary: #1d4639;
}

body[data-flow-theme="slate"] {
  --ground: #f3f0ec;
  --ground-warm: #f6f4f0;
  --panel: #ffffff;
  --line: #e5e0d8;
  --line-strong: #d3ccc1;
  --ink: #26393b;
  --ink-soft: #56625f;
  --brand-700: #3f5c5f;
  --brand-100: #eef0ee;
  --radius: 14px;
  --radius-lg: 16px;
  --shadow-sm: 0 6px 18px rgba(38, 57, 59, 0.06);
  --shadow: 0 10px 26px rgba(38, 57, 59, 0.09);
  --th-hdr: #3f5c5f;
  --th-hdr-line: #3f5c5f;
  --th-hdr-mark: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.12) 0 12px, transparent 12px 26px);
  --th-brand: #ffffff;
  --th-arrows: #f59a3c;
  --th-nav: #eef3f3;
  --th-nav-line: rgba(255, 255, 255, 0.5);
  --th-nav-hover-bg: rgba(255, 255, 255, 0.1);
  --th-sw-ink: #ffffff;
  --th-sw-line: rgba(255, 255, 255, 0.45);
  --th-sw-bg: transparent;
  --th-pill: #f8b26a;
  --th-pill-ink: #2b2a26;
  --th-pill-line: #f8b26a;
  --th-ctx: rgba(255, 255, 255, 0.92);
  --th-accent: #e2711c;
  --th-deco: linear-gradient(115deg, transparent 88%, rgba(63, 92, 95, 0.07) 88% 90%, transparent 90% 93%, rgba(63, 92, 95, 0.06) 93% 95%, transparent 95%);
  --th-test-bg: #faefe4;
  --th-test-line: #efdfcf;
  --th-eyebrow: #3f5c5f;
  --th-link: #b8520a;
  --th-icon-bg: #efece7;
  --th-icon: #3f5c5f;
  --th-hz-bg: #fde8d3;
  --th-hz-ink: #8a3e06;
  --th-hz-line: #f2b27a;
  --th-inc-bg: #e8e6e2;
  --th-primary: #3f5c5f;
}

body[data-flow-theme="eucalypt"] {
  --ground: #f6f3ec;
  --ground-warm: #f8f6f0;
  --panel: #ffffff;
  --line: #dcd8cc;
  --line-strong: #cbc6b7;
  --ink: #173d2e;
  --ink-soft: #4f5f55;
  --brand-700: #2f5a46;
  --brand-100: #edf0e8;
  --radius: 12px;
  --radius-lg: 14px;
  --shadow-sm: 0 5px 16px rgba(23, 61, 46, 0.06);
  --shadow: 0 8px 22px rgba(23, 61, 46, 0.08);
  --th-hdr: linear-gradient(90deg, #4b6b50, #56744f);
  --th-hdr-line: #4b6b50;
  --th-hdr-mark: radial-gradient(120px 90px at -10px 110%, transparent 70%, rgba(255, 255, 255, 0.18) 71% 72%, transparent 73%);
  --th-brand: #ffffff;
  --th-arrows: #f59a3c;
  --th-nav: #eef3ec;
  --th-nav-line: rgba(255, 255, 255, 0.5);
  --th-nav-hover-bg: rgba(255, 255, 255, 0.1);
  --th-sw-ink: #ffffff;
  --th-sw-line: rgba(255, 255, 255, 0.4);
  --th-sw-bg: rgba(0, 0, 0, 0.12);
  --th-pill: #f8b26a;
  --th-pill-ink: #2b2a26;
  --th-pill-line: #f8b26a;
  --th-ctx: rgba(255, 255, 255, 0.9);
  --th-accent: #e2711c;
  --th-deco:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 200'%3E%3Cg fill='%23c9d4bf' opacity='.7'%3E%3Cpath d='M10 200 C40 150 70 120 120 70' stroke='%23b8c6ac' stroke-width='3' fill='none'/%3E%3Cellipse cx='40' cy='150' rx='22' ry='9' transform='rotate(-50 40 150)'/%3E%3Cellipse cx='62' cy='160' rx='20' ry='8' transform='rotate(-10 62 160)'/%3E%3Cellipse cx='70' cy='112' rx='22' ry='9' transform='rotate(-60 70 112)'/%3E%3Cellipse cx='92' cy='120' rx='20' ry='8' transform='rotate(-15 92 120)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-55 100 80)'/%3E%3C/g%3E%3C/svg%3E") left bottom / 170px no-repeat,
    radial-gradient(55% 40% at 100% 100%, rgba(190, 205, 180, 0.45), transparent 65%);
  --th-test-bg: #f2efe6;
  --th-test-line: #e4dfd2;
  --th-eyebrow: #2f5a46;
  --th-link: #b8520a;
  --th-icon-bg: #edf0e8;
  --th-icon: #2f5a46;
  --th-hz-bg: linear-gradient(#bf550a, #a84a08);
  --th-hz-ink: #ffffff;
  --th-hz-line: #a84a08;
  --th-inc-bg: #eceee8;
  --th-primary: #2f5a46;
}

body[data-flow-theme="midnight"] {
  --ground: #e9eff5;
  --ground-warm: #eef2f7;
  --panel: #ffffff;
  --line: #dbe3ec;
  --line-strong: #c7d3e0;
  --ink: #1b2a3a;
  --ink-soft: #4f5f70;
  --brand-700: #26364a;
  --brand-100: #e8eef5;
  --radius: 12px;
  --radius-lg: 14px;
  --shadow-sm: 0 6px 18px rgba(27, 42, 58, 0.06);
  --shadow: 0 10px 26px rgba(27, 42, 58, 0.09);
  --th-hdr: #26364a;
  --th-hdr-line: #26364a;
  --th-hdr-mark: radial-gradient(160px 120px at -30px 50%, rgba(255, 255, 255, 0.12) 0 60%, transparent 61%);
  --th-brand: #ffffff;
  --th-arrows: #f59a3c;
  --th-nav: #e3ebf3;
  --th-nav-line: rgba(255, 255, 255, 0.5);
  --th-nav-hover-bg: rgba(255, 255, 255, 0.1);
  --th-sw-ink: #ffffff;
  --th-sw-line: rgba(255, 255, 255, 0.4);
  --th-sw-bg: transparent;
  --th-pill: linear-gradient(#bf550a, #a84a08);
  --th-pill-ink: #ffffff;
  --th-pill-line: #a84a08;
  --th-ctx: rgba(255, 255, 255, 0.92);
  --th-accent: #e2711c;
  --th-deco:
    radial-gradient(45% 35% at 0% 0%, rgba(255, 255, 255, 0.7), transparent 70%),
    radial-gradient(50% 40% at 100% 100%, rgba(200, 214, 230, 0.7), transparent 70%);
  --th-test-bg: #fbeee2;
  --th-test-line: #efdccb;
  --th-eyebrow: #3d5672;
  --th-link: #b8520a;
  --th-icon-bg: #e8eef5;
  --th-icon: #26364a;
  --th-hz-bg: linear-gradient(#bf550a, #a84a08);
  --th-hz-ink: #ffffff;
  --th-hz-line: #a84a08;
  --th-inc-bg: #dfe6ee;
  --th-primary: #26364a;
}

body[data-flow-theme="harbour"] {
  --ground: #eaf1f8;
  --ground-warm: #eef4f9;
  --panel: #ffffff;
  --th-card: rgba(255, 255, 255, 0.88);
  --line: #d6e2ee;
  --line-strong: #c2d3e3;
  --ink: #1d3247;
  --ink-soft: #4c6074;
  --brand-700: #2f5878;
  --brand-100: #e6eef6;
  --radius: 14px;
  --radius-lg: 16px;
  --shadow-sm: 0 6px 18px rgba(42, 78, 110, 0.07);
  --shadow: 0 10px 26px rgba(42, 78, 110, 0.1);
  --th-hdr: linear-gradient(90deg, #2a4e6e, #3f6f92);
  --th-hdr-line: #2a4e6e;
  --th-hdr-mark: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.14) 0 3px, transparent 3px 22px);
  --th-brand: #ffffff;
  --th-arrows: #f59a3c;
  --th-nav: #e6eef5;
  --th-nav-line: rgba(255, 255, 255, 0.5);
  --th-nav-hover-bg: rgba(255, 255, 255, 0.1);
  --th-sw-ink: #ffffff;
  --th-sw-line: rgba(255, 255, 255, 0.45);
  --th-sw-bg: rgba(255, 255, 255, 0.06);
  --th-pill: linear-gradient(#bf550a, #a84a08);
  --th-pill-ink: #ffffff;
  --th-pill-line: #a84a08;
  --th-ctx: rgba(255, 255, 255, 0.85);
  --th-accent: #e2711c;
  --th-deco:
    repeating-linear-gradient(115deg, transparent 0 180px, rgba(255, 255, 255, 0.55) 180px 182px, transparent 182px 260px),
    linear-gradient(160deg, #f2f7fb, #dfe9f3);
  --th-test-bg: rgba(252, 238, 224, 0.9);
  --th-test-line: #efdccb;
  --th-eyebrow: #2f5878;
  --th-link: #b8520a;
  --th-icon-bg: #e6eef6;
  --th-icon: #2f5878;
  --th-hz-bg: linear-gradient(#bf550a, #a84a08);
  --th-hz-ink: #ffffff;
  --th-hz-line: #a84a08;
  --th-inc-bg: rgba(255, 255, 255, 0.75);
  --th-primary: #2f5878;
}

/* Shared: every theme draws through the tokens above. */
body[data-flow-theme] {
  background-color: var(--ground);
  background-image: var(--th-deco);
  background-attachment: fixed;
}

body[data-flow-theme] h1,
body[data-flow-theme] h2 {
  color: var(--ink);
}

body[data-flow-theme] .eyebrow {
  color: var(--th-eyebrow);
}

body[data-flow-theme] .app-header {
  background: var(--th-hdr);
  border-top: 0;
  border-bottom: 1px solid var(--th-hdr-line);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  color: var(--th-nav);
  backdrop-filter: blur(10px);
}

body[data-flow-theme] .app-header::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 120px;
  background: var(--th-hdr-mark);
  content: "";
  pointer-events: none;
}

body[data-flow-theme] .app-header-inner {
  position: relative;
}

body[data-flow-theme] .product-brand,
body[data-flow-theme] .product-brand .product-env,
body[data-flow-theme] .product-brand .product-name {
  color: var(--th-brand);
}

body[data-flow-theme] .product-arrows svg {
  stroke: var(--th-arrows);
}

body[data-flow-theme] .workspace-switcher {
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
}

body[data-flow-theme] .workspace-switcher a {
  border: 1px solid var(--th-sw-line);
  border-radius: 10px;
  background: var(--th-sw-bg);
  color: var(--th-sw-ink);
}

body[data-flow-theme] .workspace-switcher a:hover {
  background: var(--th-nav-hover-bg);
  color: var(--th-sw-ink);
}

body[data-flow-theme] .workspace-switcher a.on {
  border-color: var(--th-pill-line);
  background: var(--th-pill);
  color: var(--th-pill-ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

body[data-flow-theme] .account-actions > a,
body[data-flow-theme] .account-actions .topbar-menu > summary,
body[data-flow-theme] .user-chip {
  color: var(--th-nav);
}

body[data-flow-theme] .account-actions > a:hover,
body[data-flow-theme] .account-actions > a.on {
  color: var(--th-nav);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-color: var(--th-accent);
  text-decoration-thickness: 2px;
}

body[data-flow-theme] .feedback-open {
  border-color: var(--th-nav-line);
  color: var(--th-nav);
}

body[data-flow-theme] .feedback-open:hover {
  background: var(--th-nav-hover-bg);
}

body[data-flow-theme] .user-avatar {
  border-color: rgba(255, 255, 255, 0.6);
  background: linear-gradient(#bf550a, #a84a08);
  color: #ffffff;
}

/* The menus that open from the bar stay solid white on every theme. */
body[data-flow-theme] .topbar-menu-items {
  background: #ffffff;
  box-shadow: var(--shadow);
}

body[data-flow-theme] .context-nav {
  background: var(--th-ctx);
}

body[data-flow-theme] .context-nav a.on::after,
body[data-flow-theme] .context-nav .context-menu.on > summary::before {
  background: var(--th-accent);
}

body[data-flow-theme] .environment-banner,
body[data-flow-theme] .test-banner {
  border-bottom-color: var(--th-test-line);
  background: var(--th-test-bg);
}

body[data-flow-theme] .btn-primary {
  border-color: var(--th-primary);
  background: var(--th-primary);
  color: #ffffff;
}

body[data-flow-theme] .btn-primary:hover {
  border-color: var(--th-primary);
  background: var(--th-primary);
  color: #ffffff;
  filter: brightness(1.12);
}

/* Home */
body[data-flow-theme] .hub-head h1::after {
  width: 58px;
  height: 3px;
  margin-top: 0.5rem;
  display: block;
  border-radius: 3px;
  background: var(--th-accent);
  content: "";
}

body[data-flow-theme] .home-report-btn {
  gap: 0.6rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.07);
}

body[data-flow-theme] .home-report-btn.is-hazard {
  border: 1px solid var(--th-hz-line);
  background: var(--th-hz-bg);
  color: var(--th-hz-ink);
  box-shadow: 0 6px 16px rgba(226, 113, 28, 0.18);
}

body[data-flow-theme] .home-report-btn.is-incident {
  border: 1px solid var(--line);
  background: var(--th-inc-bg);
  color: var(--ink);
}

body[data-flow-theme] .home-report-btn:focus-visible,
body[data-flow-theme] .home-report-btn.is-incident:focus-visible {
  outline-color: var(--ink);
}

body[data-flow-theme] .hub-tasks .panel-head > a,
body[data-flow-theme] .hub-more a,
body[data-flow-theme] .notice-more a {
  color: var(--th-link);
}

body[data-flow-theme] .hub-grid .module-card,
body[data-flow-theme] .hub-tasks {
  border-color: var(--line);
  border-left: 1px solid var(--line);
  background: var(--th-card, var(--panel));
  box-shadow: var(--shadow);
}

body[data-flow-theme] .hub-grid .module-card:hover {
  border-color: var(--line-strong);
}

/* Safety keeps its marker, as in the mock-ups: the area everybody reports into. */
body[data-flow-theme] .hub-grid .module-safety {
  border-left: 5px solid var(--th-accent);
}

body[data-flow-theme] .hub-grid .module-icon {
  background: var(--th-icon-bg);
  color: var(--th-icon);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.03);
}

body[data-flow-theme] .hub-grid .module-icon svg {
  stroke-width: 1.8;
}

body[data-flow-theme] .hub-grid .module-card.is-wip {
  background: var(--ground-warm);
}

body[data-flow-theme] .hub-grid .module-card.is-wip .module-icon {
  background: var(--th-icon-bg);
  opacity: 0.7;
}

/* Profile > Appearance */
.theme-picker {
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  border: 0;
}

.theme-option {
  position: relative;
  padding: 0.6rem 0.6rem 0.75rem;
  display: grid;
  align-content: start;
  gap: 0.35rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
}

.theme-option:hover {
  border-color: var(--line-strong);
}

/* The portal's input rule makes every input full width and 42px tall. */
.theme-option input[type="radio"] {
  position: absolute;
  top: 0.95rem;
  right: 0.95rem;
  width: 18px;
  height: 18px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  box-shadow: none;
  accent-color: #bf550a;
}

.theme-form .form-actions {
  margin-top: 1rem;
}

.theme-option:has(input:checked) {
  border-color: var(--ink);
}

.theme-option:has(input:focus-visible) {
  outline: 3px solid var(--brand-700);
  outline-offset: 2px;
}

.theme-name {
  font-weight: 700;
  color: var(--ink);
}

.theme-name .pill {
  font-size: 0.66rem;
}

.theme-blurb {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.35;
}

/* A miniature of each look: bar, area bar, two cards. Literal colours on purpose,
   because it shows the theme you would get, not the one you are wearing. */
.theme-swatch {
  height: 70px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 16px 6px 1fr;
  gap: 0 6px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: var(--sw-ground);
}

.theme-swatch i:nth-child(1) {
  grid-column: 1 / -1;
  background: var(--sw-bar);
  box-shadow: inset 8px 0 0 -2px var(--sw-arrows);
}

.theme-swatch i:nth-child(2) {
  grid-column: 1 / -1;
  background: rgba(255, 255, 255, 0.85);
}

.theme-swatch i:nth-child(3),
.theme-swatch i:nth-child(4) {
  margin: 8px 0 8px 8px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  background: #ffffff;
  box-shadow: inset 4px 0 0 var(--sw-arrows);
}

.theme-swatch i:nth-child(4) {
  margin: 8px 8px 8px 0;
  box-shadow: none;
}

.theme-swatch-classic { --sw-bar: #202629; --sw-ground: #f3f5f7; --sw-arrows: #f4a900; }
.theme-swatch-mist { --sw-bar: #ffffff; --sw-ground: #eef3f0; --sw-arrows: #e2711c; }
.theme-swatch-slate { --sw-bar: #3f5c5f; --sw-ground: #f3f0ec; --sw-arrows: #f59a3c; }
.theme-swatch-eucalypt { --sw-bar: linear-gradient(90deg, #4b6b50, #56744f); --sw-ground: #f6f3ec; --sw-arrows: #f59a3c; }
.theme-swatch-midnight { --sw-bar: #26364a; --sw-ground: #e9eff5; --sw-arrows: #e2711c; }
.theme-swatch-harbour { --sw-bar: linear-gradient(90deg, #2a4e6e, #3f6f92); --sw-ground: #eaf1f8; --sw-arrows: #f59a3c; }

@media print {
  body[data-flow-theme] {
    background: #ffffff !important;
  }
}
