/* === NEO Albiceleste brand theme (#1446) ===
   Palette (NEO brand style guide):
     Navy    #12365C  — primary brand / headers / dark text
     Marine  #173E69  — secondary brand / dark surfaces
     Celeste #43A1D5  — accent, links, focus rings, active state
     Gold    #D5B048  — highlights / brand-badges
     Gold-dk #9C7414  — deep gold (text-on-light gold, borders)
     Tint    #E9F3FB  — light surfaces / subtle backgrounds

   The custom --cyan* / --bg-* / --text* vars below drive every app component
   (sidebar, cards, forms, buttons, dashboard tiles). The --cyan* names are kept
   as the historical "accent" channel but now carry Celeste so existing rules
   don't need renaming. Each theme block ALSO overrides the relevant Bootstrap
   5.3 CSS vars so stock components (btn-primary, links, badges, focus rings)
   pick up the brand.

   Theme selection (#3047) is a PROJECT SETTING (`ui_theme`), not a client-side
   toggle. base.html renders TWO attributes on <html> from the server:
     data-bs-theme  — 'dark' | 'light' only. This is Bootstrap's own knob; it
                      drives stock component theming, so a palette must map onto
                      one of the two values Bootstrap understands.
     data-theme     — 'dark' | 'light' | 'greenblue'. Our palette selector.
   Palettes that are Bootstrap-light (greenblue) therefore inherit the light
   block first, then override it. That's why the greenblue block is declared
   AFTER [data-bs-theme="light"] — equal specificity (0,1,0), so source order
   decides. It restates the FULL variable set anyway, so the inheritance is
   belt-and-braces rather than load-bearing. */

/* --- Dark mode (default) — deep Navy/Marine surfaces, light text, Celeste
   accent (reads well on dark), Gold highlight. --- */
:root {
  --navy: #12365C;
  --marine: #173E69;
  --celeste: #43A1D5;
  --celeste-light: #6dbbe4;
  --celeste-deep: #2a7fb3;
  --gold: #D5B048;
  --gold-deep: #9C7414;
  --tint: #E9F3FB;

  --bg-primary: #0c1f33;     /* deep navy page background */
  --bg-secondary: #12365C;   /* Navy sidebar / panels */
  --bg-card: #143b66;        /* slightly lifted Marine-ish card */
  --bg-input: #0f2c4a;
  --border: #245080;
  --text: #e7f1fb;
  --text-muted: #9bb6d2;
  --cyan: #43A1D5;           /* accent channel = Celeste */
  --cyan-dark: #2a7fb3;
  --cyan-light: #6dbbe4;
  --success: #4CAF50;
  --danger: #f0625a;
  --bg-code: #081a2c;        /* log / code blocks */
  --code-text: #9bb6d2;

  /* Bootstrap 5.3 component vars → brand */
  --bs-primary: #43A1D5;
  --bs-primary-rgb: 67, 161, 213;
  --bs-link-color: #6dbbe4;
  --bs-link-color-rgb: 109, 187, 228;
  --bs-link-hover-color: #9fd2ef;
  --bs-link-hover-color-rgb: 159, 210, 239;
  --bs-warning: #D5B048;
  --bs-warning-rgb: 213, 176, 72;
  --bs-body-bg: #0c1f33;
  --bs-body-color: #e7f1fb;
  --bs-border-color: #245080;
}

/* --- Light mode (#1375/#1446) — Tint surfaces, Navy brand/text, Celeste
   accent, Gold highlight. Flips the same variables so every var-driven
   component switches together. --- */
[data-bs-theme="light"] {
  --navy: #12365C;
  --marine: #173E69;
  --celeste: #43A1D5;
  --celeste-light: #6dbbe4;
  --celeste-deep: #2a7fb3;
  --gold: #D5B048;
  --gold-deep: #9C7414;
  --tint: #E9F3FB;

  --bg-primary: #E9F3FB;     /* Tint page background */
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border: #c3d8ec;
  --text: #12365C;           /* Navy body text */
  --text-muted: #50698a;
  --cyan: #2a7fb3;           /* deepened Celeste so accent text reads on white */
  --cyan-dark: #173E69;      /* Marine for filled-dark accents */
  --cyan-light: #43A1D5;
  --success: #2e7d32;
  --danger: #d32f2f;
  --bg-code: #dcebf8;
  --code-text: #335072;

  /* Bootstrap 5.3 component vars → brand */
  --bs-primary: #12365C;       /* Navy filled buttons on light */
  --bs-primary-rgb: 18, 54, 92;
  --bs-link-color: #2a7fb3;    /* deepened Celeste link for contrast */
  --bs-link-color-rgb: 42, 127, 179;
  --bs-link-hover-color: #173E69;
  --bs-link-hover-color-rgb: 23, 62, 105;
  --bs-warning: #9C7414;       /* deep gold reads on white */
  --bs-warning-rgb: 156, 116, 20;
  --bs-body-bg: #E9F3FB;
  --bs-body-color: #12365C;
  --bs-border-color: #c3d8ec;
}

/* --- Green-Blue (#3047) — customer-brand palette: deep blue for structure
   (links, active nav, brand, badges) and green for action (filled buttons,
   success, dashboard progress banners) on white/tint surfaces.

   Source colors are the brand blue #0C51A1 and green #5FB030. Both are
   DEEPENED wherever white text sits on top, because the source green fails
   contrast as a button fill:
     #5FB030 on white text = 2.9:1  (fails AA)
     #3F8420 on white text = 4.6:1  (passes AA)
   So --bs-primary / --success use the deepened green and the bright source
   green survives as --celeste-light, which is only ever a gradient stop or a
   border. Same reasoning as the light block's deepened Celeste.

   Runs as data-bs-theme="light" (see the header note) so Bootstrap's own
   components stay light-mode. --- */
[data-theme="greenblue"] {
  --navy: #0C51A1;           /* brand blue */
  --marine: #08386F;         /* deep blue for filled secondary badges */
  --celeste: #4E9C26;        /* accent channel = brand green (mid) */
  --celeste-light: #5FB030;  /* source brand green — gradients / borders only */
  --celeste-deep: #35701A;
  --gold: #D5B048;
  --gold-deep: #9C7414;
  --tint: #EAF3FB;

  --bg-primary: #F2F7FC;     /* soft blue-white page */
  --bg-secondary: #ffffff;   /* white sidebar, like the brand site's nav */
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border: #cfe0f0;
  --text: #0C2E52;
  --text-muted: #52708f;
  --cyan: #0C51A1;           /* accent = brand blue: links, active nav, focus */
  --cyan-dark: #08386F;
  --cyan-light: #2E74C8;
  --success: #3F8420;        /* deepened brand green — reads on white */
  --danger: #d32f2f;
  --bg-code: #e4eff9;
  --code-text: #2f4a68;

  /* Bootstrap 5.3 component vars → brand */
  --bs-primary: #3F8420;       /* green filled buttons = the brand's CTA */
  --bs-primary-rgb: 63, 132, 32;
  --bs-link-color: #0C51A1;
  --bs-link-color-rgb: 12, 81, 161;
  --bs-link-hover-color: #08386F;
  --bs-link-hover-color-rgb: 8, 56, 111;
  --bs-warning: #9C7414;
  --bs-warning-rgb: 156, 116, 20;
  --bs-body-bg: #F2F7FC;
  --bs-body-color: #0C2E52;
  --bs-border-color: #cfe0f0;
}

/* Filled primary buttons in greenblue — the brand's green CTA.
   Bootstrap 5.3's .btn-primary sets `--bs-btn-bg: #0d6efd` as a LITERAL, not
   `var(--bs-primary)`, so overriding --bs-primary above does nothing for filled
   buttons; they render stock Bootstrap blue. (Same is true of the dark + light
   blocks — their --bs-primary has never colored a button. Left alone on
   purpose: this palette is new, so recoloring it changes nothing anyone has
   seen, whereas retro-fitting dark/light would silently restyle every existing
   project's buttons.) Scoped to greenblue for that reason.
   #3F8420 is the deepened brand green: 4.6:1 against the white button text,
   so it clears WCAG AA where the #5FB030 source green (2.9:1) does not. */
[data-theme="greenblue"] .btn-primary {
  --bs-btn-bg: #3F8420;
  --bs-btn-border-color: #3F8420;
  --bs-btn-hover-bg: #35701A;
  --bs-btn-hover-border-color: #2F6416;
  --bs-btn-active-bg: #2F6416;
  --bs-btn-active-border-color: #2A5913;
  --bs-btn-disabled-bg: #3F8420;
  --bs-btn-disabled-border-color: #3F8420;
  --bs-btn-focus-shadow-rgb: 63, 132, 32;
}

body {
  background: var(--bg-primary);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Theme picker (#3047) — Settings → Admin → Appearance. Radio inputs styled as
   selectable boxes, each showing the palette's page / surface / accent colors
   so you can tell them apart without applying them. The swatch colors are
   literal hexes in settings.html, NOT var(--...): they must show what you'd be
   switching TO, and a var() would show the theme you're already in. */
.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  cursor: pointer;
  min-width: 190px;
}

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

.theme-option.is-selected {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan);
}

/* The radio itself carries the a11y semantics (label wraps it, keyboard +
   screen readers work off it) — the box is only the visual, so the dot stays
   visible rather than being hidden behind the styling. */
.theme-option input[type="radio"] { margin: 0; flex: 0 0 auto; }

.theme-swatch {
  display: inline-flex;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.theme-swatch i { width: 14px; height: 22px; display: block; }

.theme-option-text { display: flex; flex-direction: column; line-height: 1.25; }
.theme-option-label { font-size: 13px; font-weight: 600; color: var(--text); }
.theme-option-hint { font-size: 11px; color: var(--text-muted); }

/* Sidebar */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  /* One row: logo, then the name, left-aligned. The right padding keeps the
     name clear of the collapse chevron, which sits at the end of this row
     (.sidebar-toggle below). 13px so 'Neo-Deliverables-Generator' fits the
     room left beside the chevron in the 260px sidebar (#845 was 14.4px, before
     the chevron existed; at that size the name ran under it). */
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
  padding: 8px 22px 8px 0;
  line-height: 1.2;
}
.sidebar-brand img { flex: none; }
/* A wider system font (Linux's DejaVu Sans) cannot fit the name on one line
   beside the chevron: it then wraps after a hyphen ("Neo-Deliverables-" /
   "Generator") rather than being cut short or running under the button. */
.sidebar-brand span { min-width: 0; }

.sidebar .nav-link {
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 2px;
  font-size: 14px;
}

.sidebar .nav-link:hover {
  color: var(--text);
  background: rgba(67, 161, 213, 0.10);
}

.sidebar .nav-link.active {
  color: var(--cyan);
  background: rgba(67, 161, 213, 0.16);
}

.sidebar-footer {
  padding: 12px 0;
  border-top: 1px solid var(--border);
  font-size: 11px;
  text-align: center;
}

/* Sidebar collapse (#6968 workspace; owner 2026-09-27: "same as claude.ai side
   panel design"). `html.sidebar-collapsed` is set by the script at the top of
   <body> in base.html from localStorage before first paint and flipped by the
   chevron (app.js). Collapsed: a 56 px rail, icons only — the labels are hidden
   with font-size 0 so the nav markup (hrefs, icons, order) stays exactly as the
   tests pin it, and the page takes the space. Hovering the rail adds
   `html.sidebar-peek`: the full sidebar slides out OVER the page (its box grows
   to the full width while a negative right margin keeps it 56 px in the flow, so
   nothing shifts), and leaving it folds it back; the chevron pins it.
   z-index 1035: the peek must paint over every sticky or raised box a page
   owns (the dashboard's Process Drawings panel is sticky at 30 and covered the
   sidebar, owner screenshot 2026-10-03; Bootstrap's sticky-top / fixed-top are
   1020 / 1030) while staying under Bootstrap's offcanvas, modals and toasts
   (1040+), so a dialog's backdrop still covers the sidebar. */
.sidebar { position: relative; z-index: 1035; transition: width .18s ease, min-width .18s ease, margin-right .18s ease, box-shadow .18s ease; }
.sidebar .nav-link, .sidebar .sidebar-brand span, .sidebar .sidebar-footer { transition: font-size .12s ease, padding .12s ease; }
/* top 24px centres the chevron on the brand row (16px nav padding + 8px brand padding, 24px logo). */
.sidebar-toggle {
  position: absolute; top: 24px; right: 6px; width: 24px; height: 24px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); color: var(--text-muted);
  font-size: 12px; line-height: 22px; text-align: center; cursor: pointer; z-index: 2;
}
.sidebar-toggle:hover { color: var(--cyan); }
.sidebar-collapsed .sidebar { width: 56px; min-width: 56px; padding-left: 6px !important; padding-right: 6px !important; }
.sidebar-collapsed .sidebar-toggle { right: 16px; }
.sidebar-collapsed:not(.sidebar-peek) .sidebar-toggle { top: 10px; }
.sidebar-collapsed .sidebar-toggle .bi { display: inline-block; transform: rotate(180deg); }
.sidebar-collapsed:not(.sidebar-peek) .sidebar-brand { font-size: 0; padding-top: 44px; padding-right: 0; justify-content: center; }
.sidebar-collapsed:not(.sidebar-peek) .sidebar-brand img { margin: 0 !important; }
.sidebar-collapsed:not(.sidebar-peek) .sidebar .nav-link { font-size: 0; padding: 10px 0; text-align: center; }
.sidebar-collapsed:not(.sidebar-peek) .sidebar .nav-link .bi { font-size: 18px; margin: 0 !important; }
.sidebar-collapsed:not(.sidebar-peek) .sidebar-footer { font-size: 0; }
.sidebar-collapsed:not(.sidebar-peek) .sidebar-footer .btn { font-size: 0; padding: 6px 0; }
.sidebar-collapsed:not(.sidebar-peek) .sidebar-footer .btn .bi { font-size: 15px; margin: 0 !important; }
.sidebar-collapsed:not(.sidebar-peek) .sidebar-footer .sidebar-user,
.sidebar-collapsed:not(.sidebar-peek) .sidebar-footer .sidebar-project,
.sidebar-collapsed:not(.sidebar-peek) .sidebar-footer .text-muted { display: none; }
/* the peek: full width painted over the page, 56 px in the flow */
.sidebar-collapsed.sidebar-peek .sidebar {
  width: 260px; min-width: 260px; margin-right: -204px; padding-left: 16px !important; padding-right: 16px !important;
  box-shadow: 6px 0 28px rgba(0, 0, 0, .38); border-right-color: var(--cyan);
}
.sidebar-collapsed.sidebar-peek .sidebar-toggle { right: 6px; }
.sidebar-collapsed.sidebar-peek .sidebar-toggle .bi { transform: rotate(180deg); }

/* Active project name shown above "Switch Project" (#1988) */
.sidebar-project {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding: 0 4px;
}
.sidebar-project .bi { color: var(--cyan); opacity: .9; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.card-title { color: var(--text); }

.pid-card {
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.pid-card:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
}

/* Step progress dots */
.step-progress {
  display: flex;
  align-items: center;
}

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  flex-shrink: 0;
}

.step-dot.done {
  background: var(--cyan-dark);
  border-color: var(--cyan);
  color: #fff;
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
}

.step-line.done {
  background: var(--cyan);
}

/* Step cards on detail page */
.step-card {
  border-left: 3px solid var(--border);
  transition: border-color 0.2s;
}

.step-card:hover {
  border-left-color: var(--cyan);
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  margin-right: 10px;
}

.step-badge.done {
  background: var(--cyan-dark);
  border-color: var(--cyan);
  color: #fff;
}

.step-log {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  max-height: 300px;
  overflow-y: auto;
  color: var(--code-text);
}

.step-log pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--code-text);
}

/* Forms */
.form-control, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
}

.form-control:focus, .form-select:focus {
  background: var(--bg-input);
  border-color: var(--cyan);
  color: var(--text);
  box-shadow: 0 0 0 0.2rem rgba(67, 161, 213, 0.25);
}

.form-control::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.form-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Buttons */
.btn-cyan {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #0a1f33;
  font-weight: 600;
}

.btn-cyan:hover {
  background: var(--cyan-light);
  border-color: var(--cyan-light);
  color: #0a1f33;
}

.btn-cyan:disabled {
  background: var(--cyan-dark);
  border-color: var(--cyan-dark);
  color: #333;
  opacity: 0.5;
}

.btn-outline-cyan {
  border-color: var(--cyan);
  color: var(--cyan);
}

.btn-outline-cyan:hover {
  background: var(--cyan);
  color: #000;
}

.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-outline-secondary:hover {
  background: var(--bg-input);
  border-color: var(--text-muted);
  color: var(--text);
}

/* Badges */
.badge.bg-success { background: var(--success) !important; }
.badge.bg-info { background: var(--cyan) !important; color: #0a1f33 !important; }
.badge.bg-warning { background: var(--gold) !important; color: #0a1f33 !important; }
.badge.bg-primary { background: var(--navy) !important; color: #fff !important; }
.badge.bg-secondary { background: var(--marine) !important; color: #fff !important; }

/* Welcome page */
.welcome-body {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  min-height: 100vh;
}

.welcome-card {
  max-width: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
}

.welcome-icon {
  font-size: 48px;
  color: var(--cyan);
}

.section-header {
  color: var(--cyan);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-dark); }

/* Spinner */
.spinner-border.text-cyan {
  color: var(--cyan) !important;
}

/* Alert */
.alert-danger {
  background: rgba(244, 67, 54, 0.1);
  border-color: rgba(244, 67, 54, 0.3);
  color: var(--danger);
}

/* Deployed strip (Settings -> Admin, #4517 / #4616): a dark panel with one
   row per piece and pill chips for the shas, in both page themes. */
.dep-panel {
  background: #1b232c;
  color: #e6ebf0;
  border: 1px solid #2b3541;
  border-radius: 6px;
  padding: 0.35rem 0.9rem;
  max-width: 640px;
}
.dep-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #2b3541;
}
.dep-row:last-child { border-bottom: 0; }
.dep-name { flex: 0 0 7rem; color: #8b98a8; }
.dep-muted { color: #8b98a8; margin-left: 0.25rem; }
.dep-chip {
  display: inline-block;
  font-family: var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.7;
  padding: 1px 8px;
  border-radius: 999px;
  margin-right: 6px;
  white-space: nowrap;
}
.dep-chip-green { background: #1f4d32; color: #8fe0a8; }
.dep-chip-blue  { background: #1e3a55; color: #8fc4f0; }
.dep-chip-amber { background: #4a3a12; color: #f0c45d; }
.dep-chip-red   { background: #4d2320; color: #ff9c92; }
.dep-chip-muted { background: #2b3541; color: #b9c3cf; }
