/* ============================================================================
   PiE Design System v2  ·  "clean lines" (Apple / Microsoft-inspired)
   Neutral canvas, generous whitespace, crisp type, PiE maroon as a sparing
   accent. Shared by the marketing site AND the product app so they match.
   Link it: <link rel="stylesheet" href="pie-design.css">
   ============================================================================ */

:root {
  /* Brand accent (used sparingly) */
  --pie-maroon: #6E1423;
  --pie-maroon-700: #58101C;
  --pie-maroon-50: #FBEFF1;
  --pie-gold: #C99A2E;
  --pie-gold-50: #FBF4E3;

  /* Neutral canvas (the dominant palette).
     Tightened for a crisp, dense, enterprise feel: cooler greys, slightly
     firmer hairlines, a calmer app canvas. */
  --ink: #16181D;          /* primary text */
  --ink-2: #41454F;        /* secondary text */
  --muted: #707784;        /* tertiary / captions */
  --line: #E4E6EB;         /* hairline borders */
  --line-2: #EEF0F3;       /* faint dividers (zebra, inner rules) */
  --line-strong: #D3D6DD;  /* hover / emphasis borders */
  --bg: #FFFFFF;           /* page */
  --bg-soft: #F6F7F9;      /* sections / app chrome */
  --bg-sidebar: #FAFBFC;   /* app sidebar canvas */
  --surface: #FFFFFF;      /* cards */

  /* Status */
  --green: #1E7D4F; --green-bg: #E9F6EF;
  --amber: #9A6B12; --amber-bg: #FBF1DC;
  --red: #B42318;   --red-bg: #FCEBEA;
  --blue: #2563A8;  --blue-bg: #EAF1FA;

  /* Type scale */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-display: clamp(2.4rem, 5vw, 4rem);
  --fs-h1: clamp(1.9rem, 3.4vw, 2.7rem);
  --fs-h2: 1.45rem;
  --fs-h3: 1.1rem;
  --fs-body: 0.95rem;
  --fs-sm: 0.85rem;
  --fs-xs: 0.76rem;

  /* Shape + depth (subtle).
     Tighter radii for a crisper enterprise read; shadows kept light so cards
     rely on a 1px border plus a whisper of depth, never a heavy drop. */
  --r-sm: 6px; --r: 9px; --r-lg: 14px; --r-pill: 999px;
  --shadow-sm: 0 1px 1px rgba(16,18,23,.04), 0 1px 2px rgba(16,18,23,.05);
  --shadow: 0 2px 6px rgba(16,18,23,.05), 0 1px 2px rgba(16,18,23,.04);
  --shadow-lg: 0 12px 36px rgba(16,18,23,.13), 0 2px 8px rgba(16,18,23,.07);
  --ring: 0 0 0 3px var(--pie-maroon-50);

  /* Spacing rhythm */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  --sp-6: 32px; --sp-7: 48px; --sp-8: 64px; --sp-9: 96px;

  /* App shell metrics (consumed by the product layout). */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 60px;
  --content-maxw: 1240px;

  --maxw: 1160px;
  --ease: cubic-bezier(.16,.84,.44,1);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background: var(--bg); font-size: var(--fs-body); line-height: 1.55;
}
h1,h2,h3,h4 { line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: var(--fs-h1); } h2 { font-size: var(--fs-h2); } h3 { font-size: var(--fs-h3); }
p { margin: 0 0 1em; color: var(--ink-2); }
a { color: var(--pie-maroon); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .text-sm { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.display { font-size: var(--fs-display); font-weight: 700; letter-spacing: -.03em; line-height: 1.05; }

/* Layout */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.section { padding: var(--sp-9) 0; }
.section.tight { padding: var(--sp-7) 0; }
.bg-soft { background: var(--bg-soft); }
.grid { display: grid; gap: var(--sp-5); }
.row { display: flex; gap: var(--sp-4); }
.center { text-align: center; }
.stack > * + * { margin-top: var(--sp-4); }

/* Logo mark: maroon rounded square with white "P" + gold dot */
.pie-logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.pie-logo .mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--pie-maroon);
  display: inline-grid; place-items: center; position: relative; flex: 0 0 auto;
}
.pie-logo .mark span { color: #fff; font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 19px; line-height: 1; }
.pie-logo .mark::after { content: ""; position: absolute; right: 6px; bottom: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--pie-gold); }

/* Buttons.
   Enterprise refinement: a crisp 6px radius (the marketing pill is opt-in via
   .btn-pill), tighter padding, one focus ring, restrained depth. One primary
   per region; ghost and dark cover the rest. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: var(--fs-sm); cursor: pointer;
  padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid transparent;
  line-height: 1.2; letter-spacing: -.005em;
  transition: transform .12s var(--ease), background .15s, box-shadow .15s, border-color .15s, color .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn:disabled { opacity: .6; cursor: default; pointer-events: none; }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn-primary { background: var(--pie-maroon); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }
.btn-primary:hover { background: var(--pie-maroon-700); text-decoration: none; box-shadow: var(--shadow-sm); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line-strong); text-decoration: none; box-shadow: var(--shadow-sm); }
.btn-soft { background: var(--bg-soft); color: var(--ink-2); border-color: transparent; }
.btn-soft:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.btn-gold { background: var(--pie-gold); color: #2a2310; }
.btn-gold:hover { filter: brightness(.97); text-decoration: none; }
.btn-pill { border-radius: var(--r-pill); }
.btn-lg { padding: 13px 22px; font-size: 1rem; border-radius: var(--r); }
.btn-sm { padding: 6px 11px; font-size: var(--fs-xs); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }
/* Icon-only square button (toolbars, row actions). */
.btn-icon { padding: 7px; width: 32px; height: 32px; }
.btn-icon.btn-sm { padding: 5px; width: 28px; height: 28px; }

/* Cards + surfaces.
   Enterprise card: 1px border plus a whisper of shadow, crisp radius. */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-5); box-shadow: var(--shadow-sm); }
.card.flat { box-shadow: none; }
.card.lift { transition: transform .16s var(--ease), box-shadow .16s, border-color .16s; }
.card.lift:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.divider { height: 1px; background: var(--line); border: 0; margin: var(--sp-5) 0; }

/* Inputs.
   Consistent focus ring (maroon border plus tint) across text, select,
   textarea; tighter padding and radius for density. */
.field { display: block; margin-bottom: var(--sp-4); }
.field > label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=tel], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: var(--fs-sm); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 11px;
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
.input:focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pie-maroon); box-shadow: var(--ring); }
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--line-strong); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23707784' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

/* Badges / pills */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 600; padding: 2px 9px; border-radius: var(--r-pill); background: var(--bg-soft); color: var(--ink-2); border: 1px solid var(--line); line-height: 1.5; }
.badge.green { background: var(--green-bg); color: var(--green); border-color: transparent; }
.badge.amber { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.badge.red { background: var(--red-bg); color: var(--red); border-color: transparent; }
.badge.blue { background: var(--blue-bg); color: var(--blue); border-color: transparent; }
.badge.maroon { background: var(--pie-maroon-50); color: var(--pie-maroon); border-color: transparent; }
.eyebrow { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--pie-maroon); }

/* Tables.
   Enterprise data table: sticky header, compact rows, clear hover, tabular
   numerals, right-aligned numbers via .num / [data-num]. Optional zebra via
   .table.zebra. Applied app-wide through the shared .table class. */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: .04em; padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: var(--bg-soft); white-space: nowrap;
}
.table thead th { position: sticky; top: 0; z-index: 2; }
/* Bare tables (no .table-wrap) scroll with the page under the sticky topbar:
   park the sticky header just below the bar so it never hides behind it. */
.content-inner .table thead th { top: var(--topbar-h); }
.table-wrap .table thead th { top: 0; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: var(--bg-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table.zebra tbody tr:nth-child(even) td { background: rgba(246,247,249,.6); }
.table.zebra tbody tr:hover td { background: var(--bg-soft); }
.table .num, .table [data-num], .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
/* Table wrapper: rounds + scrolls wide tables, keeps the sticky header crisp. */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.table-wrap .table { border-radius: inherit; }
.table-wrap .table th { border-top: 0; }

/* Top nav (marketing + app share the pattern) */
.nav { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.82); backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid var(--line); }
.nav .inner { max-width: var(--maxw); margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav .links { display: flex; align-items: center; gap: 22px; }
.nav .links a { color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500; }
.nav .links a:hover { color: var(--ink); text-decoration: none; }

/* Hero (marketing) */
.hero { padding: var(--sp-9) 0 var(--sp-8); }
.hero .display { max-width: 16ch; }
.hero p.lead { font-size: 1.18rem; color: var(--ink-2); max-width: 56ch; }

/* Footer */
.footer { background: var(--bg-soft); border-top: 1px solid var(--line); padding: var(--sp-7) 0; color: var(--muted); font-size: var(--fs-sm); }

/* Utilities */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.mt-2{margin-top:var(--sp-2)} .mt-4{margin-top:var(--sp-4)} .mt-6{margin-top:var(--sp-6)}
.hide-sm { }
@media (max-width: 760px) {
  .nav .links { display: none; }
  .section { padding: var(--sp-7) 0; }
  .grid { gap: var(--sp-4); }
}

/* ============================================================================
   ENTERPRISE APP SHELL  ·  fixed left sidebar + sticky top bar + content
   Used by the product app only (the marketing site keeps the top .nav).
   Layout: a grid with a fixed-width sidebar column and a fluid content column.
   States: .is-collapsed (icons-only, >=760px) and .is-drawer (off-canvas).
   ============================================================================ */
.app {
  --sb: var(--sidebar-w);
  display: grid;
  grid-template-columns: var(--sb) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg-soft);
}
.app.is-collapsed { --sb: var(--sidebar-w-collapsed); }

/* ---- Sidebar ---- */
.sidebar {
  grid-column: 1; position: sticky; top: 0; align-self: start;
  height: 100vh; width: var(--sb);
  display: flex; flex-direction: column;
  background: var(--bg-sidebar); border-right: 1px solid var(--line);
  z-index: 40; transition: width .18s var(--ease);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; height: var(--topbar-h);
  padding: 0 16px; border-bottom: 1px solid var(--line); flex: none;
  overflow: hidden;
}
.sidebar-brand .pie-logo { font-size: 1.05rem; }
.app.is-collapsed .sidebar-brand { padding: 0; justify-content: center; }
.app.is-collapsed .sidebar-brand .pie-logo span:last-child,
.app.is-collapsed .sidebar-brand .brand-word { display: none; }

.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px; }
.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

.nav-section { padding: 0 0 10px; }
.nav-section + .nav-section { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 4px 10px 8px;
}
.app.is-collapsed .nav-section-label { opacity: 0; height: 6px; padding: 0; }

.nav-link {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin: 1px 0; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background .14s var(--ease), color .14s;
}
.nav-link:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.nav-link .nav-ico { flex: none; width: 18px; height: 18px; display: grid; place-items: center; color: var(--muted); transition: color .14s; }
.nav-link .nav-ico svg { width: 18px; height: 18px; display: block; }
.nav-link .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-link:hover .nav-ico { color: var(--ink-2); }
.nav-link.active { background: var(--pie-maroon-50); color: var(--pie-maroon); font-weight: 600; }
.nav-link.active .nav-ico { color: var(--pie-maroon); }
.nav-link.active::before {
  content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--pie-maroon);
}
.app.is-collapsed .nav-link { justify-content: center; padding: 9px 0; }
.app.is-collapsed .nav-link .nav-label { display: none; }
.app.is-collapsed .nav-link.active::before { left: 0; }

.sidebar-foot { flex: none; border-top: 1px solid var(--line-2); padding: 10px; }

/* Collapse toggle (desktop, lives at the sidebar foot). */
.sb-collapse {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 10px; border: none; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: var(--fs-sm); font-weight: 500;
  border-radius: var(--r-sm); transition: background .14s, color .14s;
}
.sb-collapse:hover { background: var(--line-2); color: var(--ink); }
.sb-collapse .nav-ico { flex: none; width: 18px; height: 18px; display: grid; place-items: center; }
.sb-collapse .nav-ico svg { width: 18px; height: 18px; transition: transform .18s var(--ease); }
.app.is-collapsed .sb-collapse { justify-content: center; padding: 9px 0; }
.app.is-collapsed .sb-collapse .nav-label { display: none; }
.app.is-collapsed .sb-collapse .nav-ico svg { transform: rotate(180deg); }

/* ---- Content column ---- */
.content { grid-column: 2; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

/* ---- Top bar (sticky, within the content column) ---- */
.topbar {
  position: sticky; top: 0; z-index: 35; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-lead { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.topbar-title .tb-crumb { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.topbar-title .tb-crumb a { color: var(--muted); }
.topbar-title .tb-crumb a:hover { color: var(--pie-maroon); text-decoration: none; }
.topbar-title .tb-h { font-size: 15px; font-weight: 650; color: var(--ink); letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-spacer { flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }

/* Hamburger + collapse buttons in the top bar. */
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 1px solid transparent; background: none; border-radius: var(--r-sm);
  color: var(--ink-2); cursor: pointer; transition: background .14s, border-color .14s, color .14s;
}
.icon-btn svg { width: 19px; height: 19px; display: block; }
.icon-btn:hover { background: var(--bg-soft); border-color: var(--line); color: var(--ink); }
.topbar-hamburger { display: none; }

/* Kbd hint chip inside the command search. */
.kbd-hint { display: inline-flex; align-items: center; gap: 2px; flex: none;
  font-size: 10px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; line-height: 1.5; font-family: var(--font); }

/* ---- Content scroll region: page padding + max-width container ---- */
.content-body { flex: 1; }
.content-inner { max-width: var(--content-maxw); margin: 0 auto; padding: 28px 28px 72px; }

/* ---- Drawer (mobile off-canvas) ---- */
.sidebar-scrim { display: none; }
@media (min-width: 761px) {
  .topbar-collapse { display: inline-grid; }
}

/* Icons-only collapse engages by class >=761px (set by JS / localStorage). */

/* Under 760px: sidebar becomes an off-canvas drawer; hamburger appears. */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-w);
    transform: translateX(-100%); transition: transform .2s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .app.is-drawer-open .sidebar { transform: translateX(0); }
  .app.is-drawer-open .sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: 38;
    background: rgba(16,18,23,.4); animation: scrimIn .18s var(--ease);
  }
  @keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }
  .content { grid-column: 1; }
  .topbar-hamburger { display: inline-grid; }
  .topbar-collapse { display: none; }
  .sb-collapse { display: none; }
  .content-inner { padding: 20px 16px 60px; }
  /* When drawer is open the sidebar is full-width nav, never collapsed. */
  .app.is-drawer-open .sidebar .nav-link .nav-label,
  .app.is-drawer-open .sidebar .nav-section-label { display: block; opacity: 1; }
}

/* ============================================================================
   SKELETON / LOADING placeholders (calm shimmer, reduced-motion safe).
   ============================================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--line-2) 25%, var(--line) 37%, var(--line-2) 63%);
  background-size: 400% 100%; border-radius: var(--r-sm);
  animation: skel 1.3s ease-in-out infinite;
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-line { height: 12px; margin: 8px 0; }
.skel-line.sm { width: 40%; } .skel-line.md { width: 65%; } .skel-line.lg { width: 90%; }
.skel-card { height: 84px; border-radius: var(--r); }

/* ---- case completeness (ring + checklist) ---- */
.comp-ring { display: inline-flex; line-height: 0; }
.comp-ring-track { stroke: var(--line); }
.comp-ring-fill { stroke: var(--muted); transition: stroke-dashoffset .6s ease; }
.comp-ring.green .comp-ring-fill { stroke: var(--green); }
.comp-ring.amber .comp-ring-fill { stroke: var(--amber); }
.comp-ring.red .comp-ring-fill { stroke: var(--red); }
.comp-ring-text { font-family: var(--font); font-weight: 700; font-size: 11px; fill: var(--ink); }
.comp-ring-text.big { font-size: 20px; }
.comp-ring.green .comp-ring-text { fill: var(--green); }
.comp-ring.amber .comp-ring-text { fill: var(--amber); }
.comp-ring.red .comp-ring-text { fill: var(--red); }

/* dashboard triage card indicator */
.tcard-comp { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.tcard-comp-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }

/* overview completeness card */
.comp-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.comp-head-pct { font-size: var(--fs-xl, 24px); font-weight: 700; color: var(--ink); line-height: 1.1; }
.comp-head-sub { font-size: var(--fs-sm); }
.comp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.comp-item { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.comp-item .comp-mark { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 999px; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.comp-item.done .comp-mark { background: var(--green-bg); color: var(--green); }
.comp-item.todo .comp-mark { background: var(--bg-soft); color: var(--muted); }
.comp-item.done .comp-item-label { color: var(--ink-2); }
.comp-item.todo .comp-item-label { color: var(--muted); }

/* slim bar fallback (available for narrow contexts) */
.comp-bar { height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.comp-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--muted); transition: width .6s ease; }
.comp-bar.green > span { background: var(--green); }
.comp-bar.amber > span { background: var(--amber); }
.comp-bar.red > span { background: var(--red); }

/* ===================== COMMAND PALETTE (Cmd K) ===================== */
/* Top-bar trigger: a compact, fixed-size pill. Never overlays the page. */
.cmdk-trigger { display: inline-flex; align-items: center; gap: 8px; flex: none;
  max-width: 240px; height: 34px; padding: 0 10px 0 11px; cursor: pointer;
  background: var(--bg-soft); color: var(--ink-2); border: 1px solid var(--line);
  border-radius: var(--r-pill); font: inherit; font-size: var(--fs-sm);
  transition: border-color .15s, box-shadow .15s, background .15s; }
.cmdk-trigger:hover { background: var(--surface); border-color: var(--pie-maroon-50); }
.cmdk-trigger:focus-visible { outline: none; border-color: var(--pie-maroon); box-shadow: var(--ring); }
.cmdk-trigger .ck-ico { display: inline-grid; place-items: center; flex: none; color: var(--muted); }
.cmdk-trigger .ck-ico svg { width: 16px; height: 16px; }
.cmdk-trigger .ck-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; text-align: left; color: var(--muted); }
.cmdk-trigger .ck-hint { flex: none; font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; line-height: 1.4; }

/* The backdrop: a dimmed full-screen layer above the sticky top bar and all
   content. Clicking it (outside the modal) closes the palette. */
.cmdk-overlay { position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 11vh 16px 16px; background: rgba(22, 24, 29, .46);
  animation: cmdkFade .12s ease-out; }
body.cmdk-lock { overflow: hidden; }

/* The centered panel: the design-system card surface, rounded, shadow-lg. */
.cmdk-modal { width: 100%; max-width: 640px; max-height: 80vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: cmdkRise .14s ease-out; }

/* Always-visible large input row with a left magnifier. No overlap, no clip. */
.cmdk-inputbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--line); }
.cmdk-inputbar .cmdk-ico { display: inline-grid; place-items: center; flex: none; color: var(--muted); }
.cmdk-inputbar .cmdk-ico svg { width: 20px; height: 20px; }
.cmdk-input { flex: 1 1 auto; min-width: 0; border: none; outline: none; background: none;
  font: inherit; font-size: 1.05rem; color: var(--ink); padding: 2px 0; }
.cmdk-input::placeholder { color: var(--muted); }
.cmdk-inputbar:focus-within { box-shadow: inset 0 -2px 0 var(--pie-maroon); }
.cmdk-esc { flex: none; font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; line-height: 1.4; }

/* Scrollable results region hosting the same magic-search output as before. */
.cmdk-region { overflow: auto; max-height: 60vh; padding: 6px; }
.cmdk-list { display: block; }
.cmdk-empty { padding: 26px 18px; text-align: center; color: var(--muted); font-size: var(--fs-sm); line-height: 1.55; }

@media (max-width: 760px) {
  /* Collapse the command trigger to an icon button with a comfortable tap size. */
  .cmdk-trigger { max-width: none; width: 40px; height: 40px; padding: 0; justify-content: center; }
  .cmdk-trigger .ck-label, .cmdk-trigger .ck-hint { display: none; }
  /* Near full-width palette with a visible input on phones. */
  .cmdk-overlay { padding: 7vh 10px 10px; }
  .cmdk-modal { max-width: none; max-height: 86vh; }
  .cmdk-input { font-size: 16px; }
}

@keyframes cmdkFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cmdkRise { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .sidebar, .nav-link, .icon-btn, .sb-collapse, .app, .topbar { transition: none !important; }
  .comp-ring-fill, .comp-bar > span { transition: none !important; }
  .cmdk-overlay { animation: cmdkFade .1s ease-out; }
  .cmdk-modal { animation: cmdkFade .1s ease-out; }
}

/* ============================================================================
   RESPONSIVE PASS  ·  phones (about 360px to 430px) and tablets, desktop
   layout left intact. Breakpoints: 1100px (tablet), 760px (mobile drawer),
   560px (stacked cards), 480px (small phone). Reuses the design tokens above.
   ============================================================================ */

/* ---- Tablet (<=1100px): tighten the content gutter and stat density. ---- */
@media (max-width: 1100px) {
  .content-inner { padding: 24px 22px 64px; }
}

/* ---- Mobile (<=760px): readable base type, scaled headings, no overflow. ---- */
@media (max-width: 760px) {
  /* Lift base body text to a comfortable mobile reading size and relax the
     compact enterprise type scale so labels, inputs, and table cells read. */
  :root {
    --fs-body: 1rem;     /* about 16px */
    --fs-sm: 0.9rem;     /* about 14.4px */
    --fs-xs: 0.8rem;     /* about 12.8px */
    --fs-h1: clamp(1.5rem, 6.4vw, 1.95rem);
    --fs-h2: 1.3rem;
    --fs-h3: 1.06rem;
    --fs-display: clamp(2rem, 8vw, 2.7rem);
  }
  body { line-height: 1.5; }

  /* Headings never run off screen (the "Good morning, Maria" h1 included). */
  h1, h2, h3 { overflow-wrap: anywhere; word-break: break-word; }

  /* Every wide data table scrolls inside its wrapper rather than the page.
     The wrapper is added at render time so this guarantees no page overflow. */
  .table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
  .table { min-width: 560px; }
  /* Bare tables that somehow escaped the wrapper still cannot break layout. */
  .content-inner table.table { display: block; max-width: 100%; overflow-x: auto; }

  /* Touch targets: buttons and icon controls reach at least about 40px. */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .icon-btn { width: 40px; height: 40px; }
  .nav-link { padding: 11px 10px; }

  /* Drawer fits a small phone: cap its width so it never overflows the screen. */
  .sidebar { width: min(86vw, var(--sidebar-w)); }
  .app.is-drawer-open .sidebar { transform: translateX(0); }

  /* Top bar cluster: keep brand/hamburger left, search + Me reachable, nothing
     overflowing. The command trigger collapses to an icon (rules in cmdk block). */
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar-lead { min-width: 0; }
  .topbar-right { gap: 6px; }
}

/* ---- Stacked cards (<=560px): the most important lists become labeled
   blocks. The render-time wrapper carries .table-wrap; we restyle the inner
   table so each row is a readable card with label: value pairs. Header is
   visually hidden and each cell carries its column name via data-label.
   Tables opt in by setting data-stack="card" (left as scroll otherwise). ---- */
@media (max-width: 560px) {
  .table-wrap[data-stack="card"], .table-wrap.stack-card { border: 0; background: transparent; overflow: visible; }
  .table-wrap[data-stack="card"] .table,
  .table-wrap.stack-card .table { min-width: 0; display: block; }
  .table-wrap[data-stack="card"] .table thead,
  .table-wrap.stack-card .table thead { position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-wrap[data-stack="card"] .table tbody,
  .table-wrap.stack-card .table tbody { display: block; }
  .table-wrap[data-stack="card"] .table tr,
  .table-wrap.stack-card .table tr { display: block; border: 1px solid var(--line);
    border-radius: var(--r-sm); background: var(--surface); padding: 6px 4px; margin-bottom: 10px;
    box-shadow: var(--shadow-sm); }
  .table-wrap[data-stack="card"] .table td,
  .table-wrap.stack-card .table td { display: flex; align-items: baseline; justify-content: space-between;
    gap: 14px; padding: 7px 12px; border: 0; text-align: right; }
  .table-wrap[data-stack="card"] .table td::before,
  .table-wrap.stack-card .table td::before { content: attr(data-label); flex: none; text-align: left;
    font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase;
    letter-spacing: .04em; }
  .table-wrap[data-stack="card"] .table td:empty,
  .table-wrap.stack-card .table td:empty { display: none; }
}

/* ---- Small phone (<=480px): trim the gutter, keep padding present. ---- */
@media (max-width: 480px) {
  .content-inner { padding: 16px 12px 52px; }
  .card { padding: var(--sp-4); }
  .btn-lg { padding: 12px 18px; }
}
