/* =============================================================================
   candidlabs · app.css
   Shell + components for the platform. Consumes tokens.css only.
   Tuned to the approved review design (light + dark from one token set).
   ========================================================================== */

/* ---------------------------------------------------------------------------
   0. Base
--------------------------------------------------------------------------- */
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; }
.u-mono { font-family: var(--font-mono); }
.u-muted { color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   1. Wordmark — two-tone, candid (white) + labs (blue). Always on a charcoal
   chip so "candid" reads on any surface. RS-004.
--------------------------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.brand__candid { color: var(--brand-charcoal); }
.brand__labs   { color: var(--brand-primary); }
[data-theme="dark"] .brand__candid { color: #ffffff; }

/* ---------------------------------------------------------------------------
   2. Top bar
--------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: var(--topbar-height);
  padding: 0 var(--container-pad);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-default);
}
.topnav {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}
.topnav__link {
  display: inline-flex;
  align-items: center;
  height: var(--topbar-height);
  padding: 0 2px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
}
.topnav__link:hover { color: var(--text-primary); }
.topnav__link.is-active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: var(--weight-semibold);
}
.topbar__spacer { flex: 1; }
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.search {
  width: 240px;
  height: 34px;
  padding: 0 12px;
  background: var(--bg-sunken);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: border-color var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard);
}
.search::placeholder { color: var(--text-muted); }
.search:focus {
  background: var(--bg-secondary);
  border-color: var(--brand-primary);
  outline: none;
  box-shadow: var(--shadow-focus);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard);
}
.icon-btn:hover { color: var(--text-primary); background: var(--bg-sunken); }
.icon-btn .sun  { display: none; }
[data-theme="dark"] .icon-btn .sun  { display: block; }
[data-theme="dark"] .icon-btn .moon { display: none; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  cursor: pointer;
}

/* Avatar dropdown — admin menu + sign out */
.user-menu { position: relative; }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 224px;
  padding: var(--space-2);
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 60;
}
.user-menu.is-open .user-dropdown { display: block; }
.user-dropdown__email { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); color: var(--text-muted); }
.user-dropdown__divider { height: 1px; margin: var(--space-2) calc(var(--space-2) * -1); background: var(--border-subtle); }
.user-dropdown__link {
  display: block;
  width: 100%;
  padding: 8px var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  background: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.user-dropdown__link:hover { background: var(--bg-sunken); color: var(--text-primary); }
.user-dropdown__link--danger { color: var(--status-error); }
.user-dropdown__link--danger:hover { background: var(--status-error-soft); color: var(--status-error); }

/* ---------------------------------------------------------------------------
   3. Shell — rail + main
--------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  align-items: start;
  min-height: calc(100vh - var(--topbar-height));
}
.shell.is-rail-collapsed { grid-template-columns: 0 minmax(0, 1fr); }

.rail {
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  transition: width var(--dur-base) var(--ease-standard),
              opacity var(--dur-fast) var(--ease-standard);
}
.shell.is-rail-collapsed .rail {
  width: 0; opacity: 0; pointer-events: none; overflow: hidden;
}
.rail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-4) var(--space-3);
}
.rail__label {
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
}
.rail__toggle, .rail__reopen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
}
.rail__toggle:hover, .rail__reopen:hover {
  color: var(--brand-primary); border-color: var(--brand-primary);
}
.rail__nav { display: flex; flex-direction: column; gap: 1px; padding: 0 var(--space-2); }
.rail__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: color var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard);
}
.rail__link::before {
  content: "";
  position: absolute;
  inset: 7px auto 7px 0;
  width: 3px;
  background: var(--brand-primary);
  border-radius: 0 2px 2px 0;
  transform: scaleY(0);
  transition: transform var(--dur-base) var(--ease-emphasis);
}
.rail__link:hover { color: var(--text-primary); background: var(--bg-sunken); }
.rail__link.is-active {
  color: var(--brand-primary);
  background: var(--brand-primary-soft);
  font-weight: var(--weight-semibold);
}
.rail__link.is-active::before { transform: scaleY(1); }
.rail__dot {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.rail__foot { margin-top: auto; padding: var(--space-4); }
.rail__reopen { display: none; margin-bottom: var(--space-4); }
.shell.is-rail-collapsed .rail__reopen { display: inline-flex; }

/* ---------------------------------------------------------------------------
   4. Main column + page header
--------------------------------------------------------------------------- */
.main {
  min-width: 0;
  padding: var(--space-7) var(--container-pad) var(--space-9);
}
.main--wide { max-width: var(--container-max); margin: 0 auto; width: 100%; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
}
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--text-secondary); }
.breadcrumb__sep { opacity: 0.5; }
.breadcrumb [aria-current="page"] { color: var(--brand-primary); font-weight: var(--weight-semibold); }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}
.page-head__title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.page-head__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-2);
}
.page-head__sub {
  font-size: var(--text-md);
  color: var(--text-secondary);
}
.page-head__actions { display: flex; gap: var(--space-2); flex-shrink: 0; }

/* ---------------------------------------------------------------------------
   5. Tags / pills / status
--------------------------------------------------------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
}
.tag--solid { background: var(--brand-primary-soft); color: var(--brand-primary); }
.tag--outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-strong); }
.tag__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.status--good { background: var(--status-success-soft); color: var(--status-success); }
.status--warn { background: var(--status-warning-soft); color: var(--status-warning); }
.status--info { background: var(--status-info-soft); color: var(--status-info); }
.status--neutral { background: var(--status-neutral-soft); color: var(--status-neutral); }

/* ---------------------------------------------------------------------------
   6. Buttons
--------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 38px;
  padding: 0 var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard);
}
.btn:hover { border-color: var(--text-muted); background: var(--bg-sunken); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-on-brand);
}
.btn--primary:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--bg-sunken); color: var(--text-primary); }
.btn--sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn--lg { height: 44px; padding: 0 var(--space-6); font-size: var(--text-md); }

/* ---------------------------------------------------------------------------
   7. KPI row
--------------------------------------------------------------------------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(var(--kpi-cols, 3), 1fr);
  gap: var(--space-6);
  padding: var(--space-5) var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi + .kpi { position: relative; }
.kpi + .kpi::before {
  content: "";
  position: absolute;
  left: calc(var(--space-6) / -1 * 0.5 - 0px);
  top: 4px; bottom: 4px;
  width: 1px;
  background: var(--border-subtle);
}
.kpi__label {
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
}
.kpi__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  line-height: 1.1;
}
.kpi__meta { font-size: var(--text-sm); color: var(--text-secondary); }
.kpi__meta--up { color: var(--status-success); }
.kpi__meta--down { color: var(--status-error); }
.kpis--dense .kpi__value { font-size: var(--text-2xl); }

/* ---------------------------------------------------------------------------
   8. Cards & layout grids
--------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5) var(--space-6);
}
.card--flush { padding: 0; }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.card__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--text-primary); }
.card__sub { margin-top: 2px; font-size: var(--text-sm); color: var(--text-secondary); }

.link {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--brand-primary);
  text-decoration: none;
}
.link:hover { color: var(--brand-primary-hover); }

.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--space-6);
  align-items: start;
}
.section-block { margin-top: var(--space-6); }
.section-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

/* ---------------------------------------------------------------------------
   9. Activity timeline
--------------------------------------------------------------------------- */
.activity { display: flex; flex-direction: column; }
.activity__row {
  display: grid;
  grid-template-columns: 48px 16px 1fr;
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
}
.activity__row + .activity__row { border-top: 1px solid var(--border-subtle); }
.activity__date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-top: 2px;
}
.activity__dot {
  width: 8px; height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--brand-primary);
}
.activity__text { font-size: var(--text-sm); color: var(--text-secondary); line-height: var(--leading-snug); }
.activity__text strong { color: var(--text-primary); font-weight: var(--weight-semibold); }

/* ---------------------------------------------------------------------------
   10. Meter list (SKU mix / breakdowns)
--------------------------------------------------------------------------- */
.aside-title {
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}
.meters { display: flex; flex-direction: column; gap: var(--space-4); }
.meter { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: var(--space-3); }
.meter__swatch { width: 14px; height: 14px; border-radius: var(--radius-sm); }
.meter__body { min-width: 0; }
.meter__name { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-primary); }
.meter__sub { font-size: var(--text-xs); color: var(--text-muted); }
.meter__track {
  height: 6px;
  margin-top: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  overflow: hidden;
}
.meter__fill { height: 100%; border-radius: var(--radius-pill); background: var(--brand-primary); }
.meter__val { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); }

/* ---------------------------------------------------------------------------
   11. People list (contacts)
--------------------------------------------------------------------------- */
.people { display: flex; flex-direction: column; gap: var(--space-3); }
.person { display: flex; align-items: center; gap: var(--space-3); }
.person__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-pill);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}
.person__name { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-primary); }
.person__role { font-size: var(--text-xs); color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   12. Module cards (section overviews) — open tools in situ where possible
--------------------------------------------------------------------------- */
.modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: var(--space-4);
}
.module {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
}
.module:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-default); }
.module__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}
.module__title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-primary); }
.module__desc { font-size: var(--text-sm); color: var(--text-secondary); line-height: var(--leading-snug); }
.module__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--brand-primary);
}

/* ---------------------------------------------------------------------------
   13. Table
--------------------------------------------------------------------------- */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table thead th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border-default);
}
.table tbody td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur-fast) var(--ease-standard); }
.table tbody tr:hover { background: var(--bg-sunken); }
.table td strong { color: var(--text-primary); font-weight: var(--weight-semibold); }
.table .num { text-align: right; font-family: var(--font-mono); }

/* ---------------------------------------------------------------------------
   14. Toolbar (filters row) — pills + segmented
--------------------------------------------------------------------------- */
.toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.toolbar__spacer { flex: 1; min-width: 0; }
.pills { display: inline-flex; flex-wrap: wrap; gap: var(--space-2); }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard);
}
.pill:hover { color: var(--text-primary); border-color: var(--border-strong); }
.pill.is-active { color: var(--brand-primary); background: var(--brand-primary-soft); border-color: transparent; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-sunken); border-radius: var(--radius-md); }
.seg__btn {
  height: 28px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
}
.seg__btn:hover { color: var(--text-primary); }
.seg__btn.is-active { background: var(--bg-secondary); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* Tabs — views within a destination (underline). Never duplicates the rail. */
.tabs {
  display: flex;
  gap: var(--space-7);
  border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--space-6);
  overflow-x: auto;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 2px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-standard);
}
.tab::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  background: var(--brand-primary);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-base) var(--ease-emphasis);
}
.tab:hover { color: var(--text-primary); }
.tab.is-active,
.tab[aria-selected="true"] { color: var(--brand-primary); font-weight: var(--weight-semibold); }
.tab.is-active::after,
.tab[aria-selected="true"]::after { transform: scaleX(1); }

/* ---------------------------------------------------------------------------
   15. Empty state
--------------------------------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-9) var(--space-6);
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty__title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-primary); }
.empty__text { font-size: var(--text-sm); color: var(--text-secondary); max-width: 480px; }

/* ---------------------------------------------------------------------------
   16. Overlays — modal + drawer (tools surfaced in situ)
--------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--bg-overlay);
  opacity: 0;
  animation: overlay-in var(--dur-base) var(--ease-standard) forwards;
}
.overlay[hidden] { display: none; }
.overlay--drawer { justify-content: flex-end; padding: 0; }
@keyframes overlay-in { to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  transform: translateY(8px);
  animation: modal-in var(--dur-base) var(--ease-emphasis) forwards;
}
@keyframes modal-in { to { transform: translateY(0); } }
.drawer {
  width: 100%;
  max-width: 460px;
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateX(16px);
  animation: drawer-in var(--dur-base) var(--ease-emphasis) forwards;
}
.drawer--lg { max-width: 560px; }
@keyframes drawer-in { to { transform: translateX(0); } }

.overlay__head, .drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}
.overlay__title, .drawer__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--text-primary); }
.overlay__sub, .drawer__sub { margin-top: 2px; font-size: var(--text-sm); color: var(--text-secondary); }
.overlay__body, .drawer__body { padding: var(--space-6); }
.drawer__body { flex: 1; overflow-y: auto; }
.overlay__foot, .drawer__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

/* Form fields inside overlays */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field__label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-primary); }
.input {
  height: 38px;
  padding: 0 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.input:focus { outline: none; border-color: var(--brand-primary); box-shadow: var(--shadow-focus); }

.auth-page {
  min-height: 100vh;
  background:
    radial-gradient(960px 460px at 78% -8%, var(--brand-wash) 0%, transparent 58%),
    var(--bg-primary);
}
.auth-main {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: var(--space-8) var(--container-pad);
}
.auth-shell { width: 100%; max-width: 560px; }
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: clamp(24px, 3vw, 36px);
}
.auth-head { text-align: center; margin-bottom: var(--space-6); }
.auth-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: var(--weight-bold);
  letter-spacing: -0.03em;
}
.auth-sub {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: var(--text-md);
}
.auth-copy { margin-bottom: var(--space-6); text-align: center; }
.auth-lede {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.auth-text {
  margin-top: var(--space-3);
  color: var(--text-secondary);
  line-height: var(--leading-base);
}
.auth-form { margin-top: var(--space-6); }
.auth-submit { width: 100%; }
.auth-error {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--status-error);
  border-radius: var(--radius-md);
  background: var(--status-error-soft);
  color: var(--status-error);
  font-size: var(--text-sm);
}
.auth-foot {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: var(--text-xs);
  display: grid;
  gap: 6px;
}
.auth-empty {
  max-width: 480px;
  margin: var(--space-9) auto;
}
.auth-empty__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   17. Marketing homepage (signed-out, brand-led)
--------------------------------------------------------------------------- */
.mk-bar {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: 64px;
  padding: 0 var(--container-pad);
  max-width: var(--container-max);
  margin: 0 auto;
}
.mk-bar__spacer { flex: 1; }
.mk {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1100px 520px at 78% -8%, var(--brand-wash) 0%, transparent 60%),
    var(--bg-primary);
}
.mk-hero {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: clamp(56px, 9vw, 120px) var(--container-pad) clamp(40px, 6vw, 88px);
}
.mk-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--brand-primary);
  margin-bottom: var(--space-5);
}
.mk-title {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  font-weight: var(--weight-bold);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--brand-charcoal);
  max-width: 16ch;
}
.mk-title em { font-style: normal; color: var(--brand-primary); }
.mk-lede {
  margin-top: var(--space-5);
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  line-height: var(--leading-snug);
  color: var(--text-secondary);
  max-width: 52ch;
}
.mk-cta { margin-top: var(--space-7); display: flex; gap: var(--space-3); flex-wrap: wrap; }
.mk-strip {
  border-top: 1px solid var(--border-default);
  background: var(--bg-secondary);
}
.mk-strip__inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: clamp(40px, 6vw, 72px) var(--container-pad);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
}
.mk-pillar__k {
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--brand-primary);
  margin-bottom: var(--space-2);
}
.mk-pillar__t { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--text-primary); margin-bottom: 6px; }
.mk-pillar__d { font-size: var(--text-sm); color: var(--text-secondary); line-height: var(--leading-snug); }
.mk-foot {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-7) var(--container-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------------
   18. Image placeholder (drop real product shots later)
--------------------------------------------------------------------------- */
.shot {
  position: relative;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  background:
    repeating-linear-gradient(135deg, var(--bg-sunken) 0 14px, transparent 14px 28px),
    var(--bg-card);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------------------
   19. Responsive
--------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 920px) {
  .shell, .shell.is-rail-collapsed { grid-template-columns: 1fr; }
  .rail {
    position: static; width: 100%; height: auto;
    border-right: none; border-bottom: 1px solid var(--border-default);
  }
  .shell.is-rail-collapsed .rail { width: 100%; opacity: 1; pointer-events: auto; height: auto; }
  .rail__nav { flex-direction: row; flex-wrap: wrap; }
  .rail__toggle, .rail__reopen { display: none !important; }
  .topnav { gap: var(--space-3); }
  .search { width: 150px; }
  .kpis { grid-template-columns: 1fr; }
  .kpi + .kpi::before { display: none; }
  .mk-strip__inner { grid-template-columns: repeat(2, 1fr); }
  .auth-main { min-height: auto; }
}
@media (max-width: 560px) {
  .topnav { display: none; }
  .page-head { flex-direction: column; }
  .mk-strip__inner { grid-template-columns: 1fr; }
  .auth-card { padding: var(--space-5); }
  .auth-empty__actions { flex-direction: column; }
}
