/* =============================================================================
   ПивМастер · Коммерческий кабинет
   Direction: Hop Ledger — ink charcoal + hop amber, cool mist canvas
   Product UI (ops density). Not landing, not neon, not cream-serif.
   Fonts: self-hosted woff2 (CSP style-src/font-src 'self'). Manrope has Cyrillic.
   ============================================================================= */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/manrope-cyrillic-500.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/manrope-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/manrope-cyrillic-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/manrope-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./fonts/manrope-cyrillic-700.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./fonts/manrope-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/source-sans-3-cyrillic-400.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/source-sans-3-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/source-sans-3-cyrillic-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/source-sans-3-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./fonts/source-sans-3-cyrillic-700.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./fonts/source-sans-3-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-cyrillic-500.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-cyrillic-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Surfaces — cool hop-mist neutrals (chroma toward green-amber, not cream) */
  --ink: #121816;
  --ink-soft: #24302a;
  --muted: #4e5c55;
  --muted-soft: #6b7a72;
  --line: #d4dbd6;
  --line-strong: #b8c2bb;
  --surface: #fafbf9;
  --surface-subtle: #f0f3f0;
  --canvas: #e6ebe6;
  --canvas-deep: #dce4dc;

  /* Brand / chrome — Hop Ledger */
  --charcoal: #121816;
  --charcoal-elevated: #1c2420;
  --charcoal-hover: #24302a;
  --hop: #c47818;
  --hop-dark: #9a5c10;
  --hop-soft: #e8c48a;
  --hop-wash: #f7efe0;

  /* Semantic */
  --success: #1f6b4a;
  --success-bg: #e6f3ec;
  --warning: #8a6414;
  --warning-bg: #f7f0d8;
  --danger: #a33a3a;
  --danger-bg: #f8eaea;
  --info: #2a5f78;
  --info-bg: #e8f1f5;
  --focus: #2f6f8f;
  --link: #2a5f78;
  --table-header-bg: #f0f3f0;
  --table-header-fg: #24302a;

  /* Aliases for handoff / templates */
  --accent: var(--hop);
  --accent-2: var(--hop-dark);
  --border: var(--line);
  --text: var(--ink);
  --bg: var(--canvas);
  --panel: var(--surface-subtle);

  /* Type — self-hosted (CSP style-src 'self'); Manrope has Cyrillic */
  --font-sans: "Source Sans 3", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --font-brand: "Manrope", "Source Sans 3", sans-serif;
  --text-body: 0.9375rem; /* 15px */
  --text-body-compact: 0.875rem; /* 14px */
  --text-meta: 0.8125rem; /* 13px */
  --text-cap: 0.6875rem; /* 11px */
  --leading-copy: 1.5;
  --leading-compact: 1.4;
  --leading-tight: 1.25;

  /* Spacing / shape */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius: 6px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --shadow-tint: rgba(18, 24, 22, 0.06);
  --shadow: 0 1px 0 var(--shadow-tint), 0 4px 12px rgba(18, 24, 22, 0.05);

  /* Motion — заметный, но не шумный */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-inout: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-fast: 160ms;
  --dur-ui: 240ms;
  --dur-enter: 480ms;

  /* Z-index scale */
  --z-sticky: 30;
  --z-drawer-backdrop: 40;
  --z-drawer: 50;
  --z-skip: 1000;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #edf1ed 0%, var(--canvas) 28%, var(--canvas-deep) 100%);
  background-attachment: fixed;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: var(--leading-copy);
  font-kerning: normal;
  font-optical-sizing: auto;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--hop-dark); }
:focus-visible {
  outline: 2px solid var(--hop);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: var(--z-skip);
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--charcoal);
  border-radius: var(--radius-sm);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.is-hidden { display: none !important; }
.muted { color: var(--muted); }

/* -----------------------------------------------------------------------------
   App shell
   ----------------------------------------------------------------------------- */

.app-shell { min-height: 100dvh; }

.sidebar {
  position: fixed;
  z-index: var(--z-drawer);
  inset: 0 auto 0 0;
  display: flex;
  width: 252px;
  flex-direction: column;
  color: #c5d0c9;
  background:
    linear-gradient(180deg, rgba(196, 120, 24, 0.2) 0%, transparent 160px),
    linear-gradient(180deg, var(--charcoal-elevated) 0%, var(--charcoal) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: inset -1px 0 0 rgba(196, 120, 24, 0.18);
}

.brand {
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  color: #1a140c;
  background: var(--hop);
  border-radius: var(--radius-sm);
  font-family: var(--font-brand);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand strong,
.brand small { display: block; }

.brand strong {
  color: #f4f7f4;
  font-family: var(--font-brand);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand small {
  margin-top: 2px;
  color: #8a9a91;
  font-size: 11px;
  font-weight: 500;
}

.side-nav {
  overflow-y: auto;
  padding: 8px 10px 16px;
}

.nav-label {
  margin: 18px 10px 6px;
  color: #6d7d74;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  padding: 9px 11px;
  color: #b4c0b8;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.side-nav a > span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: #7f9187;
  font-size: 15px;
  transition: color var(--dur-fast) var(--ease-out);
}

/* Active indicator: amber fill bar via ::before (transform, not side-stripe border) */
.side-nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 0 2px 2px 0;
  background: var(--hop);
  opacity: 0;
  transform: translateY(-50%) scaleY(0.4);
  transition:
    height var(--dur-ui) var(--ease-out),
    opacity var(--dur-ui) var(--ease-out),
    transform var(--dur-ui) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .side-nav a:hover {
    color: #f2f6f3;
    background: rgba(255, 255, 255, 0.05);
  }
  .side-nav a:hover > span { color: var(--hop-soft); }
}

.side-nav a[aria-current="page"] {
  color: #fff;
  background: rgba(196, 120, 24, 0.16);
}

.side-nav a[aria-current="page"]::before {
  height: 60%;
  opacity: 1;
  transform: translateY(-50%) scaleY(1);
}

.side-nav a[aria-current="page"] > span { color: var(--hop-soft); }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 18px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-footer small {
  display: block;
  margin-top: 6px;
  color: #7a8a82;
  font-size: 11px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  color: var(--ink-soft);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}

.sidebar .role-badge {
  color: #e4ebe6;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
}

.app-column {
  min-height: 100dvh;
  margin-left: 252px;
}

.topbar {
  position: sticky;
  z-index: var(--z-sticky);
  top: 0;
  display: flex;
  height: 60px;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -2px 0 0 color-mix(in srgb, var(--hop) 35%, transparent);
}

.menu-button { display: none !important; }

.freshness {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}

.freshness small,
.freshness strong { display: block; }

.freshness small {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.freshness strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
}

.status-dot.is-ok {
  background: #2a9a68;
}

.status-dot.is-muted {
  background: #8e9b93;
}

.profile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile form { margin: 0; }

.profile-copy strong,
.profile-copy small {
  display: block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy strong { font-size: 12px; font-weight: 600; }
.profile-copy small { color: var(--muted); font-size: 10px; }

.avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  color: #1a140c;
  background: var(--hop);
  border-radius: 50%;
  font-family: var(--font-brand);
  font-size: 12px;
  font-weight: 700;
}

.avatar-small { width: 28px; height: 28px; flex-basis: 28px; }

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .icon-button:hover {
    color: var(--ink);
    background: var(--surface-subtle);
  }
}

.icon-button:active { transform: scale(0.97); }

.main-content {
  width: 100%;
  max-width: 1660px;
  margin: 0 auto;
  padding: 28px 32px 56px;
}

/* Motion 1: page enter — заметный подъём + лёгкий stagger */
.app-body .main-content.is-ready > * {
  animation: page-rise var(--dur-enter) var(--ease-out) both;
}

.app-body .main-content.is-ready > *:nth-child(1) { animation-delay: 0ms; }
.app-body .main-content.is-ready > *:nth-child(2) { animation-delay: 50ms; }
.app-body .main-content.is-ready > *:nth-child(3) { animation-delay: 100ms; }
.app-body .main-content.is-ready > *:nth-child(4) { animation-delay: 150ms; }
.app-body .main-content.is-ready > *:nth-child(5) { animation-delay: 200ms; }
.app-body .main-content.is-ready > *:nth-child(n+6) { animation-delay: 240ms; }

@keyframes page-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filter-panel.is-applying,
.data-section.is-applying {
  animation: filter-flash var(--dur-ui) var(--ease-out);
}

@keyframes filter-flash {
  0% { border-color: var(--hop); box-shadow: 0 0 0 1px color-mix(in srgb, var(--hop) 40%, transparent); }
  100% { border-color: var(--line); box-shadow: none; }
}

.main-content.report-main {
  max-width: none;
  padding-right: 16px;
  padding-left: 16px;
}

.drawer-backdrop { display: none; }

/* -----------------------------------------------------------------------------
   Type & page chrome
   ----------------------------------------------------------------------------- */

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 6px;
  color: var(--ink);
  font-family: var(--font-brand);
  font-size: clamp(1.85rem, 2.2vw, 2.15rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

h2 {
  margin-bottom: 4px;
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.page-heading h1 {
  padding-bottom: 10px;
  border-bottom: 3px solid var(--hop);
  width: fit-content;
  max-width: 100%;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--hop-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-heading {
  display: flex;
  min-height: 64px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-heading > div:first-child {
  display: grid;
  gap: 6px;
}

.page-heading > div:first-child > p:last-child {
  max-width: 64ch;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: var(--text-body-compact);
  line-height: 1.5;
}

.enqueue-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.enqueue-source {
  min-width: 200px;
  min-height: 40px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.period-summary {
  min-width: 220px;
  padding: 10px 14px;
  background: var(--hop-wash);
  border: 1px solid color-mix(in srgb, var(--hop) 28%, var(--line));
  border-radius: var(--radius-sm);
}

.period-summary small,
.period-summary strong,
.period-summary span { display: block; }

.period-summary small {
  color: var(--hop-dark);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.period-summary strong {
  margin: 2px 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.period-summary span {
  color: var(--muted);
  font-size: 10px;
}

.period-summary .period-tz {
  color: var(--hop-dark);
  font-variant-numeric: tabular-nums;
}

.period-tz-hint {
  grid-column: 1 / -1;
  margin: 0;
}

.period-summary .button {
  display: inline-flex;
  margin-top: 10px;
}

.section-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  max-width: 72ch;
  font-size: var(--text-meta);
  line-height: 1.45;
}
.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.journal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.export-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-soft, #24302a);
  cursor: pointer;
  user-select: none;
}

.export-option input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--hop, #3d6b52);
}

/* -----------------------------------------------------------------------------
   Buttons
   ----------------------------------------------------------------------------- */

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.button:active { transform: scale(0.97); }

.button-primary {
  color: #1a140c;
  background: var(--hop);
  border-color: var(--hop);
}

@media (hover: hover) and (pointer: fine) {
  .button-primary:hover {
    color: #1a140c;
    background: var(--hop-dark);
    border-color: var(--hop-dark);
  }
}

.button-quiet {
  color: var(--ink-soft);
  background: var(--surface);
  border-color: var(--line-strong);
}

@media (hover: hover) and (pointer: fine) {
  .button-quiet:hover {
    color: var(--ink);
    background: var(--surface-subtle);
  }
}

.button-full { width: 100%; }

.button-link {
  padding: 5px 2px;
  color: var(--link);
  background: none;
  border: 0;
  font-weight: 600;
  cursor: pointer;
}

.button-link:hover {
  color: var(--hop-dark);
  text-decoration: underline;
}

/* -----------------------------------------------------------------------------
   KPI ledger strip (not card soup)
   ----------------------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.kpi {
  position: relative;
  min-height: 118px;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}

.kpi:last-child { border-right: 0; }

.kpi-label,
.kpi-note,
.kpi a { display: block; }

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.kpi strong {
  display: block;
  margin: 6px 0 8px;
  font-family: var(--font-brand);
  font-size: clamp(1.85rem, 2.4vw, 2.15rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.kpi-note,
.kpi a {
  color: var(--muted);
  font-size: 11px;
}

.kpi a { color: var(--link); }

.kpi-warning {
  background: color-mix(in srgb, var(--danger-bg) 70%, var(--surface));
}

.kpi-warning strong { color: var(--danger); }

.workspace-section { margin-top: 28px; }

.action-list {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.action-row {
  display: grid;
  min-height: 72px;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out);
}

.action-row:last-child { border-bottom: 0; }

@media (hover: hover) and (pointer: fine) {
  .action-row:hover {
    color: var(--ink);
    background: var(--surface-subtle);
  }
}

.action-row strong,
.action-row small { display: block; }

.action-row small {
  margin-top: 2px;
  color: var(--muted);
}

.action-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--hop-dark);
  background: var(--hop-wash);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
}

.action-icon-alert {
  color: var(--danger);
  background: var(--danger-bg);
}

/* -----------------------------------------------------------------------------
   Panels, forms, tables
   ----------------------------------------------------------------------------- */

.filter-panel,
.form-panel,
.data-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filter-panel { margin-bottom: 20px; }

.filter-panel summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
}

.filter-panel summary::marker { color: var(--muted); }

.summary-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.count-badge {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  margin-left: 5px;
  padding: 0 6px;
  place-items: center;
  color: #1a140c;
  background: var(--hop);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px;
  background: var(--surface-subtle);
  border-top: 1px solid var(--line);
  align-items: start;
}

.filter-form-compact .field-search {
  grid-column: span 2;
}

.filter-period-group {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filter-period-title {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.filter-period-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 12px;
}

.filter-period-group > .field-hint {
  margin: 0;
}

.field { min-width: 0; }

.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
}

.field input:not([type="checkbox"]),
.field select {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) var(--ease-out);
}

.field-hint {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.3;
}

/* Looks like a select; nest inside .field so the label matches period/source */
.filter-fold {
  min-width: 0;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.filter-fold > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.filter-fold > summary::-webkit-details-marker { display: none; }

.filter-fold > summary::after {
  content: "+";
  color: var(--ink-soft);
  font-weight: 700;
}

.filter-fold[open] > summary {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.filter-fold[open] > summary::after { content: "−"; }

.filter-fold-placeholder {
  color: var(--ink-soft);
  font-weight: 600;
}

.filter-fold-meta {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.filter-fold .checklist {
  max-height: 296px;
  overflow: auto;
  margin: 0;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.filter-fold-search {
  margin: 0;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 0;
}

.filter-fold-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  align-items: center;
  margin: 0;
  padding: 4px 10px 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 0;
}

.filter-fold-actions .button-link {
  padding: 0;
  font-size: 12px;
  font-weight: 600;
}

.filter-fold-search input {
  width: 100%;
  min-height: 32px;
  padding: 5px 8px;
  color: var(--ink);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.filter-fold .checklist-item.is-filtered-out,
.filter-fold .checklist-item.is-source-hidden {
  display: none !important;
}

.filter-fold .field-hint {
  margin: 0;
  padding: 6px 10px 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.filter-fold[open] .field-hint {
  border-radius: 0;
}

.filter-fold[open] .filter-fold-search + .checklist,
.filter-fold[open] .filter-fold-actions + .checklist,
.filter-fold[open] .field-hint + .checklist,
.filter-fold .checklist:last-child {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.filter-fold[open] .filter-fold-search + .checklist + .field-hint,
.filter-fold[open] .filter-fold-actions + .checklist + .field-hint,
.filter-fold[open] .checklist + .field-hint {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 5px 6px;
  border-radius: 4px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
}

.checklist-item:hover { background: var(--surface-subtle); }

.checklist-item input {
  margin: 2px 0 0;
  flex: 0 0 auto;
}

.checklist-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.field input:not([type="checkbox"]):hover,
.field select:hover { border-color: #9aa89f; }

.field input:not([type="checkbox"]):focus,
.field select:focus {
  border-color: var(--hop);
  outline: 2px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 0;
}

.field-checkbox {
  display: flex;
  min-height: 38px;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 20px;
}

.field-checkbox label { margin: 0; order: 2; }
.field-checkbox input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--hop);
}
.field-checkbox .help-text,
.field-checkbox .field-error { width: 100%; order: 3; }

.filter-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  /* Match .field label + gap so buttons sit on the control baseline */
  padding-top: calc(11px * 1.35 + 5px);
}

.help-text {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.field-error {
  display: block;
  margin-top: 4px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
}

.field-invalid input:not([type="checkbox"]),
.field-invalid select { border-color: var(--danger); }

.field-date[hidden] { display: none !important; }

.field-date.is-active input {
  border-color: var(--hop);
}

.data-section {
  margin-top: 20px;
  padding: 0;
  overflow: hidden;
}

.data-section > .section-heading {
  margin-bottom: 0;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-subtle) 70%, var(--surface));
}

.data-section > .section-heading.section-heading-row {
  align-items: center;
  gap: 12px 16px;
}

.data-section > .scroll-hint {
  padding: 10px 16px 0;
}

.table-wrap {
  /* overflow-x only — vertical sticky headers break if overflow is not visible */
  overflow-x: auto;
  overflow-y: visible;
  background: var(--surface);
  border-top: 0;
  border-radius: 0;
}

.table-wrap:focus { outline-offset: -3px; }

.report-table-wrap {
  /* Fit viewport width; page scrolls vertically. */
  container-type: inline-size;
  container-name: report;
  overflow: visible;
  border-bottom: 1px solid var(--line);
}

.data-table {
  width: 100%;
  min-width: 0;
  border-spacing: 0;
  border-collapse: collapse;
  font-size: var(--text-body-compact);
  line-height: var(--leading-compact);
  color: var(--ink);
}

/* Settings / sync grids that need a bit of room */
.data-table:not(.report-table):not(.ipr-table) {
  min-width: 640px;
}

/* Auto-fit ops grid to available width */
.report-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.report-table-autorder,
.report-table-oos {
  min-width: 0;
}

.data-table.report-table th,
.data-table.report-table td {
  padding: 8px 8px;
  font-size: var(--text-meta);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table.report-table th {
  position: sticky;
  top: 60px;
  z-index: calc(var(--z-sticky) + 1);
  padding: 9px 8px;
  color: var(--ink-soft);
  background: #eef2ef;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
  text-transform: none;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--line-strong);
}

.report-table .col-store { width: 11%; }
.report-table .col-sku { width: 5%; }
.report-table .col-name { width: 16%; }
.report-table .col-meta { width: 8%; }
.report-table .col-num { width: 4.5%; }
.report-table .col-order { width: 5.5%; }

.report-table-oos .col-name { width: 22%; }
.report-table-oos .col-num { width: 8%; }
.report-table-oos .col-order { width: 11%; }

.report-table td.col-store,
.report-table td.col-meta {
  white-space: normal;
  overflow-wrap: anywhere;
}

.report-table td.col-num,
.report-table td.col-order,
.report-table td.col-sku {
  white-space: nowrap;
}

.report-table td.col-store,
.report-table td.col-name,
.report-table td.col-meta {
  vertical-align: top;
}

.report-table td.col-store {
  color: var(--ink-soft);
  font-weight: 600;
}

.report-table td.col-meta {
  color: var(--muted);
}

.report-table .product-cell strong {
  display: -webkit-box;
  overflow: hidden;
  max-width: 100%;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  font-size: var(--text-body-compact);
  font-weight: 700;
  line-height: 1.4;
}

.report-table .sku {
  font-size: 0.85em;
  font-weight: 600;
}

.report-table .no-data {
  color: var(--muted-soft);
  font-size: 0.92em;
}

@container report (max-width: 1280px) {
  .report-table .col-store { width: 10%; }
  .report-table .col-name { width: 14%; }
  .report-table .col-meta { width: 7%; }
  .data-table.report-table th,
  .data-table.report-table td {
    padding-inline: 6px;
  }
}

@container report (max-width: 1040px) {
  .report-table th.col-meta,
  .report-table td.col-meta {
    display: none;
  }
  .report-table .col-store { width: 13%; }
  .report-table .col-name { width: 20%; }
  .report-table .col-num { width: 5.5%; }
  .report-table .col-order { width: 7%; }
}

.scroll-hint {
  display: block;
  margin: 0;
  padding: 0 16px 10px;
  color: var(--muted);
  font-size: 12px;
}

.scroll-hint-mobile { display: none; }

.data-table th,
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--table-header-fg);
  background: var(--table-header-bg);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
  text-transform: none;
  white-space: nowrap;
}

.data-table th a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.data-table th a:hover { color: var(--hop-dark); }

.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-subtle) 54%, var(--surface));
}

/* Motion 2: table row hover/focus — crisp, interruptible */
.data-table tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}

.data-table tbody tr:hover td,
.data-table tbody tr:focus-within td {
  background: color-mix(in srgb, var(--hop-wash) 78%, var(--surface));
}

.data-table tbody tr:hover td:first-child,
.data-table tbody tr:focus-within td:first-child {
  box-shadow: inset 3px 0 0 var(--hop);
}

.data-table .numeric {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--ink);
  font-size: 0.92em;
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}

.data-table th.is-emphasis {
  color: var(--ink);
  background: var(--hop-wash);
  box-shadow: inset 0 -2px 0 var(--hop);
}

.data-table td.value-strong {
  color: var(--ink);
  background: color-mix(in srgb, var(--hop-wash) 76%, var(--surface));
  font-size: 1em;
  font-weight: 700;
}

.data-table tbody tr:nth-child(even) td.value-strong {
  background: color-mix(in srgb, var(--hop-wash) 82%, var(--surface-subtle));
}

.data-table tbody tr:hover td.value-strong,
.data-table tbody tr:focus-within td.value-strong {
  background: color-mix(in srgb, var(--hop-wash) 90%, var(--surface));
}

.sku {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-meta);
  font-weight: 600;
  white-space: nowrap;
}

.product-cell { min-width: 220px; }
.product-cell strong,
.product-cell small { display: block; }
.product-cell strong {
  max-width: 320px;
  font-size: var(--text-body-compact);
  font-weight: 700;
  line-height: 1.4;
}
.product-cell small {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-meta);
  line-height: 1.4;
}

.no-data {
  color: var(--muted-soft);
  font-size: var(--text-meta);
  white-space: nowrap;
}

.margin-cue {
  display: block;
  margin-top: 2px;
  color: var(--warning);
  font-size: var(--text-cap);
  font-weight: 600;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-cap);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.status-success,
.status-succeeded {
  color: var(--success);
  background: var(--success-bg);
}

.status-error,
.status-failed {
  color: var(--danger);
  background: var(--danger-bg);
}

.status-warning,
.status-queued {
  color: var(--warning);
  background: var(--warning-bg);
}

.status-running {
  color: var(--info);
  background: var(--info-bg);
}

.status-cancelled {
  color: var(--muted);
  background: var(--surface-subtle);
}

.status-neutral {
  color: var(--muted);
  background: var(--surface-subtle);
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
}

.empty-state > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-soft);
  font-size: 28px;
}

.empty-state strong {
  display: block;
  font-size: 14px;
}

.empty-state p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.pagination {
  display: grid;
  min-height: 56px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
}

.pagination > :last-child { justify-self: end; }
.pagination > span {
  color: var(--muted);
  font-size: 11px;
}

.form-panel { padding: 18px; }
.form-panel-narrow { max-width: 760px; }
.model-form { margin: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.form-grid-rules {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-fold-single > summary .filter-fold-placeholder {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-fold-single > summary .filter-fold-placeholder.is-empty {
  color: var(--ink-soft);
}

.form-grid-users { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-single { grid-template-columns: 1fr; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.unsaved-note {
  display: none;
  margin-left: 6px;
  color: var(--warning);
  font-size: 11px;
}

.is-dirty .unsaved-note { display: inline; }

.data-section + .data-section,
.form-panel + .data-section { margin-top: 20px; }

.alert {
  padding: 10px 12px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.alert + .alert { margin-top: 8px; }

.alert-error {
  color: #7a2a2a;
  background: var(--danger-bg);
  border-color: #e8c4c4;
}

.alert-info {
  color: var(--info);
  background: var(--info-bg);
  border-color: #c5d8e2;
}

.alert-success {
  color: var(--success);
  background: var(--success-bg);
  border-color: #bdd9c9;
}

.message-stack { margin-bottom: 16px; }

.user-cell {
  display: flex;
  align-items: center;
  gap: 9px;
}

.user-cell strong,
.user-cell small { display: block; }

.user-cell small {
  color: var(--muted);
  font-size: 10px;
}

.password-help ul {
  margin: 5px 0 0;
  padding-left: 18px;
}

.two-column-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.two-column-layout .data-section { margin-top: 0; }

.compact-list {
  margin: 20px -18px -18px;
  border-top: 1px solid var(--line);
}

.compact-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
}

.compact-list > div:last-child { border-bottom: 0; }
.compact-list strong,
.compact-list small { display: block; }
.compact-list small {
  color: var(--muted);
  font-size: 10px;
}

.compact-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  justify-content: flex-end;
}

.inline-form {
  display: inline;
  margin: 0;
}

.sync-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
  padding: 6px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.sync-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.sync-tabs a:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--hop) 10%, transparent);
}

.sync-tabs a[aria-current="page"] {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 2px rgba(18, 24, 22, 0.08);
}

.audit-section-full {
  max-height: none;
}

.audit-section {
  max-height: 680px;
  overflow: auto;
}

.audit-list { padding: 0 16px 16px; }

.audit-list article {
  position: relative;
  display: grid;
  grid-template-columns: 13px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.audit-list article:first-child { border-top: 0; }

.audit-marker {
  width: 7px;
  height: 7px;
  margin-top: 6px;
  background: var(--muted-soft);
  border-radius: 50%;
}

.audit-list strong { font-size: 11px; }

.audit-list p,
.audit-list time {
  display: block;
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.error-cell {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   Auth / login — brand-first
   ----------------------------------------------------------------------------- */

.auth-body {
  min-height: 100dvh;
  background: var(--charcoal);
}

.auth-main { min-height: 100dvh; }

.auth-layout {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: minmax(340px, 1.15fr) minmax(400px, 0.85fr);
}

.auth-intro {
  position: relative;
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 5vw, 72px);
  color: #c8d4cc;
  overflow: hidden;
  background-color: var(--charcoal);
  background-image:
    radial-gradient(ellipse 70% 45% at 15% 20%, rgba(196, 120, 24, 0.32), transparent 60%),
    linear-gradient(165deg, var(--charcoal-elevated) 0%, var(--charcoal) 100%);
}

.brand-auth {
  position: relative;
  z-index: 1;
  padding: 0;
}

.brand-auth .brand-mark {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
  font-size: 15px;
}

.brand-auth strong {
  font-size: 22px;
  letter-spacing: -0.03em;
}

.auth-intro-copy {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: auto 0;
}

.auth-intro-copy .brand-hero {
  margin: 0 0 20px;
  color: #f7faf7;
  font-family: var(--font-brand);
  font-size: clamp(2.6rem, 5vw, 3.75rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.auth-intro-copy h1 {
  max-width: 520px;
  color: #e8efe9;
  font-family: var(--font-brand);
  font-size: clamp(1.35rem, 2.2vw, 1.85rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.auth-intro-copy > p:last-of-type {
  max-width: 48ch;
  color: #9aaba1;
  font-size: 15px;
}

.auth-caption {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #6d7d74;
  font-size: 11px;
}

.auth-card {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 7vw, 96px);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: inset 3px 0 0 0 var(--hop);
}

.auth-card-mobile-brand {
  display: none;
  margin-bottom: 28px;
}

.auth-card > div:first-child { margin-bottom: 22px; }

.auth-card h2 {
  margin-bottom: 6px;
  font-size: 1.5rem;
}

.auth-card > div:first-child > p:last-child,
.auth-help { color: var(--muted); }

.auth-form { margin-top: 18px; }
.auth-form .field { margin-bottom: 15px; }
.auth-form .field input { min-height: 44px; }

.auth-help {
  margin: 16px 0 0;
  font-size: 11px;
  text-align: center;
}

/* Motion 3: login — явный подъём карточки и intro */
.auth-layout.is-ready .auth-intro-copy {
  animation: auth-rise var(--dur-enter) var(--ease-out) both;
}

.auth-layout.is-ready .auth-card {
  animation: auth-rise-card calc(var(--dur-enter) + 40ms) var(--ease-out) both;
  animation-delay: 80ms;
}

@keyframes auth-rise {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes auth-rise-card {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.success-state {
  max-width: 560px;
  margin: 12vh auto 0;
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}

.success-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  place-items: center;
  color: var(--success);
  background: var(--success-bg);
  border-radius: 50%;
  font-size: 22px;
  font-weight: 800;
}

.error-icon {
  color: var(--danger);
  background: var(--danger-bg);
}

.success-state p:not(.eyebrow) { color: var(--muted); }

/* -----------------------------------------------------------------------------
   Responsive
   ----------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .filter-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field-search { grid-column: span 2; }
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 16px; }
  .two-column-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  body.drawer-open { overflow: hidden; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--dur-ui) var(--ease-out);
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.28);
  }

  .drawer-open .sidebar { transform: none; }

  .drawer-backdrop {
    position: fixed;
    z-index: var(--z-drawer-backdrop);
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(10, 14, 12, 0.52);
    border: 0;
  }

  .drawer-open .drawer-backdrop { display: block; }

  .app-column { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .menu-button {
    display: grid !important;
    margin-right: 6px;
  }
  .freshness { margin-right: auto; }

  .main-content,
  .main-content.report-main { padding: 24px 18px 44px; }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }

  .form-grid,
  .form-grid-users { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .auth-layout { grid-template-columns: 1fr; }
  .auth-intro { display: none; }
  .auth-card-mobile-brand { display: flex; }
  .auth-card {
    min-height: 100dvh;
    max-width: none;
    border-left: 0;
    padding: 10vh max(24px, calc((100vw - 440px) / 2));
  }
}

@media (max-width: 640px) {
  .topbar {
    height: 56px;
    padding: 0 12px;
  }

  .freshness small { display: none; }
  .freshness strong {
    max-width: 135px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profile-copy,
  .profile > .avatar { display: none; }
  .profile { gap: 1px; }

  .main-content,
  .main-content.report-main { padding: 20px 12px 36px; }

  .page-heading {
    display: block;
    margin-bottom: 18px;
  }

  .page-heading > .button,
  .page-heading > form,
  .page-heading > .status-badge { margin-top: 14px; }

  .page-heading > form .button { width: 100%; }
  .period-summary {
    min-width: 0;
    margin-top: 14px;
  }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi {
    min-height: 108px;
    padding: 14px;
  }
  .kpi strong { font-size: 1.5rem; }

  .action-row {
    min-height: 64px;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
    padding: 10px 12px;
  }

  .action-row small { font-size: 10px; }
  .action-icon {
    width: 30px;
    height: 30px;
  }

  .filter-form {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .field-search { grid-column: 1 / -1; }
  .filter-actions { grid-column: 1 / -1; }
  .filter-actions .button { flex: 1; }
  .summary-hint { display: none; }

  .form-panel { padding: 14px; }
  .form-grid,
  .form-grid-users { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .unsaved-note {
    width: 100%;
    margin: 3px 0 0;
  }

  .data-section { padding-top: 0; }
  .data-section > .section-heading { padding: 12px 12px 10px; }
  .section-heading-row {
    display: grid;
    gap: 6px;
  }
  .result-note { justify-self: start; }

  .scroll-hint-desktop { display: none; }
  .scroll-hint-mobile {
    display: block;
    padding: 0 4px 12px;
    font-size: 13px;
  }

  /* Card stack: full-width fields (desktop col-% widths must not leak) */
  .report-table-wrap {
    background: none;
    border-top: 0;
    border-bottom: 0;
    container-type: normal;
  }

  .report-table,
  .report-table-autorder,
  .report-table-oos {
    display: block;
    width: 100%;
    min-width: 0 !important;
    table-layout: auto;
  }

  .report-table thead { display: none; }

  .report-table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .report-table tbody tr {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  .report-table tbody tr:nth-child(even) td,
  .report-table tbody tr:hover td,
  .report-table tbody tr:focus-within td {
    background: transparent;
  }

  .report-table tbody tr.report-empty-row {
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  .report-table tbody tr.report-empty-row td {
    display: block;
    width: 100% !important;
    padding: 0;
    border: 0;
  }

  .report-table th:first-child,
  .report-table td:first-child {
    position: static;
    left: auto;
    min-width: 0;
    max-width: none;
    box-shadow: none;
  }

  .report-table .col-store,
  .report-table .col-sku,
  .report-table .col-name,
  .report-table .col-meta,
  .report-table .col-num,
  .report-table .col-order,
  .report-table-oos .col-name,
  .report-table-oos .col-num,
  .report-table-oos .col-order {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
  }

  .report-table td {
    display: grid;
    grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr);
    gap: 8px 12px;
    align-items: start;
    box-sizing: border-box;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 44px;
    margin: 0;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    line-height: 1.4;
    text-align: left !important;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    overflow-wrap: break-word;
    word-break: normal;
  }

  .report-table th.col-meta,
  .report-table td.col-meta {
    display: grid;
  }

  .report-table td:last-child { border-bottom: 0; }

  .report-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    min-width: 0;
  }

  .report-table td.col-name {
    grid-template-columns: 1fr;
    gap: 4px;
    order: -2;
    padding-top: 14px;
    padding-bottom: 12px;
    background: color-mix(in srgb, var(--surface-subtle) 55%, var(--surface));
    border-bottom: 1px solid var(--line-strong);
  }

  .report-table td.col-name::before {
    color: var(--muted-soft);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .report-table td.col-name strong {
    display: block;
    max-width: none;
    overflow: visible;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    font-family: var(--font-brand);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ink);
    overflow-wrap: break-word;
  }

  .report-table td.col-store {
    order: -3;
    grid-template-columns: 1fr;
    gap: 4px;
    padding-top: 12px;
    padding-bottom: 10px;
    background: var(--charcoal);
    color: #e8eee9;
    border-bottom: 0;
    font-weight: 600;
    overflow-wrap: break-word;
  }

  .report-table td.col-store::before {
    color: var(--hop-soft);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .report-table td.col-sku {
    order: -1;
    align-items: center;
    background: color-mix(in srgb, var(--hop-wash) 40%, var(--surface));
  }

  .report-table .sku { font-size: 14px; }

  .report-table td.col-num {
    grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr);
  }

  .report-table td.col-order,
  .report-table td.value-strong {
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 52px;
    background: var(--hop-wash) !important;
    border-top: 1px solid color-mix(in srgb, var(--hop) 28%, var(--line));
    font-size: 18px;
    font-weight: 700;
  }

  .report-table td.col-order::before,
  .report-table td.value-strong::before {
    color: var(--hop-dark);
    font-size: 13px;
  }

  .report-table .product-cell strong {
    -webkit-line-clamp: unset;
    max-width: none;
    white-space: normal;
  }

  .report-table .status-badge {
    font-size: 13px;
    padding: 4px 8px;
  }

  .pagination {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 16px 4px 0;
  }
  .pagination > span {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: center;
    font-size: 13px;
  }
  .pagination .button {
    min-height: 44px;
    justify-content: center;
  }

  .auth-card { padding: 40px 20px; }
  .success-state {
    margin-top: 5vh;
    padding: 28px 20px;
  }
}

@media (max-width: 400px) {
  .filter-form { grid-template-columns: 1fr; }
  .field-search,
  .filter-actions { grid-column: auto; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi {
    min-height: 100px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .kpi:nth-child(3) { border-bottom: 1px solid var(--line); }
  .kpi:last-child { border-bottom: 0; }

  .report-table td,
  .report-table td.col-num {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .report-table td.col-order,
  .report-table td.value-strong {
    grid-template-columns: 1fr auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .auth-layout.is-ready .auth-intro-copy,
  .auth-layout.is-ready .auth-card,
  .app-body .main-content.is-ready > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

@media print {
  .sidebar,
  .topbar,
  .filter-panel,
  .pagination,
  .page-heading .button { display: none !important; }
  .app-column { margin: 0; }
  .main-content {
    max-width: none;
    padding: 0;
  }
  .data-section {
    border: 0;
    box-shadow: none;
  }
  .table-wrap { overflow: visible; }
  body { background: #fff; }
}

/* ИПР shell */
.ipr-section + .ipr-section { margin-top: 16px; }

.ipr-board {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "kpi"
    "gross"
    "plan"
    "stock"
    "matrix";
  gap: 14px;
  align-items: stretch;
}

.ipr-board > .ipr-section { margin-top: 0; }

.ipr-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ipr-panel-kpi { grid-area: kpi; }
.ipr-panel-plan { grid-area: plan; }
.ipr-panel-gross { grid-area: gross; }
.ipr-panel-stock { grid-area: stock; }
.ipr-panel-matrix { grid-area: matrix; }

.ipr-panel > .section-heading {
  padding-bottom: 8px;
}

.ipr-panel > .section-heading p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ipr-panel .table-wrap {
  flex: 1 1 auto;
  max-height: none;
  overflow: auto;
}

.ipr-panel-kpi .table-wrap,
.ipr-panel-plan .table-wrap {
  max-height: none;
}

.ipr-panel-matrix .table-wrap {
  max-height: none;
}

.ipr-empty-hint {
  margin: 0;
  padding: 0 16px 16px;
}

/* Две колонки: узкие Показатели, широкая Валовая; план/остатки на всю ширину */
@media (min-width: 1600px) {
  .ipr-board {
    grid-template-columns: minmax(240px, 20rem) minmax(0, 1fr);
    grid-template-areas:
      "kpi gross"
      "plan plan"
      "stock stock"
      "matrix matrix";
  }

  .ipr-panel .table-wrap {
    max-height: min(48vh, 520px);
  }

  .ipr-panel-kpi .table-wrap,
  .ipr-panel-plan .table-wrap {
    max-height: min(56vh, 640px);
  }

  .ipr-panel-matrix .table-wrap {
    max-height: min(60vh, 720px);
  }
}

.ipr-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 18px;
  margin: 0;
  padding: 0 16px 16px;
}

.ipr-meta div {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.ipr-meta dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: var(--text-cap);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ipr-meta dd {
  margin: 0;
  font-weight: 600;
}

.ipr-table .ipr-hint {
  max-width: none;
  color: var(--muted);
  font-size: var(--text-meta);
  line-height: 1.35;
  white-space: normal;
}

.ipr-table .ipr-hint span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* IPR grids: natural column widths, no forced fixed layout */
.ipr-table {
  min-width: 0;
  width: 100%;
  table-layout: auto;
  font-size: var(--text-body-compact);
}

.ipr-table th,
.ipr-table td {
  padding: 8px 12px;
  line-height: 1.35;
  vertical-align: middle;
}

.ipr-table th {
  position: static;
  color: var(--ink-soft);
  background: #eef2ef;
  box-shadow: none;
  text-align: left;
}

.ipr-table th.numeric {
  text-align: right;
}

.ipr-table th.is-sortable {
  cursor: pointer;
  user-select: none;
}

.ipr-table th.is-sortable:hover,
.ipr-table th.is-sortable:focus-visible {
  color: var(--hop-dark, #8a4f12);
}

.ipr-table th.is-sortable .sort-cue {
  color: var(--muted, #7a8a82);
  font-weight: 500;
}

.ipr-table th[aria-sort] .sort-cue {
  color: var(--hop, #c47818);
}

.ipr-table td:first-child {
  color: var(--ink);
  font-weight: 600;
}

.ipr-table .numeric {
  font-size: 0.9em;
  font-weight: 500;
  letter-spacing: 0;
}

/* KPI: значения рядом с подписью, без растянутой пустоты */
.ipr-kpi-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.ipr-kpi-table {
  width: 100%;
  table-layout: auto;
}

.ipr-kpi-table th,
.ipr-kpi-table td {
  padding: 8px 12px;
}

.ipr-kpi-table th:nth-child(1),
.ipr-kpi-table td:nth-child(1) {
  width: auto;
  padding-right: 16px;
}

.ipr-kpi-table th:nth-child(2),
.ipr-kpi-table td:nth-child(2) {
  width: 1%;
  padding-left: 8px;
  white-space: nowrap;
  text-align: right;
}

.ipr-plan-table {
  width: max-content;
  min-width: 100%;
  max-width: none;
  table-layout: auto;
}

.ipr-plan-table th,
.ipr-plan-table td {
  white-space: nowrap;
}

.ipr-plan-table th:nth-child(1),
.ipr-plan-table td:nth-child(1) { width: auto; }
.ipr-plan-table th:nth-child(2),
.ipr-plan-table td:nth-child(2),
.ipr-plan-table th:nth-child(3),
.ipr-plan-table td:nth-child(3),
.ipr-plan-table th:nth-child(4),
.ipr-plan-table td:nth-child(4),
.ipr-plan-table th:nth-child(5),
.ipr-plan-table td:nth-child(5),
.ipr-plan-table th:nth-child(6),
.ipr-plan-table td:nth-child(6) { width: auto; }

.ipr-plan-input {
  width: 100%;
  max-width: 9.5rem;
  margin-left: auto;
  display: block;
  min-height: 32px;
  padding: 4px 8px;
  text-align: right;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.ipr-plan-input:focus {
  border-color: var(--hop);
  outline: 2px solid color-mix(in srgb, var(--hop) 35%, transparent);
  outline-offset: 1px;
}

.ipr-plan-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px 16px 16px;
}

.ipr-matrix-table {
  width: max-content;
  min-width: 100%;
  max-width: none;
  table-layout: auto;
}

.ipr-matrix-table th,
.ipr-matrix-table td {
  white-space: nowrap;
}

.ipr-matrix-table th:nth-child(1),
.ipr-matrix-table td:nth-child(1) { width: auto; min-width: 12rem; }
.ipr-matrix-table th:nth-child(2),
.ipr-matrix-table td:nth-child(2),
.ipr-matrix-table th:nth-child(3),
.ipr-matrix-table td:nth-child(3),
.ipr-matrix-table th:nth-child(4),
.ipr-matrix-table td:nth-child(4),
.ipr-matrix-table th:nth-child(5),
.ipr-matrix-table td:nth-child(5) { width: auto; }

/* 1С group tables: never letter-wrap names (Safari shrinks first col otherwise) */
.ipr-onec-table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}

.ipr-onec-table th,
.ipr-onec-table td {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.ipr-onec-table th:first-child,
.ipr-onec-table td:first-child {
  min-width: 14rem;
  max-width: none;
  padding-right: 16px;
}

.ipr-onec-table th:not(:first-child),
.ipr-onec-table td:not(:first-child) {
  width: auto;
}

.ipr-notes {
  display: grid;
  gap: 14px;
  padding: 0 16px 16px;
}

.ipr-note {
  display: grid;
  gap: 6px;
}

.ipr-note span {
  color: var(--muted);
  font-size: var(--text-meta);
}

.ipr-note textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.ipr-report-source {
  margin: 0;
  padding: 10px 16px 0;
  color: var(--muted);
  font-size: var(--text-meta);
}

.ipr-onec-table tbody tr.ipr-total-row td {
  border-top: 2px solid var(--line-strong);
  background: color-mix(in srgb, var(--hop-wash) 56%, var(--surface));
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.ipr-onec-table tbody tr.ipr-total-row td:first-child strong {
  font-family: var(--font-brand);
  font-weight: 700;
}

.ipr-attachments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}

.ipr-attach-slot {
  display: grid;
  gap: 6px;
  min-height: 120px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
  align-content: start;
}

.ipr-attach-slot span,
.ipr-attach-slot em {
  color: var(--muted);
  font-size: 0.88rem;
  font-style: normal;
}

.ipr-attach-slot em { font-style: italic; }

/* Home dashboard — KilBil-style overview */
.dash-grain {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: color-mix(in srgb, var(--panel, #fff) 92%, transparent);
}

.dash-grain-btn {
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-right: 1px solid var(--line);
}

.dash-grain-btn:last-child { border-right: 0; }

.dash-grain-btn:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--hop, #c9852a) 10%, transparent);
}

.dash-grain-btn.is-active {
  color: var(--ink);
  background: color-mix(in srgb, var(--hop, #c9852a) 22%, transparent);
}

.dash-kpi-section { margin-top: 12px; }

.kpi-grid.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: stretch;
}

.dash-kpi-grid .kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 100px;
  min-width: 0;
  padding: 18px 8px;
  text-align: center;
  border-right: 1px solid var(--line);
  border-bottom: 0;
  overflow: hidden;
}

.dash-kpi-grid .kpi:last-child { border-right: 0; }

.dash-kpi-grid .kpi-label {
  margin: 0;
  width: 100%;
  text-align: center;
  line-height: 1.25;
}

.dash-kpi-grid .kpi strong {
  display: block;
  margin: 0;
  width: 100%;
  text-align: center;
  font-size: clamp(0.95rem, 1.35vw, 1.35rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.dash-charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin: 20px 0 18px;
  align-items: stretch;
}

.dash-charts > .data-section,
.dash-charts > .data-section + .data-section {
  margin-top: 0;
  height: 100%;
  align-self: stretch;
}

.dash-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin: 0 0 8px;
}

.dash-rank-panel {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.dash-rank-board > .data-section,
.dash-rank-board > .data-section + .data-section {
  margin-top: 0;
  height: 100%;
  align-self: stretch;
}

.dash-rank-panel .section-heading {
  margin-bottom: 0;
  min-height: 4.25rem;
  align-items: flex-start;
}

.dash-rank-panel .section-heading h2 {
  margin: 0;
}

.dash-rank-panel .section-heading p {
  margin: 0.25rem 0 0;
}

.dash-rank-board {
  grid-template-columns: 1fr;
  align-items: stretch;
}

@media (min-width: 1100px) {
  .dash-rank-board {
    grid-template-columns: 1fr 1fr;
  }
}

.dash-rank-panel-bottom .dash-rank-row:first-child .dash-rank-pos {
  color: var(--muted);
}

.dash-chart-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.dash-chart-panel .section-heading {
  margin-bottom: 0;
  flex: 0 0 auto;
  min-height: 3rem;
  display: flex;
  align-items: center;
}

.dash-chart-panel .section-heading h2 { margin: 0; }

.dash-chart {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px 16px;
  min-height: 214px;
  box-sizing: border-box;
}

.dash-plot {
  display: block;
  width: 100%;
  height: 168px;
  flex: 0 0 168px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  box-sizing: content-box;
}

.dash-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 178px;
  height: 178px;
  border-top: 1px solid var(--line);
  text-align: center;
  padding: 0 12px;
  box-sizing: border-box;
}

.dash-chart-empty .field-hint { margin: 0; }

.dash-bar-axis {
  display: flex;
  gap: 0;
  min-height: 1.35em;
  flex: 0 0 1.35em;
}

.dash-bar-axis.is-empty {
  visibility: hidden;
}

.dash-bar-tick {
  flex: 1 1 0;
  min-width: 0;
  display: block;
  text-align: center;
  font-size: 0.68rem;
  line-height: 1.2;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.dash-rank {
  list-style: none;
  margin: 0;
  padding: 4px 20px 16px;
  flex: 1 1 auto;
}

.dash-rank-row {
  display: grid;
  /* pos | name | bar | value | share — фиксированные value/share, чтобы обе колонки совпали */
  grid-template-columns: 1.75rem minmax(0, 1.1fr) minmax(5rem, 1fr) 7.75rem 3.5rem;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.dash-rank-row:last-child { border-bottom: 0; }

.dash-rank-pos {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted-soft);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.dash-rank-row:first-child .dash-rank-pos { color: var(--hop-dark); }

.dash-rank-name {
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-rank-bar {
  display: block;
  width: 100%;
  height: 4px;
  overflow: visible;
}

.dash-rank-track {
  fill: color-mix(in srgb, var(--line) 88%, transparent);
}

.dash-rank-fill {
  fill: var(--hop);
}

.dash-rank-value {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  justify-self: stretch;
}

.dash-rank-share {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  justify-self: stretch;
}

@media (max-width: 1100px) {
  .kpi-grid.dash-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dash-kpi-grid .kpi {
    border-bottom: 1px solid var(--line);
  }

  .dash-kpi-grid .kpi:nth-child(3n) { border-right: 0; }

  .dash-kpi-grid .kpi:nth-last-child(-n + 3) { border-bottom: 0; }
}

@media (max-width: 900px) {
  .dash-charts { grid-template-columns: 1fr; }
  .page-heading .dash-grain { width: 100%; }
  .dash-grain { display: flex; }
  .dash-grain-btn { flex: 1; text-align: center; }
}

@media (max-width: 720px) {
  .kpi-grid.dash-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-kpi-grid .kpi:nth-child(3n) { border-right: 1px solid var(--line); }
  .dash-kpi-grid .kpi:nth-child(2n) { border-right: 0; }
  .dash-kpi-grid .kpi:nth-last-child(-n + 3) { border-bottom: 1px solid var(--line); }
  .dash-kpi-grid .kpi:nth-last-child(-n + 2) { border-bottom: 0; }

  .dash-plot,
  .dash-chart-empty {
    height: 148px;
    flex-basis: 148px;
  }

  .dash-chart-empty { flex-basis: 158px; height: 158px; }
  .dash-bar-tick { font-size: 0.62rem; }
  .dash-rank { padding: 4px 14px 14px; }
  .dash-rank-row {
    grid-template-columns: 1.5rem minmax(0, 1fr) auto;
    grid-template-areas:
      "pos name name"
      "pos value share"
      "bar bar bar";
    gap: 6px 10px;
    padding: 12px 0;
  }
  .dash-rank-pos { grid-area: pos; align-self: start; padding-top: 2px; }
  .dash-rank-name { grid-area: name; white-space: normal; }
  .dash-rank-bar { grid-area: bar; margin-top: 2px; }
  .dash-rank-value { grid-area: value; }
  .dash-rank-share { grid-area: share; min-width: 0; }
}

@media (max-width: 720px) {
  .ipr-meta { padding: 0 8px 12px; }
  .ipr-notes,
  .ipr-attachments { padding: 0 8px 12px; }
  .ipr-report-source { margin: 0 8px 10px; }
  .ipr-table .ipr-hint { max-width: none; }
}

/* Filter / IPR load overlay */
body.is-loading {
  overflow: hidden;
}

.app-load-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--ink, #1a1f1c) 45%, transparent);
  backdrop-filter: blur(2px);
}

.app-load-overlay[hidden] {
  display: none !important;
}

.app-load-card {
  width: min(100%, 420px);
  padding: 22px 22px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface, #fff);
  box-shadow: var(--shadow);
  text-align: center;
}

.app-load-title {
  margin: 0 0 6px;
  font-family: var(--font-brand);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.app-load-text {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.app-load-progress {
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: color-mix(in srgb, var(--line) 80%, transparent);
  accent-color: var(--hop, #c9852a);
}

.app-load-progress::-webkit-progress-bar {
  background: color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: var(--radius-sm);
}

.app-load-progress::-webkit-progress-value {
  background: var(--hop, #c9852a);
  border-radius: var(--radius-sm);
}

.app-load-progress::-moz-progress-bar {
  background: var(--hop, #c9852a);
  border-radius: var(--radius-sm);
}

.app-load-pct {
  margin: 10px 0 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* =============================================================================
   Changelog / updates
   ============================================================================= */

.changelog {
  display: grid;
  gap: 16px;
  max-width: 720px;
}

.changelog-release {
  padding: 18px 20px 8px;
}

.changelog-release-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 16px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
}

.changelog-date {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--hop-dark);
  background: var(--hop-wash);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.changelog-release-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.changelog-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.changelog-item {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 10px 14px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 6%, transparent);
}

.changelog-item:last-child {
  border-bottom: 0;
}

.changelog-kind {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 3px;
}

.changelog-item.kind-new .changelog-kind { color: var(--hop-dark); }
.changelog-item.kind-fix .changelog-kind { color: #8a3b2a; }
.changelog-item.kind-improve .changelog-kind { color: #2f5d4a; }

.changelog-text {
  color: var(--ink-soft);
  line-height: 1.45;
}

@media (max-width: 640px) {
  .changelog-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
