/* ─────────────────────────────────────────────────────────────────────────
   RASSROCHKA Design System v4 — Premium FinTech / mobile-first ops.
   Tokens + Inter Variable (local WOFF2, Cyrillic). Light / dark / schemes.
   Spacing 4–64 · Radius · Shadows subtle · Motion tokens · Z-index scale.
   ───────────────────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Inter';
  src:
    url('/assets/fonts/InterVariable.woff2') format('woff2-variations'),
    url('/assets/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  font-named-instance: 'Regular';
}
@font-face {
  font-family: 'Inter';
  src:
    url('/assets/fonts/InterVariable-Italic.woff2') format('woff2-variations'),
    url('/assets/fonts/InterVariable-Italic.woff2') format('woff2');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
  font-named-instance: 'Italic';
}

/* Cross-document View Transitions (progressive; ignored if unsupported). */
@view-transition {
  navigation: auto;
}

:root {
  /* ── Semantic surfaces ── */
  --background: #f1f4f8;
  --bg-app: var(--background);
  --bg-primary: var(--background);
  --surface: #ffffff;
  --surface-1: var(--surface);
  --bg-surface: var(--surface);
  --surface-elevated: #ffffff;
  --surface-2: var(--surface-elevated);
  --bg-elevated: var(--surface-elevated);
  --surface-muted: #e8eef5;
  --bg-muted: var(--surface-muted);
  --bg-subtle: #f7f9fc;
  --bg-secondary: #e4ebf3;
  --bg-sidebar: #0a1628;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.055);
  --bg-sidebar-active: rgba(45, 180, 120, 0.16);

  /* ── Borders ── */
  --border: #dde4ee;
  --border-subtle: rgba(12, 26, 43, 0.06);
  --border-soft: #eef2f7;
  --border-strong: #c5d0de;

  /* ── Text ── */
  --text-primary: #0c1524;
  --text: var(--text-primary);
  --text-secondary: #5b6b81;
  --text-2: var(--text-secondary);
  --text-muted: #8b9bb0;
  --text-3: var(--text-muted);
  --text-inverse: #ffffff;

  /* ── Brand / primary ── */
  --primary: #178a5a;
  --brand: var(--primary);
  --primary-hover: #0f6b45;
  --brand-strong: var(--primary-hover);
  --brand-bright: #2db478;
  --brand-subtle: #e5f6ee;
  --focus-color: var(--brand-bright);

  /* ── Status ── */
  --success: #178a5a;
  --success-subtle: #e5f6ee;
  --warning: #9a6b00;
  --warning-fill: #d99914;
  --warning-subtle: #fef7e6;
  --danger: #c0392b;
  --danger-fill: #d6453a;
  --danger-subtle: #fdecea;
  --info: #2563eb;
  --info-link: #2563eb;
  --info-subtle: #eff4ff;
  --info-border: #c7d7fe;
  --accent-product: #7a5b1e;
  --accent-product-subtle: #f6ebd3;

  /* ── Charts (semantic palette) ── */
  --chart-primary: #178a5a;
  --chart-secondary: #2563eb;
  --chart-tertiary: #7c6aef;
  --chart-quaternary: #d99914;
  --chart-grid: #e8eef5;
  --chart-axis: #8b9bb0;
  --aging-1: #e8c24a;
  --aging-2: #e0a03a;
  --aging-3: #d45a3c;
  --aging-4: #c0392b;

  /* ── Spacing: 4 8 12 16 20 24 32 40 48 64 ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 40px;
  --space-10: 48px;
  --space-12: 64px;
  --page-gap: var(--space-6);
  --section-gap: var(--space-7);

  /* ── Typography scale (Inter Variable) ── */
  --font-sans: 'Inter', 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  --font-display: 2.125rem; /* 34 — display */
  --font-h1: 1.75rem; /* 28 — page title */
  --font-h2: 1.3125rem; /* 21 — section */
  --font-h3: 1.0625rem; /* 17 — card title */
  --font-h4: 0.9375rem; /* 15 */
  --font-body-lg: 1rem; /* 16 */
  --font-body: 0.875rem; /* 14 desktop body */
  --font-body-sm: 0.8125rem; /* 13 secondary */
  --font-label: 0.75rem; /* 12 */
  --font-caption: 0.75rem;
  --font-button: 0.875rem;
  --font-numeric: 1.5rem; /* KPI */
  --text-xs: var(--font-caption);
  --text-sm: var(--font-body-sm);
  --text-base: var(--font-body);
  --text-md: var(--font-body);
  --text-lg: var(--font-body-lg);
  --text-xl: var(--font-h3);
  --text-2xl: var(--font-h1);
  --lh-tight: 1.18;
  --lh-snug: 1.32;
  --lh-normal: 1.5;
  --lh-relaxed: 1.6;
  --tracking-tight: -0.022em;
  --tracking-display: -0.028em;
  --tracking-label: 0.06em;
  --tracking-numeric: -0.015em;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* ── Radius: 4 sizes ── */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 14px;
  --r-2xl: 16px;
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-xl: var(--r-xl);

  /* ── Elevation: subtle / floating / modal ── */
  --shadow-xs: 0 1px 2px rgba(12, 21, 36, 0.04);
  --shadow-sm: 0 1px 2px rgba(12, 21, 36, 0.04), 0 1px 3px rgba(12, 21, 36, 0.03);
  --shadow-subtle: var(--shadow-sm);
  --shadow-md: 0 4px 14px rgba(12, 21, 36, 0.06), 0 1px 3px rgba(12, 21, 36, 0.04);
  --shadow-floating: var(--shadow-md);
  --shadow-overlay: 0 18px 44px rgba(12, 21, 36, 0.14), 0 4px 12px rgba(12, 21, 36, 0.06);
  --shadow-modal: var(--shadow-overlay);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--brand-bright) 55%, transparent);
  --focus-ring: var(--focus);

  /* ── Shell / controls ── */
  --sidebar-w: 252px;
  --sidebar-w-collapsed: 72px;
  --side-panel-w: 400px;
  --content-max: 1360px;
  --content-narrow: 720px;
  --content-form: 880px;
  --topbar-h: 52px;
  --touch: 44px;
  --control-h: 40px;
  --control-h-sm: 36px;
  --control-h-lg: 48px;
  --tabbar-h: 60px;

  /* ── Breakpoints (documentation mirrors; media queries use raw px) ── */
  --bp-xs: 320px;
  --bp-sm: 375px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;
  --bp-2xl: 1440px;

  /* ── Motion Design System ── */
  --motion-fast: 120ms;
  --motion-normal: 180ms;
  --motion-standard: 200ms;
  --motion-slow: 240ms;
  --motion-page: 220ms;
  --motion-enter: 220ms;
  --motion-exit: 160ms;
  /* aliases used across legacy rules */
  --dur: var(--motion-fast);
  --dur-slow: var(--motion-slow);
  --motion-base: var(--motion-standard);
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-enter: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --ease: var(--ease-standard);
  --ease-out: var(--ease-enter);

  /* ── Z-index scale ── */
  --z-base: 1;
  --z-sticky: 20;
  --z-dropdown: 40;
  --z-sidebar: 50;
  --z-overlay: 60;
  --z-modal: 70;
  --z-toast: 80;
  --z-fab: 55;
  --z-tabbar: 45;

  --font: var(--font-sans);
  --font-num: var(--font-sans);

  color-scheme: light;
}

html[data-theme='dark'] {
  color-scheme: dark;
  --background: #080e18;
  --bg-app: var(--background);
  --bg-primary: var(--background);
  --bg-secondary: #0f1726;
  --surface: #111a2b;
  --bg-surface: var(--surface);
  --bg-subtle: #152033;
  --surface-muted: #1a2740;
  --bg-muted: var(--surface-muted);
  --surface-elevated: #17233a;
  --bg-elevated: var(--surface-elevated);
  --bg-sidebar: #060b14;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.055);
  --bg-sidebar-active: rgba(45, 180, 120, 0.2);

  --border: #243247;
  --border-strong: #334155;
  --border-soft: #1a2740;
  --border-subtle: rgba(255, 255, 255, 0.055);

  --text-primary: #e9eef7;
  --text: var(--text-primary);
  --text-secondary: #93a4bb;
  --text-2: var(--text-secondary);
  --text-muted: #6b7c94;
  --text-3: var(--text-muted);

  --primary: #2db478;
  --brand: var(--primary);
  --primary-hover: #3cc487;
  --brand-strong: #22a06b;
  --brand-bright: #45d492;
  --brand-subtle: rgba(45, 180, 120, 0.16);

  --success: #2db478;
  --success-subtle: rgba(45, 180, 120, 0.16);
  --warning: #e8b84a;
  --warning-fill: #e0a03a;
  --warning-subtle: rgba(232, 163, 23, 0.14);
  --danger: #f07167;
  --danger-fill: #e85d55;
  --danger-subtle: rgba(232, 93, 85, 0.14);
  --info: #6b9fff;
  --info-link: #6b9fff;
  --info-subtle: rgba(107, 159, 255, 0.12);
  --info-border: rgba(107, 159, 255, 0.26);
  --accent-product: #d4b56a;
  --accent-product-subtle: rgba(212, 181, 106, 0.12);

  --chart-primary: #2db478;
  --chart-secondary: #6b9fff;
  --chart-tertiary: #a78bfa;
  --chart-quaternary: #e8b84a;
  --chart-grid: #1a2740;
  --chart-axis: #6b7c94;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-subtle: var(--shadow-sm);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.4);
  --shadow-floating: var(--shadow-md);
  --shadow-overlay: 0 22px 52px rgba(0, 0, 0, 0.55);
  --shadow-modal: var(--shadow-overlay);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--brand-bright) 45%, transparent);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(34, 160, 107, 0.06), transparent 55%),
    radial-gradient(900px 500px at -10% 0%, rgba(15, 34, 54, 0.04), transparent 50%), var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings:
    'kern' 1,
    'liga' 1,
    'cv11' 1;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}
html[data-theme='dark'] body {
  background:
    radial-gradient(1000px 500px at 100% -10%, rgba(34, 160, 107, 0.08), transparent 50%), var(--bg-app);
}
a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  color: var(--brand);
}
p {
  margin: 0;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}
h1 {
  font-size: var(--font-h1);
  line-height: var(--lh-tight);
}
h2 {
  font-size: var(--font-h2);
  line-height: var(--lh-snug);
}
h3 {
  font-size: var(--font-h3);
  line-height: var(--lh-snug);
}
h4 {
  font-size: var(--font-h4);
  line-height: var(--lh-snug);
}
.num,
.metric-value,
.today-sum,
.bucket-sum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}
code {
  font-family: var(--font-mono);
  font-size: var(--font-caption);
  background: var(--bg-muted);
  padding: 1px 5px;
  border-radius: var(--r-sm);
}
hr.sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}
button {
  font: inherit;
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--r-sm);
}
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--brand-strong);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--r-md);
  z-index: 100;
}
.skip-link:focus {
  top: 12px;
  color: #fff;
}
.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.strong {
  font-weight: 600;
}
.muted {
  color: var(--text-2);
}
.small {
  font-size: 12px;
}
.neg {
  color: var(--danger);
}
.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.icon {
  flex: none;
}

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 120px), var(--bg-sidebar);
  color: rgba(255, 255, 255, 0.78);
  display: flex;
  flex-direction: column;
  padding: var(--space-5) 0 var(--space-4);
  z-index: 30;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 var(--space-5) var(--space-6);
}
.brand-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.brand-link:hover {
  color: #fff;
}
.brand-mark {
  display: block;
  flex-shrink: 0;
  border-radius: var(--r-md);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.brand-name {
  font-size: var(--font-body-lg);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: inherit;
}
.brand-sub {
  font-size: var(--font-body-sm);
  color: rgba(255, 255, 255, 0.58);
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-lockup-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-product {
  font-size: var(--font-caption);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.55);
}
.brand .sidebar-close {
  display: none;
  color: #fff;
}
.sidebar-backdrop {
  display: none;
}
.nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-2) 0 0;
}
.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-group {
  margin: var(--space-4) 0 var(--space-2);
  padding: 0 var(--space-5);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
}
.nav-group:first-child {
  margin-top: 0;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 var(--space-4) 0 var(--space-5);
  margin: 0 var(--space-2) 0 var(--space-2);
  border-radius: var(--r-md);
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--font-body-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease);
}
.nav-item .icon {
  color: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}
.nav-item:hover .icon {
  color: rgba(255, 255, 255, 0.85);
}
.nav-item.is-active {
  background: var(--bg-sidebar-active);
  color: #fff;
}
.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--brand-bright);
}
.nav-item.is-active .icon {
  color: var(--brand-bright);
}
.nav-item:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--brand-bright);
}
.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger-fill);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-foot {
  padding: 16px 20px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 12px 20px 0;
  padding-left: 4px;
  padding-right: 0;
}
.usermenu {
  position: relative;
}
.usermenu summary {
  list-style: none;
  cursor: pointer;
}
.usermenu summary::-webkit-details-marker {
  display: none;
}
.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin: 0 -8px;
  border-radius: var(--r-lg);
  color: #fff;
}
.user:hover {
  background: var(--bg-sidebar-hover);
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #25405f;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex: none;
}
.user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.usermenu-pop {
  position: absolute;
  bottom: calc(100% + 8px);
  left: -8px;
  right: -8px;
  background: #fff;
  color: var(--text);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-overlay);
  padding: 12px;
}
.usermenu-mail {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
  word-break: break-all;
}

.main-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 56px;
  padding: 0 var(--space-6);
  background: color-mix(in srgb, var(--bg-app) 82%, transparent);
  backdrop-filter: saturate(1.5) blur(10px);
  -webkit-backdrop-filter: saturate(1.5) blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 440px;
}
.search .icon {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  padding: 0 44px 0 38px;
  font: inherit;
  font-size: var(--font-body-sm);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.search-input::placeholder {
  color: var(--text-3);
}
.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-bright) 22%, transparent);
}
.kbd {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 550;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  background: var(--bg-subtle);
}
.search .kbd {
  position: absolute;
  right: 10px;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.today {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: var(--font-body-sm);
  font-weight: 500;
}
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease);
}
.icon-btn:hover {
  background: var(--bg-muted);
  color: var(--text);
}
.icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger-fill);
  border: 2px solid var(--bg-app);
}
.menu-btn {
  display: none;
}
.main {
  padding: var(--space-4) var(--space-7) var(--space-10);
  outline: none;
  max-width: var(--content-max);
}

/* ── Page header ───────────────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  margin: 0 0 var(--section-gap);
}
.crumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0 0 6px;
  padding: 0;
  font-size: 13px;
  color: var(--text-2);
}
.crumbs li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.crumbs a:hover {
  color: var(--brand);
}
.crumb-sep {
  color: var(--text-3);
}
.page-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--font-display);
  line-height: var(--lh-tight);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  color: var(--text);
}
.page-title-compact {
  font-size: var(--font-h1);
}
.page-subtitle {
  margin-top: 6px;
  font-size: var(--font-body-lg);
  line-height: var(--lh-snug);
  color: var(--text-2);
  font-weight: 400;
  max-width: 42rem;
}
.page-head-side {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.page-meta {
  color: var(--text-2);
  font-size: 13px;
}
.page-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--font-button);
  font-weight: 550;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard),
    transform var(--motion-fast) var(--ease-emphasized),
    opacity var(--motion-fast) var(--ease-standard);
}
.btn-primary:hover:not(:disabled):not(.is-loading),
.btn-primary-strong:hover:not(:disabled):not(.is-loading) {
  filter: brightness(1.03);
}
.btn:active:not(:disabled):not(.is-loading) {
  transform: translateY(1px) scale(0.985);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.btn-sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--font-body-sm);
  gap: 6px;
}
.btn-xs {
  height: 26px;
  padding: 0 var(--space-2);
  font-size: var(--font-caption);
  font-weight: 550;
  border-radius: var(--r-sm);
}
.btn-lg {
  height: 48px;
  padding: 0 var(--space-5);
  font-size: var(--font-body-lg);
}
.btn-block {
  width: 100%;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(13, 92, 64, 0.2);
}
.btn-primary:hover {
  background: var(--brand-strong);
  color: #fff;
}
.btn-primary-strong {
  background: var(--brand-strong);
  color: #fff;
}
.btn-primary-strong:hover {
  background: #0a4735;
  color: #fff;
}
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary .icon {
  color: var(--brand);
}
.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text);
}
.btn-danger {
  background: var(--danger-fill);
  color: #fff;
}
.btn-danger-outline {
  background: var(--bg-surface);
  border-color: color-mix(in srgb, var(--danger) 28%, var(--border));
  color: var(--danger);
}
.btn-danger-outline:hover {
  background: var(--danger-subtle);
}
.btn-link {
  background: none;
  border: 0;
  color: var(--text-2);
  height: auto;
  padding: 4px 0;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  box-shadow: none;
}
.btn-link:hover {
  color: var(--danger);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-wrap {
  display: inline-flex;
  width: auto;
}
.btn-wrap:has(.btn-block) {
  display: flex;
  width: 100%;
}
.btn-status .icon {
  color: var(--warning);
}
.link-strong {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--info-link);
  font-weight: 600;
  font-size: 14px;
}
.link-strong:hover {
  color: var(--info);
  text-decoration: underline;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.card + .card {
  margin-top: var(--space-4);
}
.card-flush {
  padding: 0;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.card-title {
  font-size: var(--font-h3);
  line-height: var(--lh-snug);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.card-sub {
  font-size: var(--font-body-sm);
  color: var(--text-2);
  margin-top: 4px;
  font-weight: 400;
}
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.count {
  display: inline-flex;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  border-radius: 11px;
  background: var(--bg-muted);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  vertical-align: 3px;
}

/* ── KPI ───────────────────────────────────────────────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.metric {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--space-5);
  min-height: 120px;
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
a.metric:hover {
  border-color: color-mix(in srgb, var(--brand) 28%, var(--border));
  box-shadow: var(--shadow-sm);
  color: inherit;
  transform: translateY(-1px);
}
.metric-label {
  font-size: var(--font-caption);
  font-weight: 550;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}
.metric-value {
  font-size: clamp(1.5rem, 1.2rem + 0.8vw, 1.875rem);
  line-height: var(--lh-tight);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  margin: var(--space-3) 0 var(--space-2);
  color: var(--text);
}
.metric-delta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-body-sm);
  font-weight: 500;
}
.metric-delta.is-good {
  color: var(--brand);
}
.metric-delta.is-bad {
  color: var(--danger-fill);
}
.metric-delta.is-neutral {
  color: var(--text-2);
}

/* ── Dashboard grid ───────────────────────────────────────────────────── */
.dash {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 272px;
  gap: 12px;
  align-items: start;
}
.dash-main {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(260px, 1fr);
  gap: 12px;
  min-width: 0;
}
.dash-main .card + .card {
  margin-top: 0;
}
.card-attention {
  grid-column: 1 / -1;
  padding-bottom: 6px;
}
.card-attention .table-wrap {
  margin: 0 -22px;
}
.card-aging .card-title {
  font-size: 15px;
}
.card-aging .card-sub {
  font-size: 13.5px;
  color: var(--text);
}
.today-panel {
  position: sticky;
  top: 72px;
  padding: 22px 20px;
}
.today-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.today-list li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.today-link {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  color: inherit;
  text-decoration: none;
  border-radius: var(--r-lg);
  margin: -6px;
  padding: 6px 8px;
  transition: background 0.15s ease;
}
.today-link:hover {
  background: var(--bg-muted);
  color: inherit;
}
.today-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.today-list p {
  font-size: 14px;
}
.today-sum {
  font-size: 17px;
  font-weight: 700;
  margin: 2px 0;
}
.today-sub {
  color: var(--text-2);
  font-size: 13.5px;
}
.today-sub a {
  color: var(--info-link);
}
.ti-ok {
  color: #fff;
  fill: var(--brand-bright);
  stroke: #fff;
}
.ti-bad {
  color: #fff;
  fill: var(--danger-fill);
  stroke: #fff;
}
.ti-warn {
  color: var(--warning-fill);
}
.ti-neutral {
  color: var(--text-2);
}
.today-panel .card-title {
  font-size: 17px;
}
.quick {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.quick .btn {
  height: auto;
  min-height: 44px;
  justify-content: flex-start;
  padding: 8px 14px;
  font-size: 13.5px;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
}
.quick .btn-primary {
  justify-content: center;
}
.notice-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.notice-title .icon {
  color: #fff;
  fill: var(--text-2);
  stroke: #fff;
}
.notice-strong {
  margin-top: 10px;
  font-weight: 600;
  font-size: 14px;
}
.notice-text {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}
.inline-form {
  display: inline-flex;
  margin: 0;
}

/* ── Selects & inputs ─────────────────────────────────────────────────── */
.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
}
.select-wrap .select-icon {
  position: absolute;
  right: 12px;
  color: var(--text-2);
  pointer-events: none;
}
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px !important;
  cursor: pointer;
}
.select-lg .select {
  height: 44px;
  min-width: 204px;
  font-size: 14.5px;
}
.select-ghost .select {
  border-color: transparent;
  background: transparent;
  font-weight: 500;
  font-size: 13.5px;
  height: 34px;
}
.select-ghost .select:hover {
  background: var(--bg-subtle);
}
.select-chip {
  width: auto;
}
.select-chip .select {
  height: 36px;
  min-width: 160px;
  font-size: 13.5px;
}
.input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  color: var(--text);
  font: inherit;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease);
}
.input:hover {
  border-color: color-mix(in srgb, var(--text-2) 45%, var(--border-strong));
}
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-bright) 22%, transparent);
}
.input::placeholder {
  color: var(--text-3);
}
.input:disabled {
  background: var(--bg-muted);
  color: var(--text-3);
  cursor: not-allowed;
}
.textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}
input[type='file'].input {
  padding: 7px 10px;
  height: auto;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  min-width: 0;
}
.field-label {
  font-size: var(--font-label);
  font-weight: 550;
  letter-spacing: 0.01em;
  color: var(--text-2);
}
.req {
  color: var(--danger);
}
.field-hint {
  font-size: 12px;
  color: var(--text-3);
}
/* Итог выбора даты оформления рассрочки: день оплаты и первый платёж */
.plan-preview {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--r-lg);
  background: var(--brand-subtle);
  color: var(--brand-strong);
  font-weight: 500;
  line-height: 1.35;
}
.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--danger);
}
.field-invalid .input {
  border-color: var(--danger-fill);
}
.field-invalid .input:focus {
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.15);
}
.counter {
  position: absolute;
  right: 2px;
  bottom: -18px;
  font-size: 12px;
  color: var(--text-3);
}
.field:has(.counter) {
  margin-bottom: 14px;
}
.checkbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  cursor: pointer;
}
.checkbox input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--brand);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 3px;
  background: var(--bg-subtle);
  gap: 2px;
}
.seg label {
  flex: 1;
}
.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.seg span {
  display: block;
  text-align: center;
  padding: 6px 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.seg input:checked + span {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.seg input:focus-visible + span {
  box-shadow: var(--focus);
}
[data-risk-select].risk-LOW {
  background-color: var(--success-subtle);
  border-color: #9fd3b8;
  font-weight: 600;
}
[data-risk-select].risk-MEDIUM {
  background-color: var(--warning-subtle);
  border-color: #f0cf8b;
  font-weight: 600;
}
[data-risk-select].risk-HIGH {
  background-color: var(--danger-subtle);
  border-color: #f3b4ad;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 16px;
}
.form-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.form-grid > .alert,
.form-grid > .alert + * {
  grid-column: 1 / -1;
}
.span-2 {
  grid-column: 1 / -1;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.form-note {
  font-size: 12.5px;
  color: var(--text-2);
}
.form-note a {
  color: var(--info-link);
  text-decoration: underline;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.stack-lg > .card + .card {
  margin-top: 0;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.grid-2.gap {
  gap: 16px;
  margin-bottom: 16px;
}
.grid-2.gap > .card + .card {
  margin-top: 0;
}
.grid-main-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}
.grid-main-side > .card + .card {
  margin-top: 0;
}
.sticky {
  position: sticky;
  top: 76px;
}
.narrow {
  max-width: 820px;
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.err-list {
  margin: 4px 0 0;
  padding-left: 18px;
}
.plain-ol {
  margin: 6px 0 0;
  padding-left: 18px;
  line-height: 1.7;
}

/* ── Filters & tabs ───────────────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.filter-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 280px;
  max-width: 420px;
}
.filter-search .icon {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  pointer-events: none;
}
.filter-search .input {
  height: 36px;
  padding-left: 38px;
}
.chip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  border-radius: 15px;
  background: var(--bg-muted);
  font-size: 12.5px;
  color: var(--text-2);
}
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 22px 0 0;
  overflow-x: auto;
}
.tabs-inset {
  margin: 0;
  padding: 0 16px;
}
.tab {
  position: relative;
  padding: 12px 12px 13px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  transition:
    color var(--motion-fast) var(--ease-standard),
    background var(--motion-fast) var(--ease-standard);
}
.tab:hover {
  color: var(--text);
}
.tab.is-active {
  color: var(--text);
  font-weight: 600;
}
.tab.is-active::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--brand);
  animation: tab-indicator-in var(--motion-standard) var(--ease-emphasized);
}
@keyframes tab-indicator-in {
  from {
    transform: scaleX(0.55);
    opacity: 0.4;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-body);
}
.table th {
  position: sticky;
  top: 0;
  background: var(--bg-subtle);
  z-index: 1;
  text-align: left;
  font-weight: 550;
  font-size: var(--font-caption);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px var(--space-4);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text);
}
.table th:first-child,
.table td:first-child {
  padding-left: var(--space-5);
}
.table th:last-child,
.table td:last-child {
  padding-right: var(--space-5);
}
.table tbody tr {
  transition: background var(--dur) var(--ease);
}
.table tbody tr:hover {
  background: color-mix(in srgb, var(--brand-subtle) 45%, var(--bg-subtle));
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.ta-right {
  text-align: right !important;
}
.ta-center {
  text-align: center;
}
.col-menu {
  width: 48px;
}
.table-dense th {
  font-size: 12px;
  padding: 8px 10px;
}
.table-dense td {
  padding: 7px 10px;
  font-size: 13px;
}
.table-dense th:first-child,
.table-dense td:first-child {
  padding-left: 2px;
}
.table-dense th:last-child,
.table-dense td:last-child {
  padding-right: 2px;
}
.table-compact td,
.table-compact th {
  padding: 6px 10px;
  font-size: 12.5px;
}
.table-scroll {
  max-height: 520px;
  overflow-y: auto;
}
.table-total {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-2);
}
.two-line {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.two-line-main {
  font-weight: 600;
  color: var(--text);
}
a.two-line-main:hover {
  color: var(--brand);
}
.two-line-sub {
  font-size: 13px;
  color: var(--text-2);
}
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.pager-info {
  margin-right: auto;
  font-size: 13px;
  color: var(--text-2);
}
.matrix td {
  vertical-align: top;
}
.perm {
  display: inline-block;
  margin: 2px 2px 2px 0;
  font-size: 11.5px;
}
.doc-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.doc-name .icon {
  color: var(--text-2);
}
.rowmenu {
  position: relative;
  display: inline-block;
}
.rowmenu summary {
  list-style: none;
}
.rowmenu summary::-webkit-details-marker {
  display: none;
}
.rowmenu-pop {
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-overlay);
  padding: 6px;
  z-index: 5;
}
.rowmenu-pop a,
.rowmenu-pop button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: none;
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.rowmenu-pop a:hover,
.rowmenu-pop button:hover {
  background: var(--bg-muted);
}
.rowmenu-pop form {
  margin: 0;
}

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1;
  border: 1px solid transparent;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-neutral {
  background: var(--bg-muted);
  color: var(--text-2);
  border-color: var(--border);
}
.badge-info {
  background: var(--info-subtle);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 18%, transparent);
}
.badge-success {
  background: var(--success-subtle);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 18%, transparent);
}
.badge-warning {
  background: var(--warning-subtle);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 18%, transparent);
}
.badge-danger {
  background: var(--danger-subtle);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 18%, transparent);
}
.badge-brand {
  background: var(--accent-product-subtle);
  color: var(--accent-product);
  border-color: color-mix(in srgb, var(--accent-product) 18%, transparent);
}

/* ── Alerts ───────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  border: 1px solid;
  font-size: 13.5px;
}
.alert > .icon {
  margin-top: 1px;
}
.alert-title {
  font-weight: 600;
}
.alert-text {
  margin-top: 3px;
  color: #334155;
  line-height: 1.5;
}
.alert-info {
  background: var(--info-subtle);
  border-color: var(--info-border);
}
.alert-info > .icon {
  color: var(--info);
}
.alert-success {
  background: var(--success-subtle);
  border-color: #b6e0c9;
}
.alert-success > .icon {
  color: var(--success);
}
.alert-warning {
  background: var(--warning-subtle);
  border-color: #f0d49a;
}
.alert-warning > .icon {
  color: var(--warning);
}
.alert-danger {
  background: var(--danger-subtle);
  border-color: #f3b4ad;
}
.alert-danger > .icon {
  color: var(--danger);
}
.main > .alert {
  margin-bottom: 16px;
}

/* ── Charts ───────────────────────────────────────────────────────────── */
.chart {
  margin: 0;
  position: relative;
}
.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.chart-svg stop {
  stop-color: var(--chart-primary);
}
.ch-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.ch-axis {
  font-size: 11.5px;
  fill: var(--text-2);
  font-family: var(--font);
}
.ch-line {
  fill: none;
  stroke: var(--chart-primary);
  stroke-width: 2.25;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}
.ch-dot {
  fill: var(--chart-primary);
  stroke: #fff;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.ch-hit {
  fill: transparent;
  cursor: pointer;
}
.ch-pt:focus-visible .ch-dot,
.ch-pt:hover .ch-dot {
  r: 6;
}
.ch-pt:focus {
  outline: none;
}
.chart-tip {
  position: absolute;
  transform: translate(-50%, -120%);
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 9px;
  border-radius: var(--r-md);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.chart-table {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-2);
}
.chart-table summary {
  cursor: pointer;
  width: max-content;
}
.aging {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding-top: 10px;
}
.aging-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
  color: var(--text);
}
.aging-col:hover .aging-bar {
  opacity: 0.85;
}
.aging-val {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.aging-bar-wrap {
  width: 72%;
  max-width: 48px;
  height: 176px;
  flex: none;
  display: block;
  border-bottom: 1px solid var(--border);
}
.aging-bar {
  transition: opacity var(--dur);
}
.aging-1 {
  fill: var(--aging-1);
}
.aging-2 {
  fill: var(--aging-2);
}
.aging-3 {
  fill: var(--aging-3);
}
.aging-4 {
  fill: var(--aging-4);
}
.aging-label {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 10px;
  line-height: 1.35;
}

/* ── Deal workspace (референс B) ──────────────────────────────────────── */
.deal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-panel-w);
  margin: -8px -28px -40px;
  min-height: calc(100vh - 60px);
}
.deal-main {
  padding: 6px 28px 40px 28px;
  min-width: 0;
}
.deal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.deal-meta {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.vsep {
  width: 1px;
  height: 14px;
  background: var(--border-strong);
}
.stepper {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 24px 0 4px;
  padding: 0;
}
.step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-right: 12px;
}
.step::after {
  content: '';
  position: absolute;
  left: 44px;
  right: 8px;
  top: 17px;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
}
.step:last-child::after {
  display: none;
}
.step-done::after {
  background: var(--brand);
}
.step-current::after {
  background: linear-gradient(90deg, var(--text) 0 0) no-repeat;
  background-size: 0 100%;
  background-color: var(--border);
}
.step-dot {
  position: relative;
  z-index: 1;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  background: #e3e7ec;
  color: #8a97a8;
  box-shadow: 0 0 0 4px var(--bg-app);
}
.step-done .step-dot {
  background: var(--brand);
  color: #fff;
}
.step-current .step-dot {
  background: var(--bg-sidebar);
  color: #fff;
}
.step-blocked .step-dot {
  background: var(--warning-fill);
  color: #fff;
}
.step-text {
  display: flex;
  flex-direction: column;
  margin-top: 18px;
  margin-left: -46px;
  padding-left: 46px;
  background: transparent;
}
.step-text {
  margin: 0;
  padding: 0;
  position: absolute;
  top: 42px;
  left: 0;
}
.step {
  padding-bottom: 42px;
}
.step-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.step-todo .step-label {
  color: var(--text-2);
  font-weight: 500;
}
.step-sub {
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
}
.section {
  padding: 22px 0 22px;
  border-bottom: 1px solid var(--border);
}
.section-last {
  border-bottom: 0;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  justify-content: space-between;
}
.section-head .section-title + .badge {
  margin-right: auto;
}
.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.section-note {
  margin-bottom: 10px;
  font-size: 13px;
}
.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 32px;
}
.section-grid > :nth-child(2) {
  border-left: 1px solid var(--border);
  padding-left: 28px;
}
.kv {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.kv-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  font-size: 14px;
}
.kv dt {
  color: var(--text-2);
}
.kv dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}
.kv dd a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}
.kv-stack .kv-row {
  grid-template-columns: 200px minmax(0, 1fr);
}
.kv-right {
  margin: 0;
  display: flex;
  flex-direction: column;
}
.kv-right .kv-row {
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 16px;
  padding: 5px 0;
  align-items: baseline;
}
.kv-right dt {
  color: var(--text-2);
  font-size: 14px;
}
.kv-right dd {
  margin: 0;
  text-align: right;
  font-size: 14.5px;
}
.kv-right .kv-sep {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 7px;
}
.kv-note {
  display: block;
  font-size: 12px;
  color: var(--text-2);
}
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ck {
  display: grid;
  grid-template-columns: 22px minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
}
.ck-label {
  color: var(--text);
}
.ck-note {
  color: var(--text-2);
  font-size: 13px;
}
.ck-ok {
  color: #fff;
  fill: var(--brand-bright);
  stroke: #fff;
}
.ck-fail {
  color: #fff;
  fill: var(--danger-fill);
  stroke: #fff;
}
.ckdot-pending {
  width: 18px;
  height: 18px;
  margin: 1px;
  border-radius: 50%;
  background: #c9d1db;
  display: block;
}
.ckdot-waiting {
  width: 18px;
  height: 18px;
  margin: 1px;
  border-radius: 50%;
  border: 2px solid #b3bdc9;
  display: block;
  background: #fff;
}
.blockers {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
}
.blockers li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.blockers .icon {
  margin-top: 2px;
  color: var(--warning);
}

.deal-side {
  background: #fff;
  border-left: 1px solid var(--border);
  padding: 18px 24px 40px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.side-block {
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--border);
}
.side-block:last-child {
  border-bottom: 0;
}
.side-block > * + * {
  margin-top: 12px;
}
.side-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.side-status .card-title + .badge {
  margin-right: auto;
}
.side-foot {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
}
.side-foot .icon {
  margin-top: 2px;
}
.panel-h {
  font-size: 17px;
  font-weight: 700;
  margin-top: 4px;
}
.panel-p {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.5;
}
.cancel-form {
  padding: 4px 0 0;
}
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.tl-item {
  position: relative;
  display: flex;
  gap: 14px;
  padding-bottom: 14px;
}
.tl-item::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 12px;
  bottom: -2px;
  width: 1px;
  background: var(--border-strong);
}
.tl-item:last-child::before {
  display: none;
}
.tl-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 6px;
  position: relative;
  z-index: 1;
}
.tl-pending .tl-dot {
  background: #c9d1db;
}
.tl-danger .tl-dot {
  background: var(--danger-fill);
}
.tl-title {
  font-size: 13.5px;
  font-weight: 500;
}
.tl-sub {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 2px;
  line-height: 1.45;
}

/* ── Buckets (Просрочка) ──────────────────────────────────────────────── */
.bucket-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.bucket {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 16px 18px 16px 22px;
  overflow: hidden;
}
.bucket::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--text-3);
}
.bucket-1::before {
  background: var(--aging-1);
}
.bucket-2::before {
  background: var(--aging-2);
}
.bucket-3::before {
  background: var(--aging-3);
}
.bucket-4::before {
  background: var(--aging-4);
}
.bucket.is-active {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}
.bucket-label {
  font-size: 13px;
  color: var(--text-2);
}
.bucket-sum {
  font-size: 20px;
  font-weight: 700;
}
.bucket-sub {
  font-size: 12.5px;
  color: var(--text-2);
}

/* ── Empty / error ────────────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 36px 16px;
  color: var(--text-2);
  text-align: center;
}
.empty .icon {
  color: var(--text-3);
}
.empty-title {
  font-weight: 600;
  color: var(--text);
}
.empty-text {
  font-size: 13px;
}
.error-page {
  max-width: 560px;
  margin: 64px auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
}
.error-page > .icon {
  color: var(--text-3);
}

/* ── Dialog ───────────────────────────────────────────────────────────── */
.dialog {
  border: 0;
  border-radius: var(--r-xl);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: var(--shadow-overlay);
  color: var(--text);
}
.dialog-wide {
  width: min(760px, calc(100vw - 32px));
}
.dialog[open] {
  animation: dlg-in var(--motion-enter) var(--ease-enter);
}
.dialog::backdrop {
  background: rgba(15, 27, 45, 0.45);
  animation: backdrop-in var(--motion-enter) var(--ease-standard);
}
@keyframes dlg-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 0;
}
.dialog-title {
  font-size: 18px;
  font-weight: 700;
}
.dialog-body {
  padding: 16px 22px 22px;
}
[data-toggle][hidden],
[data-vehicle][hidden] {
  display: none !important;
}

/* ── Toast ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 10px 12px 16px;
  border-radius: var(--r-lg);
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow-overlay);
  font-size: 14px;
  animation: toast-in var(--motion-enter) var(--ease-enter);
}
.toast .icon-btn {
  color: rgba(255, 255, 255, 0.7);
  width: 28px;
  height: 28px;
}
.toast .icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.toast-success > .icon {
  color: var(--brand-bright);
}
.toast-danger > .icon {
  color: #f5a8a2;
}
.toast-warning > .icon {
  color: var(--warning-fill);
}
.toast-info > .icon {
  color: #93c5fd;
}
.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity var(--motion-exit) var(--ease-exit),
    transform var(--motion-exit) var(--ease-exit);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ── Command palette ──────────────────────────────────────────────────── */
.palette {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 27, 45, 0.45);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
}
.palette[hidden] {
  display: none;
}
.palette-box {
  width: min(640px, calc(100vw - 32px));
  background: #fff;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;
}
.palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.palette-input {
  flex: 1;
  border: 0;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  outline: none;
}
.palette-results {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 50vh;
  overflow-y: auto;
}
.palette-results li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-lg);
}
.palette-results li a[aria-selected='true'],
.palette-results li a:hover {
  background: var(--bg-muted);
  color: var(--text);
}
.pal-type {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  min-width: 56px;
  text-align: center;
}
.pal-title {
  font-weight: 600;
}
.pal-sub {
  font-size: 12.5px;
  color: var(--text-2);
}
.pal-empty {
  padding: 18px;
  color: var(--text-2);
  font-size: 13.5px;
  text-align: center;
}
.pal-mark {
  background: color-mix(in srgb, var(--brand) 28%, transparent);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.palette-foot {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 13px;
}
.palette-foot a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
}
.palette-foot a:hover {
  color: var(--brand);
}

/* ── Auth ─────────────────────────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  background: var(--bg-app);
}
.auth-body:not(:has(.auth-panel)) {
  grid-template-columns: 1fr;
  place-items: center;
  background: radial-gradient(1200px 600px at 10% -10%, #163150 0%, var(--bg-sidebar) 60%);
  padding: 24px 16px;
}
.auth-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  padding: 40px 48px 36px;
  color: #fff;
  background:
    radial-gradient(900px 420px at -10% 110%, rgba(34, 160, 107, 0.22), transparent 55%),
    radial-gradient(640px 320px at 110% -10%, rgba(27, 122, 80, 0.16), transparent 50%), var(--bg-sidebar);
  overflow: hidden;
}
.auth-panel-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image:
    linear-gradient(30deg, transparent 47.5%, #fff 50%, transparent 52.5%),
    linear-gradient(-30deg, transparent 47.5%, #fff 50%, transparent 52.5%);
  background-size: 88px 152px;
  -webkit-mask-image: radial-gradient(120% 80% at 80% 20%, #000 20%, transparent 70%);
  mask-image: radial-gradient(120% 80% at 80% 20%, #000 20%, transparent 70%);
}
.auth-panel-top,
.auth-panel-copy,
.auth-panel-foot {
  position: relative;
  z-index: 1;
}
.auth-panel .brand-name {
  font-size: 22px;
  letter-spacing: 0.06em;
}
.auth-panel .brand-product {
  font-size: 13.5px;
}
.auth-panel-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-bright);
  margin: 0 0 12px;
}
.auth-panel-heading {
  font-size: 32px;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.03em;
  max-width: 16ch;
  margin: 0 0 28px;
}
.auth-panel-points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 36ch;
}
.auth-panel-points li {
  position: relative;
  padding-left: 22px;
  font-size: 14.5px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
}
.auth-panel-points li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--brand-bright);
}
.auth-panel-foot {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.48);
}
.auth {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px 24px;
}
.auth-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.auth-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  margin: 0;
  text-align: center;
}
.auth-title {
  font-size: var(--font-h1);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: var(--lh-tight);
  text-align: center;
}
.auth-form {
  gap: 16px;
  margin-top: 4px;
}
.auth-form .input {
  height: 44px;
}
.field-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--info-link);
  white-space: nowrap;
}
.field-link:hover {
  color: var(--brand);
}
.auth-foot {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--text-3);
}
.demo-hint {
  font-size: 13px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 14px;
}
.demo-hint summary {
  cursor: pointer;
  font-weight: 600;
}
.demo-hint ul {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.8;
}
.demo-hint p {
  margin-top: 8px;
}
.error-page .page-title {
  font-size: 28px;
}
.auth .error-page {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  margin: 0;
}
@media (max-width: 959px) {
  .auth-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .auth-panel {
    padding: 24px 32px 22px;
    gap: 0;
    min-height: 0;
  }
  .auth-panel-copy,
  .auth-panel-foot,
  .auth-panel-glow {
    display: none;
  }
  .auth {
    align-items: flex-start;
    padding: 40px 32px;
    background: #fff;
  }
}

/* ── Deal form ────────────────────────────────────────────────────────── */
.calc .kv-right dd {
  font-size: 15px;
}
.calc .card-head {
  margin-bottom: 6px;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1439px) {
  :root {
    --side-panel-w: 360px;
  }
  .dash {
    grid-template-columns: minmax(0, 1fr);
  }
  .today-panel {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 28px;
  }
  .today-panel > .card-title {
    grid-column: 1;
  }
  .today-panel > .today-list {
    grid-column: 1;
    grid-row: 2;
    margin-top: 0;
  }
  .today-panel > hr {
    display: none;
  }
  .today-panel > .card-title:nth-of-type(2) {
    grid-column: 2;
    grid-row: 1;
  }
  .today-panel > .quick {
    grid-column: 2;
    grid-row: 2;
    margin-top: 0;
  }
  .today-panel > .notice {
    grid-column: 3;
    grid-row: 1 / span 2;
  }
}
@media (max-width: 1279px) {
  :root {
    --sidebar-w: 76px;
  }
  .brand {
    padding: 0 0 22px;
    justify-content: center;
  }
  .brand-sub,
  .nav-label,
  .user-text,
  .usermenu summary > .icon {
    display: none;
  }
  .brand-name {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 0;
    margin: 0 10px;
    border-radius: var(--r-lg);
  }
  .nav-item.is-active::before {
    left: -10px;
    border-radius: 0 3px 3px 0;
  }
  .nav-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
  }
  .sidebar-foot {
    margin: 12px 10px 0;
    padding: 12px 0 0;
    display: flex;
    justify-content: center;
  }
  .usermenu-pop {
    left: 0;
    right: auto;
    width: 240px;
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dash-main {
    grid-template-columns: minmax(0, 1fr);
  }
  .deal-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .deal-side {
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .grid-main-side {
    grid-template-columns: minmax(0, 1fr);
  }
  .sticky {
    position: static;
  }
  .bucket-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 1023px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  :root {
    --sidebar-w: 260px;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 272px;
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 220ms var(--ease),
      visibility 0s linear 220ms;
    box-shadow: var(--shadow-overlay);
  }
  .shell.sidebar-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 220ms var(--ease);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 27, 45, 0.45);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms;
  }
  .shell.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar .brand {
    padding: 0 20px 22px 24px;
    justify-content: space-between;
  }
  .sidebar .brand-sub,
  .sidebar .nav-label,
  .sidebar .user-text {
    display: revert;
  }
  .sidebar .brand-name {
    display: inline;
    font-size: 16px;
  }
  .sidebar .nav-item {
    justify-content: flex-start;
    padding: 0 16px 0 24px;
    margin: 0 8px 0 0;
    border-radius: 0 var(--r-lg) var(--r-lg) 0;
  }
  .sidebar .nav-item.is-active::before {
    left: 0;
  }
  .sidebar .nav-badge {
    position: static;
  }
  .sidebar .sidebar-foot {
    display: block;
    margin: 12px 20px 0;
  }
  .brand .sidebar-close,
  .menu-btn {
    display: inline-flex;
  }
  .topbar {
    padding: 0 16px;
  }
  .today {
    display: none;
  }
  .main {
    padding: 8px 16px 32px;
  }
  .deal-layout {
    margin: -8px -16px -32px;
  }
  .deal-main {
    padding: 6px 16px 24px;
  }
  .deal-side {
    padding: 16px;
  }
  .section-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
  .section-grid > :nth-child(2) {
    border-left: 0;
    padding-left: 0;
    border-top: 1px dashed var(--border);
    padding-top: 16px;
  }
  .today-panel {
    grid-template-columns: minmax(0, 1fr);
  }
  .today-panel > * {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
  .grid-2,
  .grid-2.gap {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 767px) {
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }
  .page-title {
    font-size: 26px;
  }
  .page-title-compact {
    font-size: 24px;
  }
  .page-subtitle {
    font-size: 14px;
  }
  .kpis {
    grid-template-columns: minmax(0, 1fr);
  }
  .metric {
    min-height: 0;
    padding: 16px;
  }
  .metric-value {
    font-size: 24px;
    margin: 8px 0 6px;
  }
  .search .kbd {
    display: none;
  }
  .stepper {
    grid-template-columns: repeat(5, minmax(56px, 1fr));
    overflow-x: auto;
  }
  .step-sub {
    display: none;
  }
  .step-label {
    font-size: 12px;
  }
  .step::after {
    left: 40px;
  }
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .kv-row,
  .kv-stack .kv-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
  .ck {
    grid-template-columns: 22px minmax(0, 1fr);
  }
  .ck-note,
  .ck-action {
    grid-column: 2;
  }
  .bucket-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .table th:first-child,
  .table td:first-child {
    padding-left: 14px;
  }
  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
  .aging {
    gap: 6px;
  }
  .aging-bar-wrap {
    height: 140px;
  }
  .aging-val {
    font-size: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
@media print {
  .sidebar,
  .topbar,
  .deal-side .btn,
  .toast,
  .palette {
    display: none !important;
  }
  .shell {
    display: block;
  }
  .deal-layout {
    grid-template-columns: 1fr 320px;
    margin: 0;
  }
}

/* ── Безопасность, импорт, печать (этап production) ───────────────────── */
.auth-text {
  color: var(--text-2);
  margin: -8px 0 0;
  font-size: 14.5px;
  line-height: 1.45;
}
.auth-link {
  margin: 14px 0 0;
  text-align: center;
  font-size: 14px;
}
.auth-link a {
  color: var(--info-link);
}
.input-code {
  font-size: 22px;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.usermenu-link {
  justify-content: flex-start;
  margin-bottom: 4px;
}
.usermenu-link:hover {
  color: var(--text);
}
.form-inline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  max-width: 420px;
}
.mfa-setup {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  align-items: start;
}
.mfa-qr {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: #fff;
  line-height: 0;
}
.qr {
  display: block;
  max-width: 100%;
  height: auto;
}
.mfa-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 18px;
  font-size: 15px;
}
.mfa-steps li::marker {
  font-weight: 700;
  color: var(--brand);
}
.secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}
.secret {
  font:
    600 16px/1.4 ui-monospace,
    'SF Mono',
    Menlo,
    Consolas,
    monospace;
  letter-spacing: 0.06em;
  background: var(--bg-muted);
  border-radius: var(--r-md);
  padding: 6px 10px;
  word-break: break-all;
}
.codes {
  font:
    600 18px/1.9 ui-monospace,
    'SF Mono',
    Menlo,
    Consolas,
    monospace;
  letter-spacing: 0.08em;
  columns: 2;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 16px 24px;
  margin: 0 0 16px;
  max-width: 460px;
}
.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--brand);
  flex: none;
}
.form-actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  gap: 12px;
  padding: 14px 0;
  background: linear-gradient(to top, var(--bg-app) 70%, rgba(245, 247, 250, 0));
}
.row-actions form {
  display: inline;
}
.col-actions {
  width: 1%;
  white-space: nowrap;
}
.mono {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.warn {
  color: var(--warning);
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

/* Загрузка файлов */
.upload-box {
  display: grid;
  gap: 14px;
}
.dropzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 28px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--bg-subtle);
  color: var(--text-2);
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease);
}
.dropzone:hover,
.dropzone.is-drag {
  border-color: var(--brand-bright);
  background: var(--brand-subtle);
}
.dropzone.is-invalid {
  border-color: var(--danger-fill);
}
.dropzone input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dz-title {
  font-weight: 600;
  color: var(--text);
}
.dz-hint {
  font-size: 13px;
}
.dz-file {
  font-weight: 600;
  color: var(--brand-strong);
}
.dropzone-compact {
  padding: 16px 14px;
}
.dropzone-compact .dz-title {
  font-size: 14px;
}
.steps-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}
.issue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.issue-list li {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 13px;
}
.issue-list .icon {
  flex: none;
  margin-top: 2px;
}
.issue-list .is-error {
  color: var(--danger);
}
.issue-list .is-warn {
  color: var(--warning);
}
.metric-sm {
  min-height: 0;
  padding: 16px 18px;
}
.metric-sm .metric-value {
  font-size: 24px;
  margin: 8px 0 4px;
}
.match-cell {
  display: grid;
  gap: 6px;
  min-width: 240px;
}
.input-sm {
  height: 34px;
  font-size: 13px;
  padding: 0 10px;
}
.select-wrap .input-sm {
  padding-right: 30px;
}
.purpose {
  display: block;
  max-width: 340px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.45;
}

/* Меню документов */
.deal-title-row {
  position: relative;
}
.dropdown {
  position: relative;
}
.dropdown > summary {
  list-style: none;
  cursor: pointer;
}
.dropdown > summary::-webkit-details-marker {
  display: none;
}
.dropdown-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 300px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-overlay);
  padding: 6px;
  display: grid;
}
.dropdown-pop a {
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
}
.dropdown-pop a:hover {
  background: var(--bg-muted);
}
.print-menu {
  margin-left: auto;
}

@media (max-width: 767px) {
  .mfa-setup {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .codes {
    columns: 1;
  }
  .dropdown-pop {
    left: 0;
    right: auto;
    min-width: min(300px, calc(100vw - 32px));
  }
  .print-menu {
    margin-left: 0;
  }
  .match-cell {
    min-width: 200px;
  }
}
.grid-2 > .card + .card {
  margin-top: 0;
}
.card-flush > .card-head {
  padding: 18px 22px 0;
}
.card-flush > .table-wrap:first-child .table thead th {
  padding-top: 14px;
}
.card-flush .table-dense th:first-child,
.card-flush .table-dense td:first-child {
  padding-left: 22px;
}
.card-flush .table-dense th:last-child,
.card-flush .table-dense td:last-child {
  padding-right: 22px;
}
.table-statement td {
  vertical-align: top;
  padding-top: 12px;
  padding-bottom: 12px;
}
.form-actions-sticky {
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════
   Мобильная версия (≤ 767 px): нижняя навигация, таблицы-карточки,
   диалоги-шторки, поля 16 px (без автозума iOS), зоны нажатия от 44 px.
   ═══════════════════════════════════════════════════════════════════════ */
.tabbar,
.deal-mobile-status,
.mobile-action-bar,
.mobile-fab,
.mobile-brand,
.mobile-quick,
.client-mobile-bar,
.client-followup-sheet {
  display: none;
}

@media (max-width: 767px) {
  :root {
    --tabbar-h: 60px;
    --safe-b: env(safe-area-inset-bottom, 0px);
  }
  html {
    -webkit-tap-highlight-color: transparent;
  }
  body {
    padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
  }
  body.has-action-bar {
    padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 72px);
  }

  /* Верхняя панель: компактная, с учётом «чёлки» */
  .topbar {
    height: calc(52px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 10px 0;
    gap: 6px;
  }
  .menu-btn {
    display: none !important;
  }
  .mobile-brand {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
  }
  .mobile-brand:active {
    background: var(--bg-muted);
  }
  .search {
    flex: 1;
    max-width: none;
    min-width: 0;
  }
  .search .kbd {
    display: none;
  }
  .search-input {
    font-size: 16px;
    min-height: 44px;
  }
  .topbar .today {
    display: none;
  }
  .h1,
  .page-title,
  .page-head .h1 {
    font-size: 22px;
    line-height: 1.25;
    letter-spacing: -0.02em;
  }
  .h2 {
    font-size: 18px;
  }
  .h3 {
    font-size: 16px;
  }

  /* Нижняя панель вкладок */
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding: 4px 4px var(--safe-b);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--border);
  }
  .tabbar-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    border: 0;
    background: none;
    border-radius: var(--r-lg);
    color: var(--text-3);
    font: 500 11px/1.1 var(--font);
    text-align: center;
    cursor: pointer;
    transition: color var(--dur) var(--ease);
  }
  .tabbar-item span:not(.tabbar-badge) {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tabbar-item:active {
    background: var(--bg-muted);
  }
  .tabbar-item.is-active {
    color: var(--brand);
    font-weight: 600;
  }
  .tabbar-badge {
    position: absolute;
    top: 3px;
    left: calc(50% + 6px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger-fill);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
  }

  /* Меню «Ещё» выезжает поверх панели */
  .sidebar {
    z-index: 40;
    width: min(300px, 86vw);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .sidebar-backdrop {
    z-index: 35;
  }

  /* Контент */
  .main {
    padding: 8px 16px 24px;
  }
  .page-head {
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-actions {
    display: grid;
    grid-auto-flow: row;
    gap: 8px;
  }
  .page-actions .btn,
  .page-head-side .btn,
  .page-head-side .select-wrap {
    width: 100%;
    justify-content: center;
  }
  .crumbs {
    display: none;
  }

  /* Сводные показатели: 2 × 2 */
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .metric {
    padding: 14px;
    border-radius: var(--r-lg);
  }
  .metric-label {
    font-size: 12.5px;
    line-height: 1.3;
  }
  .metric-value {
    font-size: 19px;
    letter-spacing: -0.02em;
    margin: 6px 0 4px;
    overflow-wrap: anywhere;
  }
  .metric-delta {
    font-size: 12px;
    gap: 4px;
  }
  .metric-sm .metric-value {
    font-size: 19px;
  }
  .card {
    padding: 16px;
    border-radius: var(--r-lg);
  }
  .card-title {
    font-size: 17px;
  }
  .card-flush > .card-head {
    padding: 16px 16px 0;
  }

  /* Поля: 16 px — iOS не увеличивает страницу при фокусе; высота 48 px */
  .input,
  .select,
  .textarea,
  .input-sm {
    font-size: 16px;
  }
  .input:not(.textarea),
  .select {
    min-height: 48px;
  }
  .input-sm {
    min-height: 44px;
    height: 44px;
  }
  .btn {
    min-height: 44px;
  }
  .btn-sm {
    min-height: 38px;
  }
  .form-actions,
  .form-actions-sticky {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .form-actions .btn,
  .form-actions-sticky .btn {
    width: 100%;
    justify-content: center;
  }
  .form-actions-sticky {
    bottom: calc(var(--tabbar-h) + var(--safe-b));
  }
  .deal-form .btn-primary-strong.btn-lg {
    position: sticky;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
    z-index: 4;
  }

  /* Фильтры списков — в две колонки на всю ширину */
  .filters,
  .filter-row,
  .list-filters {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .filters > *,
  .filter-row > *,
  .list-filters > * {
    width: 100% !important;
    min-width: 0 !important;
  }
  .filters > .search-field,
  .filters > :first-child,
  .list-filters > :first-child {
    grid-column: 1 / -1;
  }

  /* Вкладки: прокрутка пальцем без полосы */
  .tabs,
  .seg,
  .segmented {
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tab {
    scroll-snap-align: start;
    padding: 12px 10px 13px;
  }

  /* ── Таблицы → карточки ─────────────────────────────────────────────── */
  .table-wrap.has-cards {
    overflow: visible;
    border: 0;
  }
  .table-cards,
  .table-cards tbody {
    display: block;
    width: 100%;
  }
  .table-cards thead {
    display: none;
  }
  .table-cards tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 6px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: #fff;
  }
  .card:not(.card-flush) .table-cards tr {
    padding: 14px 0;
  }
  .table-cards tr:last-child {
    border-bottom: 0;
  }
  .table-cards tr:hover {
    background: #fff;
  }
  .table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    grid-column: 1 / -1;
    padding: 0 !important;
    border: 0 !important;
    min-width: 0;
    text-align: right;
    font-size: 14px;
  }
  .table-cards td::before {
    content: attr(data-label);
    flex: none;
    max-width: 45%;
    color: var(--text-3);
    font-size: 12.5px;
    font-weight: 500;
    text-align: left;
  }
  .table-cards td[data-label='']::before,
  .table-cards td.is-empty {
    display: none;
  }
  .table-cards td[data-label=''] {
    justify-content: flex-start;
    text-align: left;
  }
  /* Первая ячейка — заголовок карточки */
  .table-cards td:first-child {
    grid-column: 1;
    display: block;
    text-align: left;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
  }
  .table-cards td:first-child::before {
    display: none;
  }
  /* Если вторая ячейка — статус или сумма, ставим её справа от заголовка */
  .table-cards td:first-child + td:has(.badge:only-child) {
    grid-column: 2;
    grid-row: 1;
    display: block;
  }
  .table-cards td:first-child + td:has(.badge:only-child)::before {
    display: none;
  }
  .table-cards .two-line {
    align-items: flex-end;
    text-align: right;
  }
  .table-cards td:first-child .two-line {
    align-items: flex-start;
    text-align: left;
  }
  .table-cards .row-actions,
  .table-cards .inline-form,
  .table-cards td form {
    justify-content: flex-start;
  }
  .table-cards td:has(> .row-actions),
  .table-cards td:has(> form),
  .table-cards td:has(> .inline-form),
  .table-cards td.col-actions,
  .table-cards td.col-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 6px !important;
  }
  .table-cards td.col-actions::before,
  .table-cards td.col-menu::before {
    display: none;
  }
  /* Кнопки в карточках строк: на 320px не раздувают страницу */
  .table-cards td:has(.btn),
  .table-cards td:has(button),
  .table-cards td:has(a.btn) {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .table-cards td:has(.btn)::before,
  .table-cards td:has(button)::before,
  .table-cards td:has(a.btn)::before {
    max-width: none;
  }
  .table-cards td .btn,
  .table-cards td button.btn,
  .table-cards td a.btn {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    white-space: normal;
    height: auto;
    min-height: var(--touch);
    text-wrap: balance;
  }
  .table-wrap,
  .card,
  .dash-main,
  .main {
    min-width: 0;
    max-width: 100%;
  }
  .table-cards tfoot,
  .table-cards tfoot tr {
    display: block;
  }
  .table-total,
  .table-cards tfoot td {
    display: flex;
    justify-content: space-between;
  }
  .table-cards .perm {
    display: inline-block;
    margin: 2px 0;
  }
  .matrix.table-cards td {
    display: block;
    text-align: left;
  }
  .matrix.table-cards td::before {
    display: block;
    max-width: none;
    margin-bottom: 4px;
  }
  .table-statement.has-cards .match-cell {
    min-width: 0;
    width: 100%;
  }
  .table-cards td:has(.match-cell) {
    display: block;
    text-align: left;
  }
  .table-cards td:has(.match-cell)::before {
    display: block;
    margin-bottom: 6px;
  }
  .purpose {
    max-width: none;
    text-align: right;
  }

  /* ── Диалоги → шторки снизу ─────────────────────────────────────────── */
  .dialog,
  .dialog-wide {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .dialog[open] {
    animation: sheet-in 240ms var(--ease);
  }
  .dialog-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
    padding-top: 18px;
  }
  .dialog-head::before {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 2px;
    background: var(--border-strong);
  }
  .dialog-body {
    overflow-y: auto;
  }

  /* Уведомления — над нижней панелью */
  .toast {
    left: 12px;
    right: 12px;
    max-width: none;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  }
  body.has-action-bar .toast {
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 84px);
  }

  /* ── Карточка сделки ────────────────────────────────────────────────── */
  .deal-layout {
    display: flex;
    flex-direction: column;
  }
  .deal-title-row {
    gap: 8px;
  }
  .deal-meta {
    width: 100%;
  }
  .print-menu {
    width: 100%;
  }
  .print-menu > summary {
    width: 100%;
    justify-content: center;
  }
  .dropdown-pop {
    left: 0;
    right: 0;
    min-width: 0;
  }
  .deal-mobile-status {
    position: sticky;
    top: calc(52px + env(safe-area-inset-top, 0px));
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 14px 0 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text);
    box-shadow: var(--shadow-xs);
    text-decoration: none;
    min-height: var(--touch);
  }
  .dms-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
  }
  .dms-facts {
    font-size: 13px;
    color: var(--text-2);
  }
  .dms-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--brand);
  }
  .deal-side {
    scroll-margin-top: 64px;
    border-left: 0;
    border-top: 8px solid var(--bg-app);
  }
  .mobile-action-bar {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--tabbar-h) + var(--safe-b));
    z-index: 29;
    padding: 10px 16px;
    background: linear-gradient(to top, rgba(245, 247, 250, 0.98) 75%, rgba(245, 247, 250, 0));
  }
  .mobile-action-bar[hidden] {
    display: none;
  }
  .mobile-action-bar .btn {
    box-shadow: 0 6px 18px rgba(14, 90, 67, 0.28);
  }

  /* FAB — одно создание сущностей */
  .mobile-fab {
    display: block;
    position: fixed;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
    z-index: 28;
  }
  .mobile-fab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 18px;
    background: var(--brand);
    color: #fff;
    box-shadow: 0 8px 24px rgba(14, 90, 67, 0.35);
    cursor: pointer;
    transition:
      transform 0.15s ease,
      background 0.15s ease;
  }
  .mobile-fab.is-open .mobile-fab-btn,
  .mobile-fab-btn[aria-expanded='true'] {
    background: var(--text);
    transform: rotate(45deg);
  }
  .mobile-fab-btn:active {
    transform: scale(0.96);
  }
  .mobile-fab-sheet {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    display: flex;
    flex-direction: column;
    min-width: 220px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    background: var(--surface, #fff);
    box-shadow: var(--shadow-lg, 0 12px 40px rgba(15, 23, 42, 0.18));
  }
  .mobile-fab-sheet[hidden] {
    display: none;
  }
  .mobile-fab-sheet a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 10px 14px;
    border-radius: var(--r-lg);
    color: var(--text);
    font: 600 15px/1.2 var(--font);
    text-decoration: none;
  }
  .mobile-fab-sheet a:active {
    background: var(--bg-muted);
  }
  body.has-action-bar .mobile-fab {
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 84px);
  }

  /* Быстрые действия на Dashboard */
  .mobile-quick {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 8px;
    margin: 0 0 16px;
  }
  .mobile-quick-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 72px;
    padding: 10px 6px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface, #fff);
    color: var(--text);
    font: 600 11px/1.2 var(--font);
    text-align: center;
    text-decoration: none;
  }
  .mobile-quick-item:active {
    background: var(--bg-muted);
  }
  .mobile-quick-item svg {
    color: var(--brand);
  }

  /* Dashboard: порядок блоков под мобильный приоритет */
  .dash-mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .dash-mobile-stack > .dash {
    display: contents;
  }
  .dash-order-today {
    order: 1;
  }
  .dash-order-kpi {
    order: 2;
  }
  .dash-order-queue {
    order: 3;
  }
  .dash-order-brief {
    order: 4;
  }
  .dash-order-insights {
    order: 5;
  }
  .dash-order-charts,
  .dash-mobile-stack .dash-main {
    order: 6;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .dash-mobile-stack .card-chart,
  .dash-mobile-stack .card-aging {
    order: 10;
  }
  .dash-mobile-stack .card-attention {
    order: 0;
  }
  .dash-mobile-stack .today-panel .sep,
  .dash-mobile-stack .today-panel .card-title:nth-of-type(2),
  .dash-mobile-stack .today-panel .quick {
    display: none;
  }
  .brief-item a,
  .queue-item a,
  .today-link {
    min-height: 48px;
  }

  .client-mobile-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 14px;
  }
  .client-mobile-bar a,
  .client-mobile-bar button,
  .client-mobile-bar summary,
  .client-mobile-bar > span {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 56px;
    padding: 8px 4px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface, #fff);
    color: var(--text);
    font: 600 11px/1.15 var(--font);
    text-decoration: none;
    cursor: pointer;
    list-style: none;
  }
  .client-mobile-bar summary::-webkit-details-marker {
    display: none;
  }
  .client-mobile-bar a:active,
  .client-mobile-bar button:active,
  .client-mobile-bar summary:active {
    background: var(--bg-muted);
  }
  .client-mobile-bar svg {
    color: var(--brand);
  }
  .client-mobile-bar .is-disabled {
    opacity: 0.45;
    cursor: default;
  }
  .client-more-menu {
    position: relative;
  }
  .client-more-pop {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 5;
    display: flex;
    flex-direction: column;
    min-width: 180px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface, #fff);
    box-shadow: var(--shadow-md);
  }
  .client-more-pop a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 12px;
    border: 0;
    border-radius: var(--r-md);
    font: 600 14px/1.2 var(--font);
  }
  .client-followup-sheet {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
  }
  .client-hero-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .hero-kpi-value {
    font-size: 17px;
    overflow-wrap: anywhere;
  }
  .page-head .followup-presets,
  .page-actions .followup-presets {
    display: none;
  }

  /* AI sticky ask on mobile */
  .ask-form {
    position: sticky;
    top: calc(52px + env(safe-area-inset-top, 0px));
    z-index: 5;
  }
  .ask-row {
    flex-direction: column;
    align-items: stretch;
  }
  .ask-row .btn {
    width: 100%;
  }
  .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Search results — large rows */
  .search-page .two-line-main {
    font-size: 16px;
    font-weight: 600;
  }
  .search-page .table-cards tr {
    padding: 16px;
  }

  /* Tasks segmented feel */
  .tabs-inset {
    display: flex;
    overflow-x: auto;
    gap: 0;
    -webkit-overflow-scrolling: touch;
  }

  /* Offline banner */
  .offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
    background: var(--danger-fill);
    color: #fff;
    font: 600 13px/1.3 var(--font);
    text-align: center;
  }
  .offline-banner[hidden] {
    display: none !important;
  }

  /* Document preview — fullscreen-like */
  .doc-preview {
    margin: 0 -16px;
    min-height: calc(100dvh - 160px - var(--tabbar-h) - var(--safe-b));
    background: #0b1220;
  }
  .doc-preview img,
  .doc-preview iframe {
    width: 100%;
    height: calc(100dvh - 160px - var(--tabbar-h) - var(--safe-b));
    min-height: 60vh;
    border: 0;
    object-fit: contain;
  }

  /* Chart tap targets */
  .chart-svg [data-tip],
  .aging-bar,
  .chart-hit {
    cursor: pointer;
  }

  /* Empty / error compact */
  .empty {
    padding: 28px 16px;
  }
  .empty-title {
    font-size: 17px;
  }
  .empty .btn {
    min-height: 48px;
  }

  @media (prefers-reduced-motion: reduce) {
    .mobile-fab-btn,
    .tabbar-item,
    .dialog {
      transition: none !important;
      animation: none !important;
    }
  }

  /* Графики и dashboard */
  .chart-card .card-head,
  .dash .card-head {
    flex-wrap: wrap;
  }
  .aging-bar-wrap {
    height: 110px;
  }

  /* Вход и публичные страницы */
  .auth-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .auth-panel {
    padding: 20px 20px 18px;
    gap: 0;
    min-height: 0;
  }
  .auth-panel-copy,
  .auth-panel-foot,
  .auth-panel-glow {
    display: none;
  }
  .auth-panel .brand-name {
    font-size: 18px;
  }
  .auth-panel .brand-mark {
    width: 36px;
    height: 36px;
  }
  .auth {
    align-items: flex-start;
    padding: 28px 20px calc(32px + env(safe-area-inset-bottom, 0px));
    background: #fff;
  }
  .auth-title {
    font-size: 24px;
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* Режим «на главном экране» (PWA): учитываем вырезы экрана по бокам */
@media (display-mode: standalone) and (max-width: 767px) {
  .main {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
}
@media (max-width: 767px) {
  .filters {
    padding: 12px 16px;
  }
  .filter-search {
    grid-column: 1 / -1;
  }
}
@media (max-width: 767px) {
  .card:not(.card-flush) .table-wrap.has-cards {
    margin-left: 0;
    margin-right: 0;
  }
  .card.card-flush {
    padding: 0;
  }
  .table-scroll.has-cards {
    max-height: none;
    overflow: visible;
  }
  .page-head-side {
    align-items: stretch;
    justify-content: stretch;
    width: 100%;
  }
  .page-head-side > *,
  .page-head-side form,
  .page-head-side select {
    width: 100%;
  }
  .select-chip {
    min-width: 0;
    width: 100%;
  }

  /* График платежей: компактная строка на взнос */
  .schedule-cards .table-cards tr {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    column-gap: 10px;
    row-gap: 2px;
    padding: 11px 0;
    align-items: center;
  }
  .schedule-cards .table-cards td {
    display: block;
    text-align: left;
    font-size: 14px;
  }
  .schedule-cards .table-cards td::before {
    display: none;
  }
  .schedule-cards .table-cards td:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / span 2;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
  }
  .schedule-cards .table-cards td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    font-weight: 600;
  }
  .schedule-cards .table-cards td:nth-child(3) {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
    font-weight: 600;
  }
  .schedule-cards .table-cards td:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
    font-size: 12.5px;
    color: var(--text-2);
  }
  .schedule-cards .table-cards td:nth-child(4)::before {
    display: inline;
    content: 'оплачено ';
    font-size: 12.5px;
    color: var(--text-3);
  }
  .schedule-cards .table-cards td:nth-child(5) {
    display: none;
  }
  .schedule-cards .table-cards td:nth-child(6) {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
  }
}
/* Логотип на страницах входа не зависит от свёрнутого меню */
.auth-panel .brand-name {
  display: inline;
}
@media (max-width: 1023px) {
  .sidebar .user-text {
    display: flex;
  }
}
/* Планшет (768–1023): статус сделки вверху и кнопка главного действия внизу экрана */
@media (min-width: 768px) and (max-width: 1023px) {
  .deal-mobile-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 16px 0 0;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: #fff;
    color: var(--text);
  }
  .dms-main {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .dms-facts {
    font-size: 13.5px;
    color: var(--text-2);
  }
  .dms-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    color: var(--brand);
  }
  .mobile-action-bar {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 29;
    padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(245, 247, 250, 0.98) 75%, rgba(245, 247, 250, 0));
  }
  .mobile-action-bar[hidden] {
    display: none;
  }
  .mobile-action-bar .btn {
    max-width: 520px;
    margin: 0 auto;
  }
  body.has-action-bar {
    padding-bottom: 80px;
  }
}
@media (max-width: 767px) {
  .select-chip .select,
  .filters .input,
  .page-head .select,
  .card-head .select,
  select.input {
    font-size: 16px;
  }
}

/* ── v1.2: queue, notifications, density, skeleton, alloc preview ───────── */
body[data-density='compact'] .data-table td,
body[data-density='compact'] .data-table th {
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}
.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.queue-item a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  transition: background var(--dur) var(--ease);
}
.queue-item a:hover {
  background: var(--bg-subtle);
  color: inherit;
}
.queue-title {
  font-weight: 600;
  font-size: var(--text-md);
}
.queue-sub {
  color: var(--text-2);
  font-size: var(--text-sm);
}
.queue-item.tone-danger .queue-title {
  color: var(--danger);
}
.queue-item.tone-warning .queue-title {
  color: var(--warning);
}
.insights-row {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
}
.notif-menu {
  position: relative;
}
.notif-menu > summary {
  list-style: none;
}
.notif-menu > summary::-webkit-details-marker {
  display: none;
}
.notif-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(360px, calc(100vw - 24px));
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-overlay);
  z-index: 40;
  overflow: hidden;
}
.notif-head {
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.notif-empty {
  padding: var(--space-5) var(--space-4);
  color: var(--text-3);
  font-size: var(--text-sm);
}
.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow: auto;
}
.notif-list a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--dur) var(--ease);
}
.notif-list a:hover {
  background: var(--bg-subtle);
  color: inherit;
}
.notif-list a.is-unread .notif-title {
  font-weight: 600;
}
.notif-title {
  font-size: var(--text-sm);
}
.notif-detail {
  font-size: var(--text-xs);
  color: var(--text-3);
}
.notif-foot {
  display: block;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--brand);
  border-top: 1px solid var(--border);
}
.alloc-preview {
  font-size: var(--text-xs);
  color: var(--text-2);
  max-width: 220px;
}
.alloc-preview summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
}
.alloc-preview ul {
  margin: 6px 0 0;
  padding-left: 16px;
}
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
}
.muted {
  color: var(--text-2);
  font-size: var(--text-sm);
}
[aria-busy='true'] {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-subtle) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: var(--r-sm);
  min-height: 14px;
}
@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
.card-queue {
  margin-bottom: var(--space-5);
}
dialog.dialog[open] {
  animation: dlg-in var(--motion-enter) var(--ease-enter);
}

/* ── Design System v2: dark surfaces + dialog/toast/empty polish ───────── */
html[data-theme='dark'] .metric,
html[data-theme='dark'] .btn-secondary,
html[data-theme='dark'] .btn-danger-outline,
html[data-theme='dark'] .search-input,
html[data-theme='dark'] .toast {
  background: var(--bg-surface);
}
html[data-theme='dark'] .alert-text {
  color: var(--text-2);
}
html[data-theme='dark'] .dialog {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
html[data-theme='dark'] .dialog::backdrop {
  background: rgba(2, 8, 18, 0.72);
}
html[data-theme='dark'] .usermenu-pop,
html[data-theme='dark'] .notif-pop,
html[data-theme='dark'] .rowmenu-pop {
  background: var(--bg-elevated);
  border-color: var(--border);
}
.dialog {
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  padding: 0;
  max-width: min(520px, calc(100vw - 32px));
}
.dialog-title {
  font-size: var(--font-h3);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.empty {
  padding: var(--space-9) var(--space-6);
}
.empty-title {
  font-size: var(--font-h4);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  margin-top: var(--space-3);
}
.empty-text {
  font-size: var(--font-body-sm);
  color: var(--text-2);
  margin-top: var(--space-2);
  max-width: 28rem;
}
.tabs {
  gap: 2px;
}
.tab {
  font-size: var(--font-body-sm);
  font-weight: 550;
  letter-spacing: 0.01em;
  transition:
    color var(--dur) var(--ease),
    background var(--dur) var(--ease);
}
.filters {
  gap: var(--space-2);
  padding: var(--space-3) 0;
}
.toast {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-floating);
  backdrop-filter: blur(8px);
}
.main-col {
  min-width: 0;
  background: transparent;
}
@media (max-width: 1023px) {
  .main {
    padding: var(--space-3) var(--space-4) var(--space-10);
  }
  .page-title {
    font-size: var(--font-h1);
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 767px) {
  .kpis {
    grid-template-columns: 1fr;
  }
  .metric {
    min-height: 0;
    padding: var(--space-4);
  }
  .metric-value {
    font-size: 1.5rem;
    margin: var(--space-2) 0;
  }
  .nav-group {
    display: none;
  }
}

/* ── Intelligence / AI surfaces ─────────────────────────────────────────── */
.brief-list,
.quick-cmd-list,
.priority-reasons,
.factor-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brief-list a,
.quick-cmd-list a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: inherit;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--r-lg);
}
.brief-list a:hover,
.quick-cmd-list a:hover {
  background: var(--bg-muted);
}
.brief-title {
  font-weight: 600;
}
.brief-item.tone-danger .brief-title,
.queue-item.tone-danger .queue-title {
  color: var(--danger-fill, #b42318);
}
.brief-item.tone-warning .brief-title {
  color: var(--warning-fill, #b54708);
}
.ask-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.ask-row .input {
  flex: 1;
}
.ask-form {
  padding: 18px 20px;
}
.saved-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.factor-list {
  margin: 10px 0 0;
  font-size: 13.5px;
  color: var(--text-2);
}
.factor-list strong {
  color: var(--text);
  font-weight: 600;
}
.ai-why {
  margin-top: 10px;
}
.ai-why summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.ai-quick-mobile {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
@media (max-width: 720px) {
  .ai-quick-mobile {
    display: flex;
  }
  .ask-form .field-hint {
    display: none;
  }
}
.ask-form-inline {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.ai-scoped-result {
  padding: 10px 12px;
  border-radius: var(--radius-md, 8px);
  background: var(--surface-2, rgba(0, 0, 0, 0.03));
}
.risk-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.priority-reasons {
  margin: 0 0 14px;
  font-size: 13.5px;
}
.metrics-row-sm {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
}
.small {
  font-size: 12.5px;
}
.mt-sm {
  margin-top: 10px;
}
@media (max-width: 720px) {
  .ask-row {
    flex-direction: column;
  }
}

/* ─── Product v1.3 — command center surfaces ─────────────────────────────── */
:root {
  --background: var(--bg-app);
  --surface: var(--bg-surface);
  --surface-elevated: var(--bg-elevated);
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
}

.page-tabs {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin: 0 0 var(--space-5);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.page-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--font-label);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}
.page-tab:hover {
  color: var(--text-primary);
}
.page-tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.page-tab-count {
  min-width: 1.25rem;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg-muted);
  font-size: var(--font-caption);
  color: var(--text-muted);
}
.page-tab.is-active .page-tab-count {
  background: var(--brand-subtle);
  color: var(--brand-strong);
}

.client-hero {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-xs);
}
.client-hero-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.hero-kpi-label {
  display: block;
  font-size: var(--font-caption);
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.hero-kpi-value {
  font-size: var(--font-h3);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}
.hero-kpi.is-danger .hero-kpi-value {
  color: var(--danger);
}
.client-hero-contacts {
  margin-top: var(--space-3);
  font-size: var(--font-body-sm);
}

.progress {
  margin: var(--space-3) 0;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-caption);
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-muted);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  transition: width var(--motion-slow) var(--ease-emphasized);
}
/* Ширина полосы задаётся классом-атрибутом, а не style="": CSP запрещает инлайн-стили (style-src 'self'). */
.progress-fill[data-pct='0'] {
  width: 0%;
}
.progress-fill[data-pct='1'] {
  width: 1%;
}
.progress-fill[data-pct='2'] {
  width: 2%;
}
.progress-fill[data-pct='3'] {
  width: 3%;
}
.progress-fill[data-pct='4'] {
  width: 4%;
}
.progress-fill[data-pct='5'] {
  width: 5%;
}
.progress-fill[data-pct='6'] {
  width: 6%;
}
.progress-fill[data-pct='7'] {
  width: 7%;
}
.progress-fill[data-pct='8'] {
  width: 8%;
}
.progress-fill[data-pct='9'] {
  width: 9%;
}
.progress-fill[data-pct='10'] {
  width: 10%;
}
.progress-fill[data-pct='11'] {
  width: 11%;
}
.progress-fill[data-pct='12'] {
  width: 12%;
}
.progress-fill[data-pct='13'] {
  width: 13%;
}
.progress-fill[data-pct='14'] {
  width: 14%;
}
.progress-fill[data-pct='15'] {
  width: 15%;
}
.progress-fill[data-pct='16'] {
  width: 16%;
}
.progress-fill[data-pct='17'] {
  width: 17%;
}
.progress-fill[data-pct='18'] {
  width: 18%;
}
.progress-fill[data-pct='19'] {
  width: 19%;
}
.progress-fill[data-pct='20'] {
  width: 20%;
}
.progress-fill[data-pct='21'] {
  width: 21%;
}
.progress-fill[data-pct='22'] {
  width: 22%;
}
.progress-fill[data-pct='23'] {
  width: 23%;
}
.progress-fill[data-pct='24'] {
  width: 24%;
}
.progress-fill[data-pct='25'] {
  width: 25%;
}
.progress-fill[data-pct='26'] {
  width: 26%;
}
.progress-fill[data-pct='27'] {
  width: 27%;
}
.progress-fill[data-pct='28'] {
  width: 28%;
}
.progress-fill[data-pct='29'] {
  width: 29%;
}
.progress-fill[data-pct='30'] {
  width: 30%;
}
.progress-fill[data-pct='31'] {
  width: 31%;
}
.progress-fill[data-pct='32'] {
  width: 32%;
}
.progress-fill[data-pct='33'] {
  width: 33%;
}
.progress-fill[data-pct='34'] {
  width: 34%;
}
.progress-fill[data-pct='35'] {
  width: 35%;
}
.progress-fill[data-pct='36'] {
  width: 36%;
}
.progress-fill[data-pct='37'] {
  width: 37%;
}
.progress-fill[data-pct='38'] {
  width: 38%;
}
.progress-fill[data-pct='39'] {
  width: 39%;
}
.progress-fill[data-pct='40'] {
  width: 40%;
}
.progress-fill[data-pct='41'] {
  width: 41%;
}
.progress-fill[data-pct='42'] {
  width: 42%;
}
.progress-fill[data-pct='43'] {
  width: 43%;
}
.progress-fill[data-pct='44'] {
  width: 44%;
}
.progress-fill[data-pct='45'] {
  width: 45%;
}
.progress-fill[data-pct='46'] {
  width: 46%;
}
.progress-fill[data-pct='47'] {
  width: 47%;
}
.progress-fill[data-pct='48'] {
  width: 48%;
}
.progress-fill[data-pct='49'] {
  width: 49%;
}
.progress-fill[data-pct='50'] {
  width: 50%;
}
.progress-fill[data-pct='51'] {
  width: 51%;
}
.progress-fill[data-pct='52'] {
  width: 52%;
}
.progress-fill[data-pct='53'] {
  width: 53%;
}
.progress-fill[data-pct='54'] {
  width: 54%;
}
.progress-fill[data-pct='55'] {
  width: 55%;
}
.progress-fill[data-pct='56'] {
  width: 56%;
}
.progress-fill[data-pct='57'] {
  width: 57%;
}
.progress-fill[data-pct='58'] {
  width: 58%;
}
.progress-fill[data-pct='59'] {
  width: 59%;
}
.progress-fill[data-pct='60'] {
  width: 60%;
}
.progress-fill[data-pct='61'] {
  width: 61%;
}
.progress-fill[data-pct='62'] {
  width: 62%;
}
.progress-fill[data-pct='63'] {
  width: 63%;
}
.progress-fill[data-pct='64'] {
  width: 64%;
}
.progress-fill[data-pct='65'] {
  width: 65%;
}
.progress-fill[data-pct='66'] {
  width: 66%;
}
.progress-fill[data-pct='67'] {
  width: 67%;
}
.progress-fill[data-pct='68'] {
  width: 68%;
}
.progress-fill[data-pct='69'] {
  width: 69%;
}
.progress-fill[data-pct='70'] {
  width: 70%;
}
.progress-fill[data-pct='71'] {
  width: 71%;
}
.progress-fill[data-pct='72'] {
  width: 72%;
}
.progress-fill[data-pct='73'] {
  width: 73%;
}
.progress-fill[data-pct='74'] {
  width: 74%;
}
.progress-fill[data-pct='75'] {
  width: 75%;
}
.progress-fill[data-pct='76'] {
  width: 76%;
}
.progress-fill[data-pct='77'] {
  width: 77%;
}
.progress-fill[data-pct='78'] {
  width: 78%;
}
.progress-fill[data-pct='79'] {
  width: 79%;
}
.progress-fill[data-pct='80'] {
  width: 80%;
}
.progress-fill[data-pct='81'] {
  width: 81%;
}
.progress-fill[data-pct='82'] {
  width: 82%;
}
.progress-fill[data-pct='83'] {
  width: 83%;
}
.progress-fill[data-pct='84'] {
  width: 84%;
}
.progress-fill[data-pct='85'] {
  width: 85%;
}
.progress-fill[data-pct='86'] {
  width: 86%;
}
.progress-fill[data-pct='87'] {
  width: 87%;
}
.progress-fill[data-pct='88'] {
  width: 88%;
}
.progress-fill[data-pct='89'] {
  width: 89%;
}
.progress-fill[data-pct='90'] {
  width: 90%;
}
.progress-fill[data-pct='91'] {
  width: 91%;
}
.progress-fill[data-pct='92'] {
  width: 92%;
}
.progress-fill[data-pct='93'] {
  width: 93%;
}
.progress-fill[data-pct='94'] {
  width: 94%;
}
.progress-fill[data-pct='95'] {
  width: 95%;
}
.progress-fill[data-pct='96'] {
  width: 96%;
}
.progress-fill[data-pct='97'] {
  width: 97%;
}
.progress-fill[data-pct='98'] {
  width: 98%;
}
.progress-fill[data-pct='99'] {
  width: 99%;
}
.progress-fill[data-pct='100'] {
  width: 100%;
}
.progress-fill.tone-brand {
  background: linear-gradient(90deg, var(--brand), var(--brand-bright));
}
.progress-fill.tone-success {
  background: var(--success);
}
.progress-fill.tone-warning {
  background: var(--warning-fill);
}
.progress-fill.tone-danger {
  background: var(--danger-fill);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 var(--space-4);
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--font-caption);
  text-decoration: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
.chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.chip.is-active {
  background: var(--brand-subtle);
  border-color: transparent;
  color: var(--brand-strong);
  font-weight: 600;
}
.prio-score {
  display: inline-flex;
  min-width: 2rem;
  justify-content: center;
  font-weight: 700;
  color: var(--brand-strong);
}

.seg-control {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  gap: 2px;
  margin-bottom: var(--space-4);
}
.seg-item {
  padding: 8px 14px;
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--font-label);
  font-weight: 500;
}
.seg-item.is-active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.cal-range {
  margin: 0 0 var(--space-4);
}
.cal-grid {
  display: grid;
  gap: var(--space-3);
}
.cal-week,
.cal-month {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.cal-day {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  min-height: 120px;
  overflow: hidden;
}
.cal-day.is-today {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand-subtle);
}
.cal-day.is-past {
  opacity: 0.85;
}
.cal-day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--font-body-sm);
  font-weight: 600;
}
.cal-day-count {
  font-size: var(--font-caption);
  background: var(--brand-subtle);
  color: var(--brand-strong);
  border-radius: 999px;
  padding: 2px 8px;
}
.cal-events {
  list-style: none;
  margin: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cal-event a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  text-decoration: none;
  color: inherit;
  border-left: 3px solid var(--border-strong);
}
.cal-event.state-overdue a {
  border-left-color: var(--danger);
  background: var(--danger-subtle);
}
.cal-event.state-paid a {
  border-left-color: var(--success);
}
.cal-event.state-partial a {
  border-left-color: var(--info);
}
.cal-event-client {
  display: block;
  font-weight: 600;
  font-size: var(--font-body-sm);
}
.cal-event-meta {
  display: block;
  font-size: var(--font-caption);
  color: var(--text-muted);
  margin: 2px 0 4px;
}
.cal-empty {
  padding: 12px;
  font-size: var(--font-caption);
}

.note-form {
  margin-bottom: var(--space-4);
}
.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.note-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}
.note-body {
  margin: 0 0 6px;
  white-space: pre-wrap;
}
.note-meta {
  margin: 0;
  font-size: var(--font-caption);
}
.doc-mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.doc-mini-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--font-body-sm);
}
.factor-list {
  margin: 8px 0 0;
  padding-left: 1.1rem;
  color: var(--text-secondary);
  font-size: var(--font-body-sm);
}
.text-sm {
  font-size: var(--font-body-sm);
}

@media (max-width: 720px) {
  .client-hero-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .page-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .cal-week,
  .cal-month {
    grid-template-columns: 1fr;
  }
}

/* ─── v1.4 Entity drawer + workspace ──────────────────────────────────────── */
.entity-drawer[hidden] {
  display: none !important;
}
.entity-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
}
.entity-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}
.entity-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.2s ease;
}
@keyframes drawer-in {
  from {
    transform: translateX(12px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
.entity-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.entity-drawer-title {
  margin: 0;
  font-size: var(--font-h3);
}
.entity-drawer-body {
  padding: 16px 18px;
  overflow: auto;
  flex: 1;
}

.ws-today-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.ws-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 var(--space-5);
}
.ws-quick-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font: 600 13px/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.ws-quick-item:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.ws-quick-item svg {
  color: var(--brand);
}
.form-more {
  margin-top: 4px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 8px 14px 12px;
  background: var(--bg-subtle);
}
.form-more > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-2);
  padding: 6px 0;
  list-style: none;
}
.form-more > summary::-webkit-details-marker {
  display: none;
}
.form-more[open] > summary {
  margin-bottom: 10px;
  color: var(--text);
}
.form-more .form-grid {
  margin: 0;
}
.palette-foot button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.mobile-fab-sheet button[role='menuitem'] {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--r-lg);
  background: transparent;
  color: var(--text);
  font: 600 15px/1.2 var(--font);
  text-align: left;
  cursor: pointer;
}
.ws-stat {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.ws-stat-label {
  display: block;
  font-size: var(--font-caption);
  color: var(--text-muted);
  margin-bottom: 4px;
}
.ws-stat-value {
  font-size: var(--font-h2);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.ws-stat.is-danger .ws-stat-value {
  color: var(--danger);
}
.ws-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
}
.ws-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ws-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.ws-item a {
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
}
.ws-item-title {
  display: block;
  font-weight: 600;
  font-size: var(--font-body-sm);
}
.followup-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.input-sm {
  max-width: 11rem;
  padding: 6px 8px;
  font-size: var(--font-caption);
}
.sched-cell.state-paid {
  color: var(--success);
}
.sched-cell.state-overdue {
  color: var(--danger);
  font-weight: 600;
}
.sched-cell.state-due_today {
  color: var(--info);
  font-weight: 600;
}
.sched-cell.state-partially_paid {
  color: var(--warning);
}

@media (max-width: 720px) {
  .ws-grid {
    grid-template-columns: 1fr;
  }
}

/* v1.4+ wave-2 polish */
.toolbar-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2, var(--bg-muted));
}
.dash-widgets {
  position: relative;
}
.dash-widgets > summary {
  list-style: none;
  cursor: pointer;
}
.dash-widgets > summary::-webkit-details-marker {
  display: none;
}
.dash-widgets-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 40;
  min-width: 14rem;
  padding: 0.75rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border);
  background: var(--surface, var(--bg));
  box-shadow: var(--shadow-md, 0 8px 24px rgb(0 0 0 / 12%));
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
@media (max-width: 720px) {
  .dash-widgets-panel {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 4.5rem;
  }
  .toolbar-bulk {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ── Design System 2.0 / Motion aliases (canonical tokens live in :root) ── */
:root {
  --surface-1: var(--bg-surface);
  --surface-2: var(--bg-elevated);
  --surface-3: var(--bg-subtle);
}
.client-tags-row,
.followup-presets,
.deal-health {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-3);
}
.chip-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.relation-graph {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-soft);
}
.rg-node {
  padding: 0.35rem 0.7rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-3);
  font-size: var(--font-caption);
  text-decoration: none;
  color: var(--text);
}
.rg-node.is-root {
  background: var(--brand-subtle);
  border-color: transparent;
  font-weight: 600;
}
.rg-edge {
  width: 1rem;
  height: 1px;
  background: var(--border-strong);
}
.note-item.is-pinned {
  border-left: 3px solid var(--brand);
  padding-left: var(--space-3);
}
.doc-preview {
  margin: var(--space-4) 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-muted);
  min-height: 60vh;
}
.doc-preview iframe,
.doc-preview img {
  width: 100%;
  min-height: 70vh;
  border: 0;
  display: block;
  object-fit: contain;
  background: #111;
}
.offline-banner {
  position: sticky;
  top: 0;
  z-index: 80;
  padding: 0.5rem 1rem;
  background: var(--warning-subtle);
  color: var(--warning);
  text-align: center;
  font-size: var(--font-body-sm);
  border-bottom: 1px solid var(--border);
}
.shortcut-help {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.shortcut-help[hidden] {
  display: none;
}
.shortcut-panel {
  width: min(420px, 100%);
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-overlay);
  padding: var(--space-5);
}
.shortcut-panel kbd {
  font-family: var(--font-mono);
  font-size: var(--font-caption);
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-muted);
}
@media (min-width: 768px) and (max-width: 1100px) {
  .app-shell {
    --sidebar-w: 220px;
  }
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Design System v3 — Premium polish layer (shell · components · responsive)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Typography utilities */
.type-display {
  font-size: var(--font-display);
  line-height: var(--lh-tight);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
}
.type-h1 {
  font-size: var(--font-h1);
  line-height: var(--lh-tight);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.type-h2 {
  font-size: var(--font-h2);
  line-height: var(--lh-snug);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.type-h3 {
  font-size: var(--font-h3);
  line-height: var(--lh-snug);
  font-weight: 600;
}
.type-h4 {
  font-size: var(--font-h4);
  line-height: var(--lh-snug);
  font-weight: 600;
}
.type-body-lg {
  font-size: var(--font-body-lg);
  line-height: var(--lh-relaxed);
}
.type-body {
  font-size: var(--font-body);
  line-height: var(--lh-normal);
}
.type-body-sm {
  font-size: var(--font-body-sm);
  line-height: var(--lh-normal);
  color: var(--text-secondary);
}
.type-label {
  font-size: var(--font-label);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-secondary);
}
.type-caption {
  font-size: var(--font-caption);
  line-height: var(--lh-normal);
  color: var(--text-muted);
}
.type-numeric,
.num,
.metric-value,
.today-sum,
.bucket-sum {
  font-variant-numeric: tabular-nums;
  font-feature-settings:
    'tnum' 1,
    'kern' 1;
  letter-spacing: var(--tracking-numeric);
  font-family: var(--font-num);
}

body {
  background:
    radial-gradient(
      1100px 520px at 100% -8%,
      color-mix(in srgb, var(--brand-bright) 7%, transparent),
      transparent 58%
    ),
    radial-gradient(800px 420px at -8% 0%, color-mix(in srgb, var(--info) 4%, transparent), transparent 52%),
    var(--background);
}

/* ── Shell / Sidebar collapse ── */
.shell {
  transition: grid-template-columns var(--motion-slow) var(--ease-standard);
}
.shell.is-sidebar-collapsed {
  --sidebar-w: var(--sidebar-w-collapsed);
}
.shell.is-sidebar-collapsed .brand-name,
.shell.is-sidebar-collapsed .brand-sub,
.shell.is-sidebar-collapsed .brand-product,
.shell.is-sidebar-collapsed .nav-label,
.shell.is-sidebar-collapsed .nav-group,
.shell.is-sidebar-collapsed .user-text,
.shell.is-sidebar-collapsed .usermenu summary > .icon:last-child {
  display: none;
}
.shell.is-sidebar-collapsed .brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
.shell.is-sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0;
  margin-inline: 10px;
}
.shell.is-sidebar-collapsed .nav-item.is-active::before {
  left: -10px;
}
.shell.is-sidebar-collapsed .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  font-size: 10px;
}
.shell.is-sidebar-collapsed .sidebar-foot {
  display: flex;
  justify-content: center;
  margin-inline: 8px;
  padding-inline: 0;
}
.shell.is-sidebar-collapsed .sidebar-collapse-btn .icon-collapse-open {
  display: none;
}
.shell.is-sidebar-collapsed .sidebar-collapse-btn .icon-collapse-closed {
  display: block;
}
.sidebar-collapse-btn .icon-collapse-closed {
  display: none;
}

.sidebar-collapse-btn {
  display: none;
  width: 28px;
  height: 28px;
  margin: var(--space-2) auto 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--r-md);
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.sidebar-collapse-btn:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}
@media (min-width: 1280px) {
  .sidebar-collapse-btn {
    display: inline-flex;
  }
}

.sidebar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 140px), var(--bg-sidebar);
}
.nav-item {
  height: 38px;
  border-radius: var(--r-md);
}
.nav-item.is-active {
  background: var(--bg-sidebar-active);
  box-shadow: inset 0 0 0 1px rgba(45, 180, 120, 0.18);
}
.nav-group {
  font-size: 10px;
  letter-spacing: 0.1em;
}

/* Collapsed nav tooltip */
.shell.is-sidebar-collapsed .nav-item[data-tip] {
  position: relative;
}
.shell.is-sidebar-collapsed .nav-item[data-tip]:hover::after,
.shell.is-sidebar-collapsed .nav-item[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  padding: 6px 10px;
  border-radius: var(--r-md);
  background: var(--text-primary);
  color: var(--text-inverse);
  font-size: var(--font-caption);
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-floating);
  pointer-events: none;
}
html[data-theme='dark'] .shell.is-sidebar-collapsed .nav-item[data-tip]:hover::after {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.topbar {
  height: var(--topbar-h);
  padding-inline: var(--space-6);
  background: color-mix(in srgb, var(--background) 78%, transparent);
}
.search-input {
  height: 34px;
  border-radius: var(--r-md);
  background: var(--surface);
}

/* ── Page rhythm ── */
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-6) var(--space-10);
  display: flex;
  flex-direction: column;
  gap: var(--page-gap);
}
.page-narrow {
  max-width: var(--content-narrow);
}
.page-form {
  max-width: var(--content-form);
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: 0;
}
.page-title {
  font-size: var(--font-display);
  line-height: var(--lh-tight);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  overflow-wrap: anywhere;
}
.page-sub {
  margin-top: var(--space-1);
  font-size: var(--font-body-sm);
  color: var(--text-secondary);
  max-width: 52ch;
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--space-2);
  font-size: var(--font-caption);
  color: var(--text-muted);
}
.crumbs a {
  color: var(--text-secondary);
}
.crumbs a:hover {
  color: var(--primary);
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) 0;
}

/* ── Buttons v3 ── */
.btn {
  height: 36px;
  border-radius: var(--r-md);
  font-weight: 550;
}
.btn-lg {
  height: 44px;
  min-height: var(--touch);
}
.btn-sm {
  height: 30px;
}
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}
.btn-primary {
  box-shadow: 0 1px 2px color-mix(in srgb, var(--primary-hover) 25%, transparent);
}
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: var(--text-inverse);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
.btn-secondary.is-loading::after,
.btn-outline.is-loading::after,
.btn-ghost.is-loading::after {
  border-top-color: var(--primary);
}
@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}
.icon-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}
.icon-btn:focus-visible {
  box-shadow: var(--focus-ring);
}

/* ── Cards / KPI ── */
.card {
  border-radius: var(--r-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-subtle);
  border-color: var(--border);
}
.card + .card {
  margin-top: var(--space-4);
}
.kpis {
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.metric {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  padding: var(--space-5);
  min-height: 112px;
  background: var(--surface);
}
.metric::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: color-mix(in srgb, var(--primary) 55%, transparent);
  border-radius: 0 2px 2px 0;
  opacity: 0.85;
}
.metric-label {
  font-size: 11px;
  letter-spacing: var(--tracking-label);
}
.metric-value {
  font-size: clamp(1.35rem, 1.1rem + 0.7vw, 1.75rem);
  margin: var(--space-2) 0 var(--space-2);
}
.metric-context {
  font-size: var(--font-caption);
  color: var(--text-muted);
  margin-top: 2px;
}
.dash {
  gap: var(--space-4);
}
.dash-main {
  gap: var(--space-4);
}

/* ── Tables ── */
.table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-subtle);
  height: 40px;
  border-bottom: 1px solid var(--border);
}
.table td {
  height: 48px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-soft);
}
.table tbody tr {
  transition: background var(--dur) var(--ease);
}
.table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}
.table tbody tr.is-selected,
.table tbody tr[aria-selected='true'] {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  box-shadow: inset 3px 0 0 var(--primary);
}
.table td.num,
.table th.num,
.table .col-money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}
.table .col-date {
  white-space: nowrap;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
  flex: none;
}
.badge-neutral {
  background: var(--bg-muted);
  color: var(--text-secondary);
}
.badge-info {
  background: var(--info-subtle);
  color: var(--info);
}
.badge-success {
  background: var(--success-subtle);
  color: var(--success);
}
.badge-warning {
  background: var(--warning-subtle);
  color: var(--warning);
}
.badge-danger {
  background: var(--danger-subtle);
  color: var(--danger);
}
.badge-brand {
  background: var(--brand-subtle);
  color: var(--primary-hover);
}

/* ── Forms ── */
.field-label {
  font-size: var(--font-label);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field-hint {
  margin-top: 6px;
  font-size: var(--font-caption);
  color: var(--text-muted);
  line-height: var(--lh-normal);
}
.input,
.select,
textarea.input {
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--font-body);
  color: var(--text-primary);
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.input:hover,
.select:hover,
textarea.input:hover {
  border-color: var(--border-strong);
}
.input:focus,
.select:focus,
textarea.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-bright) 22%, transparent);
}
.input::placeholder,
textarea.input::placeholder {
  color: var(--text-muted);
}
textarea.input {
  height: auto;
  min-height: 96px;
  padding: var(--space-3);
  resize: vertical;
  line-height: var(--lh-relaxed);
}
.field-invalid .input,
.field-invalid .select,
.field-invalid textarea.input {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger-subtle) 35%, var(--surface));
}
.field-error {
  margin-top: 6px;
  font-size: var(--font-caption);
  color: var(--danger);
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

/* Checkbox / radio / switch */
input[type='checkbox'],
input[type='radio'] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--border-strong);
  transition: background var(--dur) var(--ease);
  cursor: pointer;
  flex: none;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur) var(--ease);
}
.switch.is-on,
input:checked + .switch {
  background: var(--primary);
}
.switch.is-on::after,
input:checked + .switch::after {
  transform: translateX(18px);
}

/* ── Modals / drawers / toasts ── */
.dialog {
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  max-width: min(520px, calc(100vw - 24px));
}
.dialog-sm {
  max-width: min(400px, calc(100vw - 24px));
}
.dialog-lg {
  max-width: min(720px, calc(100vw - 24px));
}
.dialog-xl {
  max-width: min(960px, calc(100vw - 24px));
}
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-soft);
  background: var(--bg-subtle);
}
.drawer-panel {
  background: var(--surface-elevated);
  box-shadow: var(--shadow-modal);
  border-left: 1px solid var(--border);
}
.toast {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-floating);
  border: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-body-sm);
}
.toast-success {
  border-left: 3px solid var(--success);
}
.toast-danger {
  border-left: 3px solid var(--danger);
}
.toast-warning {
  border-left: 3px solid var(--warning-fill);
}
.toast-info {
  border-left: 3px solid var(--info);
}

/* ── Tabs / chips / filter bar ── */
.seg-control,
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-muted);
  border-radius: var(--r-md);
}
.seg-item,
.tab {
  height: 30px;
  padding: 0 12px;
  border-radius: calc(var(--r-md) - 2px);
  font-size: var(--font-body-sm);
  font-weight: 500;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
}
.seg-item.is-active,
.tab.is-active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
}
.chip,
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--font-caption);
  color: var(--text-secondary);
}
.chip.is-active,
.filter-chip.is-active {
  background: var(--brand-subtle);
  border-color: transparent;
  color: var(--primary-hover);
  font-weight: 600;
}

/* ── Empty / error / skeleton ── */
.empty {
  padding: var(--space-10) var(--space-6);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-xl);
  background: color-mix(in srgb, var(--bg-subtle) 80%, transparent);
}
.empty .icon {
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}
.empty-title {
  font-size: var(--font-h3);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.empty-text {
  color: var(--text-secondary);
  font-size: var(--font-body-sm);
  max-width: 36ch;
  margin: 0 auto var(--space-4);
}
.skeleton-card {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.skeleton-line {
  height: 12px;
}
.skeleton-line.w-40 {
  width: 40%;
}
.skeleton-line.w-60 {
  width: 60%;
}
.skeleton-line.w-80 {
  width: 80%;
}
.skeleton-block {
  height: 72px;
  border-radius: var(--r-md);
}

/* ── Charts ── */
.chart {
  color: var(--chart-axis);
}
.chart .ch-grid line,
.chart .grid line {
  stroke: var(--chart-grid);
  stroke-width: 1;
}
.chart .ch-axis,
.chart text {
  fill: var(--chart-axis);
  font-size: 11px;
  font-family: var(--font);
}
.chart-tip {
  background: var(--text-primary);
  color: var(--text-inverse);
  font-size: var(--font-caption);
  padding: 6px 8px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-floating);
  pointer-events: none;
}
html[data-theme='dark'] .chart-tip {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.chart-empty {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: var(--font-body-sm);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
}

/* ── Tooltip ── */
[data-tooltip] {
  position: relative;
}
.ui-tooltip {
  position: absolute;
  z-index: 80;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--text-primary);
  color: var(--text-inverse);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: var(--shadow-floating);
  pointer-events: none;
}

/* ── Mobile tables → cards ── */
@media (max-width: 767px) {
  .page {
    padding: var(--space-4) var(--space-4) calc(72px + env(safe-area-inset-bottom));
    gap: var(--space-4);
  }
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .page-title {
    font-size: 1.375rem;
  }
  .kpis {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
  }
  .metric {
    min-height: 96px;
    padding: var(--space-4);
  }
  .metric-value {
    font-size: 1.25rem;
  }
  .table-wrap.has-cards,
  .table-scroll.is-responsive {
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .table-wrap.has-cards .table,
  .table-scroll.is-responsive .table,
  .table-mobile-cards {
    display: block;
  }
  .table-wrap.has-cards thead,
  .table-scroll.is-responsive thead {
    display: none;
  }
  .table-wrap.has-cards tbody,
  .table-scroll.is-responsive tbody {
    display: grid;
    gap: var(--space-3);
  }
  .table-wrap.has-cards tr,
  .table-scroll.is-responsive tr {
    display: grid;
    gap: 8px;
    padding: var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
  }
  .table-wrap.has-cards td,
  .table-scroll.is-responsive td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    height: auto;
    padding: 0;
    border: 0;
    text-align: right;
  }
  .table-wrap.has-cards td::before,
  .table-scroll.is-responsive td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: left;
  }
  .table-wrap.has-cards td:first-child,
  .table-scroll.is-responsive td:first-child {
    display: block;
    text-align: left;
    font-weight: 600;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 2px;
  }
  .table-wrap.has-cards td:first-child::before,
  .table-scroll.is-responsive td:first-child::before {
    display: none;
  }
  .dialog,
  .dialog[open] {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    align-self: end;
    max-height: min(92vh, 100%);
  }
  .field .input,
  .field .select,
  .field textarea.input,
  .btn-lg,
  .btn-block {
    min-height: var(--touch);
  }
  .btn {
    min-height: 40px;
  }
  .icon-btn {
    width: var(--touch);
    height: var(--touch);
    min-width: var(--touch);
    min-height: var(--touch);
  }
  .tabbar {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .page {
    padding-inline: var(--space-5);
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dash-main {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Dark contrast polish */
html[data-theme='dark'] .card,
html[data-theme='dark'] .metric,
html[data-theme='dark'] .search-input,
html[data-theme='dark'] .input,
html[data-theme='dark'] .select,
html[data-theme='dark'] textarea.input {
  background: var(--surface);
}
html[data-theme='dark'] .tabbar {
  background: rgba(12, 18, 28, 0.92);
  border-top-color: var(--border);
}
html[data-theme='dark'] .table-cards tr,
html[data-theme='dark'] .mobile-quick-item,
html[data-theme='dark'] .client-mobile-bar a,
html[data-theme='dark'] .client-mobile-bar button,
html[data-theme='dark'] .deal-mobile-status,
html[data-theme='dark'] .mobile-fab-sheet {
  background: var(--surface);
}
html[data-theme='dark'] .mobile-action-bar {
  background: linear-gradient(to top, rgba(12, 18, 28, 0.98) 75%, rgba(12, 18, 28, 0));
}
html[data-theme='dark'] .offline-banner {
  background: var(--danger-fill);
  color: #fff;
}
html[data-theme='dark'] .table th {
  background: var(--bg-subtle);
}
html[data-theme='dark'] .empty {
  background: color-mix(in srgb, var(--bg-subtle) 70%, transparent);
}
html[data-theme='dark'] .btn-primary {
  color: #062416;
  font-weight: 600;
}
html[data-theme='dark'] .badge-brand {
  color: var(--brand-bright);
}

/* Focus visibility across interactive set */
a:focus-visible,
button:focus-visible,
.nav-item:focus-visible,
.seg-item:focus-visible,
.tab:focus-visible,
.chip:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Motion Design System — unified interactions (tokens in :root)
   Prefer transform/opacity. Exit faster than enter. Respect reduced-motion.
   ═══════════════════════════════════════════════════════════════════════════ */

.main {
  animation: page-enter var(--motion-enter) var(--ease-enter);
}
@keyframes page-enter {
  from {
    opacity: 0.92;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

a.link-strong,
.panel-p a,
.field-link,
.notif-foot,
.crumbs a {
  transition: color var(--motion-fast) var(--ease-standard);
}

.card {
  transition:
    border-color var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard),
    background var(--motion-fast) var(--ease-standard);
}
a.metric {
  transition:
    border-color var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard),
    transform var(--motion-fast) var(--ease-emphasized);
}
a.metric:active {
  transform: translateY(0) scale(0.992);
}

.icon-btn {
  transition:
    background var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard),
    transform var(--motion-fast) var(--ease-emphasized),
    box-shadow var(--motion-fast) var(--ease-standard);
}
.icon-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.btn-primary:active:not(:disabled):not(.is-loading),
.btn-primary-strong:active:not(:disabled):not(.is-loading) {
  filter: brightness(0.96);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}
.btn.is-success-flash {
  background: var(--success) !important;
  border-color: transparent !important;
  color: #fff !important;
}

.nav-item {
  transition:
    background var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard);
}
.nav-item .icon {
  transition: color var(--motion-fast) var(--ease-standard);
}

@media (max-width: 1023px) {
  .sidebar {
    transition:
      transform var(--motion-slow) var(--ease-emphasized),
      visibility 0s linear var(--motion-slow);
  }
  .shell.sidebar-open .sidebar {
    transition: transform var(--motion-enter) var(--ease-enter);
  }
  .sidebar-backdrop {
    transition: opacity var(--motion-standard) var(--ease-standard);
  }
}

.tabbar-item {
  transition:
    color var(--motion-fast) var(--ease-standard),
    background var(--motion-fast) var(--ease-standard),
    transform var(--motion-fast) var(--ease-emphasized);
}
.tabbar-item:active {
  transform: scale(0.96);
}

.mobile-fab-btn {
  transition:
    transform var(--motion-standard) var(--ease-emphasized),
    background var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard);
}
.mobile-fab-sheet:not([hidden]) {
  transform-origin: bottom right;
  animation: popover-in var(--motion-enter) var(--ease-enter);
}

.usermenu-pop,
.notif-pop,
.rowmenu-pop,
.dropdown-pop,
.client-more-pop {
  transform-origin: top right;
  animation: popover-in var(--motion-enter) var(--ease-enter);
}
@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.rowmenu-pop {
  animation-duration: var(--motion-fast);
}

details[open] > summary .select-icon,
.select-wrap:focus-within .select-icon,
details.usermenu[open] > summary > .icon:last-child,
details.print-menu[open] > summary .icon {
  transform: rotate(180deg);
}
.select-icon,
details.usermenu > summary > .icon:last-child,
details.print-menu summary .icon {
  transition: transform var(--motion-fast) var(--ease-emphasized);
}

.shell.is-sidebar-collapsed .nav-item[data-tip]:hover::after {
  animation: tip-in var(--motion-fast) var(--ease-enter);
}
@keyframes tip-in {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 767px) {
  .dialog[open],
  dialog.dialog[open] {
    animation: sheet-in var(--motion-enter) var(--ease-enter);
  }
}

.palette:not([hidden]) {
  animation: backdrop-in var(--motion-enter) var(--ease-standard);
}
.palette:not([hidden]) .palette-box {
  animation: palette-in var(--motion-enter) var(--ease-enter);
}
@keyframes palette-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.palette-results li a {
  transition: background var(--motion-fast) var(--ease-standard);
}

.input,
.select,
.textarea,
.search-input {
  transition:
    border-color var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard),
    background var(--motion-fast) var(--ease-standard);
}
.field-error {
  animation: field-error-in var(--motion-enter) var(--ease-enter);
}
@keyframes field-error-in {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.dropzone {
  transition:
    border-color var(--motion-fast) var(--ease-standard),
    background var(--motion-standard) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard);
}
.dropzone.is-drag {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-bright) 28%, transparent);
}

.badge {
  transition:
    background var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard);
}

.table tbody tr {
  transition: background var(--motion-fast) var(--ease-standard);
}
.table tbody tr.is-selected {
  background: color-mix(in srgb, var(--brand-subtle) 70%, transparent);
}
.toolbar-bulk {
  animation: bar-in var(--motion-enter) var(--ease-enter);
}
@keyframes bar-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

tr.is-completing {
  opacity: 0.55;
  transition: opacity var(--motion-slow) var(--ease-exit);
}
tr.is-completing td:first-child {
  text-decoration: line-through;
}

.notif-list a {
  transition: background var(--motion-fast) var(--ease-standard);
}
.notif-list a.is-unread {
  background: color-mix(in srgb, var(--brand-subtle) 55%, transparent);
}

.chart {
  animation: fade-in var(--motion-enter) var(--ease-enter);
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.offline-banner {
  transition:
    transform var(--motion-standard) var(--ease-emphasized),
    opacity var(--motion-standard) var(--ease-standard);
}
.offline-banner.is-reconnect {
  background: var(--success);
}

.doc-preview img,
.doc-preview iframe {
  animation: fade-in var(--motion-slow) var(--ease-enter);
}

.ai-thinking {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.ai-thinking i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: think-dot 1s var(--ease-standard) infinite;
}
.ai-thinking i:nth-child(2) {
  animation-delay: 0.15s;
}
.ai-thinking i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes think-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.btn.is-loading::after {
  animation: btn-spin 0.65s linear infinite;
}

.dialog.is-closing {
  animation: dlg-out var(--motion-exit) var(--ease-exit) forwards;
}
@keyframes dlg-out {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

.shell.resizing {
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .main,
  .chart,
  .toast,
  .dialog[open],
  dialog.dialog[open],
  .palette:not([hidden]),
  .palette:not([hidden]) .palette-box,
  .mobile-fab-sheet:not([hidden]),
  .usermenu-pop,
  .notif-pop,
  .rowmenu-pop,
  .dropdown-pop,
  .toolbar-bulk,
  .doc-preview img,
  .doc-preview iframe,
  .tab.is-active::after {
    animation: none !important;
  }
  .btn:active:not(:disabled),
  .icon-btn:active:not(:disabled),
  a.metric:hover,
  a.metric:active,
  .tabbar-item:active,
  .mobile-fab.is-open .mobile-fab-btn {
    transform: none !important;
  }
  .skeleton,
  .ai-thinking i,
  .btn.is-loading::after {
    animation: none !important;
  }
  .skeleton {
    background: var(--bg-muted);
  }
}

/* iOS: поля ввода не мельче 16 px на телефоне, иначе Safari увеличивает страницу при фокусе.
   Стоит в конце файла: глобальное .input-sm выше (caption) не должно перебивать мобильный размер. */
@media (max-width: 767px) {
  .input,
  .select,
  .textarea,
  .input-sm {
    font-size: 16px;
  }
}

/* ── Settings hub + accent palettes ──────────────────────────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: sticky;
  top: var(--space-4);
}
.settings-nav-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md, 10px);
  border: 1px solid transparent;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}
.settings-nav-item:hover {
  border-color: var(--border);
  background: var(--bg-subtle);
}
.settings-nav-item.is-active {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: var(--brand-subtle);
  box-shadow: inset 3px 0 0 var(--primary);
}
.settings-nav-label {
  font-weight: 600;
  font-size: var(--font-body);
}
.settings-nav-hint {
  font-size: var(--font-caption);
}
.settings-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.settings-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}
.theme-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}
.theme-mode-card,
.accent-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}
.theme-mode-card:hover,
.accent-card:hover {
  border-color: var(--border-strong);
}
.theme-mode-card.is-selected,
.accent-card.is-selected,
.theme-mode-card[aria-pressed='true'],
.accent-card[aria-pressed='true'] {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
  background: var(--brand-subtle);
}
.theme-mode-title,
.accent-name {
  font-weight: 600;
  font-size: var(--font-body);
}
.theme-mode-preview {
  width: 100%;
  height: 52px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background:
    linear-gradient(var(--p-text), var(--p-text)) 36% 34% / 34% 4px no-repeat,
    linear-gradient(var(--p-accent), var(--p-accent)) 36% 66% / 18% 8px no-repeat,
    linear-gradient(var(--p-card), var(--p-card)) 70% 50% / 64% 64% no-repeat,
    linear-gradient(90deg, var(--p-side) 0 20%, var(--p-bg) 20%);
}
.theme-mode-preview--light {
  --p-side: #0a1628;
  --p-bg: #f1f4f8;
  --p-card: #ffffff;
  --p-text: #0c1524;
  --p-accent: #178a5a;
}
.theme-mode-preview--dark {
  --p-side: #060b14;
  --p-bg: #080e18;
  --p-card: #111a2b;
  --p-text: #e9eef7;
  --p-accent: #2db478;
}
.theme-mode-preview--system {
  --p-side: #0a1628;
  --p-bg: #f1f4f8;
  --p-card: #ffffff;
  --p-text: #0c1524;
  --p-accent: #178a5a;
  background:
    linear-gradient(135deg, transparent 50%, #080e18 50%),
    linear-gradient(var(--p-card), var(--p-card)) 70% 50% / 64% 64% no-repeat,
    linear-gradient(90deg, var(--p-side) 0 20%, var(--p-bg) 20%);
}
.theme-mode-preview--sepia {
  --p-side: #3a2f1f;
  --p-bg: #f4eee2;
  --p-card: #fffcf5;
  --p-text: #2b2418;
  --p-accent: #178a5a;
}
.theme-mode-preview--contrast {
  --p-side: #000000;
  --p-bg: #ffffff;
  --p-card: #ffffff;
  --p-text: #000000;
  --p-accent: #0f6b45;
  box-shadow: inset 0 0 0 1px #000;
}
.theme-mode-preview--midnight {
  --p-side: #050914;
  --p-bg: #0b1020;
  --p-card: #141d3a;
  --p-text: #e6ebff;
  --p-accent: #2db478;
}
.theme-mode-preview--charcoal {
  --p-side: #0b0b0b;
  --p-bg: #141414;
  --p-card: #1f1f1f;
  --p-text: #ededed;
  --p-accent: #2db478;
}
.accent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
}
.accent-card {
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
}
.accent-swatch {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}
.accent-swatch--emerald {
  background: #178a5a;
}
.accent-swatch--ocean {
  background: #1a6fb5;
}
.accent-swatch--slate {
  background: #475569;
}
.accent-swatch--amber {
  background: #b45309;
}
.accent-swatch--rose {
  background: #be123c;
}
.accent-swatch--violet {
  background: #6d28d9;
}
.accent-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mb-md {
  margin-bottom: var(--space-4);
}
@media (max-width: 767px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    gap: var(--space-2);
    padding-bottom: var(--space-1);
  }
  .settings-nav-item {
    min-width: 140px;
    flex: 0 0 auto;
  }
  .settings-nav-hint {
    display: none;
  }
}

/* Accent overrides (light defaults; dark adjusts brightness) */
html[data-accent='ocean'] {
  --primary: #1a6fb5;
  --brand: var(--primary);
  --primary-hover: #155a94;
  --brand-strong: var(--primary-hover);
  --brand-bright: #3b8fd4;
  --brand-subtle: #e5f1fb;
  --success: #1a6fb5;
  --success-subtle: #e5f1fb;
  --bg-sidebar-active: rgba(26, 111, 181, 0.18);
  --chart-primary: #1a6fb5;
}
html[data-accent='slate'] {
  --primary: #475569;
  --brand: var(--primary);
  --primary-hover: #334155;
  --brand-strong: var(--primary-hover);
  --brand-bright: #64748b;
  --brand-subtle: #eef2f7;
  --success: #475569;
  --success-subtle: #eef2f7;
  --bg-sidebar-active: rgba(71, 85, 105, 0.22);
  --chart-primary: #475569;
}
html[data-accent='amber'] {
  --primary: #b45309;
  --brand: var(--primary);
  --primary-hover: #92400e;
  --brand-strong: var(--primary-hover);
  --brand-bright: #d97706;
  --brand-subtle: #fef3e6;
  --success: #b45309;
  --success-subtle: #fef3e6;
  --bg-sidebar-active: rgba(180, 83, 9, 0.2);
  --chart-primary: #b45309;
}
html[data-accent='rose'] {
  --primary: #be123c;
  --brand: var(--primary);
  --primary-hover: #9f1239;
  --brand-strong: var(--primary-hover);
  --brand-bright: #e11d48;
  --brand-subtle: #fde8ee;
  --success: #be123c;
  --success-subtle: #fde8ee;
  --bg-sidebar-active: rgba(190, 18, 60, 0.18);
  --chart-primary: #be123c;
}
html[data-accent='violet'] {
  --primary: #6d28d9;
  --brand: var(--primary);
  --primary-hover: #5b21b6;
  --brand-strong: var(--primary-hover);
  --brand-bright: #7c3aed;
  --brand-subtle: #f0e9ff;
  --success: #6d28d9;
  --success-subtle: #f0e9ff;
  --bg-sidebar-active: rgba(109, 40, 217, 0.2);
  --chart-primary: #6d28d9;
}

html[data-theme='dark'][data-accent='ocean'] {
  --primary: #3b8fd4;
  --brand: var(--primary);
  --primary-hover: #5aa3de;
  --brand-strong: #1a6fb5;
  --brand-bright: #7eb8e8;
  --brand-subtle: rgba(59, 143, 212, 0.16);
  --success: #3b8fd4;
  --success-subtle: rgba(59, 143, 212, 0.16);
}
html[data-theme='dark'][data-accent='slate'] {
  --primary: #94a3b8;
  --brand: var(--primary);
  --primary-hover: #cbd5e1;
  --brand-strong: #64748b;
  --brand-bright: #e2e8f0;
  --brand-subtle: rgba(148, 163, 184, 0.16);
  --success: #94a3b8;
  --success-subtle: rgba(148, 163, 184, 0.16);
}
html[data-theme='dark'][data-accent='amber'] {
  --primary: #f59e0b;
  --brand: var(--primary);
  --primary-hover: #fbbf24;
  --brand-strong: #d97706;
  --brand-bright: #fcd34d;
  --brand-subtle: rgba(245, 158, 11, 0.16);
  --success: #f59e0b;
  --success-subtle: rgba(245, 158, 11, 0.16);
}
html[data-theme='dark'][data-accent='rose'] {
  --primary: #fb7185;
  --brand: var(--primary);
  --primary-hover: #fda4af;
  --brand-strong: #e11d48;
  --brand-bright: #fecdd3;
  --brand-subtle: rgba(251, 113, 133, 0.16);
  --success: #fb7185;
  --success-subtle: rgba(251, 113, 133, 0.16);
}
html[data-theme='dark'][data-accent='violet'] {
  --primary: #a78bfa;
  --brand: var(--primary);
  --primary-hover: #c4b5fd;
  --brand-strong: #7c3aed;
  --brand-bright: #ddd6fe;
  --brand-subtle: rgba(167, 139, 250, 0.16);
  --success: #a78bfa;
  --success-subtle: rgba(167, 139, 250, 0.16);
}

/* ── Color schemes: поверхности и текст поверх светлой/тёмной базы ─────────── */
html[data-theme='light'][data-scheme='sepia'] {
  --background: #f4eee2;
  --bg-app: var(--background);
  --bg-primary: var(--background);
  --surface: #fffcf5;
  --bg-surface: var(--surface);
  --surface-elevated: #fffdf8;
  --bg-elevated: var(--surface-elevated);
  --surface-muted: #ece3d2;
  --bg-muted: var(--surface-muted);
  --bg-subtle: #f9f4ea;
  --bg-secondary: #e8dec9;
  --bg-sidebar: #3a2f1f;
  --bg-sidebar-hover: rgba(255, 240, 210, 0.07);
  --border: #e2d6bf;
  --border-subtle: rgba(58, 47, 31, 0.08);
  --border-soft: #efe6d6;
  --border-strong: #cdbd9e;
  --text-primary: #2b2418;
  --text: var(--text-primary);
  --text-secondary: #6b5c45;
  --text-2: var(--text-secondary);
  --text-muted: #9a8a70;
  --text-3: var(--text-muted);
  --chart-grid: #ece3d2;
  --chart-axis: #9a8a70;
}
html[data-theme='light'][data-scheme='contrast'] {
  --background: #ffffff;
  --bg-app: var(--background);
  --bg-primary: var(--background);
  --surface: #ffffff;
  --bg-surface: var(--surface);
  --surface-elevated: #ffffff;
  --bg-elevated: var(--surface-elevated);
  --surface-muted: #ededed;
  --bg-muted: var(--surface-muted);
  --bg-subtle: #f6f6f6;
  --bg-secondary: #e6e6e6;
  --bg-sidebar: #000000;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.12);
  --border: #6b7280;
  --border-subtle: rgba(0, 0, 0, 0.3);
  --border-soft: #9ca3af;
  --border-strong: #111827;
  --text-primary: #000000;
  --text: var(--text-primary);
  --text-secondary: #1f2937;
  --text-2: var(--text-secondary);
  --text-muted: #374151;
  --text-3: var(--text-muted);
  --danger: #a1170c;
  --warning: #7a4f00;
  --info: #1d4ed8;
  --info-link: #1d4ed8;
  --chart-grid: #d1d5db;
  --chart-axis: #374151;
  --focus: 0 0 0 2px #ffffff, 0 0 0 4px #000000;
}
html[data-theme='light'][data-scheme='contrast'] body,
html[data-theme='light'][data-scheme='sepia'] body {
  background: var(--bg-app);
}
html[data-theme='light'][data-scheme='contrast'] a:not(.btn):not(.nav-item):hover {
  text-decoration: underline;
}
html[data-theme='dark'][data-scheme='midnight'] {
  --background: #0b1020;
  --bg-app: var(--background);
  --bg-primary: var(--background);
  --bg-secondary: #10172d;
  --surface: #141d3a;
  --bg-surface: var(--surface);
  --bg-subtle: #18223f;
  --surface-muted: #1e2a4d;
  --bg-muted: var(--surface-muted);
  --surface-elevated: #1a2547;
  --bg-elevated: var(--surface-elevated);
  --bg-sidebar: #050914;
  --border: #283560;
  --border-strong: #3a4878;
  --border-soft: #1e2a4d;
  --border-subtle: rgba(160, 180, 255, 0.07);
  --text-primary: #e6ebff;
  --text: var(--text-primary);
  --text-secondary: #9ba7d0;
  --text-2: var(--text-secondary);
  --text-muted: #6d79a5;
  --text-3: var(--text-muted);
  --chart-grid: #1e2a4d;
  --chart-axis: #6d79a5;
}
html[data-theme='dark'][data-scheme='charcoal'] {
  --background: #141414;
  --bg-app: var(--background);
  --bg-primary: var(--background);
  --bg-secondary: #181818;
  --surface: #1f1f1f;
  --bg-surface: var(--surface);
  --bg-subtle: #242424;
  --surface-muted: #2b2b2b;
  --bg-muted: var(--surface-muted);
  --surface-elevated: #262626;
  --bg-elevated: var(--surface-elevated);
  --bg-sidebar: #0b0b0b;
  --border: #343434;
  --border-strong: #474747;
  --border-soft: #2b2b2b;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --text-primary: #ededed;
  --text: var(--text-primary);
  --text-secondary: #a3a3a3;
  --text-2: var(--text-secondary);
  --text-muted: #737373;
  --text-3: var(--text-muted);
  --chart-grid: #2b2b2b;
  --chart-axis: #737373;
}
html[data-theme='dark'][data-scheme='charcoal'] body {
  background: var(--bg-app);
}
html[data-theme='dark'][data-scheme='midnight'] .tabbar,
html[data-theme='dark'][data-scheme='charcoal'] .tabbar {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

/* ── View Transitions + mobile typography polish (v4) ─────────────────────── */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--motion-page);
  animation-timing-function: var(--ease-standard);
}
::view-transition-old(root) {
  animation-name: vt-fade-out;
}
::view-transition-new(root) {
  animation-name: vt-fade-in;
}
@keyframes vt-fade-out {
  to {
    opacity: 0;
  }
}
@keyframes vt-fade-in {
  from {
    opacity: 0;
  }
}

.shell {
  view-transition-name: app-shell;
}
.topbar {
  view-transition-name: app-topbar;
}
.tabbar {
  view-transition-name: app-tabbar;
}
.main {
  view-transition-name: app-main;
}

@media (max-width: 767px) {
  body {
    font-size: var(--font-body-lg); /* ~16px — readable + no iOS zoom on inputs */
    line-height: var(--lh-relaxed);
  }
  .h1,
  h1 {
    font-size: clamp(1.375rem, 5vw, 1.75rem);
    letter-spacing: var(--tracking-tight);
    line-height: var(--lh-tight);
  }
  .h2,
  h2 {
    font-size: clamp(1.125rem, 4vw, 1.3125rem);
  }
  .page-head {
    gap: var(--space-3);
  }
  .main {
    padding-left: max(var(--space-4), env(safe-area-inset-left, 0px));
    padding-right: max(var(--space-4), env(safe-area-inset-right, 0px));
  }
  .num,
  .metric-value,
  .money,
  td.num,
  th.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings:
      'tnum' 1,
      'lnum' 1;
    letter-spacing: var(--tracking-numeric);
  }
  /* Sticky form actions stay above tabbar + keyboard */
  .form-actions.is-sticky,
  .sticky-actions {
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .main {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }
}

/* Empty / error / success state rhythm */
.empty,
.state-empty,
.state-error,
.state-success {
  text-wrap: pretty;
}
.state-error {
  color: var(--danger);
}
.state-success {
  color: var(--success);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
  .shell,
  .topbar,
  .tabbar,
  .main {
    view-transition-name: none;
  }
}
