/* ==========================================================================
   Typefaces. Both are SIL Open Font License 1.1 and are served from this
   origin, so there is no runtime request to a font host and `font-src 'self'`
   already covers them. See public/fonts/OFL.md.
   Space Grotesk carries the structure and the numerals; Inter carries dense
   text, where it stays the more legible of the two.
   ========================================================================== */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/assets/fonts/space-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ==========================================================================
   Agency OS design system
   Off-white surfaces, near-black structure, one deep red accent.
   Every colour, radius and space below is a token; components never hard-code.
   ========================================================================== */

/* Onboarding: grouped sections and a single focused editing surface. */
.onboarding-progress { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-block: 1.25rem; font-size: .875rem; }
.onboarding-layout { display: grid; grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.onboarding-sidebar { min-width: 0; }
.onboarding-nav-container > summary { display: none; }
.onboarding-content fieldset { min-width: 0; border: 0; padding: 0; margin: 0; }
.onboarding-content .work-panel { margin: 0; padding: .75rem; background: var(--surface-raised); }
.onboarding-content .work-panel > summary { padding-block: .25rem; }
.onboarding-sections { display: grid; gap: .25rem; margin-bottom: 1rem; }
.onboarding-sections details { border-bottom: 1px solid var(--surface-sunken); padding-block: .25rem; }
.onboarding-sections summary { padding: .75rem .5rem; cursor: pointer; font-weight: 600; font-size: .875rem; }
.onboarding-sections summary > span { float: right; font-weight: 400; }
.onboarding-sections a { display: flex; justify-content: space-between; gap: .5rem; padding: .65rem .75rem; border-radius: .4rem; text-decoration: none; color: inherit; font-size: .8125rem; }
.onboarding-sections a:hover { background: var(--surface-card); }
.onboarding-sections a[aria-current="page"] { background: var(--surface-sunken); font-weight: 700; box-shadow: inset 3px 0 var(--surface-dark); }
.onboarding-saved { font-size: .6875rem; font-weight: 400; align-self: center; }
.onboarding-meta { border-top: 1px solid var(--surface-sunken); padding: 1rem .5rem; font-size: .8125rem; }
.onboarding-meta summary { cursor: pointer; }
.onboarding-content { min-width: 0; }
.onboarding-content > .panel { margin-top: 0; }
.onboarding-content .button-row { flex-wrap: wrap; }
@media (max-width: 900px) {
  .onboarding-nav-container > summary { display: list-item; cursor: pointer; padding: .75rem; background: var(--surface-card); border-radius: .5rem; font-weight: 600; }
  .onboarding-nav-container[open] > summary { margin-bottom: .75rem; }
  .onboarding-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .onboarding-sections { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem; }
  .onboarding-sections details { grid-column: 1 / -1; }
  .onboarding-meta { padding-block: .5rem; }
}

:root {
  color-scheme: light;

  /* Surfaces. The page is white and the cards are the grey — the reference's
     hierarchy, which a bordered-white-card-on-grey layout inverts. */
  --surface-app: #ffffff;
  --surface-card: #f4f4f4;
  --surface-raised: #ffffff;
  --surface-sunken: #eaeaea;
  --surface-chrome: #ffffff;
  --surface-dark: #09080a;
  --surface-dark-2: #1e1c1e;
  --surface-dark-3: #2a272a;
  --border-dark-2: #3d393c;

  /* Text */
  --text-primary: #09080a;
  --text-secondary: #5c5a5a;
  --text-muted: #8d8988;
  --text-on-dark: #f4f4f4;
  --text-on-dark-muted: #a6a1a1;
  /* Pure white, for anything sitting on the accent or a near-black surface. */
  --text-on-accent: #ffffff;

  /* Lines. Quiet enough to separate without drawing the eye. */
  --border-default: #ececec;
  --border-strong: #dcdcdc;
  --border-dark: #232022;

  /* Accent */
  --accent-primary: #950707;
  --accent-hover: #7a0606;
  --accent-soft: #fbecea;
  --accent-line: #edcfcc;
  --accent-warm: #ff562c;
  --accent-warm-soft: #fff1ec;
  --accent-warm-line: #f6cfc2;
  --accent-warm-ink: #a33718;

  /* Status. Every status also carries a glyph or text label, never colour alone. */
  --status-danger: #950707;
  --status-danger-soft: #fbecea;
  --status-danger-line: #edcfcc;
  --status-warning: #855313;
  --status-warning-soft: #fbf2e4;
  --status-warning-line: #e8d5b4;
  --status-success: #2f6a4c;
  --status-success-soft: #e9f1ec;
  --status-success-line: #c6ddd0;
  --status-info: #4a4746;
  --status-info-soft: #f0efee;
  --status-info-line: #dcd9d8;
  --status-system: #6b5350;
  --status-system-soft: #f4eeed;
  --status-neutral: #5c5a5a;
  --status-neutral-soft: #f0efee;
  --status-neutral-line: #dedcdb;

  /* The warm accent is the one hue not used for a fill, so a focus ring stays
     visible on white, on grey and on the near-black surfaces alike. */
  --focus: #ff562c;

  /* Radius. Restrained: a tool, not a toy. Pills are reserved for chips and
     the two headline stat cards. */
  --radius-xs: .3rem;
  --radius-sm: .5rem;
  --radius-md: .5rem;
  --radius-lg: .625rem;
  --radius-xl: .875rem;
  --radius-pill: 999px;

  /* Elevation. Surfaces are separated by a line, not a shadow; only things
     that genuinely float above the page carry one. */
  --shadow-card: none;
  --shadow-raise: 0 1px 2px rgb(9 8 10 / 5%), 0 4px 12px -6px rgb(9 8 10 / 10%);
  --shadow-pop: 0 12px 32px -10px rgb(9 8 10 / 22%);

  /* Layout */
  --rail-width: 14.5rem;
  --rail-collapsed: 4rem;
  --topbar-height: 3.75rem;
  --page-gutter: clamp(1rem, 2.4vw, 2.5rem);

  /* Type */
  --font-sans: "Space Grotesk", "Inter", "Segoe UI Variable Text", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Space Grotesk", "Inter", "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Cascadia Code", Consolas, monospace;

  /* Compatibility aliases: existing views still name these. */
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--border-default);
  --paper: var(--surface-raised);
  --surface: var(--surface-card);
  --accent: var(--accent-primary);
  --danger: var(--status-danger);

  font-family: var(--font-sans);
}

* { box-sizing: border-box; min-width: 0; }
/* Author display rules otherwise beat the UA rule for [hidden], which would
   leave filtered-out cards and rows on screen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--surface-app);
  color: var(--text-primary);
  font-size: .875rem;
  line-height: 1.5;
  letter-spacing: -.002em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
:root { accent-color: var(--accent-primary); }
/* Chrome draws the search field's clear button with a fixed blue glyph. Masking
   it with currentColor keeps the control and loses the off-system colour. */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none;
  width: .7rem; height: .7rem; cursor: pointer; opacity: .45;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 3l10 10M13 3L3 13' stroke='%23000' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 3l10 10M13 3L3 13' stroke='%23000' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center / contain no-repeat;
}
input[type="search"]::-webkit-search-cancel-button:hover { opacity: .9; }
a, button, summary { transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 120ms ease; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
img, svg { max-width: 100%; }

.skip-link {
  position: fixed; top: .6rem; left: .6rem; z-index: 60;
  transform: translateY(-250%);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--surface-card); padding: .6rem .9rem; font-weight: 650; text-decoration: none;
}
.skip-link:focus { transform: none; }

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1, h2, h3, h4, p { margin-top: 0; }
h1, h2 { text-wrap: balance; }
p { max-width: 72ch; text-wrap: pretty; }

h1 {
  margin-bottom: .25rem;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -.035em;
}
h2 {
  margin-bottom: .15rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 550;
  line-height: 1.3;
  letter-spacing: -.02em;
}
h3 { margin: 0; font-size: .9375rem; font-weight: 550; line-height: 1.35; letter-spacing: -.012em; }

.brand, .topbar-title, .rail-link, .rail-group-label,
.primary-action, .secondary-action, .dark-action, .text-action,
.chip-toggle, .status-chip, .badge, .chip-danger, .chip-warn, .chip-success,
.chip-info, .chip-neutral, .priority, .surface-nav a, .surface-nav span,
.board-head h3, .board-count, .task-title, .entity-title strong, .entity-title h3,
.metric-hero, .wallet-big, .queue-card strong, .promo-action, .flow-steps li,
.perm-state, .empty-state strong, th, dt {
  font-family: var(--font-display);
}

.eyebrow {
  font-family: var(--font-display);
  margin-bottom: .3rem;
  color: var(--text-secondary);
  font-size: .8125rem;
  font-weight: 400;
  letter-spacing: 0;
}
.lede { max-width: 68ch; color: var(--text-secondary); font-size: .875rem; }
.muted { color: var(--text-secondary); }
.mono { font-family: var(--font-mono); font-size: .78rem; letter-spacing: -.01em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.subsection-title { margin: 1rem 0 .5rem; font-size: .8125rem; font-weight: 620; }
.warning-copy { color: var(--status-warning); font-weight: 700; }

/* --------------------------------------------------------------------------
   Application shell: rail + topbar + workspace
   -------------------------------------------------------------------------- */

/* The rail is an icon column by default, the way the reference carries it, and
   expands to labels on request. Every icon keeps an accessible name. */
.app-shell { display: grid; grid-template-columns: var(--rail-collapsed) minmax(0, 1fr); min-height: 100vh; }
html[data-rail="expanded"] .app-shell { grid-template-columns: var(--rail-width) minmax(0, 1fr); }

.app-rail {
  position: sticky; top: 0; align-self: start;
  display: flex; flex-direction: column; gap: .5rem;
  height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 1.1rem .6rem 1rem;
  background: var(--surface-chrome);
  border-right: 1px solid var(--border-default);
}
.rail-head { display: flex; align-items: center; gap: .55rem; padding: .15rem .3rem .5rem; }
.app-rail { align-items: stretch; }
.brand {
  display: inline-flex; align-items: center; gap: .55rem; min-width: 0;
  color: var(--text-primary); font-family: var(--font-display);
  font-size: .8125rem; font-weight: 620; letter-spacing: -.02em; text-decoration: none;
}
.brand-mark {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 1.5rem; height: 1.5rem; border-radius: var(--radius-sm);
  background: var(--surface-dark); color: var(--text-on-dark);
  font-size: .7rem; font-weight: 620; letter-spacing: -.03em;
}
.brand-word { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-toggle { margin-left: auto; }

.rail-group { display: grid; gap: .1rem; margin-bottom: .3rem; }
.rail-group-label {
  padding: .5rem .5rem .25rem;
  color: var(--text-muted); font-size: .6875rem; font-weight: 450;
  letter-spacing: .04em; text-transform: uppercase;
}
.rail-link {
  display: flex; align-items: center; gap: .55rem;
  border-radius: var(--radius-sm); padding: .35rem .5rem;
  color: var(--text-secondary); font-size: .8125rem; font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
.rail-link .nav-icon { flex: 0 0 auto; width: 1.2rem; height: 1.2rem; stroke-width: 1.8; }
.rail-link-label { overflow: hidden; text-overflow: ellipsis; }
.rail-link:hover { background: var(--surface-raised); color: var(--text-primary); }
.rail-link[aria-current="page"] {
  background: var(--accent-primary);
  color: var(--text-on-accent);
  font-weight: 560;
}
.rail-link[aria-current="page"]:hover { background: var(--accent-hover); color: var(--text-on-accent); }
.rail-count {
  margin-left: auto; border-radius: var(--radius-pill);
  background: var(--surface-sunken); padding: .05rem .42rem;
  color: var(--text-secondary); font-size: .7rem; font-weight: 750; font-variant-numeric: tabular-nums;
}
.rail-link[aria-current="page"] .rail-count { background: rgb(255 255 255 / 22%); color: var(--text-on-accent); }

.rail-foot { margin-top: auto; padding-top: .7rem; border-top: 1px solid var(--border-default); }
.rail-user { display: flex; align-items: center; gap: .55rem; min-width: 0; padding: .45rem .5rem; }
.rail-user-text { display: grid; min-width: 0; }
.rail-user-text strong { overflow: hidden; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.rail-user-text span { color: var(--text-muted); font-size: .72rem; }

/* Collapsed (default) */
html:not([data-rail="expanded"]) .rail-link-label,
html:not([data-rail="expanded"]) .rail-count,
html:not([data-rail="expanded"]) .rail-user-text,
html:not([data-rail="expanded"]) .app-rail .brand-word { display: none; }
html:not([data-rail="expanded"]) .rail-group-label {
  height: 1px; width: 1.25rem; margin: .3rem auto; padding: 0;
  overflow: hidden; background: var(--border-default); color: transparent;
}
html:not([data-rail="expanded"]) .rail-group:first-child .rail-group-label { display: none; }
html:not([data-rail="expanded"]) .rail-group { gap: .15rem; margin-bottom: 0; }
html:not([data-rail="expanded"]) .rail-nav { display: grid; gap: 0; }
html:not([data-rail="expanded"]) .app-rail { padding-inline: .55rem; align-items: center; }
html:not([data-rail="expanded"]) .rail-group { justify-items: center; width: 100%; }
html:not([data-rail="expanded"]) .rail-link {
  justify-content: center; width: 2.5rem; height: 2.5rem;
  padding: 0; border-radius: var(--radius-lg);
}
html:not([data-rail="expanded"]) .rail-group { gap: .55rem; }
html:not([data-rail="expanded"]) .rail-head { justify-content: center; }
html:not([data-rail="expanded"]) .rail-toggle { display: none; }
html:not([data-rail="expanded"]) .rail-user { justify-content: center; padding-inline: 0; }
html:not([data-rail="expanded"]) .app-rail .brand { justify-content: center; }
html[data-rail="expanded"] .rail-expand { display: none; }
.rail-foot-actions { display: flex; align-items: center; gap: .3rem; padding: .35rem .5rem 0; }
.rail-expand, .rail-signout {
  width: 1.95rem; height: 1.95rem;
  border-color: transparent; background: none; color: var(--text-muted);
}
.rail-expand svg, .rail-signout svg { width: 1rem; height: 1rem; }
.rail-signout:hover { background: var(--status-danger-soft); color: var(--status-danger); border-color: transparent; }
html:not([data-rail="expanded"]) .rail-foot-actions { flex-direction: column; gap: .2rem; padding: .35rem 0 0; }

.app-main { display: flex; flex-direction: column; min-width: 0; }

/* No rule under the header: the title and its controls sit on the page. */
.app-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: flex-end; gap: .5rem;
  min-height: var(--topbar-height);
  padding: .5rem var(--page-gutter) .25rem;
  background: color-mix(in srgb, var(--surface-app) 92%, transparent);
  backdrop-filter: blur(10px);
}
.topbar-context { display: none; }
.topbar-title { overflow: hidden; font-family: var(--font-display); font-size: .8125rem; font-weight: 600; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: .4rem; }
.topbar-brand { display: none; flex: 0 0 auto; }
.topbar-search {
  display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 0 1 16rem;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: var(--surface-card); padding: .45rem .9rem;
}
.topbar-search svg { width: 1rem; height: 1rem; flex: 0 0 auto; color: var(--text-muted); }
.topbar-search input {
  min-width: 0; min-height: 0; border: 0; border-radius: 0; background: none; padding: 0;
  font-size: .875rem;
}
.topbar-search input:hover { border: 0; }
.topbar-search input:focus-visible { outline: none; }
.topbar-search:focus-within { border-color: var(--border-strong); background: var(--surface-card); }
.topbar-bell { position: relative; }
.topbar-bell .bell-count {
  position: absolute; top: -.2rem; right: -.2rem;
  min-width: 1.15rem; height: 1.15rem; padding: 0 .25rem;
  display: grid; place-items: center;
  border-radius: var(--radius-pill); background: var(--accent-primary); color: var(--text-on-accent);
  font-size: .65rem; font-weight: 750; font-variant-numeric: tabular-nums;
}
.app-topbar .menu > summary.secondary-action { padding: .45rem .85rem; }
.app-topbar .menu > summary.icon-button { width: 2.25rem; height: 2.25rem; padding: 0; background: none; }
.app-topbar .menu > summary.icon-button .avatar { width: 2.25rem; height: 2.25rem; border-radius: var(--radius-pill); }

/* Legacy header (login and error pages keep a simple bar). */
.app-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem 1rem; min-height: var(--topbar-height);
  padding: .5rem var(--page-gutter);
  background: var(--surface-chrome);
}
.identity { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .55rem; min-width: 0; color: var(--text-secondary); font-size: .85rem; }

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 var(--page-gutter) 5rem;
}
.monitoring-workspace { width: min(1600px, 100%); }

/* --------------------------------------------------------------------------
   Menus (native <details>): quick create, user menu, row actions
   -------------------------------------------------------------------------- */

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
/* A closed <details> still lays its children out in current Chrome, which left
   an off-screen panel box behind. Hiding it explicitly also keeps its links out
   of the tab order while the menu is closed. */
.menu:not([open]) > .menu-panel { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 30;
  display: grid; gap: .1rem; width: max-content;
  min-width: min(13rem, calc(100vw - 1.5rem));
  max-width: min(20rem, calc(100vw - 1.5rem));
  padding: .4rem;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--surface-chrome); box-shadow: var(--shadow-pop);
}
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: .45rem;
  width: 100%; border: 0; border-radius: var(--radius-xs);
  background: transparent; padding: .35rem .5rem;
  color: var(--text-primary); font: inherit; font-size: .78rem; font-weight: 520;
  text-align: left; text-decoration: none; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-raised); }
.menu-label { padding: .45rem .5rem .2rem; color: var(--text-muted); font-size: .8125rem; font-weight: 400; }
.menu-sep { margin: .3rem 0; border: 0; border-top: 1px solid var(--border-default); }

/* --------------------------------------------------------------------------
   Buttons and controls
   -------------------------------------------------------------------------- */

.primary-action, .secondary-action, .dark-action {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  width: fit-content; border-radius: var(--radius-pill);
  min-height: 2.25rem; padding: .45rem 1rem;
  font: inherit; font-size: .875rem; font-weight: 500;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.primary-action { border: 1px solid var(--accent-primary); background: var(--accent-primary); color: var(--text-on-accent); }
.primary-action:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.dark-action { border: 1px solid var(--surface-dark); background: var(--surface-dark); color: var(--text-on-dark); }
.dark-action:hover { background: var(--surface-dark-2); }
.secondary-action { border: 1px solid var(--border-strong); background: var(--surface-raised); color: var(--text-primary); }
.secondary-action:hover { background: var(--surface-card); }
.primary-action:active, .secondary-action:active, .dark-action:active { transform: translateY(1px); }
.primary-action:disabled, .secondary-action:disabled, .dark-action:disabled { cursor: wait; opacity: .5; }

.text-action {
  border: 0; border-radius: var(--radius-sm); background: transparent;
  padding: .3rem .45rem; color: var(--text-secondary);
  font: inherit; font-size: .8125rem; font-weight: 450; cursor: pointer;
}
.text-action:hover { background: var(--surface-raised); color: var(--text-primary); }
.danger-action { color: var(--status-danger); font-weight: 700; }
.danger-action:hover { background: var(--status-danger-soft); color: var(--status-danger); }

.icon-button {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 2.25rem; height: 2.25rem;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: var(--surface-card); color: var(--text-primary);
  padding: 0; cursor: pointer;
}
.icon-button:hover { background: var(--surface-raised); color: var(--text-primary); border-color: var(--border-strong); }
.icon-button svg { width: 1.05rem; height: 1.05rem; }

.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-raised); padding: .45rem .65rem;
  min-height: 2.25rem;
  color: var(--text-primary); font: inherit; font-size: .875rem;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-muted); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { min-height: 5.5rem; resize: vertical; }
input[type="checkbox"], input[type="radio"] {
  width: 1.15rem; height: 1.15rem; flex: 0 0 auto; accent-color: var(--accent-primary);
}
/* The label is the tap target, so it carries the comfortable height. */
.check-row, .checkbox-field { min-height: 2.1rem; cursor: pointer; }
summary { min-height: 1.7rem; padding-block: .2rem; }
select { appearance: base-select; }

.stack-form label, .inline-form label, .review-row label, .work-form label,
.compact-form label, .auth-card label, .filter-panel label {
  display: grid; gap: .3rem;
  color: var(--text-secondary); font-size: .8125rem; font-weight: 400;
}
.stack-form { display: grid; gap: .8rem; margin-top: 1rem; }
.work-form { display: grid; gap: .8rem; margin-top: 1rem; }
.compact-form { display: grid; gap: .5rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.inline-form label { flex: 1 1 12rem; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; }
.check-row, .checkbox-field { display: flex !important; align-items: center; gap: .5rem !important; }
.check-row input, .checkbox-field input { width: auto; }
.field-narrow { max-width: 6rem; }
.field-medium { max-width: 12rem; }
.form-error { min-height: 1.4rem; margin-bottom: 0; color: var(--status-danger); font-size: .84rem; }
.form-status {
  margin: 0; border-left: 3px solid var(--status-success); border-radius: var(--radius-sm);
  background: var(--status-success-soft); padding: .65rem .75rem;
  color: var(--status-success); font-size: .84rem; line-height: 1.45;
}
.form-status:empty { display: none; }
.compact-form button, .action-stack button {
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--surface-raised); min-height: 2.25rem; padding: .45rem .9rem;
  color: var(--text-primary); font: inherit; font-size: .875rem; font-weight: 500; cursor: pointer;
}
.compact-form button:hover, .action-stack button:hover { background: var(--surface-card); }

/* Filter toolbar: chips and compact selects rather than a filter form. */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  margin-bottom: 1rem;
}
.toolbar-spacer { flex: 1 1 auto; }
.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip-toggle {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--surface-raised); padding: .35rem .8rem;
  color: var(--text-secondary); font-size: .8125rem; font-weight: 450;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.chip-toggle:hover { background: var(--surface-card); color: var(--text-primary); }
.chip-toggle[aria-pressed="true"], .chip-toggle[aria-current="true"], .chip-toggle[aria-current="page"] {
  border-color: var(--surface-dark); background: var(--surface-dark); color: var(--text-on-dark);
}
.chip-toggle-count { color: inherit; font-variant-numeric: tabular-nums; opacity: .7; }
.filter-select {
  display: inline-flex; align-items: center; gap: .4rem;
  color: var(--text-muted); font-size: .8125rem; font-weight: 400;
}
.filter-select select {
  width: auto; border-radius: var(--radius-pill); padding: .38rem 1.6rem .38rem .7rem;
  color: var(--text-primary); font-size: .8rem; font-weight: 650; letter-spacing: 0; text-transform: none;
}

/* --------------------------------------------------------------------------
   Page heading
   -------------------------------------------------------------------------- */

.page-heading, .workspace-heading {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: .75rem 1.5rem; padding: 0 0 1.25rem;
}
.page-heading > div:first-child, .workspace-heading > div:first-child { min-width: 0; }

.breadcrumbs { padding-bottom: .5rem; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; list-style: none; color: var(--text-muted); font-size: .8rem; }
.breadcrumbs li + li::before { content: "/"; margin-right: .45rem; color: var(--border-strong); }
.breadcrumbs a { color: var(--text-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text-primary); text-decoration: underline; }

.section-heading {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem .75rem; margin-bottom: .7rem;
}
.section-heading h2 { margin-bottom: 0; }
.section-heading > div:first-child { min-width: 0; }

/* --------------------------------------------------------------------------
   Panels and cards
   -------------------------------------------------------------------------- */

.panel, .work-panel {
  margin-bottom: 1rem;
  padding: 1.15rem;
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card);
}
.panel-dark {
  border-color: var(--border-dark); background: var(--surface-dark); color: var(--text-on-dark);
}
.panel-dark h2, .panel-dark h3, .panel-dark strong { color: var(--text-on-dark); }
.panel-dark .eyebrow, .panel-dark .muted, .panel-dark .lede { color: var(--text-on-dark-muted); }
.panel-flush { padding: 0; overflow: hidden; }
.panel-flush > .section-heading { margin: 0; padding: clamp(1rem, 2.2vw, 1.35rem); }
.work-panel > summary { cursor: pointer; font-weight: 750; }
.work-panel > summary::marker { color: var(--text-muted); }

.two-column { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(18rem, .65fr); gap: 1rem; align-items: start; }
.section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18.5rem), 1fr)); gap: 1rem; align-items: start; }
.card-grid-wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr)); }

/* Metric tiles ------------------------------------------------------------ */

.metric-strip, .summary-grid, .metric-grid, .delay-strip, .wallet-grid, .queue-grid {
  display: grid; gap: 1rem; margin-bottom: 1.5rem;
}
.metric-strip { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); border: 0; background: none; }
.summary-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); margin-bottom: 0; }
.metric-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }
.delay-strip { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); border: 0; }
.wallet-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr)); }
.queue-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }

.metric-strip > *, .summary-grid article, .metric-grid > *, .delay-strip span {
  display: grid; align-content: start; gap: .15rem; min-width: 0;
  padding: 1rem 1.15rem;
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card);
}
/* Inside a grey card, a nested surface goes white — hierarchy without a border.
   Page → grey panel → white card is the same three steps everywhere. */
.panel .metric-strip > *, .panel .summary-grid article, .panel .metric-grid > *,
.panel .delay-strip span, .work-panel .metric-strip > *, .work-panel .summary-grid article,
.panel .entity-card, .panel .task-card, .panel .connection-card, .panel .wallet-card,
.panel .queue-card, .panel .board-empty, .panel .empty-state,
.work-panel .entity-card, .work-panel .task-card, .work-panel .connection-card,
.work-panel .queue-card, .work-panel .board-empty, .work-panel .empty-state {
  background: var(--surface-raised);
}
.panel .entity-card:hover, .panel .task-card:hover, .panel .connection-card:hover,
.work-panel .entity-card:hover, .work-panel .task-card:hover {
  background: var(--surface-card);
}
/* A nested surface inside a white card goes back to grey. */
.panel .entity-card .entity-facts, .panel .task-card .task-foot { border-top-color: var(--border-default); }
.metric-strip strong, .summary-grid strong, .metric-grid strong, .delay-strip strong, .wallet-big {
  font-family: var(--font-display);
  font-size: 1.9rem; font-weight: 450; line-height: 1.1;
  letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.metric-strip > * > span, .summary-grid > article > span, .summary-grid small,
.metric-grid span, .delay-strip span, .compact-list small {
  color: var(--text-secondary); font-size: .8125rem; font-weight: 400;
}
.delay-strip span { padding: .9rem 1rem; }
.delay-strip strong { display: block; color: var(--text-primary); }
.metric-strip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A metric tile that is also a link, and the dark emphasis tile from the reference. */
a.metric-tile, a.queue-card, a.entity-card { text-decoration: none; color: inherit; }
a.metric-tile:hover, a.queue-card:hover { background: var(--surface-sunken); }
/* `a.metric-tile { color: inherit }` outranks a plain class, which left the
   value invisible on the dark tile. */
.metric-tile-dark,
a.metric-tile.metric-tile-dark { border-color: var(--border-dark); background: var(--surface-dark); color: var(--text-on-dark); }
.metric-tile-dark span,
a.metric-tile.metric-tile-dark span { color: var(--text-on-dark-muted); }
a.metric-tile.metric-tile-dark:hover { background: var(--surface-dark-2); }
.metric-tile-accent { border-color: var(--accent-line) !important; background: var(--accent-soft) !important; }
.metric-tile-accent strong { color: var(--accent-primary); }

.metric-delta {
  display: inline-flex; align-items: center; gap: .25rem; justify-self: start;
  border-radius: var(--radius-pill); padding: .1rem .5rem;
  font-size: .72rem; font-weight: 750; font-variant-numeric: tabular-nums;
  background: var(--status-neutral-soft); color: var(--text-secondary);
}
.metric-delta[data-tone="danger"] { background: var(--status-danger-soft); color: var(--status-danger); }
.metric-delta[data-tone="success"] { background: var(--status-success-soft); color: var(--status-success); }
.metric-delta[data-tone="warning"] { background: var(--status-warning-soft); color: var(--status-warning); }

/* Hero figure inside a panel: one number that answers the panel's question. */
.metric-hero {
  margin: 0 0 .5rem; font-family: var(--font-display);
  font-size: clamp(2rem, 3.4vw, 2.5rem); font-weight: 450; line-height: 1;
  letter-spacing: -.045em; font-variant-numeric: tabular-nums;
}
.metric-hero span { color: var(--text-muted); font-size: .84rem; font-weight: 600; letter-spacing: 0; }

/* Dark panel: the one high-emphasis surface per screen. */
.panel-dark .metric-hero span { color: var(--text-on-dark-muted); }
.panel-dark .entity-facts, .panel-dark .detail-list div { border-color: var(--border-dark); }
.panel-dark .entity-facts dt, .panel-dark .detail-list dt { color: var(--text-on-dark-muted); }
.panel-dark .entity-facts dd, .panel-dark .detail-list dd { color: var(--text-on-dark); }
.panel-dark .detail-list div { background: var(--surface-dark-2); }
.panel-dark .secondary-action { border-color: var(--border-dark); background: var(--surface-dark-2); color: var(--text-on-dark); }
.panel-dark .secondary-action:hover { background: var(--surface-dark-3); border-color: var(--border-dark-2); }
.panel-dark .text-action { color: var(--text-on-dark-muted); }
.panel-dark .text-action:hover { background: var(--surface-dark-2); color: var(--text-on-dark); }
.panel-dark progress.progress { background: var(--surface-dark-2); }
.panel-dark progress.progress::-webkit-progress-bar { background: var(--surface-dark-2); }
.panel-dark progress.progress::-webkit-progress-value { background: var(--text-on-dark); }
.panel-dark progress.progress::-moz-progress-bar { background: var(--text-on-dark); }
.panel-dark progress.progress.progress-short::-webkit-progress-value { background: var(--accent-warm); }
.panel-dark progress.progress.progress-short::-moz-progress-bar { background: var(--accent-warm); }
.panel-dark .status-chip[data-tone="dark"] { border-color: var(--border-dark-2); background: var(--surface-dark-2); color: var(--text-on-dark); }

/* Action queue cards ------------------------------------------------------ */

.queue-card {
  display: grid; align-content: start; gap: .15rem; min-width: 0;
  padding: 1rem 1.15rem;
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card);
  color: inherit; text-decoration: none;
}
.queue-card .queue-icon { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; margin-bottom: .2rem; border-radius: var(--radius-xs); background: var(--surface-raised); color: var(--text-secondary); font-size: .8rem; line-height: 1; }
.queue-card .queue-icon svg { width: .9rem; height: .9rem; }
.queue-card.queue-hot .queue-icon { color: var(--accent-primary); }
.warning-copy svg { width: .95rem; height: .95rem; vertical-align: -.15em; }
.queue-card strong { font-family: var(--font-display); font-size: 1.9rem; font-weight: 450; line-height: 1.1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.queue-card span:last-child { color: var(--text-secondary); font-size: .8125rem; }
.queue-card.queue-hot { border-color: var(--accent-line); background: var(--accent-soft); }
.queue-card.queue-hot .queue-icon { background: rgb(149 7 7 / 10%); }
.queue-card.queue-hot strong { color: var(--accent-primary); }
.queue-card.queue-warn { border-color: var(--status-warning-line); background: var(--status-warning-soft); }
.queue-card.queue-warn strong { color: var(--status-warning); }
/* A queue card whose value is a phrase rather than a count. */
.queue-card-text strong { font-size: 1rem; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }

/* Entity cards: clients, employees, connections, generic records ----------- */

.entity-card {
  display: grid; align-content: start; gap: .7rem; min-width: 0;
  padding: 1.15rem;
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card);
}
.entity-card:hover { background: var(--surface-sunken); }
.entity-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem .65rem; min-width: 0; }
.entity-head > .status-chip, .entity-head > .badge { flex: 0 0 auto; margin-left: auto; }
.entity-title { display: grid; gap: .1rem; min-width: 0; flex: 1 1 8rem; }
.entity-title strong, .entity-title h3 { font-size: 1rem; font-weight: 550; letter-spacing: -.02em; overflow-wrap: anywhere; }
.entity-title a { text-decoration: none; }
.entity-title a:hover { text-decoration: underline; text-underline-offset: 2px; }
.entity-title span { color: var(--text-secondary); font-size: .8125rem; }
.entity-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 6.5rem), 1fr));
  gap: .5rem; margin: 0; padding-top: .8rem; border-top: 1px solid var(--border-strong);
}
.entity-facts div { min-width: 0; }
.entity-facts dt { color: var(--text-muted); font-size: .75rem; font-weight: 400; }
.entity-facts dd { margin: .15rem 0 0; font-size: .875rem; font-weight: 450; overflow-wrap: anywhere; }
.entity-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }

/* Task cards and board ---------------------------------------------------- */

/* A board keeps its columns on one line and scrolls, rather than wrapping a
   column onto a second row where it would be missed. */
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(18rem, 1fr);
  gap: 1rem; align-items: start; overflow-x: auto; padding-bottom: .4rem;
}
.board-column { display: grid; align-content: start; gap: .75rem; min-width: 0; }
.board-head { display: flex; align-items: center; gap: .5rem; padding: 0 .15rem; }
.board-head h3 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 550; letter-spacing: -.03em; }
.board-count { margin-right: auto; border: 0; background: none; padding: 0; color: var(--text-muted); font-size: 1.3rem; font-weight: 450; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.board-empty { border: 0; border-radius: var(--radius-lg); background: var(--surface-card); padding: 1.15rem; color: var(--text-muted); font-size: .8125rem; text-align: center; }

.task-card {
  position: relative;
  display: grid; align-content: start; gap: .6rem; min-width: 0;
  padding: 1.15rem;
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card);
}
/* The whole card opens the task, the way the reference's cards behave. The
   links inside it stay individually clickable above the stretched target. */
.task-card .task-title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.task-card .task-context a, .task-card .task-foot a { position: relative; z-index: 1; }
.task-card:hover { background: var(--surface-sunken); }
.task-card[data-overdue="yes"] { box-shadow: inset 3px 0 0 0 var(--status-danger); }
.task-card[data-status="DONE"] { opacity: .72; }
.task-card[data-status="DONE"] .task-title a { color: var(--text-secondary); }
.task-card[data-task-priority="P0"] {
  background: var(--surface-dark); color: var(--text-on-dark);
}
.task-card[data-task-priority="P0"]:hover { background: var(--surface-dark-2); }
.task-card[data-task-priority="P0"] .task-title a,
.task-card[data-task-priority="P0"] .task-context a:hover { color: var(--text-on-dark); }
.task-card[data-task-priority="P0"] .task-copy,
.task-card[data-task-priority="P0"] .task-context a { color: var(--text-on-dark-muted); }
.task-card[data-task-priority="P0"] .task-context,
.task-card[data-task-priority="P0"] .task-foot,
.task-card[data-task-priority="P0"] .task-foot-item svg { color: var(--text-on-dark-muted); }
.task-card[data-task-priority="P0"] .task-foot { border-top-color: var(--border-dark-2); }
.task-card[data-task-priority="P0"] .task-foot-item[data-tone="danger"],
.task-card[data-task-priority="P0"] .task-foot-item[data-tone="danger"] svg { color: var(--accent-warm); }
.task-card[data-task-priority="P0"] .avatar { background: var(--surface-dark-3); }
.task-card[data-task-priority="P0"] progress.progress-mini { accent-color: var(--text-on-dark); }
.task-card[data-task-priority="P0"] .icon-button { border-color: var(--border-dark-2); background: transparent; color: var(--text-on-dark); }
.task-card[data-task-priority="P0"] .icon-button:hover { background: var(--surface-dark-3); }
/* On the dark card the solid near-black chip would vanish, so it inverts to a
   light pill — the way the reference marks its one priority card. The danger
   and priority chips keep their red, which still reads against near-black. */
.task-card[data-task-priority="P0"] .task-card-top > .status-chip {
  background: var(--text-on-dark); color: var(--surface-dark);
}
.task-card[data-task-priority="P0"] .badge { border-color: var(--border-dark-2); background: var(--surface-dark-3); color: var(--text-on-dark); }
.task-card[data-task-priority="P0"][data-overdue="yes"] { box-shadow: inset 3px 0 0 0 var(--accent-warm); }
.task-card[data-task-priority="P0"] .avatar { background: var(--surface-dark-3); color: var(--text-on-dark); box-shadow: 0 0 0 1px var(--border-dark-2); }
.task-card[data-task-priority="P0"] .progress-line { color: var(--text-on-dark-muted); }
.task-card-top { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.task-title { margin: 0; font-size: 1rem; font-weight: 550; line-height: 1.3; letter-spacing: -.02em; }
.task-title a { text-decoration: none; }
.task-title a:hover { text-decoration: underline; text-underline-offset: 2px; }
.task-context { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; color: var(--text-muted); font-size: .8125rem; }
.task-context a { color: var(--text-secondary); font-weight: 650; text-decoration: none; }
.task-context a:hover { color: var(--text-primary); text-decoration: underline; }
.task-copy {
  margin: 0; max-width: none; color: var(--text-secondary); font-size: .8125rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem;
  padding-top: .7rem; border-top: 1px solid var(--border-strong);
  color: var(--text-muted); font-size: .8125rem;
}
.task-foot-item { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.task-foot-item svg { width: .9rem; height: .9rem; flex: 0 0 auto; color: var(--text-muted); }
.task-foot-item[data-tone="danger"] { color: var(--status-danger); font-weight: 700; }
.task-foot-item[data-tone="danger"] svg { color: var(--status-danger); }
.task-foot-actions { margin-left: auto; display: inline-flex; gap: .3rem; position: relative; z-index: 1; }

.progress-line { display: inline-flex; align-items: center; gap: .4rem; min-width: 0; }
progress.progress-mini { width: 3.4rem; height: .3rem; margin: 0; flex: 0 0 auto; }

/* Avatars ----------------------------------------------------------------- */

.avatar {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 1.6rem; height: 1.6rem; border-radius: var(--radius-pill);
  background: var(--surface-dark); color: var(--text-on-dark);
  font-size: .6875rem; font-weight: 500; letter-spacing: .01em;
}
.avatar-lg { width: 2.75rem; height: 2.75rem; font-size: .9375rem; }
.avatar-soft { background: var(--surface-sunken); color: var(--text-primary); }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { width: 1.5rem; height: 1.5rem; font-size: .6rem; margin-left: -.4rem; box-shadow: 0 0 0 2px var(--surface-card); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.assignee { display: inline-flex; align-items: center; gap: .4rem; font-weight: 650; }
.presence { display: inline-flex; align-items: center; gap: .4rem; color: var(--status-success); font-size: .8rem; font-weight: 700; }
.presence span, .presence-dot { width: .5rem; height: .5rem; flex: 0 0 auto; border-radius: 50%; background: var(--status-success); box-shadow: 0 0 0 3px var(--status-success-soft); }

/* --------------------------------------------------------------------------
   Status chips, badges, priority
   -------------------------------------------------------------------------- */

.badge, .status-chip, .chip-danger, .chip-warn, .chip-success, .chip-info, .chip-neutral {
  display: inline-flex; align-items: center; gap: .3rem;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: var(--status-neutral-soft); padding: .18rem .6rem;
  color: var(--status-neutral); font-size: .75rem; font-weight: 450; white-space: nowrap;
}
.status-chip::before, .chip-danger::before, .chip-warn::before, .chip-success::before, .chip-info::before {
  content: ""; width: .3rem; height: .3rem; flex: 0 0 auto; border-radius: 50%; background: currentColor;
}
.chip-danger, .status-chip[data-tone="danger"] { border-color: var(--status-danger-line); background: var(--status-danger-soft); color: var(--status-danger); }
.chip-warn, .status-chip[data-tone="warning"] { border-color: var(--status-warning-line); background: var(--status-warning-soft); color: var(--status-warning); }
.chip-success, .status-chip[data-tone="success"] { border-color: var(--status-success-line); background: var(--status-success-soft); color: var(--status-success); }
.chip-info, .status-chip[data-tone="info"] { border-color: var(--status-info-line); background: var(--status-info-soft); color: var(--status-info); }
.status-chip[data-tone="dark"] { border-color: var(--surface-dark); background: var(--surface-dark); color: var(--text-on-dark); }
/* A card's lead chip is solid, the way the reference marks a card: near-black
   for an ordinary state, brand red for one that needs attention. Nuanced status
   tones stay in tables and detail panels where they are read, not scanned. */
.task-card-top > .status-chip[data-status],
.task-card-top > .status-chip,
.entity-head > .status-chip[data-status],
.entity-head > .status-chip {
  background: var(--surface-dark); color: var(--text-on-dark); border-color: transparent;
}
.task-card-top > .status-chip::before, .entity-head > .status-chip::before { display: none; }
.task-card-top > .chip-danger, .entity-head > .chip-danger,
.task-card-top > .status-chip[data-status="BLOCKED"],
.task-card-top > .status-chip[data-status="CANCELLED"],
.entity-head > .status-chip[data-status="EXITED"] {
  background: var(--accent-primary); color: var(--text-on-accent); border-color: transparent;
}
.task-card-top > .chip-danger::before, .entity-head > .chip-danger::before { display: none; }
.task-card-top > .chip-warn, .entity-head > .chip-warn {
  background: var(--status-warning); color: var(--text-on-accent); border-color: transparent;
}
.task-card-top > .chip-warn::before, .entity-head > .chip-warn::before { display: none; }
.task-card-top > .badge, .entity-head > .badge {
  background: transparent; color: var(--text-muted); border: 1px solid var(--border-strong);
}
.badge { border-color: var(--border-default); background: var(--surface-raised); color: var(--text-secondary); font-size: .72rem; }

/* Known workflow states map to a tone so every screen reads the same. */
.status-chip[data-status="DONE"], .status-chip[data-status="APPROVED"], .status-chip[data-status="ONBOARDED"],
.status-chip[data-status="EFFECTIVE"], .status-chip[data-status="PAID"], .status-chip[data-status="CONNECTED"],
.status-chip[data-status="ACKNOWLEDGED"], .status-chip[data-status="COMPLETED"], .status-chip[data-status="SIGNED"],
.status-chip[data-status="CONFIRMED"], .status-chip[data-status="FULL_DAY"], .status-chip[data-status="ACTIVE"] {
  border-color: var(--status-success-line); background: var(--status-success-soft); color: var(--status-success);
}
.status-chip[data-status="BLOCKED"], .status-chip[data-status="CANCELLED"], .status-chip[data-status="REJECTED"],
.status-chip[data-status="MANAGER_REJECTED"], .status-chip[data-status="HR_REJECTED"], .status-chip[data-status="REVOKED"],
.status-chip[data-status="MISSING_PUNCH"], .status-chip[data-status="ABSENT"], .status-chip[data-status="DECLINED"],
.status-chip[data-status="AUTHORIZATION_FAILED"], .status-chip[data-status="EXITED"], .status-chip[data-status="LOP"] {
  border-color: var(--status-danger-line); background: var(--status-danger-soft); color: var(--status-danger);
}
.status-chip[data-status="PENDING"], .status-chip[data-status="PENDING_HR"], .status-chip[data-status="PENDING_MANAGER"],
.status-chip[data-status="EVIDENCE_PENDING"], .status-chip[data-status="IN_PROGRESS"], .status-chip[data-status="WAITING_FOR_CLIENT"],
.status-chip[data-status="HALF_DAY"], .status-chip[data-status="ON_PROBATION"], .status-chip[data-status="EXTENDED"],
.status-chip[data-status="REAUTHORIZATION_REQUIRED"], .status-chip[data-status="EXPIRED"], .status-chip[data-status="UNPAID"] {
  border-color: var(--status-warning-line); background: var(--status-warning-soft); color: var(--status-warning);
}
.status-chip[data-status="TODO"], .status-chip[data-status="BACKLOG"], .status-chip[data-status="NOT_ADDED"],
.status-chip[data-status="NOT_APPLICABLE"], .status-chip[data-status="CONNECTING"], .status-chip[data-status="SENT"] {
  border-color: var(--border-default); background: var(--surface-raised); color: var(--text-secondary);
}

.priority {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.9rem;
  border-radius: var(--radius-pill); padding: .18rem .5rem;
  font-size: .75rem; font-weight: 550; letter-spacing: .01em;
}
.priority-p0 { background: var(--accent-primary); color: var(--text-on-accent); }
.priority-p1 { background: var(--accent-warm-soft); color: var(--accent-warm-ink); border: 1px solid var(--accent-warm-line); }
.priority-p2 { background: var(--status-info-soft); color: var(--status-info); border: 1px solid var(--status-info-line); }
.priority-p3 { background: var(--status-neutral-soft); color: var(--text-secondary); border: 1px solid var(--status-neutral-line); }

/* --------------------------------------------------------------------------
   Notices, callouts, empty states
   -------------------------------------------------------------------------- */

.notice {
  display: flex; align-items: flex-start; gap: .45rem;
  max-width: none; margin-bottom: .75rem;
  border: 1px solid var(--status-info-line);
  border-radius: var(--radius-sm);
  background: var(--status-info-soft); padding: .45rem .65rem;
  color: var(--status-info); font-size: .78rem; font-weight: 520;
}
.notice-success { border-color: var(--status-success-line); border-left-color: var(--status-success); background: var(--status-success-soft); color: var(--status-success); }
.notice-error { border-color: var(--status-danger-line); border-left-color: var(--status-danger); background: var(--status-danger-soft); color: var(--status-danger); }
.callout {
  margin-bottom: .75rem;
  border: 1px solid var(--status-warning-line);
  border-radius: var(--radius-sm); background: var(--status-warning-soft);
  padding: .6rem .75rem; color: var(--status-warning); font-size: .78rem;
}
.callout strong { color: inherit; }

.empty-state {
  display: flex; align-items: flex-start; gap: .8rem;
  padding: 1.15rem;
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card);
}
.empty-state p { margin: .25rem 0 0; color: var(--text-secondary); font-size: .85rem; }
.empty-mark {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 2.1rem; height: 2.1rem; border-radius: var(--radius-md);
  background: var(--surface-raised); border: 0;
  color: var(--text-muted); font-weight: 500;
}

/* --------------------------------------------------------------------------
   Tabs / secondary navigation
   -------------------------------------------------------------------------- */

.surface-nav {
  display: flex; gap: .3rem; overflow-x: auto;
  margin-bottom: 1rem; padding-bottom: .15rem;
  scrollbar-width: thin;
}
.surface-nav a, .surface-nav span {
  flex: 0 0 auto;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  padding: .4rem .85rem;
  color: var(--text-secondary); font-size: .875rem; font-weight: 450;
  text-decoration: none; white-space: nowrap;
}
.surface-nav a:hover { background: var(--surface-sunken); color: var(--text-primary); }
.surface-nav a[aria-current="page"] { border-color: var(--surface-dark); background: var(--surface-dark); color: var(--text-on-dark); }
.surface-nav span[aria-disabled="true"] { color: var(--text-muted); cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Lists, detail lists, activity
   -------------------------------------------------------------------------- */

.detail-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: .6rem; margin: 0 0 1rem;
}
.detail-list div { min-width: 0; padding: .7rem .8rem; border-radius: var(--radius-sm); background: var(--surface-raised); }
.detail-list dt { color: var(--text-muted); font-size: .75rem; font-weight: 400; }
.detail-list dd { margin: .2rem 0 0; font-size: .875rem; font-weight: 450; }
.detail-list dd.mono, .connection-facts dd.mono { overflow-wrap: anywhere; }

.compact-list { display: grid; gap: 0; margin-bottom: 1rem; }
.compact-list > div {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border-default); font-size: .85rem;
}
.compact-list > div:last-child { border-bottom: 0; }
.compact-list small { display: block; }
.compact-list .assignee { align-items: center; gap: .5rem; }
.compact-list .assignee > span { display: grid; }

.activity-list { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.activity-list li {
  display: grid; gap: .12rem;
  min-width: 0; overflow-wrap: anywhere;
  padding: .7rem .85rem; border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-size: .8125rem;
}
.activity-list li strong { font-size: .87rem; }
.activity-list li span { color: var(--text-secondary); }
.monitoring-activity p { max-width: none; margin: .3rem 0 0; font-size: .85rem; }
.timeline-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .35rem 1rem; }
.timeline-heading time { color: var(--text-muted); font-size: .74rem; white-space: nowrap; }

.project-list { display: grid; }
.project-list article {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1rem;
  padding: .85rem 0; border-top: 1px solid var(--border-default);
}
.project-list article:first-child { border-top: 0; }
.project-list h3 a { text-decoration: none; }
.project-list h3 a:hover { text-decoration: underline; }
.project-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; color: var(--text-secondary); font-size: .82rem; }
.project-meta a { color: var(--accent-primary); font-weight: 700; text-decoration: none; }
.project-meta a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap, .table-scroll { overflow-x: auto; border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-card);
  color: var(--text-muted); font-size: .75rem; font-weight: 400;
  text-align: left; white-space: nowrap;
}
th, td { padding: .6rem .7rem; border-bottom: 1px solid var(--border-strong); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-raised); }
.data-table { min-width: 46rem; }
.monitoring-table { min-width: 72rem; }
.table-meta, .table-copy { display: block; margin-top: .15rem; color: var(--text-muted); font-size: .8125rem; }
.table-copy { max-width: 38rem; color: var(--text-secondary); }

.row-actions { position: relative; }
.row-actions > summary { cursor: pointer; color: var(--text-secondary); font-size: .82rem; font-weight: 700; white-space: nowrap; }
.row-actions > summary:hover { color: var(--text-primary); }
.action-stack {
  display: grid; gap: .7rem; width: min(28rem, 82vw); margin-top: .55rem;
  padding: 1rem; border: 0; border-radius: var(--radius-md);
  background: var(--surface-raised);
}
.action-stack details { border-top: 1px solid var(--border-default); padding-top: .5rem; }
.action-stack summary { cursor: pointer; font-size: .82rem; font-weight: 700; }

/* --------------------------------------------------------------------------
   Drawer (CSS-only, :target driven)
   -------------------------------------------------------------------------- */

.drawer {
  position: fixed; inset: 0; z-index: 50;
  display: grid; grid-template-columns: minmax(0, 1fr) min(34rem, 100%);
  visibility: hidden; pointer-events: none;
}
.drawer:target { visibility: visible; pointer-events: auto; }
.drawer-scrim {
  grid-area: 1 / 1 / 2 / 3;
  background: rgb(9 8 10 / 38%);
  opacity: 0; transition: opacity 180ms ease;
}
.drawer:target .drawer-scrim { opacity: 1; }
.drawer-panel {
  grid-area: 1 / 2 / 2 / 3;
  /* The scrim spans both grid columns and its opacity transition puts it on
     its own layer, so without an explicit stacking position it hit-tests above
     the panel and swallows every click inside the drawer. */
  position: relative; z-index: 1;
  display: flex; flex-direction: column; min-width: 0;
  height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-chrome); border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-pop);
}
.drawer-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: flex-start; gap: .7rem;
  padding: 1.15rem; border-bottom: 1px solid var(--border-default);
  background: var(--surface-chrome);
}
.drawer-head > div { min-width: 0; flex: 1 1 auto; }
.drawer-body { display: grid; gap: .9rem; padding: 1.15rem; }
.drawer-close { flex: 0 0 auto; text-decoration: none; }

/* --------------------------------------------------------------------------
   Auth, intro, error pages
   -------------------------------------------------------------------------- */

.centered-page, .auth-page, .state-page { min-height: calc(100dvh - var(--topbar-height)); display: grid; place-items: center; padding: 1.5rem; }
.intro-card, .auth-card, .state-page { width: min(100%, 30rem); }
.intro-card, .auth-card {
  display: grid; gap: 1rem; padding: clamp(1.5rem, 4vw, 2rem);
  border: 0; border-radius: var(--radius-xl);
  background: var(--surface-card);
}
.auth-card .primary-action { width: 100%; }
.auth-reset-form { display: grid; gap: 1rem; }
.auth-reset-form label { display: grid; gap: .3rem; color: var(--text-secondary); font-size: .8125rem; }
.auth-link-row { display: flex; justify-content: flex-end; margin-top: -.35rem; font-size: .8125rem; }
.auth-link-row-start { justify-content: flex-start; margin-top: 0; }
.auth-link-row a { color: var(--text-secondary); text-underline-offset: .18em; }
.auth-link-row a:hover { color: var(--text-primary); }
.auth-action-link { text-align: center; }
.state-page { align-content: center; place-items: start; }
.state-page .state-reason {
  max-width: 34rem; margin: 0 auto 1rem;
  border: 1px solid var(--border-default); border-left: 3px solid var(--status-danger);
  border-radius: var(--radius-md); background: var(--surface-card);
  padding: .75rem .9rem; text-align: left;
}
.state-page .button-row { justify-content: center; }

/* --------------------------------------------------------------------------
   Module: permission matrix
   -------------------------------------------------------------------------- */

.legend-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; color: var(--text-secondary); font-size: .78rem; }
.perm-state { display: inline-flex; align-items: center; gap: .3rem; border-radius: var(--radius-xs); padding: .16rem .45rem; font-size: .75rem; font-weight: 750; white-space: nowrap; }
.perm-on { background: var(--status-success-soft); color: var(--status-success); }
.perm-off { background: var(--status-danger-soft); color: var(--status-danger); }
.perm-source { display: inline-flex; border-radius: var(--radius-xs); background: var(--surface-raised); padding: .16rem .45rem; color: var(--text-secondary); font-size: .73rem; font-weight: 650; }
.perm-override { background: var(--status-info-soft); color: var(--status-info); }
.perm-system { background: var(--status-system-soft); color: var(--status-system); }
.perm-module { margin-bottom: .6rem; border: 0; border-radius: var(--radius-md); background: var(--surface-raised); overflow: hidden; }
.perm-module > summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .75rem .9rem; cursor: pointer; font-weight: 700; }
.perm-module > summary:hover { background: var(--surface-raised); }
.perm-module-meta { color: var(--text-muted); font-size: .76rem; font-weight: 600; }
.perm-module-actions { padding: 0 .9rem .3rem; }
.perm-table th, .perm-table td { padding: .5rem .6rem; }
.perm-table th { position: static; }
select.perm-change { width: auto; border-radius: var(--radius-sm); padding: .3rem .45rem; font-size: .8rem; }
.perm-save-bar {
  position: sticky; bottom: 0; z-index: 3;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem;
  margin-top: .9rem; padding: 1rem 1.15rem;
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface-raised); box-shadow: 0 -6px 20px -12px rgb(9 8 10 / 18%);
}
.perm-save-bar label { flex: 1 1 20rem; margin: 0; }
.perm-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); gap: .35rem .8rem; padding: .6rem .9rem .9rem; }
.diff-changed td { background: var(--status-warning-soft); }
.diff-unchanged { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Module: leave
   -------------------------------------------------------------------------- */

.wallet-card {
  display: grid; align-content: start; gap: .15rem;
  padding: 1rem 1.15rem;
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card);
}
.wallet-card h3 {
  display: flex; align-items: center; gap: .4rem; margin-bottom: .35rem;
  color: var(--text-secondary); font-size: .9375rem; font-weight: 450;
}
.wallet-big { margin: 0 0 .15rem; }
.wallet-big span { color: var(--text-muted); font-size: .78rem; font-weight: 600; letter-spacing: 0; }
.wallet-meta { margin: 0; color: var(--text-secondary); font-size: .78rem; }

.panel-fit { container-type: inline-size; }
.date-range { display: inline-block; }
.date-range time { white-space: nowrap; }
.stack-table td[data-label] { min-width: 0; }

@container (max-width: 34rem) {
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr { display: block; width: 100%; }
  .stack-table tr { padding: .7rem 0; border-bottom: 1px solid var(--border-default); }
  .stack-table tr:hover td { background: none; }
  .stack-table tr:last-child { border-bottom: 0; }
  .stack-table td { display: grid; grid-template-columns: 4.75rem minmax(0, 1fr); gap: .5rem; padding: .18rem 0; border: 0; }
  .stack-table td::before { content: attr(data-label); padding-top: .1rem; color: var(--text-muted); font-size: .75rem; font-weight: 400; }
  .stack-table td:not([data-label]) { display: block; }
  .stack-table td:not([data-label])::before { content: none; }
  .stack-table .table-copy { max-width: none; margin-top: 0; font-size: .83rem; }
  .stack-table .status-chip { justify-self: start; }
}

.request-actions { display: grid; gap: .6rem; }
.request-action { display: grid; gap: .6rem; padding: 1rem 1.15rem; border: 0; border-radius: var(--radius-md); background: var(--surface-raised); }
.request-action-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; }
.request-action-head strong { min-width: 0; }
.request-action-dates { flex: 1 1 auto; color: var(--text-secondary); font-size: .79rem; }
.request-action-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.request-form { flex: 1 1 17rem; display: grid; gap: .3rem; min-width: 0; }
.request-form > label { color: var(--text-secondary); font-size: .76rem; font-weight: 700; }
.request-field { display: flex; flex-wrap: wrap; gap: .5rem; min-width: 0; }
.request-field input { flex: 1 1 10rem; min-width: 0; }
.request-field .secondary-action { flex: 0 0 auto; }
.request-cancel { flex: 0 0 auto; }

@container (max-width: 22rem) {
  .request-field input, .request-field .secondary-action, .request-cancel, .request-cancel .text-action { flex-basis: 100%; width: 100%; }
}

.review-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem; padding: .85rem 0; border-top: 1px solid var(--border-default); }
.review-row > * { min-width: 0; }
.review-row > div:first-child { flex: 1 1 18rem; }
.review-row label { flex: 1 1 10rem; }
.review-row button { flex: 0 0 auto; }
.review-row p { margin: .2rem 0 0; color: var(--text-secondary); font-size: .8rem; }

.leave-calendar-grid { margin-top: .5rem; }
.calendar-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .4rem; }
.calendar-list span { display: grid; gap: .1rem; padding: .55rem .7rem; border-radius: var(--radius-sm); background: var(--surface-raised); font-size: .8125rem; }
.calendar-list time { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Module: attendance calendar
   -------------------------------------------------------------------------- */

.att-calendar {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px;
  border: 0; border-radius: var(--radius-md);
  background: var(--border-strong); overflow: hidden;
}
.att-calendar-head {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  color: var(--text-muted); font-size: .75rem; font-weight: 400;
}
.att-calendar-head span { padding: .35rem .45rem; }
.att-day {
  display: grid; align-content: start; gap: .12rem; min-height: 4.6rem;
  padding: .45rem .55rem; background: var(--surface-raised);
  color: inherit; font-size: .8125rem; text-decoration: none;
}
.att-day:hover { background: var(--surface-card); }
.att-day[aria-current="date"] { outline: 1.5px solid var(--accent-primary); outline-offset: -1.5px; }
.att-day-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.att-day-icon { font-size: .8rem; line-height: 1; }
.att-day-label { color: var(--text-muted); font-size: .65rem; line-height: 1.25; }
.att-day-time { color: var(--text-primary); font-size: .72rem; font-variant-numeric: tabular-nums; }
.att-empty { background: var(--surface-card); }
/* The day's state is carried by its glyph, not by a coloured edge on every
   cell — a month of stripes reads as alarm rather than information. */
.att-FULL_DAY .att-day-icon { color: var(--status-success); }
.att-HALF_DAY .att-day-icon { color: var(--status-warning); }
.att-ABSENT .att-day-icon { color: var(--status-danger); }
.att-MISSING_PUNCH { background: var(--status-danger-soft); }
.att-MISSING_PUNCH .att-day-icon { color: var(--status-danger); }
.att-PAID_LEAVE .att-day-icon { color: var(--status-info); }
.att-LOP .att-day-icon { color: var(--status-system); }
.att-EMERGENCY_LEAVE .att-day-icon { color: var(--accent-warm); }
.att-HOLIDAY { background: var(--surface-card); }
.att-HOLIDAY .att-day-icon { color: var(--text-muted); }
.att-WEEKEND { background: var(--surface-card); }
.att-WEEKEND .att-day-num, .att-WEEKEND .att-day-label { color: var(--text-muted); }
.att-IN_PROGRESS { background: var(--status-success-soft); }
.att-IN_PROGRESS .att-day-icon { color: var(--status-success); }
.att-PENDING_LEAVE .att-day-icon { color: var(--status-info); }

progress.progress {
  display: block; width: 100%; height: .45rem; margin: .35rem 0 0;
  border: 0; border-radius: var(--radius-pill);
  background: var(--surface-sunken); appearance: none; overflow: hidden;
}
progress.progress::-webkit-progress-bar { background: var(--surface-sunken); }
progress.progress::-webkit-progress-value { background: var(--surface-dark); border-radius: var(--radius-pill); }
progress.progress::-moz-progress-bar { background: var(--surface-dark); }
progress.progress.progress-short::-webkit-progress-value { background: var(--status-warning); }
progress.progress.progress-short::-moz-progress-bar { background: var(--status-warning); }
progress.progress.progress-accent::-webkit-progress-value { background: var(--accent-primary); }
progress.progress.progress-accent::-moz-progress-bar { background: var(--accent-primary); }

/* --------------------------------------------------------------------------
   Module: workflow steps
   -------------------------------------------------------------------------- */

.flow-steps { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: .6rem 0 0; padding: 0; list-style: none; }
.flow-steps li {
  display: inline-flex; align-items: center; gap: .3rem;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: var(--surface-raised); padding: .2rem .65rem;
  color: var(--text-muted); font-size: .75rem; font-weight: 450; white-space: nowrap;
}
.flow-steps li::before { content: "○"; font-size: .7rem; }
.flow-steps li[data-state="done"] { border-color: var(--status-success-line); background: var(--status-success-soft); color: var(--status-success); }
.flow-steps li[data-state="done"]::before { content: "✓"; font-weight: 800; }
.flow-steps li[data-state="active"] { border-color: var(--surface-dark); background: var(--surface-dark); color: var(--text-on-dark); }
.flow-steps li[data-state="active"]::before { content: "●"; }
.flow-steps li[data-state="rejected"] { border-color: var(--status-danger-line); background: var(--status-danger-soft); color: var(--status-danger); }
.flow-steps li[data-state="rejected"]::before { content: "✕"; font-weight: 800; }

/* --------------------------------------------------------------------------
   Module: AI & MCP
   -------------------------------------------------------------------------- */

.connection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); gap: .8rem; }
.connection-card {
  display: grid; align-content: start; gap: .7rem; min-width: 0;
  padding: 1.15rem; border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card);
}
.connection-card:hover { background: var(--surface-sunken); }
.connection-head { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.connection-title { display: grid; gap: .1rem; flex: 1 1 8rem; min-width: 0; }
.connection-title span { color: var(--text-muted); font-size: .77rem; }
.connection-icon {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 2.2rem; height: 2.2rem; border-radius: var(--radius-md);
  background: var(--surface-dark); color: var(--text-on-dark); font-weight: 750;
}
.connection-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr)); gap: .5rem; margin: 0; padding-top: .7rem; border-top: 1px solid var(--border-default); }
.connection-facts div { min-width: 0; }
.connection-facts dt { color: var(--text-muted); font-size: .75rem; font-weight: 400; }
.connection-facts dd { margin: .1rem 0 0; font-size: .84rem; font-weight: 650; overflow-wrap: anywhere; }
.connection-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.connection-actions form { min-width: 0; }
.connection-rename > summary { cursor: pointer; color: var(--text-muted); font-size: .79rem; font-weight: 700; }
.connection-rename .request-field { margin-top: .5rem; }

.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: .6rem; }
.guide-card { min-width: 0; border: 0; border-radius: var(--radius-md); background: var(--surface-raised); padding: 1rem 1.15rem; }
.guide-card > summary { display: flex; align-items: center; gap: .55rem; cursor: pointer; font-weight: 700; }
.guide-card[open] { grid-column: 1 / -1; }
.guide-card p { margin: .7rem 0 0; }
.guide-steps { display: grid; gap: .35rem; margin: .6rem 0 0; padding-left: 1.2rem; font-size: .85rem; overflow-wrap: anywhere; }
.config-block { overflow-x: auto; margin: .7rem 0 0; padding: .75rem .85rem; border: 0; border-radius: var(--radius-sm); background: var(--surface-sunken); }

.consent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .7rem; }
.consent-module { min-width: 0; padding: 1rem 1.15rem; border: 0; border-radius: var(--radius-md); background: var(--surface-raised); }
.consent-module h3 { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .5rem; color: var(--text-secondary); font-size: .875rem; font-weight: 450; }
.consent-list { display: grid; gap: .25rem; margin: 0; padding: 0; list-style: none; font-size: .85rem; }
.consent-list li { display: grid; grid-template-columns: 1rem minmax(0, 1fr); gap: .45rem; align-items: baseline; }
.consent-yes span:first-child { color: var(--status-success); font-weight: 800; }
.consent-no { color: var(--text-muted); }
.consent-no span:first-child { color: var(--status-danger); font-weight: 800; }
.access-tools { margin: .6rem 0 0; color: var(--text-secondary); overflow-wrap: anywhere; }

/* --------------------------------------------------------------------------
   Module: salary slip document
   -------------------------------------------------------------------------- */

.slip-preview { background: var(--surface-card); }
.slip-preview .slip { display: grid; gap: 1rem; }
.slip-preview .slip-head { display: flex; align-items: center; gap: 1rem; padding-bottom: .8rem; border-bottom: 1px solid var(--border-default); }
.slip-preview .slip-logo { max-height: 3rem; max-width: 12rem; width: auto; height: auto; }
.slip-preview h2 { margin: 0; }
.slip-preview h3 { margin: .7rem 0 .2rem; color: var(--text-secondary); font-size: .875rem; font-weight: 450; }
.slip-preview table { width: 100%; border-collapse: collapse; }
.slip-preview th, .slip-preview td { padding: .5rem .6rem; border-bottom: 1px solid var(--border-default); text-align: left; vertical-align: top; }
.slip-preview th { position: static; color: var(--text-secondary); font-size: .78rem; font-weight: 700; letter-spacing: 0; text-transform: none; white-space: nowrap; }
.slip-preview td { font-variant-numeric: tabular-nums; }
.slip-preview .slip-amounts td { font-weight: 700; }
.slip-preview .slip-note, .slip-preview .slip-foot { color: var(--text-secondary); font-size: .82rem; }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.spaced-sm { margin-top: .4rem; }
.spaced-md { margin-top: .8rem; }
.spaced-above { margin-top: 1rem; }
.spaced-below { margin-bottom: 1rem; }
.spaced-block { margin: .6rem 0 1rem; }
.flush { padding: 0; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: .6rem; }
.filter-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.report-range { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; }
.report-range label { min-width: 9rem; }
.nav-icon { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; }

/* --------------------------------------------------------------------------
   Mobile navigation
   -------------------------------------------------------------------------- */

.mobile-nav { display: none; }
.mobile-more { position: relative; }

@media (max-width: 900px) {
  :root { --topbar-height: 3.5rem; }
  .topbar-brand { display: inline-flex; }
  .topbar-context { display: none; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  html[data-rail="collapsed"] .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-rail { display: none; }
  .workspace { padding-bottom: 6.5rem; }

  .mobile-nav {
    position: fixed; left: 50%; bottom: .75rem; z-index: 40;
    display: flex; align-items: center; gap: .1rem;
    width: max-content; max-width: calc(100% - 1.5rem);
    transform: translateX(-50%);
    padding: .35rem;
    border-radius: var(--radius-pill);
    background: var(--surface-dark);
    box-shadow: var(--shadow-pop);
  }
  .mobile-nav a, .mobile-nav > details > summary {
    display: grid; justify-items: center; gap: .1rem;
    min-width: 3.9rem; min-height: 3rem; padding: .4rem .55rem;
    border-radius: var(--radius-pill);
    color: var(--text-on-dark-muted); font-size: .63rem; font-weight: 650;
    text-decoration: none; list-style: none; cursor: pointer;
  }
  .mobile-nav > details > summary::-webkit-details-marker { display: none; }
  .mobile-nav .nav-icon { width: 1.2rem; height: 1.2rem; }
  .mobile-nav a:hover, .mobile-nav > details > summary:hover { color: var(--text-on-dark); }
  .mobile-nav a[aria-current="page"] { background: var(--accent-primary); color: var(--text-on-accent); }
  .mobile-more[open] > summary { background: var(--surface-dark-2); color: var(--text-on-dark); }
  .mobile-more .menu-panel {
    position: fixed; left: 50%; right: auto; bottom: 4.6rem; top: auto;
    width: min(21rem, calc(100vw - 1.5rem)); transform: translateX(-50%);
    max-height: 60vh; overflow-y: auto;
  }

  /* Comfortable touch targets: the same controls, more room around them. */
  .text-action { padding-block: .55rem; }
  .work-panel > summary, .row-actions > summary, .connection-rename > summary, .guide-card > summary { padding-block: .45rem; }
  .chip-toggle { padding-block: .5rem; }
  .two-column, .section-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .field-wide { grid-column: auto; }
  .project-list article { grid-template-columns: minmax(0, 1fr); }
  .drawer { grid-template-columns: minmax(0, 1fr); }
  .drawer-panel { grid-area: 1 / 1 / 2 / 2; border-left: 0; }
  .att-day { min-height: 3.8rem; }
  .att-day-label { display: none; }
  .perm-check-grid { grid-template-columns: 1fr; }
  .report-range { width: 100%; justify-content: flex-start; }
  .report-range label { min-width: 0; width: calc(50% - .4rem); }
  .timeline-heading { align-items: flex-start; flex-direction: column; gap: .15rem; }
}

@media (max-width: 560px) {
  .page-heading, .workspace-heading, .section-heading { flex-direction: column; align-items: stretch; }
  .page-heading .button-row, .workspace-heading .button-row { justify-content: flex-start; }
  .report-range label { width: 100%; }
  .mobile-nav a, .mobile-nav > details > summary { min-width: 3.3rem; }
  .board { grid-auto-flow: row; grid-auto-columns: auto; overflow-x: visible; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media print {
  .app-rail, .app-topbar, .app-header, .mobile-nav, .skip-link, .page-heading .button-row { display: none; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .panel, .work-panel, .slip-preview { border: 0; box-shadow: none; }
}

/* Employee / person record header ---------------------------------------- */
.profile-header .entity-head { align-items: center; gap: .7rem; }
.profile-header h1 { margin: 0; font-size: clamp(1rem, 1.3vw, 1.15rem); }
.profile-header .entity-title { gap: .2rem; }
.profile-header .entity-title span { font-size: .78rem; color: var(--text-secondary); }
.profile-header .button-row { flex: 0 0 auto; }

/* Task card footer: the name is the first thing to give way when a card is
   narrow — the avatar and its accessible label still identify the assignee. */
@container (max-width: 20rem) {
  .task-card .task-foot .assignee { font-size: 0; gap: 0; }
  .task-card .task-foot .assignee .avatar { font-size: .6rem; }
}
.task-card { container-type: inline-size; }

/* The mini checklist bar must keep its size: the generic progress rule sets a
   full width, and a shrinking flex item squeezed the count out of the row. */
.task-foot > .task-foot-item { flex: 0 0 auto; }
.task-foot > .task-foot-actions { flex: 0 0 auto; }
progress.progress.progress-mini { width: 3rem; height: .3rem; margin: 0; }
.task-foot > .assignee {
  flex: 1 1 5rem; min-width: 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

/* Summary tiles are written label-first for screen readers; on screen the value
   leads, so every tile in the app reads the same way. */
.summary-grid article { display: flex; flex-direction: column; }
.summary-grid article > strong { order: 1; }
.summary-grid article > span { order: 2; }
.summary-grid article > small { order: 3; color: var(--text-muted); font-size: .74rem; }

/* ==========================================================================
   Dashboard analytics — the reference's bar series, dot matrix and pill stats
   ========================================================================== */

.analytics-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, .95fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}

.chart-card {
  display: flex; flex-direction: column; min-width: 0;
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card); overflow: hidden;
  padding: 1.15rem 1.15rem 0;
}
.chart-card > .eyebrow { margin-bottom: 1.1rem; color: var(--text-primary); font-size: .9375rem; font-weight: 450; }
.chart-figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: .1rem .55rem; margin-bottom: 1rem; }
.chart-figure strong {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 3.4vw, 2.75rem); font-weight: 450; line-height: 1;
  letter-spacing: -.045em; font-variant-numeric: tabular-nums;
}
.chart-figure span { color: var(--text-muted); font-size: .875rem; }

.chart-bars { position: relative; margin-top: auto; }
.chart-bars svg { display: block; width: 100%; height: 11rem; }
.chart-bar { fill: var(--surface-dark); }
.chart-bar-accent { fill: var(--accent-primary); }
.chart-bars-labels {
  position: absolute; inset: auto 0 0 0;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding-bottom: .55rem;
}
.chart-bars-labels span {
  color: rgb(255 255 255 / 74%); font-size: .8125rem; font-weight: 400; text-align: center;
}
.chart-bars-labels span.is-accent { color: var(--text-on-accent); }

.chart-split { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex: 1 1 auto; padding-bottom: 1.25rem; }
.chart-split > div { min-width: 0; }
.chart-dots { width: min(11rem, 46%); height: auto; flex: 0 0 auto; align-self: flex-start; }
.chart-dot { fill: var(--surface-dark); }
.chart-dot-rest { fill: var(--accent-primary); }

.stat-stack { display: grid; grid-template-rows: 1fr 1fr; gap: 1rem; min-width: 0; }
.stat-pill {
  display: flex; align-items: center; gap: 1rem; min-width: 0;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  padding: 1.15rem 1.15rem 1.15rem 1.75rem;
  color: inherit; text-decoration: none;
}
.stat-pill-dark { background: var(--surface-dark); color: var(--text-on-dark); }
.stat-pill-light { background: var(--surface-raised); border-color: var(--border-default); }
.stat-pill-light:hover { background: var(--surface-sunken); }
.stat-pill-dark:hover { background: var(--surface-dark-2); }
.stat-pill-body { display: grid; gap: .2rem; min-width: 0; flex: 1 1 auto; }
.stat-pill-body > span:first-child { color: var(--text-secondary); font-size: .9375rem; }
.stat-pill-dark .stat-pill-body > span:first-child { color: var(--text-on-dark-muted); }
.stat-pill-body strong {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 2.6vw, 2.3rem); font-weight: 450; line-height: 1.05;
  letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.stat-pill-body small { color: var(--text-muted); font-size: .8125rem; }
.stat-pill-dark .stat-pill-body small { color: var(--text-on-dark-muted); }
.stat-pill-go {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 3rem; height: 3rem; border-radius: 50%;
}
.stat-pill-go svg { width: 1.1rem; height: 1.1rem; }
.stat-pill-dark .stat-pill-go { background: var(--text-on-accent); color: var(--surface-dark); }
.stat-pill-light .stat-pill-go { background: var(--surface-dark); color: var(--text-on-accent); }

/* Attention card: the one red surface, shown only when something is waiting. */
.promo-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 1.25rem;
  min-height: 14rem; padding: 1.4rem;
  border-radius: var(--radius-lg); background: var(--accent-primary); color: var(--text-on-accent);
}
.promo-card h2 { color: var(--text-on-accent); font-size: 1.3rem; font-weight: 500; line-height: 1.3; letter-spacing: -.025em; }
.promo-card p { max-width: 28ch; margin: 0; color: rgb(255 255 255 / 82%); font-size: .875rem; }
.promo-card > div { position: relative; z-index: 1; }
.promo-mark { position: absolute; right: -3rem; top: 3.5rem; width: 12rem; height: 12rem; pointer-events: none; }
.promo-mark path { fill: var(--accent-warm); opacity: .55; }
.promo-action {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border-radius: var(--radius-pill); background: var(--text-on-accent); color: var(--text-primary);
  padding: .7rem .7rem .7rem 1.2rem; font-size: .9375rem; font-weight: 450; text-decoration: none;
}
.promo-action span:last-child { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; }
.promo-action:hover { background: var(--surface-card); }

/* Work columns, headed the way the reference heads its board. */
.work-columns { display: grid; grid-template-columns: minmax(0, .85fr) repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; margin-bottom: 1.5rem; }
.work-columns .board-head h3 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 550; letter-spacing: -.03em; }

/* Responsive rules for the analytics blocks. Declared after the components so
   they win on source order, not by raising specificity. */
@media (max-width: 1180px) {
  .analytics-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stat-stack { grid-column: 1 / -1; grid-template-rows: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .work-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .analytics-row { grid-template-columns: minmax(0, 1fr); }
  .stat-stack { grid-column: auto; }
  .work-columns { grid-template-columns: minmax(0, 1fr); }
  .topbar-search { display: none; }
  .chart-bars svg { height: 8.5rem; }
  .promo-card { min-height: 12rem; }
}

@media (max-width: 560px) {
  .stat-stack { grid-template-columns: minmax(0, 1fr); }
  .chart-split { flex-direction: column; align-items: flex-start; gap: .9rem; }
  .chart-dots { width: min(11rem, 60%); }
}

/* A destructive control is sometimes a standalone button and sometimes a text
   action; both need a comfortable target. */
.danger-action {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: var(--status-danger-soft); color: var(--status-danger);
  min-height: 2.25rem; padding: .45rem 1rem;
  font: inherit; font-size: .875rem; font-weight: 500; cursor: pointer;
}
.danger-action:hover { background: var(--status-danger-line); color: var(--status-danger); }
.text-action.danger-action { border: 0; background: transparent; padding: .45rem .5rem; }
.text-action.danger-action:hover { background: var(--status-danger-soft); }

/* A chip used as a value in a facts list wraps rather than escaping its cell. */
.entity-facts dd .status-chip,
.detail-list dd .status-chip { white-space: normal; }

/* A badge sometimes carries a sentence rather than a word, so it wraps instead
   of pushing out of its panel. Status chips keep their single line. */
.badge { white-space: normal; }

/* The mobile header keeps the brand on the left of the control cluster. */
@media (max-width: 900px) {
  .topbar-brand { margin-right: auto; }
}
