/* ==========================================================================
   Liquid glass design tokens.

   The palette follows the ministry EIS prototype: a blue product accent,
   cool neutral surfaces, and distinct semantic colors for operational state.
   ========================================================================== */

:root {
  color-scheme: light;

  /* --- Light theme (default) --- */

  /* Ambient backdrop the glass samples. */
  --canvas: #f4f7fc;
  --ambient-1: #c9deff;
  --ambient-2: #ffd7c4;
  --ambient-3: #ccf0e0;
  --ambient-4: #e3d8ff;

  /* Glass. */
  --glass-fill: rgba(255, 255, 255, 0.62);
  --glass-fill-strong: rgba(255, 255, 255, 0.94);
  --glass-fill-soft: rgba(255, 255, 255, 0.35);
  --glass-hairline: rgba(19, 32, 56, 0.1);
  --glass-highlight: rgba(255, 255, 255, 0.85);
  --glass-hover: rgba(255, 255, 255, 0.72);
  /* Opaque panel for overlays that cannot sample a backdrop (see .search-results). */
  --panel-solid: #ffffff;
  /* Text on a solid accent fill. Dark themes use light accents, so this flips. */
  --on-accent: #ffffff;
  --ink-on-cap: #4b5563;
  --scrim: rgba(12, 20, 33, 0.5);

  /* Text and structure. */
  --ink: #111827;
  --ink-soft: #4b5563;
  --muted: #5f6876;
  --faint: #667180;

  --surface: var(--glass-fill);
  --surface-soft: var(--glass-fill-soft);
  --line: rgba(19, 32, 56, 0.1);
  --line-strong: rgba(19, 32, 56, 0.2);

  --sidebar: rgba(255, 255, 255, 0.62);
  --sidebar-soft: rgba(19, 32, 56, 0.07);
  --sidebar-ink: #111827;
  --sidebar-ink-soft: #5f6876;
  --sidebar-hairline: rgba(19, 32, 56, 0.09);

  /* Product brand. */
  --brand: #1b5fb8;
  --brand-strong: #154c94;
  --brand-soft: #eaf2fd;
  --brand-on-chip: #154c94;

  /* Operational state. */
  --green: #0ca30c;
  --green-on-chip: #0a7a0a;
  --green-strong: #0a7a0a;
  --green-soft: #e7f7e7;
  --blue: #1b5fb8;
  --blue-on-chip: #154c94;
  --blue-soft: #eaf2fd;
  --amber: #b47600;
  --amber-on-chip: #7a5200;
  --amber-soft: #fdf3dd;
  --red: #d03b3b;
  --red-on-chip: #b32f2f;
  --red-soft: #fbe9e9;
  --violet: #4a3aa7;
  --violet-on-chip: #4a3aa7;
  --violet-soft: #eeecfa;

  /* Blur, radius, elevation. */
  --blur-sm: 12px;
  --blur-md: 30px;
  --blur-lg: 60px;
  --r-xs: 4px;
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;
  --elev-1: 0 1px 2px rgba(19, 32, 56, 0.06), 0 4px 14px rgba(19, 32, 56, 0.06);
  --elev-2: 0 8px 30px rgba(19, 32, 56, 0.12);
  --elev-3: 0 24px 70px rgba(19, 32, 56, 0.28);
  --shadow: var(--elev-2);

  --sidebar-width: 244px;
  --topbar-height: 64px;
  /* Inset shared by every floating panel, so the rhythm stays consistent. */
  --gutter: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --canvas: #0b0e14;
    --ambient-1: #16345c;
    --ambient-2: #4a2a1c;
    --ambient-3: #12402f;
    --ambient-4: #2a2050;

    --glass-fill: rgba(32, 37, 46, 0.62);
    --glass-fill-strong: rgba(22, 27, 35, 0.95);
    --glass-fill-soft: rgba(255, 255, 255, 0.04);
    --glass-hairline: rgba(255, 255, 255, 0.11);
    --glass-highlight: rgba(255, 255, 255, 0.1);
    --glass-hover: rgba(255, 255, 255, 0.09);
    --panel-solid: #161b23;
    --on-accent: #ffffff;
    --ink-on-cap: #c3cbd7;
    --scrim: rgba(0, 0, 0, 0.62);

    --ink: #e7ebf1;
    --ink-soft: #a4aebb;
    --muted: #a4aebb;
    --faint: #8b96a4;

    --line: #262d38;
    --line-strong: #333c4a;

    --sidebar: rgba(32, 37, 46, 0.62);
    --sidebar-soft: rgba(255, 255, 255, 0.09);
    --sidebar-ink: #e7ebf1;
    --sidebar-ink-soft: #a4aebb;
    --sidebar-hairline: rgba(255, 255, 255, 0.1);

    --brand: #3987e5;
    --brand-strong: #4f97ea;
    --brand-soft: #16283e;
    --brand-on-chip: #a8cbf5;

    --green: #5ec95e;
    --green-on-chip: #5ec95e;
    --green-strong: #4fbf4f;
    --green-soft: #0f2a15;
    --blue: #5f9fea;
    --blue-on-chip: #a8cbf5;
    --blue-soft: #16283e;
    --amber: #e0a83a;
    --amber-on-chip: #efcb95;
    --amber-soft: #2a2110;
    --red: #e56b6b;
    --red-on-chip: #f2b5af;
    --red-soft: #2b1517;
    --violet: #9085e9;
    --violet-on-chip: #b8b1f7;
    --violet-soft: #211d38;

    --elev-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 5px 16px rgba(0, 0, 0, 0.3);
    --elev-2: 0 14px 42px rgba(0, 0, 0, 0.5);
    --elev-3: 0 24px 70px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: transparent;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* render() focuses the content region for screen readers on every view change.
   It is a programmatic focus target, not an interactive control, so its ring
   is suppressed — it was invisible before only because no gap exposed it. */
#app-content:focus,
#app-content:focus-visible {
  outline: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

.app-shell {
  position: relative;
  min-height: 100vh;
}

/* The ambient wash every glass surface samples. Fixed rather than absolute:
   the drawer, scrims, popovers, and toasts are fixed siblings outside
   .app-shell, so an absolutely-positioned layer would not sit behind them. */
.app-shell::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(58% 44% at 12% 6%, var(--ambient-1) 0%, transparent 62%),
    radial-gradient(52% 40% at 88% 0%, var(--ambient-2) 0%, transparent 58%),
    radial-gradient(60% 50% at 74% 92%, var(--ambient-3) 0%, transparent 62%),
    radial-gradient(54% 46% at 16% 94%, var(--ambient-4) 0%, transparent 60%),
    var(--canvas);
  content: "";
}

.sidebar {
  position: fixed;
  inset: var(--gutter) auto var(--gutter) var(--gutter);
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 20px 14px 14px;
  color: var(--sidebar-ink);
  border: 1px solid var(--sidebar-hairline);
  border-radius: var(--r-xl);
  background: var(--sidebar);
  box-shadow: var(--elev-2);
  backdrop-filter: blur(var(--blur-lg)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(180%);
}

.brand {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 11px;
  padding: 0 9px 18px;
  border-bottom: 1px solid var(--sidebar-hairline);
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 38px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid var(--glass-highlight);
  border-radius: var(--r-sm);
  color: var(--on-accent);
  background: var(--brand);
  font-size: 20px;
  font-weight: 700;
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-copy strong {
  overflow: hidden;
  color: var(--sidebar-ink);
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  overflow: hidden;
  color: var(--sidebar-ink-soft);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-nav {
  display: grid;
  gap: 4px;
  padding-top: 18px;
}

.nav-item {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--sidebar-ink-soft);
  background: transparent;
  text-align: left;
  transition: color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.nav-item:hover {
  color: var(--sidebar-ink);
  background: var(--sidebar-soft);
}

.nav-item:active {
  transform: translateY(1px);
}

.nav-item.is-active {
  color: var(--on-accent);
  background: var(--brand);
  box-shadow: 0 5px 16px rgba(27, 95, 184, 0.35);
}

.nav-item.is-active {
  font-weight: 600;
}

.nav-item.is-active .nav-count:not(.nav-count-alert) {
  color: var(--on-accent);
  background: rgba(255, 255, 255, 0.28);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke-width: 1.8;
}

.nav-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-size: 15px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  display: grid;
  min-width: 24px;
  height: 22px;
  place-items: center;
  border-radius: var(--r-pill);
  color: var(--sidebar-ink);
  background: var(--sidebar-soft);
  font-size: 13px;
  font-weight: 600;
}

.nav-count-alert {
  color: var(--on-accent);
  background: var(--red);
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-hairline);
}

.user-compact {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 0;
  border-radius: var(--r-sm);
  color: inherit;
  background: transparent;
  text-align: left;
}

.user-compact:hover {
  background: var(--sidebar-soft);
}

.user-compact .brand-copy {
  flex: 1;
}

.user-compact > svg {
  width: 14px;
  color: var(--sidebar-ink-soft);
}

.avatar {
  display: inline-grid;
  width: 32px;
  height: 36px;
  flex: 0 0 32px;
  place-items: center;
  border-radius: 50%;
  color: var(--brand-on-chip);
  background: var(--brand-soft);
  font-size: 13px;
  font-weight: 600;
}

.avatar-dark {
  color: var(--on-accent);
  background: var(--brand);
}

/* The sidebar floats, so the content column clears its width plus the gutter
   on both sides of it. */
.workspace {
  min-height: 100vh;
  margin-left: calc(var(--sidebar-width) + var(--gutter) * 2);
}

.topbar {
  position: sticky;
  top: var(--gutter);
  z-index: 20;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: var(--gutter) var(--gutter) 0;
  padding: 0 22px;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-lg);
  background: var(--glass-fill);
  box-shadow: var(--elev-2);
  backdrop-filter: blur(var(--blur-lg)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(180%);
}

.global-search {
  position: relative;
  display: flex;
  width: min(460px, 55vw);
  min-width: 0;
  height: 38px;
  align-items: center;
  gap: 9px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-sm);
  color: var(--muted);
  background: var(--glass-fill);
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.global-search:focus-within {
  border-color: var(--line-strong);
  background: var(--glass-fill-strong);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.global-search > svg {
  width: 17px;
  flex: 0 0 17px;
}

.global-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}

.global-search kbd {
  display: grid;
  min-width: 20px;
  height: 20px;
  flex: none;
  place-items: center;
  padding: 0 5px;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-xs);
  color: var(--ink-on-cap);
  background: var(--glass-fill-strong);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

/* This panel is nested inside .global-search, which sits inside .topbar — both
   set backdrop-filter, and a backdrop-filter ancestor becomes a backdrop root.
   A nested blur can therefore only sample its parent, never the page, so the
   translucent fill let page content read straight through. It uses an opaque
   panel instead of glass, and caps its height so long result sets scroll. */
/* Topbar controls share one radius so the row reads as a single system. */
.topbar .quarter-select select,
.topbar .icon-button,
.topbar .mobile-avatar {
  border-radius: var(--r-sm);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: min(520px, calc(100vw - 32px));
  max-height: min(60vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-md);
  background: var(--panel-solid);
  box-shadow: var(--elev-3);
}

.search-group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 13px 6px;
  color: var(--faint);
  background: var(--panel-solid);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.search-result {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}

.search-result:hover {
  background: var(--glass-hover);
}

.search-result > svg {
  width: 17px;
  color: var(--muted);
}

.search-result-copy {
  display: grid;
  min-width: 0;
  flex: 1;
}

.search-result-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-copy small {
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quarter-select {
  position: relative;
  display: flex;
  height: 38px;
  align-items: center;
}

.quarter-select select {
  min-width: 102px;
  height: 38px;
  appearance: none;
  padding: 0 31px 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.quarter-select svg {
  position: absolute;
  right: 10px;
  width: 13px;
  pointer-events: none;
}

.icon-button,
.mobile-avatar {
  position: relative;
  display: grid;
  width: 34px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  background: var(--surface);
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--glass-hover);
}

.theme-toggle {
  color: var(--brand);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.notification-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border: 1px solid white;
  border-radius: 50%;
  background: var(--red);
}

.mobile-avatar {
  display: none;
  border: 0;
}

/* Pulled up under the floating topbar so content scrolls beneath it; the top
   padding restores where the content visually begins. */
#app-content {
  min-height: calc(100vh - var(--topbar-height));
  margin-top: calc((var(--topbar-height) + var(--gutter)) * -1);
  padding: calc(var(--topbar-height) + var(--gutter) * 2) 28px 28px;
}

.view-enter {
  animation: view-in 220ms ease-out both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-heading-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 25px;
  font-weight: 600;
  line-height: 1.25;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

h3 {
  margin-bottom: 3px;
  font-size: 14px;
  font-weight: 700;
}

.page-heading p,
.section-heading p,
.drawer-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.heading-actions,
.toolbar-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.button:hover {
  border-color: var(--line-strong);
  background: var(--glass-hover);
}

.button:active {
  transform: translateY(1px);
}

.button svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

.button-primary {
  border-color: var(--brand);
  color: var(--on-accent);
  background: var(--brand);
}

.button-primary:hover {
  border-color: var(--brand-strong);
  background: var(--brand-strong);
}

.button-danger {
  border-color: var(--red);
  color: var(--red);
  background: var(--surface);
}

.button-text {
  padding-inline: 4px;
  border-color: transparent;
  color: var(--brand);
  background: transparent;
}

.button-text:hover {
  border-color: transparent;
  background: var(--brand-soft);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.segmented {
  display: inline-flex;
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-soft);
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.segmented button {
  display: inline-flex;
  min-width: 32px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-pill);
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}

.segmented button.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(19, 32, 56, 0.08);
}

.segmented svg {
  width: 14px;
  height: 14px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  margin-bottom: 26px;
  overflow: hidden;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-lg);
  background: var(--glass-fill);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  box-shadow: var(--elev-1), inset 0 1px 0 var(--glass-highlight);
}

.metric {
  position: relative;
  min-width: 0;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-icon {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--brand-on-chip);
  background: var(--brand-soft);
}

.metric-icon svg {
  width: 14px;
  height: 14px;
}

.metric-value {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
}

.metric-foot {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  color: var(--faint);
  font-size: 12px;
}

.trend-up {
  color: var(--green-on-chip);
}

.trend-down {
  color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.8fr);
  gap: 28px;
}

.dashboard-grid > * {
  min-width: 0;
}

.content-section {
  min-width: 0;
  padding-top: 2px;
}

.content-section + .content-section {
  margin-top: 28px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label > svg {
  width: 17px;
  color: var(--brand);
}

.mini-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
}

.workload-chart {
  display: grid;
  gap: 14px;
  padding: 18px 0 8px;
  border-top: 1px solid var(--line);
}

.chart-row {
  display: grid;
  grid-template-columns: 128px minmax(140px, 1fr) 34px;
  align-items: center;
  gap: 12px;
}

.chart-person {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.chart-person .avatar {
  width: 26px;
  height: 26px;
  flex-basis: 26px;
  font-size: 11px;
}

.chart-person span:last-child {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stacked-bar {
  display: flex;
  height: 9px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--line);
}

.stacked-segment {
  height: 100%;
  transition: width 400ms ease;
}

.chart-count {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.source-list {
  display: grid;
  gap: 17px;
  padding: 17px 0 4px;
  border-top: 1px solid var(--line);
}

.source-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.source-icon,
.integration-mark {
  display: grid;
  width: 34px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  background: var(--surface);
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.source-icon svg,
.integration-mark svg {
  width: 16px;
}

.source-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.source-name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--line);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.source-count {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-lg);
  background: var(--glass-fill);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  box-shadow: var(--elev-1), inset 0 1px 0 var(--glass-highlight);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  background: var(--glass-fill-soft);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background-color 140ms ease;
}

.data-table tbody tr:hover {
  background: var(--glass-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.clickable-row {
  cursor: pointer;
}

.cell-primary {
  min-width: 210px;
}

.cell-title {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.cell-title strong {
  overflow: hidden;
  max-width: 420px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-title small,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.task-id {
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.person {
  display: flex;
  min-width: 130px;
  align-items: center;
  gap: 8px;
}

.person .avatar {
  width: 27px;
  height: 27px;
  flex-basis: 27px;
  font-size: 11px;
}

.person-copy {
  display: grid;
  min-width: 0;
}

.person-copy strong {
  overflow: hidden;
  max-width: 130px;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-copy small {
  color: var(--muted);
  font-size: 11px;
}

.badge {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  color: var(--ink-soft);
  background: var(--line);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge svg {
  width: 11px;
  height: 11px;
}

.badge-green {
  color: var(--green-on-chip);
  background: var(--green-soft);
}

.badge-blue {
  color: var(--blue-on-chip);
  background: var(--blue-soft);
}

.badge-amber {
  color: var(--amber-on-chip);
  background: var(--amber-soft);
}

.badge-red {
  color: var(--red-on-chip);
  background: var(--red-soft);
}

.badge-violet {
  color: var(--violet-on-chip);
  background: var(--violet-soft);
}

.badge-outline {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.priority {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.priority::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
}

.priority.high::before {
  background: var(--red);
}

.priority.medium::before {
  background: var(--amber);
}

.priority.low::before {
  background: var(--blue);
}

.deadline {
  display: grid;
  white-space: nowrap;
}

.deadline strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.deadline small {
  color: var(--muted);
  font-size: 11px;
}

.deadline.is-overdue strong,
.deadline.is-overdue small {
  color: var(--red);
}

.activity-list {
  border-top: 1px solid var(--line);
}

.activity-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.activity-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--brand-on-chip);
  background: var(--brand-soft);
}

.activity-icon svg {
  width: 14px;
}

.activity-copy {
  min-width: 0;
}

.activity-copy p {
  margin-bottom: 2px;
  color: var(--ink-soft);
  font-size: 13px;
}

.activity-copy strong {
  color: var(--ink);
}

.activity-copy small,
.activity-time {
  color: var(--faint);
  font-size: 11px;
  white-space: nowrap;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.filter-row {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-select {
  height: 38px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.filter-search {
  display: flex;
  width: min(260px, 100%);
  height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.filter-search svg {
  width: 14px;
  color: var(--muted);
}

.filter-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}

.tabs {
  display: flex;
  min-width: 0;
  gap: 20px;
  margin-bottom: 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 1px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.tab.is-active {
  color: var(--ink);
}

.tab.is-active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--brand);
  content: "";
}

.tab-count {
  display: grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  border-radius: var(--r-pill);
  color: var(--muted);
  background: var(--line);
  font-size: 11px;
}

.plan-progress {
  display: grid;
  min-width: 110px;
  gap: 5px;
}

.plan-progress-top {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.plan-progress .progress-track {
  height: 4px;
}

.inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.inline-actions .icon-button {
  width: 29px;
  height: 29px;
  border-color: transparent;
  background: transparent;
}

.inline-actions .icon-button:hover {
  border-color: var(--line);
  background: var(--surface);
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(235px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.board-column {
  min-width: 235px;
}

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 0 3px 8px;
  border-bottom: 2px solid var(--line);
}

.board-header strong {
  font-size: 13px;
}

.board-header span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.board-column.is-overdue .board-header {
  border-color: var(--red);
}

.board-cards {
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

.task-card {
  display: grid;
  gap: 10px;
  min-height: 142px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  box-shadow: var(--elev-1), inset 0 1px 0 var(--glass-highlight);
}

.task-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 5px 14px rgba(19, 32, 56, 0.07);
  transform: translateY(-1px);
}

.task-card-top,
.task-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.task-card h3 {
  display: -webkit-box;
  min-height: 36px;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--ink);
  line-height: 1.4;
}

.task-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.avatar-stack {
  display: flex;
  align-items: center;
  padding-left: 5px;
}

.avatar-stack .avatar {
  width: 25px;
  height: 25px;
  margin-left: -5px;
  border: 2px solid var(--surface);
  font-size: 10px;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  padding: 30px;
  overflow: hidden;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-lg);
  text-align: center;
}

.empty-state > div {
  max-width: 330px;
}

.empty-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  place-items: center;
  border-radius: var(--r-md);
  color: var(--brand-on-chip);
  background: var(--brand-soft);
}

.empty-icon svg {
  width: 20px;
}

.empty-state p {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.approval-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(420px, 1.28fr);
  min-height: 610px;
  overflow: hidden;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-lg);
  background: var(--surface);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  box-shadow: var(--elev-1), inset 0 1px 0 var(--glass-highlight);
}

.approval-queue {
  border-right: 1px solid var(--line);
}

.queue-header,
.review-header {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.queue-header h2,
.review-header h2 {
  margin: 0;
  font-size: 14px;
}

.queue-item {
  display: grid;
  width: 100%;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  box-shadow: var(--elev-1), inset 0 1px 0 var(--glass-highlight);
}

.queue-item:hover,
.queue-item.is-selected {
  background: var(--glass-hover);
}

.queue-item.is-selected {
  box-shadow: inset 3px 0 var(--brand);
}

.queue-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--brand-on-chip);
  background: var(--brand-soft);
}

.queue-icon svg {
  width: 14px;
}

.queue-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.queue-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-copy span,
.queue-time {
  color: var(--muted);
  font-size: 11px;
}

.review-panel {
  min-width: 0;
}

.review-body {
  padding: 22px;
}

.review-summary {
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.review-summary h2 {
  max-width: 720px;
  font-size: 20px;
}

/* Real borders and a transparent gap. The previous 1px-gap trick painted a
   parent background through the gaps to fake hairlines, which cannot go
   translucent — the "borders" would have been opaque patches on glass. */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
  border: 0;
  background: transparent;
}

.meta-item {
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-md);
  background: var(--glass-fill-soft);
}

.meta-item span {
  display: block;
  margin-bottom: 3px;
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
}

.meta-item strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-document {
  min-height: 205px;
  padding: 18px;
  border-left: 3px solid var(--brand);
  background: var(--glass-hover);
}

.result-document p {
  max-width: 780px;
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.attachment svg {
  width: 14px;
  color: var(--muted);
}

.review-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.review-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.integration-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-lg);
  background: var(--surface);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  box-shadow: var(--elev-1), inset 0 1px 0 var(--glass-highlight);
}

.integration-tile {
  display: grid;
  min-width: 0;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 11px;
  padding: 18px;
  border-right: 1px solid var(--line);
}

.integration-tile:last-child {
  border-right: 0;
}

.integration-copy {
  display: grid;
  min-width: 0;
}

.integration-copy strong {
  font-size: 13px;
}

.integration-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.integration-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  color: var(--green-on-chip);
  font-size: 11px;
  font-weight: 700;
}

.integration-state::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.integration-state.warning {
  color: var(--amber-on-chip);
}

.integration-state.error {
  color: var(--red);
}

.health-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 22px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
}

.health-banner > svg {
  width: 18px;
  flex: 0 0 18px;
  color: var(--amber);
}

.health-banner p {
  margin: 2px 0 0;
  color: var(--amber-on-chip);
  font-size: 13px;
}

.event-id {
  font-family: "SFMono-Regular", Consolas, monospace;
  color: var(--ink-soft);
  font-size: 12px;
}

.rating-formula {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-lg);
  background: var(--surface);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  box-shadow: var(--elev-1), inset 0 1px 0 var(--glass-highlight);
}

.formula-part {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.formula-part:last-child {
  border-right: 0;
}

.formula-value {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 4px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 700;
}

.formula-copy {
  min-width: 0;
}

.formula-copy strong {
  display: block;
  font-size: 13px;
}

.formula-copy small {
  color: var(--muted);
  font-size: 11px;
}

.score {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.score strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.score span {
  color: var(--faint);
  font-size: 11px;
}

.score-components {
  display: grid;
  width: 180px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.component-bar {
  height: 5px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--line);
}

.component-bar span {
  display: block;
  height: 100%;
  background: var(--brand);
}

.rank {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.detail-drawer {
  position: fixed;
  top: var(--gutter);
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 70;
  width: min(520px, calc(100vw - var(--gutter) * 2));
  overflow-y: auto;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--elev-3);
  transform: translateX(105%);
  transition: transform 220ms ease;
  backdrop-filter: blur(var(--blur-lg)) saturate(190%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(190%);
}

.detail-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  min-height: 66px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--glass-fill-strong);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
}

.drawer-header-copy {
  min-width: 0;
}

.drawer-header h2 {
  margin: 0;
  font-size: 17px;
}

.drawer-header .icon-button {
  flex: 0 0 34px;
}

.drawer-body {
  padding: 20px;
}

.drawer-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.drawer-section:first-child {
  padding-top: 0;
}

.drawer-section:last-child {
  border-bottom: 0;
}

.drawer-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.drawer-section-title h3 {
  margin: 0;
}

.drawer-description {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.stage-list {
  display: grid;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  min-height: 50px;
}

.stage::before {
  position: absolute;
  top: 23px;
  bottom: -1px;
  left: 11px;
  width: 1px;
  background: var(--line);
  content: "";
}

.stage:last-child::before {
  display: none;
}

.stage-marker {
  z-index: 1;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--faint);
  background: var(--surface);
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.stage-marker svg {
  width: 11px;
}

.stage.is-done .stage-marker {
  border-color: var(--green);
  color: var(--on-accent);
  background: var(--green);
}

.stage.is-current .stage-marker {
  border: 5px solid var(--brand-soft);
  background: var(--brand);
}

.stage-copy {
  padding-bottom: 13px;
}

.stage-copy strong {
  display: block;
  font-size: 12px;
}

.stage-copy small {
  color: var(--muted);
  font-size: 11px;
}

/* Delegation and SLA ------------------------------------------------------ */

/* Both cards size to their own content; the grid would otherwise stretch the
   shorter one, leaving a large empty area under the cascade. */
.delegation-tree,
.delegation-panel {
  align-self: start;
  padding: 18px 20px 20px;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-lg);
  background: var(--glass-fill);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  box-shadow: var(--elev-1), inset 0 1px 0 var(--glass-highlight);
}

.delegation-list {
  margin-top: 6px;
}

.delegation-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

/* A select sizes to its widest option unless told not to. The task contour
   holds long task titles, which otherwise forced the layout viewport wider
   than the screen and pushed the fixed mobile tab bar off-screen. */
.delegation-toolbar .filter-select {
  min-width: 0;
  max-width: min(520px, 100%);
  flex: 1 1 320px;
  min-height: 38px;
}

/* Tags stay a tight cluster beside the select rather than being spread across
   the full toolbar width by the parent's space-between. */
.toolbar-tags {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar-tags .badge {
  flex: none;
}

@media (max-width: 700px) {
  /* flex-basis on the cross-axis-stretched column layout collapses the
     select's height, so pin it explicitly rather than flexing it. */
  .delegation-toolbar .filter-select {
    width: 100%;
    max-width: 100%;
    flex: none;
    height: 38px;
    min-height: 38px;
  }
}

.delegation-node {
  width: 100%;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.delegation-node .stage-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
}

.delegation-identity {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.delegation-node:hover .stage-copy {
  background: var(--glass-hover);
}

.delegation-node.is-focused .stage-copy {
  border-color: var(--line-strong);
  background: var(--glass-hover);
}

/* Co-executors are siblings at the same depth: parallel, never chained. The
   connector is suppressed on the last one so the cascade does not dangle. */
.delegation-node.level-2 {
  margin-left: 22px;
}

.delegation-node:last-child::before {
  display: none;
}

.delegation-node.level-2 .stage-marker {
  color: var(--blue);
}

.delegation-copy small {
  display: block;
}

.sla-meter {
  margin-top: 16px;
}

.sla-meter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.sla-track {
  position: relative;
  overflow: visible;
}

.sla-threshold {
  position: absolute;
  top: -2px;
  width: 1px;
  height: 9px;
  background: var(--line-strong);
}

.sla-threshold.is-crossed {
  background: var(--ink-soft);
}

.sla-note {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.key-value-list {
  display: grid;
}

.key-value {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.key-value:last-child {
  border-bottom: 0;
}

.key-value span {
  color: var(--muted);
}

.key-value strong {
  max-width: 62%;
  text-align: right;
}

.assignee-list {
  display: grid;
  gap: 9px;
}

.assignee-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.assignee-row:last-child {
  border-bottom: 0;
}

.assignee-row .person {
  flex: 1;
}

.timeline {
  display: grid;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr);
  gap: 9px;
  padding-bottom: 16px;
}

.timeline-item::before {
  position: absolute;
  top: 27px;
  bottom: 0;
  left: 13px;
  width: 1px;
  background: var(--line);
  content: "";
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-icon {
  z-index: 1;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface);
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.timeline-icon svg {
  width: 12px;
}

.timeline-copy p {
  margin-bottom: 2px;
  font-size: 12px;
}

.timeline-copy small {
  color: var(--muted);
  font-size: 11px;
}

.drawer-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  background: var(--glass-fill-strong);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--scrim);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  animation: fade-in 150ms ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--scrim);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 180ms ease-out both;
  backdrop-filter: blur(var(--blur-lg)) saturate(190%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(190%);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.modal-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  outline: 0;
  background: var(--surface);
  font-size: 13px;
  backdrop-filter: blur(var(--blur-sm)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(160%);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
}

.callout {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 15px;
  padding: 11px 12px;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  color: var(--blue-on-chip);
  font-size: 12px;
}

.callout svg {
  width: 15px;
  flex: 0 0 15px;
}

.callout.warning {
  border-color: var(--amber);
  color: var(--amber-on-chip);
  background: var(--amber-soft);
}

/* Anchored below the floating topbar: gutter + bar height + a small gap. */
.popover {
  position: fixed;
  top: calc(var(--gutter) * 2 + var(--topbar-height) + 6px);
  right: calc(var(--gutter) * 2);
  z-index: 90;
  width: min(360px, calc(100vw - 24px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 150ms ease-out both;
  backdrop-filter: blur(var(--blur-lg)) saturate(190%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(190%);
}

.popover-header {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.popover-header strong {
  font-size: 13px;
}

.notification-item {
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr);
  gap: 9px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.notification-item:last-child {
  border-bottom: 0;
}

.notification-item.is-unread {
  background: var(--brand-soft);
}

.notification-copy p {
  margin-bottom: 2px;
  color: var(--ink-soft);
  font-size: 12px;
}

.notification-copy small {
  color: var(--muted);
  font-size: 11px;
}

.user-popover {
  top: auto;
  right: auto;
  bottom: 70px;
  left: 14px;
  width: 216px;
}

.menu-list {
  display: grid;
  padding: 6px;
}

.menu-item {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.menu-item:hover {
  background: var(--glass-hover);
}

.menu-item svg {
  width: 15px;
  color: var(--muted);
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: grid;
  width: min(360px, calc(100vw - 40px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--glass-hairline);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: toast-in 220ms ease-out both;
  backdrop-filter: blur(var(--blur-lg)) saturate(190%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(190%);
}

.toast-icon {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  color: var(--on-accent);
  background: var(--green);
}

.toast-icon svg {
  width: 13px;
}

.toast-copy strong {
  display: block;
  font-size: 13px;
}

.toast-copy span {
  color: var(--muted);
  font-size: 11px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  :root {
    --sidebar-width: 76px;
  }

  .sidebar {
    padding-inline: 10px;
  }

  .brand {
    justify-content: center;
    padding-inline: 0;
  }

  .sidebar .brand-copy,
  .sidebar .nav-label,
  .sidebar .nav-count,
  .user-compact > svg {
    display: none;
  }

  .sidebar .nav-item,
  .user-compact {
    justify-content: center;
    padding-inline: 0;
  }

  .metric-strip {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .metric:nth-child(3) {
    border-right: 0;
  }

  .metric:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }

  .dashboard-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.75fr);
  }
}

@media (max-width: 920px) {
  :root {
    --gutter: 10px;
  }

  #app-content {
    padding: 24px 20px;
  }

  .topbar {
    padding-inline: 20px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .approval-layout {
    grid-template-columns: 290px minmax(380px, 1fr);
    overflow-x: auto;
  }

  .integration-summary,
  .rating-formula {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .integration-tile:nth-child(2),
  .formula-part:nth-child(2) {
    border-right: 0;
  }

  .integration-tile:nth-child(n + 3),
  .formula-part:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 700px) {
  :root {
    --sidebar-width: 0px;
    --topbar-height: 58px;
    --gutter: 8px;
  }

  body {
    padding-bottom: calc(62px + var(--gutter) * 2 + env(safe-area-inset-bottom));
  }

  /* Floating dock, inset from all three edges like the iOS home bar. */
  .sidebar {
    inset: auto var(--gutter) calc(var(--gutter) + env(safe-area-inset-bottom)) var(--gutter);
    z-index: 50;
    display: block;
    width: auto;
    height: 62px;
    padding: 5px 6px;
    overflow-x: auto;
    border: 1px solid var(--sidebar-hairline);
    border-radius: var(--r-xl);
    box-shadow: var(--elev-2);
  }

  .sidebar > .brand,
  .sidebar-footer {
    display: none;
  }

  .primary-nav {
    display: grid;
    width: 100%;
    min-width: 100%;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 0;
  }

  .sidebar .nav-item {
    display: grid;
    min-height: 51px;
    place-items: center;
    gap: 1px;
    padding: 4px 2px;
  }

  .sidebar .nav-label {
    display: block;
    width: 100%;
    flex: none;
    color: inherit;
    font-size: 10px;
    text-align: center;
  }

  .nav-item svg {
    width: 17px;
    height: 17px;
  }

  .workspace {
    margin-left: 0;
  }

  .topbar {
    gap: 8px;
    padding-inline: 14px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .global-search {
    width: auto;
    height: 36px;
    flex: 1;
  }

  .global-search kbd,
  .quarter-select {
    display: none;
  }

  .mobile-avatar {
    display: grid;
  }

  #app-content {
    padding: 20px 14px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
  }

  h1 {
    font-size: 21px;
  }

  .heading-actions .button {
    flex: 1;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-inline: -14px;
  }

  .metric {
    padding: 15px 14px;
  }

  .metric:nth-child(2n) {
    border-right: 0;
  }

  .metric:nth-child(3) {
    border-right: 1px solid var(--line);
  }

  .metric:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .metric:last-child {
    grid-column: 1 / -1;
  }

  .metric-value {
    font-size: 22px;
  }

  .chart-row {
    grid-template-columns: 96px minmax(100px, 1fr) 28px;
    gap: 8px;
  }

  .chart-person .avatar {
    display: none;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .mini-legend {
    justify-content: flex-start;
  }

  .page-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-search {
    width: 100%;
    grid-column: 1 / -1;
  }

  .toolbar-actions {
    justify-content: space-between;
  }

  .table-wrap {
    margin-inline: -14px;
  }

  .data-table th,
  .data-table td {
    padding: 11px 10px;
  }

  .approval-layout {
    display: block;
    min-height: 0;
    margin-inline: -14px;
    overflow: visible;
  }

  .approval-queue {
    border-right: 0;
  }

  .review-panel {
    border-top: 8px solid var(--canvas);
  }

  .review-body {
    padding: 18px 14px;
  }

  .meta-grid {
    grid-template-columns: 1fr 1fr;
  }

  .review-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .review-footer .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .integration-summary,
  .rating-formula {
    grid-template-columns: 1fr;
    margin-inline: -14px;
  }

  .integration-tile,
  .integration-tile:nth-child(2),
  .formula-part,
  .formula-part:nth-child(2) {
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .integration-tile:first-child,
  .formula-part:first-child {
    border-top: 0;
  }

  .score-components {
    width: 120px;
  }

  .detail-drawer {
    top: 8vh;
    width: 100vw;
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .drawer-body {
    padding: 18px 16px;
  }

  .popover {
    top: 52px;
    right: 12px;
  }

  .user-popover {
    top: 52px;
    right: 12px;
    bottom: auto;
    left: auto;
  }

  .modal-layer {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-full {
    grid-column: auto;
  }

  .toast-region {
    right: 12px;
    bottom: 74px;
    width: calc(100vw - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Transparency fallbacks.

   Glass degrades to solid fills wherever blur is unavailable or unwanted. The
   token swap is enough on its own: every glass surface reads --glass-fill,
   so redefining it here converts the whole console in one place.
   ========================================================================== */

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root {
    --glass-fill: #ffffff;
    --glass-fill-strong: #ffffff;
    --glass-fill-soft: #fafbfc;
    --glass-hover: #eaf2fd;
    --sidebar: #ffffff;
  }

  :root[data-theme="dark"] {
    --glass-fill: #161b23;
    --glass-fill-strong: #1b212a;
    --glass-fill-soft: #1b212a;
    --glass-hover: #16283e;
    --sidebar: #161b23;
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --glass-fill: #ffffff;
    --glass-fill-strong: #ffffff;
    --glass-fill-soft: #fafbfc;
    --glass-hover: #eaf2fd;
    --sidebar: #ffffff;
    --scrim: rgba(12, 20, 33, 0.7);
  }

  *,
  *::before,
  *::after {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .app-shell::before {
    background: var(--canvas);
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root[data-theme="dark"] {
    --glass-fill: #161b23;
    --glass-fill-strong: #1b212a;
    --glass-fill-soft: #1b212a;
    --glass-hover: #16283e;
    --sidebar: #161b23;
  }
}

/* Blur is expensive to composite; drop it when motion is also unwelcome. */
@media (prefers-reduced-motion: reduce) {
  .app-shell::before {
    background: var(--canvas);
  }
}
