/* Components. Use tokens from theme.css only. */

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-feature-settings: 'cv11', 'ss01';
  color: var(--text-primary);
  background: var(--surface-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); color: var(--text-primary); letter-spacing: -0.015em; line-height: 1.25; }
p { margin: 0; }
a { color: var(--brand-primary); text-underline-offset: 3px; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.85em; }
.sub { color: var(--text-muted); font-size: 0.95rem; }
:focus-visible { outline: 0; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; }
.content { width: 100%; max-width: 1680px; margin: 0 auto; padding: 2rem clamp(1.25rem, 3vw, 3rem) 3rem; flex: 1; }
.footer { padding: 1.25rem clamp(1.25rem, 3vw, 3rem); color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--surface-border); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.5rem;
  padding: 1.5rem 1rem 1rem;
  background: linear-gradient(180deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 45%);
  color: var(--sidebar-text);
  scrollbar-width: thin;
}
.sidebar-brand { display: flex; align-items: center; justify-content: flex-start; align-self: flex-start; padding: 0 0.75rem; min-height: 44px; }
.sidebar-brand .logo-full { height: 44px; width: auto; display: block; object-position: left center; }
.sidebar-brand .logo-mark { height: 38px; width: 38px; display: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1 0 auto; }
.nav-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--sidebar-muted); padding: 1.1rem 0.75rem 0.45rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.6rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--sidebar-text); text-decoration: none; font-size: 0.93rem; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-strong); box-shadow: inset 3px 0 0 var(--brand-accent); }
.nav-item.active svg.i { color: var(--brand-accent); }
.nav-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.soon-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sidebar-muted); opacity: 0.7; }
.user-box {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem;
  border-radius: var(--radius-md); background: var(--sidebar-hover); border: 1px solid var(--sidebar-border);
}
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: 0.85rem; color: var(--sidebar-text-strong); }
.user-meta strong, .user-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { color: var(--sidebar-muted); font-size: 0.76rem; }
.sidebar .icon-btn { color: var(--sidebar-muted); }
.sidebar .icon-btn:hover { color: var(--sidebar-text-strong); background: var(--sidebar-hover); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 60px; padding: 0 clamp(1.25rem, 3vw, 3rem);
  background: color-mix(in srgb, var(--surface-bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--surface-border);
}
.crumbs { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }
.crumbs strong { color: var(--text-primary); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.env-chip { font-family: var(--font-mono); font-size: 0.72rem; padding: 0.25rem 0.55rem; border-radius: 999px; border: 1px solid var(--surface-border); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
[data-theme='dark'] .theme-light, :root:not([data-theme='dark']) .theme-dark { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 2rem; }
.eyebrow { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--brand-primary); margin-bottom: 0.4rem; }
.page-head h1 { font-size: clamp(1.6rem, 2.2vw, 2.1rem); font-weight: 700; }
.page-head .sub { margin-top: 0.4rem; max-width: 60ch; font-size: 1rem; }
.head-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- Buttons & forms ---------- */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font: inherit; font-size: 0.92rem; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: 0.65rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--brand-primary); color: var(--brand-primary-contrast);
  box-shadow: var(--shadow-1); transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--brand-primary-strong); }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: var(--surface-card); color: var(--text-primary); border-color: var(--surface-border); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost {
  font: inherit; font-size: 0.84rem; font-weight: 600; cursor: pointer;
  padding: 0.4rem 0.75rem; border: 0; border-radius: var(--radius-sm);
  background: var(--brand-primary-soft); color: var(--brand-primary);
}
.btn-ghost:hover { filter: brightness(0.97); }
.btn-ghost.danger { background: var(--status-danger-soft); color: var(--status-danger); }
label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.87rem; font-weight: 600; color: var(--text-secondary); }
input, select {
  font: inherit; font-size: 0.95rem; color: var(--text-primary);
  padding: 0.65rem 0.85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border); background: var(--surface-card);
  transition: border-color 0.15s, box-shadow 0.15s;
}
select { appearance: none; padding-right: 2.25rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6b74' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 18px; cursor: pointer; }
input::placeholder { color: var(--text-muted); opacity: 0.8; }
input:focus, select:focus { outline: 0; border-color: var(--brand-primary); box-shadow: var(--focus-ring); }
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.9rem; background: var(--status-danger-soft); color: var(--status-danger); margin-bottom: 1.25rem; }
.alert.ok { background: var(--status-success-soft); color: var(--status-success); }

/* ---------- Cards ---------- */
.card { background: var(--surface-card); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); padding: 1.5rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.card-head h2 { font-size: 1.08rem; font-weight: 650; }
.card-head .sub { font-size: 0.86rem; margin-top: 0.15rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 2.5rem 0 1rem; }
.section-title h2 { font-size: 1.15rem; font-weight: 650; }
.section-title .sub { font-size: 0.88rem; }

.grid { display: grid; gap: 1.25rem; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); }
.grid-modules { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.grid-split { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); align-items: start; margin-top: 1.25rem; }
.grid-two { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.stack { display: grid; gap: 1.25rem; }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 0.75rem; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.kpi-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--brand-primary-soft); color: var(--brand-primary); }
.kpi-value { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0; margin-left: 0.25rem; }
.kpi-foot { font-size: 0.84rem; color: var(--text-muted); }
.kpi.pending { background: var(--surface-sunken); box-shadow: none; border-style: dashed; }
.kpi.pending .kpi-value { color: var(--text-muted); }
.kpi.pending .kpi-icon { background: var(--surface-card); color: var(--text-muted); }

/* Tags & badges */
.tag {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-sunken); color: var(--text-muted);
}
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-live, .tag-done { background: var(--status-success-soft); color: var(--status-success); }
.tag-next { background: var(--status-info-soft); color: var(--status-info); }
.tag-warn { background: var(--status-warning-soft); color: var(--status-warning); }
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 6px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.05em; background: var(--brand-primary-soft); color: var(--brand-primary); }

/* Roadmap */
.roadmap { list-style: none; margin: 0; padding: 0; display: grid; }
.roadmap li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 1rem; padding-bottom: 1.4rem; position: relative; }
.roadmap li:last-child { padding-bottom: 0; }
.roadmap li::before { content: ''; position: absolute; left: 19px; top: 40px; bottom: 4px; width: 2px; background: var(--surface-border); }
.roadmap li:last-child::before { display: none; }
.phase-n {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 0.95rem; font-variant-numeric: tabular-nums;
  background: var(--surface-card); color: var(--text-muted); border: 2px solid var(--surface-border);
}
.roadmap li.done .phase-n { background: var(--status-success); border-color: var(--status-success); color: var(--brand-primary-contrast); }
.roadmap li.next .phase-n { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-primary-contrast); box-shadow: 0 0 0 5px var(--brand-primary-soft); }
.phase-body { padding-top: 0.45rem; }
.phase-title { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-weight: 650; }
.phase-mods { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.chip { font-size: 0.8rem; padding: 0.25rem 0.6rem; border-radius: 6px; background: var(--surface-sunken); color: var(--text-secondary); text-decoration: none; }
.chip:hover { color: var(--brand-primary); }

/* Lists in cards */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 0.8rem; padding: 0.75rem 0; border-top: 1px solid var(--surface-border); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow strong { display: block; font-size: 0.93rem; font-weight: 600; }
.list .grow span { display: block; font-size: 0.83rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-row { justify-content: space-between; font-size: 0.92rem; }
.status-row > span:first-child { color: var(--text-secondary); }
.empty { text-align: center; padding: 1.5rem 1rem; color: var(--text-muted); font-size: 0.9rem; }
.empty svg.i { width: 28px; height: 28px; color: var(--status-success); margin-bottom: 0.4rem; }

/* Module cards */
.module { display: flex; flex-direction: column; gap: 0.75rem; text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.module:hover { border-color: var(--brand-primary); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.module-top { display: flex; justify-content: space-between; align-items: center; }
.module-icon { width: 42px; height: 42px; border-radius: var(--radius-md); display: grid; place-items: center; background: var(--brand-primary-soft); color: var(--brand-primary); }
.module-icon.lg { width: 56px; height: 56px; }
.module-icon.lg svg.i { width: 26px; height: 26px; }
.module h3 { font-size: 1.02rem; font-weight: 650; }
.module p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.55; flex: 1; }
.module-foot { font-size: 0.8rem; color: var(--text-muted); padding-top: 0.75rem; border-top: 1px solid var(--surface-border); }
.group-label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin: 1.75rem 0 0.85rem; }

/* Coming soon */
.soon-hero { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.25rem; background: linear-gradient(120deg, var(--brand-primary-soft), var(--surface-card) 70%); }
.soon-hero h2 { font-size: 1.1rem; }
.checks { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.75rem; }
.checks li { display: flex; gap: 0.7rem; font-size: 0.95rem; color: var(--text-secondary); }
.checks li svg.i { color: var(--brand-primary); margin-top: 2px; }
.meta { display: grid; gap: 1.1rem; }
.meta dt { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.meta dd { margin: 0.3rem 0 0; font-size: 0.95rem; color: var(--text-secondary); }
.back { display: inline-flex; align-items: center; gap: 0.4rem; margin-top: 1.5rem; font-weight: 600; font-size: 0.9rem; text-decoration: none; }

/* Table */
.table-card { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); background: var(--surface-sunken); padding: 0.8rem 1.5rem; }
td { padding: 1rem 1.5rem; border-top: 1px solid var(--surface-border); font-size: 0.93rem; color: var(--text-secondary); }
tbody tr:hover { background: var(--surface-hover); }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }
.cell-user { display: flex; align-items: center; gap: 0.75rem; font-weight: 600; color: var(--text-primary); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 0.9rem;
  background: var(--brand-primary); color: var(--brand-primary-contrast);
}
.avatar.sm { width: 32px; height: 32px; font-size: 0.82rem; }
.invite { display: grid; grid-template-columns: minmax(220px, 1.3fr) 1fr 1fr auto; gap: 1rem; align-items: end; margin-bottom: 1.5rem; }
.invite h2 { font-size: 1.05rem; }
.invite .sub { font-size: 0.86rem; margin-top: 0.2rem; }

/* ---------- Auth pages ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
  padding: clamp(2rem, 5vw, 4rem);
  background: radial-gradient(120% 90% at 0% 0%, var(--sidebar-bg-2), var(--sidebar-bg) 60%);
  color: var(--sidebar-text);
}
.auth-hero::after {
  content: ''; position: absolute; inset: auto -10% -30% 30%; height: 70%;
  background: repeating-radial-gradient(circle at 100% 100%, transparent 0 38px, color-mix(in srgb, var(--brand-accent) 8%, transparent) 38px 40px);
  pointer-events: none;
}
.auth-hero .logo-full { height: 56px; width: auto; position: relative; align-self: flex-start; object-position: left center; }
.auth-hero h1 { color: var(--sidebar-text-strong); font-size: clamp(2.1rem, 3.6vw, 3.2rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.auth-hero p { margin-top: 1rem; max-width: 32rem; font-size: 1.05rem; color: var(--sidebar-muted); }
.auth-hero .hero-copy, .auth-hero .hero-foot { position: relative; }
.hero-foot { display: flex; gap: 2rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--sidebar-muted); }
.hero-foot span { display: flex; align-items: center; gap: 0.5rem; }
.hero-foot svg.i { color: var(--brand-accent); }
.auth-panel { display: grid; place-items: center; padding: 2rem; background: var(--surface-card); }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 1.1rem; }
.login h2 { font-size: 1.75rem; font-weight: 700; }
.login .sub { margin-top: -0.6rem; }
.login .alert { margin: 0; }
.login .btn { width: 100%; padding: 0.8rem; margin-top: 0.35rem; }

/* Error */
.error-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.error-page { text-align: center; max-width: 460px; display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.err-code { font-size: 4.5rem; font-weight: 800; line-height: 1; color: var(--brand-primary); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.error-page .btn { margin-top: 0.75rem; }

/* ---------- Navigation groups ---------- */
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label em, .group-label em { font-style: normal; font-weight: 600; text-transform: none; letter-spacing: 0.02em; font-size: 0.68rem; margin-left: 0.4rem; padding: 0.1rem 0.45rem; border-radius: 999px; background: var(--sidebar-hover); }
.group-label em { background: var(--surface-sunken); }
/* WateRecoup (internal) group sits at the bottom, set apart from operator work */
.nav-bottom { margin-top: auto; padding-top: 0.75rem; border-top: 1px solid var(--sidebar-border); }
.nav-bottom .nav-label { padding-top: 0.4rem; }
.group-label:last-of-type { padding-top: 1.5rem; border-top: 1px dashed var(--surface-border); }

/* Simple copy blocks */
.usage { color: var(--text-secondary); font-size: 1rem; line-height: 1.65; margin-bottom: 1.25rem; }
.card-head .i { color: var(--brand-primary); width: 22px; height: 22px; }
.mobile-card { background: linear-gradient(135deg, var(--brand-primary-soft), var(--surface-card) 75%); }
.mobile-card .usage { margin-bottom: 0; }
.roadmap.steps .phase-n { background: var(--brand-primary-soft); border-color: var(--brand-primary-soft); color: var(--brand-primary); }
.roadmap.steps .sub { margin-top: 0.3rem; font-size: 0.9rem; }

/* ---------- Extra components ---------- */
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.link-sm { font-size: 0.84rem; font-weight: 600; text-decoration: none; }
.link-sm:hover { text-decoration: underline; }
.link-sm.center { text-align: center; }
.form-stack { display: grid; gap: 1rem; }
.form-stack .btn { justify-self: start; }
.status-icon { width: 52px; height: 52px; border-radius: var(--radius-md); display: grid; place-items: center; }
.status-icon svg.i { width: 26px; height: 26px; }
.status-icon.ok { background: var(--status-success-soft); color: var(--status-success); }
.status-icon.warn { background: var(--status-warning-soft); color: var(--status-warning); }
.break { word-break: break-word; }
.menu-btn, .topbar-logo, .nav-overlay { display: none; }
.td-actions-inline { display: inline; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .grid-split { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .invite { grid-template-columns: 1fr 1fr; }
  .invite > div:first-child { grid-column: 1 / -1; }
}
/* Tablet: icon-only sidebar with compact mark */
@media (min-width: 721px) and (max-width: 1100px) {
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 1.25rem 0.75rem; align-items: center; }
  .sidebar-brand { padding: 0; align-self: center; justify-content: center; }
  .sidebar-brand .logo-full, .nav-text, .soon-dot, .user-meta { display: none; }
  .sidebar-brand .logo-mark { display: block; }
  .sidebar nav { width: 100%; }
  .nav-group { width: 100%; }
  .nav-bottom { border-top: 0; padding-top: 0; }
  .nav-item { justify-content: center; padding: 0.7rem; }
  .nav-label { display: block; height: 1px; padding: 0; margin: 0.6rem 0.5rem; background: var(--sidebar-border); font-size: 0; overflow: hidden; }
  .nav-label em { display: none; }
  .user-box { flex-direction: column; padding: 0.5rem; }
  .user-link { flex: 0; }
}

/* Phone: slide-out menu, stacked tables, 44px touch targets, 16px inputs (stops iOS zoom) */
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 30;
    width: min(300px, 86vw); height: 100vh; height: 100dvh;
    transform: translateX(-100%); transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
    animation: none; box-shadow: none;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 0.4); }
  body.nav-open { overflow: hidden; }
  .nav-overlay { display: block; position: fixed; inset: 0; z-index: 20; background: rgb(8 20 26 / 0.5); opacity: 0; pointer-events: none; transition: opacity 0.28s; }
  body.nav-open .nav-overlay { opacity: 1; pointer-events: auto; }

  .topbar { height: 56px; padding: 0 0.75rem; gap: 0.5rem; }
  .menu-btn { display: grid; }
  .topbar-logo { display: block; margin-right: auto; }
  .topbar-logo img { height: 30px; width: auto; display: block; }
  .crumbs, .env-chip { display: none; }
  .content { padding: 1.25rem 1rem 2rem; }
  .footer { padding: 1rem; }
  .footer span:last-child { display: none; }

  .icon-btn { width: 44px; height: 44px; }
  .btn, button.btn, .btn-ghost { min-height: 44px; }
  input, select { font-size: 16px; min-height: 46px; }
  .page-head { margin-bottom: 1.25rem; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .section-title { flex-direction: column; gap: 0.2rem; margin-top: 1.75rem; }
  .card { padding: 1.15rem; }
  .kpi-value { font-size: 1.9rem; }
  .invite { grid-template-columns: 1fr; }
  .form-stack .btn { justify-self: stretch; }

  /* Tables become one card per row */
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
  .stack-table thead { display: none; }
  .stack-table tr { padding: 0.9rem 1rem; border-top: 1px solid var(--surface-border); }
  .stack-table tr:first-child { border-top: 0; }
  .stack-table td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.4rem 0; border: 0; text-align: right; }
  .stack-table td::before { content: attr(data-label); flex-shrink: 0; font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); text-align: left; }
  .stack-table td.actions { flex-wrap: wrap; justify-content: flex-start; gap: 0.5rem; padding-top: 0.7rem; }
  .stack-table td.actions::before { display: none; }
  .stack-table td.actions form { flex: 1 1 auto; }
  .stack-table td.actions .btn-ghost { width: 100%; }

  /* Auth pages: compact brand strip on top */
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 1.25rem 1.25rem 1.5rem; gap: 1rem; min-height: 0; }
  .auth-hero .logo-full { height: 40px; }
  .auth-hero h1 { font-size: 1.6rem; }
  .auth-hero p, .hero-foot { display: none; }
  .auth-panel { padding: 1.75rem 1.25rem 2.5rem; place-items: start center; }
}
@media (max-width: 380px) {
  .kpi-value { font-size: 1.7rem; }
  .content { padding-left: 0.85rem; padding-right: 0.85rem; }
}

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-primary) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes drift { from { transform: translate(0, 0); } to { transform: translate(-24px, -18px); } }
@keyframes sweep { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.page-head, .section-title, .group-label { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.grid > *, .stack > *, .invite, .table-card, .soon-hero, .roadmap li { animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.grid > *:nth-child(1), .roadmap li:nth-child(1) { animation-delay: 0.04s; }
.grid > *:nth-child(2), .roadmap li:nth-child(2) { animation-delay: 0.09s; }
.grid > *:nth-child(3), .roadmap li:nth-child(3) { animation-delay: 0.14s; }
.grid > *:nth-child(4), .roadmap li:nth-child(4) { animation-delay: 0.19s; }
.grid > *:nth-child(5), .roadmap li:nth-child(5) { animation-delay: 0.24s; }
.grid > *:nth-child(6), .roadmap li:nth-child(6) { animation-delay: 0.29s; }
.grid > *:nth-child(n+7) { animation-delay: 0.33s; }
.grid-split > *:nth-child(2) { animation-delay: 0.12s; }
.topbar, .sidebar { animation: fade 0.4s ease both; }
.nav-item { animation: fade 0.4s ease both; }

/* Hover and press feedback */
.card { transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s; }
.kpi:not(.pending):hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.nav-item svg.i { transition: transform 0.2s; }
.nav-item:hover svg.i { transform: translateX(2px) scale(1.08); }
.btn svg.i { transition: transform 0.2s; }
.btn:hover svg.i { transform: rotate(90deg); }
.btn:hover { box-shadow: var(--shadow-2); }
.icon-btn svg.i { transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1); }
.icon-btn:hover svg.i { transform: rotate(20deg); }
.module:hover .module-icon { background: var(--brand-primary); color: var(--brand-primary-contrast); transform: scale(1.06) rotate(-4deg); }
.module-icon { transition: background 0.2s, color 0.2s, transform 0.25s; }
.sidebar-brand { transition: opacity 0.2s, transform 0.2s; }
.sidebar-brand:hover { opacity: 0.9; transform: translateX(2px); }
.btn-ghost { transition: filter 0.15s, transform 0.1s; }
.btn-ghost:active { transform: scale(0.97); }
tbody tr { transition: background 0.15s; }
.chip { transition: background 0.15s, color 0.15s, transform 0.15s; }
.chip:hover { background: var(--brand-primary-soft); transform: translateY(-1px); }
.back svg.i { transition: transform 0.2s; }
.back:hover svg.i { transform: translateX(-4px); }
html { transition: background 0.3s; }
body, .card, .topbar, input { transition: background-color 0.3s, border-color 0.3s, color 0.3s; }

/* Live indicators */
.roadmap li.next .phase-n { animation: pulse-ring 2.2s ease-out infinite; }
.tag-live::before { animation: blink 2.4s ease-in-out infinite; }
.soon-dot { animation: blink 3s ease-in-out infinite; }
.kpi.pending { background-image: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--surface-card) 70%, transparent) 50%, transparent 70%); background-size: 200% 100%; animation: rise 0.55s both, sweep 4.5s linear 1s infinite; }
.auth-hero::after { animation: drift 14s ease-in-out infinite alternate; }
.auth-hero .hero-copy { animation: rise 0.8s 0.1s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.auth-hero .hero-foot { animation: rise 0.8s 0.3s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.login > * { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.login > *:nth-child(2) { animation-delay: 0.06s; }
.login > *:nth-child(3) { animation-delay: 0.12s; }
.login > *:nth-child(4) { animation-delay: 0.18s; }
.login > *:nth-child(5) { animation-delay: 0.24s; }
.error-page { animation: rise 0.6s both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* ---------- Add user page and confirm popup ---------- */
.grid-form { grid-template-columns: minmax(0, 1.5fr) minmax(min(300px, 100%), 1fr); align-items: start; }
.back-top { margin: 0 0 0.75rem; }
.field-group { border: 0; margin: 0; padding: 0; display: grid; gap: 0.6rem; min-width: 0; }
.field-group legend { font-size: 0.87rem; font-weight: 600; color: var(--text-secondary); padding: 0; margin-bottom: 0.6rem; }
.choice { flex-direction: row; align-items: flex-start; gap: 0.8rem; padding: 0.85rem 1rem; border: 1px solid var(--surface-border); border-radius: var(--radius-md); cursor: pointer; font-weight: 400; transition: border-color 0.15s, background 0.15s; }
.choice:hover { border-color: var(--brand-primary); }
.choice:has(input:checked) { border-color: var(--brand-primary); background: var(--brand-primary-soft); }
.choice.disabled { opacity: 0.6; cursor: not-allowed; background: var(--surface-sunken); }
.choice.disabled:hover { border-color: var(--surface-border); }
.choice input { min-height: 0; width: 18px; height: 18px; margin: 2px 0 0; padding: 0; accent-color: var(--brand-primary); flex-shrink: 0; }
.choice span { display: grid; gap: 0.15rem; min-width: 0; }
.choice strong { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.choice small { font-size: 0.84rem; color: var(--text-muted); line-height: 1.4; }
.choice .tag { font-style: normal; }
.form-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; padding-top: 0.5rem; }
.steps-list { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.7rem; color: var(--text-secondary); font-size: 0.95rem; line-height: 1.55; }
.steps-list li::marker { color: var(--brand-primary); font-weight: 700; }

.dialog { border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-2); width: min(440px, calc(100vw - 2rem)); }
.dialog::backdrop { background: rgb(8 20 26 / 0.55); backdrop-filter: blur(2px); }
.dialog[open] { animation: rise 0.25s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.dialog[open]::backdrop { animation: fade 0.2s ease both; }
.dialog form { padding: 1.5rem; display: grid; gap: 0.75rem; }
.dialog h2 { font-size: 1.2rem; }
.dialog .sub { line-height: 1.55; word-break: break-word; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.75rem; }

@media (max-width: 1100px) { .grid-form { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .form-actions .btn { flex: 1; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; }
}

/* ---------- Profile ---------- */
.user-link { display: flex; align-items: center; gap: 0.7rem; flex: 1; min-width: 0; padding: 0.15rem; margin: -0.15rem; border-radius: var(--radius-sm); color: inherit; text-decoration: none; transition: background 0.15s; }
.user-link:hover, .user-link.active { background: var(--sidebar-hover); }
.avatar.xl { width: 64px; height: 64px; font-size: 1.5rem; }
.profile-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--surface-border); }
.profile-id { display: grid; gap: 0.4rem; justify-items: start; min-width: 0; }
.profile-id h2 { font-size: 1.3rem; word-break: break-word; }
.profile-grid { align-items: start; }
