/* Rightman OS — canonical stylesheet.

   Owns the design system: palette, type, and the shared components
   (buttons, tables, forms, cards, badges, shell). Page-specific
   layout rules can still live in template <style> blocks, but those
   blocks should reference the custom properties below — no hardcoded
   hex codes anywhere.

   The strict CSP allows 'unsafe-inline' for <style> blocks but not
   for <script>; self-hosted fonts + this stylesheet stay within the
   policy (`style-src 'self' 'unsafe-inline'`). No CDN.
*/

/* --- Fonts --------------------------------------------------------- */

@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/Inter-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/Inter-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/Inter-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
  font-style: normal;
}

/* --- Palette + tokens --------------------------------------------- */

:root {
  /* Brand */
  --color-navy: #0F4C81;
  --color-navy-deep: #0A3155;
  --color-navy-light: #DBEAFE;
  --color-ochre: #C9923D;
  --color-rust: #B5552B;
  --color-sand: #EFE4D2;
  --color-off-white: #FAFAF7;

  /* Neutrals */
  --color-text: #0F172A;
  --color-text-muted: #475569;
  --color-text-subtle: #64748B;
  --color-border: #E2E8F0;
  --color-border-warm: #E5DFD0;
  --color-bg: #FAFAF7;
  --color-bg-elevated: #FFFFFF;
  --color-bg-section: #F5F0E4;

  /* Semantic */
  --color-success: #15803D;
  --color-success-bg: #DCFCE7;
  --color-success-border: #BBF7D0;
  --color-warning: #854D0E;
  --color-warning-bg: #FEF3C7;
  --color-warning-border: #FDE68A;
  --color-danger: #991B1B;
  --color-danger-bg: #FEE2E2;
  --color-danger-border: #FECACA;
  /* Info — a generic blue distinct from the navy brand; used for the
     dedup "this merge collapses N workers" note and similar hints. */
  --color-info: #1E40AF;
  --color-info-bg: #EFF6FF;
  --color-info-border: #BFDBFE;

  /* Type scale */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 28px;
  --font-h1: 22px;
  --font-h2: 18px;
  --font-h3: 15px;
  --font-body: 14px;
  --font-small: 13px;
  --font-micro: 11px;

  /* Elevation + the larger "panel" radius. The 4/6/8px component radii used
     elsewhere stay as they are — these are additive, for cards and the
     master-detail panes (clients/workers registry screens). */
  --radius-card: 10px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-pop: 0 8px 24px rgba(15, 23, 42, .12);

  /* Motion — Monday-calibrated: fast, eased functional feedback (hover,
     reveal, swap-settle). Animation must never sit between the operator
     and the data. (Slow/overshoot tokens arrive with the item-panel +
     celebration passes that need them.) */
  --motion-fast: 100ms;
  --motion-med: 180ms;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  /* A confident, product-grade ease for lifts/reveals — emphasis without
     a cartoonish overshoot. */
  --ease-emphasize: cubic-bezier(0.2, 0.8, 0.2, 1);
  /* Neutral hover wash — rows/controls that highlight without a hue. */
  --hover-wash: rgba(100, 116, 139, 0.08);
  /* Lift for interactive cards/tiles on hover. */
  --shadow-card-hover: 0 4px 14px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .05);
}

/* The projects module's own accent identity — a confident indigo (Linear/
   Height family) that reads as a modern PM product, distinct from the
   corporate navy the rest of the app keeps. Scoped to main.pj-app (set in
   base.html for /projects paths): overriding the navy token triple here
   re-tints every navy-referencing component inside — buttons, the active
   tab pill, links, group rails, the info/mirror chips, cockpit tiles,
   focus rings — from one place, with no hard-coded colours downstream.
   Flip these three to change the whole projects palette; move them to
   :root to take the accent app-wide. */
.pj-app {
  /* Indigo-600 family: vibrant as a fill (white text, strong contrast)
     AND dark enough to stay legible as text on the light chip/soft
     background — AA both ways. */
  --color-navy: #4f46e5;
  --color-navy-deep: #4338ca;
  --color-navy-light: #eef2ff;
}
/* Product-grade card surface across the whole projects module: a softer
   radius + a real (if subtle) shadow, so item detail, the smart-board
   panels, add-item, and settings all read as elevated surfaces rather
   than flat bordered boxes. Scoped to .pj-app — the rest of the app's
   cards are unchanged. */
.pj-app .card {
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border-color: var(--color-border);
}
.pj-app .card-header { font-size: var(--font-micro); letter-spacing: .06em; }
/* A restrained one-shot pulse when an item reaches a terminal (Done)
   status — the small "it's done" moment, no confetti. Fires only on the
   just-changed item's chip (server tags it after the move); the global
   prefers-reduced-motion block collapses it to nothing. */
.pj-app .pj-celebrate { animation: pj-done-pulse 520ms var(--ease-emphasize); transform-origin: left center; }
@keyframes pj-done-pulse {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.18); }
  62%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* Horizontal-scroll wrapper so a wide table scrolls sideways inside its
   own box on a narrow screen instead of clipping or pushing the page
   wide. App-wide-safe (additive). */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Mobile (<700px): projects LIST tables collapse to stacked cards. Scoped
   to .pj-cards so the rest of the app's tables (workers/clients/review)
   are untouched. Each cell labels itself from its data-label attribute;
   the header row is hidden. */
@media (max-width: 700px) {
  table.data.pj-cards { border: none; background: none; }
  table.data.pj-cards thead { display: none; }
  table.data.pj-cards tbody tr {
    display: block;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    background: var(--color-bg-elevated);
    padding: .35rem 0;
    margin-bottom: .6rem;
  }
  table.data.pj-cards tbody tr:hover { background: var(--color-bg-elevated); }
  table.data.pj-cards td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 5px 12px;
    border: none;
    text-align: right;
  }
  table.data.pj-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: var(--font-micro);
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: left;
    flex: none;
  }
  /* The first cell is the card's title line — full width, no label. */
  table.data.pj-cards td:first-child {
    display: block;
    text-align: left;
    font-weight: 600;
    padding-bottom: .1rem;
  }
  table.data.pj-cards td:first-child::before { content: none; }
  /* A cell with nothing to show collapses (no empty labelled line). */
  table.data.pj-cards td:empty { display: none; }
}

/* Accessibility + trust: honour the OS "reduce motion" setting everywhere
   — animations collapse to near-instant, no parallax/scroll hijack. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Reset + base ------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  margin: 0 0 0.5em;
}
h1 { font-size: var(--font-h1); font-weight: 600; }
h2 { font-size: var(--font-h2); font-weight: 600; }
h3 { font-size: var(--font-h3); font-weight: 600; }

p { margin: 0 0 1rem; }
code {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.9em;
}

/* --- Keyboard focus ----------------------------------------------- */
/* Every interactive control needs a visible focus indicator for keyboard
   operators (WCAG 2.4.7). :focus-visible keeps the ring off mouse clicks
   but shows it on Tab. Form inputs keep their own border+ring rule below.
   :where() carries zero specificity, so any component can still override. */
:where(a, button, summary, [tabindex="0"]):focus-visible {
  outline: 2px solid var(--color-navy);
  outline-offset: 2px;
}
/* The topbar sits on navy — a navy ring would vanish there, so the
   controls inside it get the light-blue token instead. */
.topbar :where(a, button, label):focus-visible {
  outline-color: var(--color-navy-light);
}

/* --- App shell ---------------------------------------------------- */

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  /* minmax(0,1fr) lets the column shrink below its content's min-content,
     so a wide child (table, 2-col widget) scrolls inside .content instead
     of blowing the whole shell wider than the viewport. */
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 3.25rem;
  background: var(--color-navy);
  color: #fff;
  border-bottom: 1px solid var(--color-navy-deep);
  position: relative;
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 0.25rem; min-width: 0; }
/* Hamburger — hidden on desktop, shown in the mobile media query. */
.nav-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-left: -8px;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
}
.nav-burger:hover { background: rgba(255, 255, 255, 0.12); }
.burger-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
/* Visually-hidden checkbox that drives the drawer (kept operable). */
.nav-toggle { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.nav-backdrop { display: none; }
.wordmark {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.wordmark-logo {
  display: block;
  height: 40px;
  width: auto;
}
.user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: var(--font-small);
}
.user-name { color: rgba(255, 255, 255, 0.85); }
.signout-form { display: inline; margin: 0; }
.signout-button {
  font: inherit;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: var(--font-small);
}
.signout-button:hover { background: rgba(255, 255, 255, 0.1); }

/* Language selector (#14). Default styling targets the dark navy topbar
   (white-on-dark, matching .signout-button); body.auth overrides it for
   the light auth card below. CSP-safe: it's a plain submit-button group. */
.lang-select { display: inline-flex; gap: 2px; margin: 0; }
.lang-btn {
  font: inherit;
  font-size: var(--font-small);
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.lang-btn-active { background: rgba(255, 255, 255, 0.2); color: #fff; cursor: default; }

.layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}
aside.sidebar {
  background: var(--color-bg-elevated);
  border-right: 1px solid var(--color-border-warm);
  padding: 0.75rem 0;
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 9px 16px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--font-small);
  border-left: 3px solid transparent;
}
.nav-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--color-text-subtle);
}
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item a:hover {
  background: var(--color-off-white);
  color: var(--color-text);
}
.nav-item a:hover .nav-icon { color: var(--color-text-muted); }
.nav-item.active a {
  background: var(--color-navy-light);
  color: var(--color-navy-deep);
  font-weight: 500;
  border-left-color: var(--color-navy);
}
.nav-item.active a .nav-icon { color: var(--color-navy); }
/* "Admin" group label above the admin-only links. */
.nav-section {
  margin: 0.625rem 0 0;
  padding: 0.625rem 16px 0.25rem;
  border-top: 1px solid var(--color-border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

/* --- Sidebar feature groups + roadmap rows ------------------------ */
/* Each live feature is a collapsible <details> group; the timesheet
   feature is open by default. Native <details> keeps this CSS/JS-free
   and CSP-safe (no inline script). */
.nav-group { list-style: none; }
.nav-group-summary {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 9px 16px;
  color: var(--color-text);
  font-size: var(--font-small);
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  list-style: none;             /* hide the default disclosure triangle */
  user-select: none;
}
.nav-group-summary::-webkit-details-marker { display: none; }
.nav-group-summary:hover { background: var(--color-off-white); }
.nav-group-summary .nav-icon { color: var(--color-text-muted); }
.nav-caret {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-left: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--color-text-subtle);
  transition: transform 0.18s ease;
}
.nav-group-details[open] > .nav-group-summary .nav-caret { transform: rotate(180deg); }
/* Sub-items indent under the group header to show the hierarchy. */
.nav-sublist .nav-item a { padding-left: 2.75rem; }

/* Roadmap features — visible but inert, with a "Soon" pill. */
.nav-item-soon .nav-soon-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 9px 16px;
  color: var(--color-text-subtle);
  font-size: var(--font-small);
  border-left: 3px solid transparent;
  cursor: default;
}
.nav-item-soon .nav-icon { color: var(--color-text-subtle); opacity: 0.7; }
.nav-soon-badge {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: var(--font-micro);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  background: var(--color-bg-section);
  border: 1px solid var(--color-border-warm);
  border-radius: 999px;
  padding: 1px 8px;
}

main.content { padding: 1.5rem; min-width: 0; }

/* Fixed app shell (desktop): pin the shell to the viewport so the topbar
   and sidebar stay put and only .content scrolls. Each region owns its
   overflow; min-height:0 lets the grid items shrink to the track instead
   of growing with their content. Below 768px the sidebar is an off-canvas
   overlay (responsive block below) and the page scrolls normally, so this
   only applies on desktop. */
@media (min-width: 769px) {
  .app { height: 100vh; }
  .layout { min-height: 0; }
  aside.sidebar { min-height: 0; overflow-y: auto; }
  main.content { min-height: 0; overflow-y: auto; }
}

/* --- Responsive shell --------------------------------------------- */
/* Desktop keeps the fixed 16rem sidebar. Below 768px the sidebar
   becomes an off-canvas drawer toggled by #nav-toggle (CSS-only). */
@media (max-width: 768px) {
  .nav-burger { display: inline-flex; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  aside.sidebar {
    position: fixed;
    top: 3.25rem;
    left: 0;
    bottom: 0;
    width: 16rem;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    box-shadow: 2px 0 16px rgba(15, 23, 42, 0.18);
  }
  #nav-toggle:checked ~ .app aside.sidebar { transform: translateX(0); }
  .nav-backdrop {
    position: fixed;
    inset: 3.25rem 0 0 0;
    z-index: 35;
    background: rgba(15, 23, 42, 0.45);
  }
  #nav-toggle:checked ~ .nav-backdrop { display: block; }
  .nav-item a { padding: 12px 18px; }   /* larger touch targets */
  main.content { padding: 1rem; }
}
@media (max-width: 480px) {
  header.topbar { padding: 0 0.75rem; }
  .user-name { display: none; }          /* reclaim topbar width */
  .wordmark-logo { height: 34px; }
}

/* --- Buttons ------------------------------------------------------ */

.btn-primary,
.btn-secondary,
.btn-text,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: var(--font-small);
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background-color var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard);
}
.btn-primary:active:not(:disabled),
.btn-secondary:active,
.btn-text:active,
.btn-danger:active { transform: translateY(0.5px); }
.btn-primary {
  background: var(--color-navy);
  color: #fff;
  border: 1px solid var(--color-navy);
}
.btn-primary:hover:not(:disabled) { background: var(--color-navy-deep); border-color: var(--color-navy-deep); }
.btn-primary:disabled {
  background: var(--color-text-subtle);
  border-color: var(--color-text-subtle);
  cursor: not-allowed;
}
.btn-secondary {
  background: #fff;
  color: var(--color-navy);
  border: 1px solid var(--color-navy);
}
.btn-secondary:hover { background: var(--color-navy-light); }
.btn-text {
  background: transparent;
  color: var(--color-navy);
  border: none;
  padding: 4px 8px;
}
.btn-text:hover { background: var(--color-navy-light); }
.btn-danger {
  background: #fff;
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}
.btn-danger:hover { background: var(--color-danger-bg); }

/* --- Tables ------------------------------------------------------- */

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-small);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}
table.data thead { background: var(--color-bg-section); }
table.data th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
}
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--hover-wash); }
table.data td.muted { color: var(--color-text-subtle); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.row-link { cursor: pointer; }
table.data tr.row-link a { color: inherit; text-decoration: none; }
table.data tr.row-link a:hover { color: var(--color-text); }
/* Whole-row click affordance for list tables (workers, clients): the row
   hovers as a unit and the first cell carries the link that fills the row. */
table.data tr.row-link:hover { background: var(--hover-wash); }

/* --- Review per-worker accordion ---------------------------------- */
/* Collapses a period's flat day-by-day list into one expandable group
   per worker (summary = days + total hours + status). */
.worker-groups { display: flex; flex-direction: column; gap: 0.5rem; }
.worker-group {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg-elevated);
  overflow: hidden;
  /* Skip rendering offscreen worker groups -- on a 17-worker / 340-
     entry period the browser otherwise paints every accordion table
     on every scroll, which produces visible scroll lag. The browser
     reserves contain-intrinsic-size as a placeholder and only paints
     the group's table when it enters the viewport. ~180px is the
     collapsed-summary height; expanded groups get their real height
     once painted and shrink the placeholder cache. */
  content-visibility: auto;
  contain-intrinsic-size: auto 180px;
}
.worker-group.wg-unresolved { border-color: var(--color-danger-border); }
.wg-summary {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.6rem 0.875rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.wg-summary::-webkit-details-marker { display: none; }
.wg-summary::before {
  content: "\25B8";  /* ▸ — rotates to ▾ when open */
  color: var(--color-text-subtle);
  font-size: 11px;
  transition: transform 0.15s ease;
}
.worker-group[open] > .wg-summary::before { transform: rotate(90deg); }
.wg-summary:hover { background: var(--color-off-white); }
.wg-name { font-weight: 600; color: var(--color-text); }
.wg-meta {
  color: var(--color-text-muted);
  font-size: var(--font-small);
  font-variant-numeric: tabular-nums;
}
.wg-summary .badge { margin-left: auto; }
.worker-group > table.data {
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--color-border);
}

/* --- Forms -------------------------------------------------------- */

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  font: inherit;
  font-size: var(--font-body);
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: #fff;
  color: var(--color-text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-navy);
  box-shadow: 0 0 0 3px var(--color-navy-light);
}
textarea { min-height: 5rem; resize: vertical; }
label {
  display: block;
  font-size: var(--font-small);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

/* --- Cards -------------------------------------------------------- */

.card {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-warm);
  border-radius: 6px;
  padding: 16px;
}
.card-header {
  font-size: var(--font-small);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

/* --- Badges ------------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: var(--font-micro);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.badge-green { background: var(--color-success-bg); color: var(--color-success); }
.badge-yellow { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-red { background: var(--color-danger-bg); color: var(--color-danger); }

/* --- Status chips -------------------------------------------------- */
/* Colored status pills (projects boards; per-board status sets pick
   from this fixed named-token palette — service.STATUS_COLORS must
   stay in sync with the color classes here). */
.status-chip {
  display: inline-block;
  font-size: var(--font-micro);
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-chip.gray { background: var(--color-bg-section); color: var(--color-text-muted); }
.status-chip.blue { background: var(--color-info-bg); color: var(--color-info); }
.status-chip.green { background: var(--color-success-bg); color: var(--color-success); }
.status-chip.yellow { background: var(--color-warning-bg); color: var(--color-warning); }
.status-chip.red { background: var(--color-danger-bg); color: var(--color-danger); }
.status-chip.navy { background: var(--color-navy-light); color: var(--color-navy); }
/* Solid variant — the Monday-style filled block (saturated background,
   white text): a pattern you SEE across fifty rows, not a detail you
   read. Used by the status picker chips and kanban column heads. */
.status-chip.solid.gray { background: var(--color-text-subtle); color: #fff; }
.status-chip.solid.blue { background: var(--color-info); color: #fff; }
.status-chip.solid.green { background: var(--color-success); color: #fff; }
.status-chip.solid.yellow { background: var(--color-warning); color: #fff; }
.status-chip.solid.red { background: var(--color-danger); color: #fff; }
.status-chip.solid.navy { background: var(--color-navy); color: #fff; }

/* Group color rails — Monday's colored left-edge accent per group. */
.rail-gray { border-left: 4px solid var(--color-text-subtle); }
.rail-blue { border-left: 4px solid var(--color-info); }
.rail-green { border-left: 4px solid var(--color-success); }
.rail-yellow { border-left: 4px solid var(--color-warning); }
.rail-red { border-left: 4px solid var(--color-danger); }
.rail-navy { border-left: 4px solid var(--color-navy); }

/* Status picker — CSP-safe popover on native <details>: the summary is
   the current status as a solid chip; options are one solid chip button
   per status (hx-post via hx-vals). No JS, no native <select>. */
.chip-picker { position: relative; display: inline-block; }
.chip-picker > summary { list-style: none; cursor: pointer; user-select: none; }
.chip-picker > summary::-webkit-details-marker { display: none; }
.chip-picker[open] > summary .status-chip { box-shadow: 0 0 0 2px var(--color-navy-light); }
.chip-picker-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
}
.chip-picker-menu button {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  text-align: left;
}
.chip-picker-menu .status-chip {
  display: block;
  text-align: center;
  padding: 5px 10px;
  transition: transform var(--motion-fast) var(--ease-standard);
}
.chip-picker-menu button:hover .status-chip { transform: scale(1.04); }

/* Battery — Monday's most recognizable pixel after status colors: a
   proportional segmented bar of a board's status distribution. Segment
   widths are inline styles (style-src allows); colors are the tokens. */
.battery {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--color-bg-section);
  min-width: 120px;
}
.battery .seg { display: block; height: 100%; }
.battery .seg.gray { background: var(--color-text-subtle); }
.battery .seg.blue { background: var(--color-info); }
.battery .seg.green { background: var(--color-success); }
.battery .seg.yellow { background: var(--color-warning); }
.battery .seg.red { background: var(--color-danger); }
.battery .seg.navy { background: var(--color-navy); }

/* --- Avatar chip ---------------------------------------------------- */
/* Initials circle for owners (projects kanban cards; reusable anywhere
   a compact person marker is needed). */
.avatar-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-navy-light);
  color: var(--color-navy);
  font-size: var(--font-micro);
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: none;
}

/* --- Alerts ------------------------------------------------------- */

.alert {
  padding: 10px 12px;
  border-radius: 4px;
  font-size: var(--font-body);
  margin-bottom: 1rem;
}
.alert-error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}
.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}
.alert-info {
  background: var(--color-bg-section);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-warm);
}

/* --- Page help (retrofit panel) ----------------------------------- */

.page-help {
  background: var(--color-bg-section);
  border: 1px solid var(--color-border-warm);
  border-radius: 4px;
  padding: 0.5rem 0.85rem;
  margin: 0 0 1rem;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--color-text-muted);
}
.page-help-purpose {
  margin: 0 0 0.25rem;
  color: var(--color-text);
  font-weight: 500;
  font-size: 13px;
}
.page-help-how { margin: 0; }

/* --- Flash messages ---------------------------------------------- */
/* Rendered above each page's content by base.html. Carry the level   */
/* (success / info / warning / error) as a class. The optional         */
/* `flash-token` block shows a one-shot copyable value (currently the */
/* setup-URL after creating a user).                                   */
.flashes { margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.flash {
  padding: 0.6rem 0.85rem;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}
.flash p { margin: 0; }
.flash-success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success-border); }
.flash-info { background: var(--color-bg-section); color: var(--color-text-muted); border-color: var(--color-border-warm); }
.flash-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning-border); }
.flash-error { background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-danger-border); }
.flash-token {
  display: block;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text);
  font-size: 12px;
  word-break: break-all;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}

/* --- Source-preview empty state ---------------------------------- */
/* Rendered in the review screen's source panel when an attachment    */
/* mime type isn't previewable in-browser (or when the storage path   */
/* can't be resolved). Same .source-empty class also gets emitted in  */
/* the iframe body by the routes when S3 returns 404 — the inline    */
/* CSS in that response mirrors the rules below.                     */
.source-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--color-bg-section);
  border: 1px solid var(--color-border-warm);
  border-radius: 4px;
  color: var(--color-text-muted);
  font-size: var(--font-small);
  min-height: 8rem;
}
.source-empty p { margin: 0; }
.source-empty-hint {
  color: var(--color-text-subtle);
  font-size: 12px;
}
.source-empty a {
  color: var(--color-navy);
  text-decoration: none;
  font-weight: 500;
  margin-top: 0.5rem;
}
.source-empty a:hover { text-decoration: underline; }

/* --- Auth pages (centered card) ----------------------------------- */

/* Language selector on the light auth card (overrides the dark-topbar
   defaults above): right-aligned above the logo, dark-on-light. */
body.auth .lang-select {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}
body.auth .lang-btn {
  color: var(--color-text-muted);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
}
body.auth .lang-btn:hover {
  color: var(--color-navy);
  border-color: var(--color-navy);
  background: transparent;
}
body.auth .lang-btn-active {
  color: #fff;
  background: var(--color-navy);
  border-color: var(--color-navy);
}

body.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--color-bg);
}
body.auth main {
  width: 100%;
  max-width: 28rem;
  padding: 2rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-warm);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
body.auth header { margin-bottom: 1.5rem; }
body.auth .auth-logo {
  display: block;
  height: 72px;
  width: auto;
  margin: 0 auto 1.25rem;
}
body.auth h1 { margin: 0.25rem 0 0; font-size: 1.5rem; font-weight: 600; }
body.auth form { display: flex; flex-direction: column; gap: 1rem; }
body.auth .hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--color-text-subtle);
}
body.auth button[type="submit"] {
  /* Inherits .btn-primary look without the class — keeps existing */
  /* auth templates compatible without restructuring their markup.  */
  padding: 10px 16px;
  font: inherit;
  font-size: var(--font-small);
  font-weight: 500;
  color: #fff;
  background: var(--color-navy);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
body.auth button[type="submit"]:hover { background: var(--color-navy-deep); }
