@font-face {
  font-family: "Inter";
  src: url("./assets/fonts/inter/InterVariable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Static Bold/Condensed-only face. Kept exactly as-is and reserved for the boot preloader
   (.boot-word) only — every other Martian Mono usage moved to the variable face below so
   font-weight keeps working per element instead of collapsing to a single static weight. */
@font-face {
  font-family: "Martian Mono";
  src: url("./assets/fonts/martian-mono/MartianMonoCondensed-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-stretch: condensed;
  font-display: swap;
}

/* Unadjusted variable face is retained only for the protected wordmark. */
@font-face {
  font-family: "Martian Mono Condensed";
  src: url("./assets/fonts/martian-mono/MartianMonoCondensedVF.woff2") format("woff2-variations");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-style: normal;
  font-display: swap;
}

/* Variable technical face. At the same 1000pt local render its x glyph is
   600px versus Inter's 547px, so the adjusted family uses the measured 91% ratio. */
@font-face {
  font-family: "Martian Mono Condensed Adjusted";
  src: url("./assets/fonts/martian-mono/MartianMonoCondensedVF.woff2") format("woff2-variations");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-style: normal;
  size-adjust: 91%;
  font-display: swap;
}

:root {
  
  --dh-black-lt: #2e2a38;
  --dh-black: #282430;
  --dh-black-dk: #24202b;
  --dh-black-dk-most: #1e1b24;
  --dh-red-lt: #d64353;
  --dh-red: #c23b4d;
  --dh-red-dk: #a83343;
  --dh-white-lt: #fefefe;
  --dh-white: #f0f0f0;
  --dh-white-dk: #e8e3e7;
  --dh-white-lt: #eeeeee;
  --dh-lt-grey: #dadada;

  --maestro-font-ui: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Martian Mono Condensed Adjusted", ui-monospace, monospace;
  --font-size-xs: 10px;
  --font-size-sm: 13px;
  --font-size-md: 16px;
  --table-font-size: var(--font-size-sm);
  --table-font-size-compact: 10px;
  --table-header-line-height: 1.18;
  --table-line-height: 1.35;
  --color-danger: #963440;
  --color-surface-light: #eeeeee;
  --color-bg: var(--dh-black-dk-most);
  --color-text: var(--dh-white);
  --color-muted: #1f1d1d;
  --color-surface-dark: #303030;
  --color-line-dark: #424242;
  --color-success: #25724f;
  --color-warning: #a56714;
  --color-status-success-bg: #dff0e6;
  --color-status-warning-bg: var(--color-surface-light);
  --color-status-danger-bg: #f1dada;
  --color-status-automatic-bg: #dceafb;
  --color-status-automatic-text: #245c91;
  --color-status-external-bg: #ece4f6;
  --color-status-external-text: #68448a;
  --color-notice-border: var(--color-warning);
  --color-notice-bg: var(--color-surface-light);
  --color-notice-text: var(--color-muted);
  --color-error-border: #e0a0a0;
  --color-error-bg: #fff0f0;
  --color-success-border: #9fd3b6;
  --color-success-bg: #effaf3;
  --color-shadow: rgba(0, 0, 0, 0.26);
  --color-accent-tint: rgba(194, 59, 77, 0.24);
  --color-focus-ring: rgba(194, 59, 77, 0.34);
  --color-on-dark-subtle: rgba(238, 238, 238, 0.08);
  --color-on-dark-line: rgba(238, 238, 238, 0.18);
  --color-on-dark-border: rgba(238, 238, 238, 0.24);
  --color-on-dark-dim: rgba(238, 238, 238, 0.62);
  --color-on-dark-muted: rgba(238, 238, 238, 0.68);
  --color-on-dark-strong: rgba(238, 238, 238, 0.78);
}

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--color-bg);
  --surface: var(--color-muted);
  --surface-2: var(--color-surface-dark);
  --ink: var(--color-text);
  --muted: var(--color-on-dark-muted);
  --line: var(--color-line-dark);
  --sidebar-bg: var(--color-muted);
  --sidebar-ink: var(--color-text);
  --sidebar-muted: var(--color-on-dark-dim);
  --sidebar-line: var(--color-on-dark-line);
  --sidebar-control-bg: var(--color-on-dark-subtle);
  --sidebar-control-line: var(--color-on-dark-border);
  --nav-ink: var(--color-on-dark-strong);
  --nav-active-ink: var(--color-text);
  --accent: var(--dh-red);
  --accent-strong: var(--dh-red);
  --accent-soft: var(--dh-red);
  --action-contrast: var(--color-text);
  --ok: var(--color-success);
  --warn: var(--color-warning);
  --bad: var(--color-danger);
  --focus: var(--dh-red);
  --shadow: 0 10px 12px var(--color-shadow);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: var(--color-surface-light);
  --surface: #ffffff;
  --surface-2: var(--color-surface-light);
  --ink: var(--color-muted);
  --muted: var(--color-line-dark);
  --line: rgba(31, 29, 29, 0.24);
  --sidebar-bg: var(--color-muted);
  --sidebar-ink: var(--color-text);
  --sidebar-muted: var(--color-on-dark-dim);
  --sidebar-line: var(--color-on-dark-line);
  --sidebar-control-bg: var(--color-on-dark-subtle);
  --sidebar-control-line: var(--color-on-dark-border);
  --nav-ink: var(--color-on-dark-strong);
  --nav-active-ink: var(--color-text);
  --accent: var(--dh-red);
  --accent-strong: var(--dh-red);
  --accent-soft: var(--dh-red);
  --action-contrast: var(--color-text);
  --ok: var(--color-success);
  --warn: var(--color-warning);
  --bad: var(--color-danger);
  --focus: var(--dh-red);
  --shadow: 0 10px 12px var(--color-shadow);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body,
button,
input,
select,
textarea {
  font-family: var(--maestro-font-ui);
  font-weight: 300;
  font-stretch: 75%;
  font-optical-sizing: auto;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

h1,
h2,
h3,
h4,
h5,
h6,
strong,
b {
  font-weight: 400;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
}


h2 {
  font-size: 22px;
  line-height: 1.15;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip: rect(0 0 0 0);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 36px;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.technical-code {
  font-family: var(--mono);
  font-size: var(--font-size-md);
  font-weight: 500;
  font-stretch: 75%;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1.25;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.technical-code--small {
  font-size: var(--font-size-sm);
}

.technical-code--large {
  font-size: 16px;
}

.technical-code--uppercase {
  text-transform: uppercase;
}

.technical-code--muted {
  opacity: 0.5;
}

.sr-only {
  position: fixed !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--action-contrast);
}

.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.danger {
  border-color: var(--color-danger);
  color: var(--bad);
}

.boot,
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--dh-black-lt);
  padding: 36px;
}

.login-shell {
  color-scheme: dark;
  --surface: var(--color-muted);
  --surface-2: var(--color-surface-dark);
  --ink: var(--color-text);
  --muted: var(--color-on-dark-muted);
  --accent: var(--dh-red);
  --accent-strong: var(--dh-red-lt);
  --action-contrast: var(--color-text);
  background: var(--dh-black-dk);
  color: var(--dh-white);
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--dh-black-dk);
  transition: visibility 200ms ease;
}

.boot.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-word {
  display: inline-grid;
  grid-template-columns: repeat(7, 1ch);
  color: var(--dh-white);
  font-family: "Martian Mono", ui-monospace, monospace;
  font-size: clamp(26px, 7vw, 42px);
  font-weight: 500;
  font-stretch: condensed;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.boot-char {
  display: inline-grid;
  width: 1ch;
  place-items: center;
  animation: boot-slot-reel 80ms linear infinite alternate;
}

.boot-char.is-locked {
  animation: none;
  transform: translateY(0);
}

.app,
.login-shell,
.public-shell {
  animation: app-enter 260ms ease both;
}

@keyframes boot-slot-reel {
  from { transform: translateY(-0.08em); }
  to { transform: translateY(0.08em); }
}

@keyframes app-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.login-panel {
  --login-logo-height: 38px;
  position: relative;
}

.login-panel-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 64px;
  transform: translateY(-38px);
}

.maestro-login-mark {
  display: grid;
  width: 100%;
  place-items: center;
}

.maestro-login-word {
  display: inline-grid;
  grid-template-columns: repeat(7, 1ch);
  justify-content: center;
  width: min(280px, 80vw);
  color: var(--dh-white);
  font-family: var(--mono);
  font-size: 42px;
  font-weight: 600;
  font-stretch: 75%;
  letter-spacing: 0;
  line-height: 1;
  padding: 32px;
}

.maestro-char {
  display: inline-grid;
  width: 1ch;
  place-items: center;
  color: var(--dh-white);
  transition: transform 360ms ease, opacity 360ms ease;
}

.maestro-char.is-changing-out {
  opacity: 0;
  transform: translateY(-0.45em);
}

.maestro-char.is-digit {
  animation: maestro-digit-in 360ms ease both;
  color: var(--dh-red-lt);
}

@keyframes maestro-digit-in {
  from {
    opacity: 0;
    transform: translateY(0.45em);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-panel p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 180ms ease;
}

.app.sidebar-collapsed {
  grid-template-columns: 76px 1fr;
}

.sidebar {
  background: var(--dh-black);
  color: var(--sidebar-ink);
  padding: 64px 36px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
  transition: padding 180ms ease;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-head {
  display: block;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 32px;
}

.brand {
  border-bottom: 2px solid var(--dh-red);
}

.brand-logo {
  display: block;
  width: fit-content;
  max-width: 100%;
}

.brand-logo img {
  display: block;
  width: auto;
  max-width: 100%;
  height: 24px;
  max-height: 24px;
}

.brand-logo-sidebar {
  width: fit-content;
  margin-left: 0;
}

.brand-wordmark {
  display: inline-block;
  color: var(--sidebar-ink);
  font-family: "Martian Mono Condensed", ui-monospace, monospace;
  font-size: 18 px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 2;
}

.brand-logo-login {
  --login-logo-height: 20px;
  width: fit-content;
  padding: var(--login-logo-height);
  margin: calc(-1 * var(--login-logo-height)) 0 0 calc(-1 * var(--login-logo-height));
}

.brand-logo-login img {
  height: var(--login-logo-height);
  max-height: var(--login-logo-height);
}

.login-panel .field input {
  border-radius: 30px;
}

.login-panel .field + .field {
  margin-top: 8px;
  border-radius: 30px;
}

.login-submit {
  display: block;
  min-width: 150px;
  min-height: 46px;
  margin: 52px auto 0;
  font-size: 16px;
}

.menu-toggle {
  display: none;
  width: 56px;
  height: 32px;
  padding: 0;
  border-color: var(--sidebar-control-line);
  background: var(--sidebar-control-bg);
  border-radius: 36px;
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 36px;
  background: var(--sidebar-ink);
}

.sidebar-collapse-toggle {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-color: var(--sidebar-control-line);
  background: var(--sidebar-control-bg);
  color: var(--sidebar-ink);
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.theme-toggle {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 18px;
  border-color: var(--accent);
  background: var(--color-line-dark);
  color: var(--action-contrast);
  font-weight: 300;
  display: inline-grid;
  place-items: center;
}

.theme-toggle:hover {
  border-color: var(--accent-strong);
  background: var(--color-line-dark);
}

.theme-toggle-icon {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  position: relative;
  line-height: 1;
}

.theme-toggle-icon svg {
  position: absolute;
  width: 22px;
  height: 22px;
  opacity: 0;
  transform: rotate(90deg) scale(0.2);
  transition: transform 280ms ease, opacity 280ms ease;
}

[data-theme="dark"] .theme-toggle .theme-icon-sun,
[data-theme="light"] .theme-toggle .theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-toggle .theme-icon-sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.2);
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle-icon svg { transition: none; }
}

.menu-panel {
  box-sizing: border-box;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 42px;
  padding-top: 20px;
}

.sidebar-search-trigger {
  font-size: 16px;
  width: fit-content;
  min-height: 36px;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 16px;
  border-color: var(--dh-red);
  background: var(--dh-black-lt);
  color: var(--sidebar-ink);
  text-align: left;
}

.sidebar-search-trigger:hover,
.sidebar-search-trigger:focus-visible {
  border-color: var(--dh-red-lt);
  background: var(--color-on-dark-line);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  text-align: left;
  justify-content: flex-start;
  gap: 12px;
  padding-left: 6px;
  border-color: transparent;
  background: transparent;
  color: var(--nav-ink);
}

.nav-icon {
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  line-height: 1;
}

.nav-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.icon-action {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  flex: 0 0 32px;
  padding: 0;
  vertical-align: middle;
}

.action-icon {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  line-height: 1;
}

.action-icon svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 16px;
}

.sidebar-collapsed .sidebar {
  padding-inline: 14px;
}

.sidebar-collapsed .brand-logo-sidebar,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .sidebar-search-label,
.sidebar-collapsed .sidebar-search-trigger kbd,
.sidebar-collapsed .session small,
.sidebar-collapsed .session .nav-label {
  display: none;
}

.sidebar-collapsed .brand {
  min-height: 27px;
}

.sidebar-collapsed .nav button,
.sidebar-collapsed .sidebar-search-trigger,
.sidebar-collapsed .session button {
  justify-content: center;
}

/* свернутое меню */
.sidebar-collapsed .sidebar-search-trigger {
  padding-inline: 10px;
}

.sidebar-collapsed .nav button {
  padding-left: 6px;
}

.nav button.active,
.nav button:hover {
  background: var(--color-accent-tint);
  color: var(--nav-active-ink);
}

@media (min-width: 921px) {
  
  .sidebar-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .sidebar-actions {
    padding-top: 0px;
  }

  .brand-logo img {
    height: 32px;
    max-height: 32px;
  }

  .sidebar-collapsed .sidebar {
    padding-top: 18px;
  }

  .nav button {
    transition: transform 150ms ease, color 150ms ease, background-color 150ms ease;
    transform-origin: left center;
  }

  .nav button:hover {
    color: rgb(255, 255, 255);
    transform: scale(1.05);
  }
}

.session {
  margin-top: auto;
  display: grid;
  justify-items: start;
  gap: 12px;
  width: 100%;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-line);
}

/* Роль пользователя */
.session-role {
  color: var(--sidebar-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* Кнопки выхода и переключения темы */
.session-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/* Выход из системы */
.session-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Переключение темы */
.session .theme-toggle {
  justify-self: auto;
}

.menu-backdrop {
  display: none;
}

.nav-lock {
  overflow: hidden;
}

.context-lock {
  overflow: hidden;
}

.main {
  min-width: 0;
  padding: 64px 42px;
}

[data-theme="light"] .main {--dh-color-white-dk: #e8e3e7;}

.maestro-toast-container {
  position: fixed;
  top: 24px;
  bottom: auto;
  left: auto;
  z-index: 90;
  width: min(360px, calc(100vw - 48px));
  max-height: calc(100dvh - 48px);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
  pointer-events: none;
}

.maestro-toast-slot {
  overflow: hidden;
  transition: height 220ms cubic-bezier(.22, 1, .36, 1);
}

.maestro-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 12px var(--color-shadow);
  font-family: var(--maestro-font-ui);
  font-size: var(--font-size-sm);
  line-height: 1.4;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-12px) scale(.96);
  transition: opacity 220ms cubic-bezier(.22, 1, .36, 1), transform 220ms cubic-bezier(.22, 1, .36, 1);
}

.maestro-toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.maestro-toast[data-type="success"] { border-left-color: var(--ok); }
.maestro-toast[data-type="error"] { border-left-color: var(--bad); }
.maestro-toast[data-type="warning"] { border-left-color: var(--warn); }
.maestro-toast[data-type="info"] { border-left-color: var(--color-status-automatic-text); }
.maestro-toast[data-type="loading"] { border-left-color: var(--muted); }

.maestro-toast__icon {
  flex: none;
  width: 14px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}
.maestro-toast[data-type="success"] .maestro-toast__icon { color: var(--ok); }
.maestro-toast[data-type="error"] .maestro-toast__icon { color: var(--bad); }
.maestro-toast[data-type="warning"] .maestro-toast__icon { color: var(--warn); }
.maestro-toast[data-type="info"] .maestro-toast__icon { color: var(--color-status-automatic-text); }

.maestro-toast__message {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.maestro-toast__close {
  flex: none;
  width: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.maestro-toast__close:hover,
.maestro-toast__close:focus-visible { color: var(--ink); }

@media (max-width: 920px) {
  .maestro-toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100dvh - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .maestro-toast-slot,
  .maestro-toast {
    transition-duration: 1ms;
  }
}

.context-overlay {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: block;
  width: auto;
  min-height: 0;
  padding: 0;
  pointer-events: none;
  opacity: 0;
  background: rgba(0, 0, 0, 0.25);
  border: 0;
  border-radius: 0;
  backdrop-filter: blur(4px);
  transition: opacity 180ms ease, backdrop-filter 180ms ease;
}

.context-overlay.is-open {
  pointer-events: auto;
  opacity: 1;
}

.context-panel {
  position: fixed;
  top: 82px;
  right: 42px;
  z-index: 8;
  display: none;
  width: min(360px, calc(100vw - 44px));
  max-height: calc(100vh - 104px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 32px;
  box-shadow: var(--shadow);
}

.context-panel.is-open {
  display: block;
}

.context-panel-inner {
  display: grid;
  gap: 12px;
  padding: 24px;
}

.context-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.context-panel-head h2 {
  margin: 3px 0 0;
  font-size: 18px;
}

.context-panel-head button {
  width: 36px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.context-trigger {
  height: 30px;
  min-height: 30px;
  padding: 0;
}

.context-trigger {
  width: 32px;
  min-width: 32px;
  padding-inline: 0;
  border-radius: 999px;
  font-family: var(--maestro-font-ui);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  touch-action: manipulation;
}

.context-trigger > span {
  display: block;
  transform: translateY(-2px);
}

.context-trigger[aria-expanded="true"] {
  color: var(--action-contrast);
  background: var(--accent);
  border-color: var(--accent);
}

.context-trigger:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.action-menu {
  position: fixed;
  z-index: 1000;
  display: grid;
  width: max-content;
  min-width: 190px;
  max-width: min(280px, calc(100vw - 16px));
  max-height: min(420px, calc(100vh - 16px));
  padding: 6px;
  overflow: auto;
  color: var(--ink);
  font-size: var(--font-size-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.action-menu [role="menuitem"] {
  width: 100%;
  min-height: 32px;
  justify-content: flex-start;
  padding: 6px 10px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border-color: transparent;
  border-radius: 5px;
}

.action-menu [role="menuitem"]:hover,
.action-menu [role="menuitem"]:focus-visible {
  color: var(--ink);
  background: var(--color-accent-tint);
  border-color: transparent;
  outline: none;
}

.action-menu [role="menuitem"]:focus-visible {
  box-shadow: inset 0 0 0 1px var(--focus);
}

.action-menu [role="menuitem"]:disabled,
.action-menu [role="menuitem"][aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-menu .context-actions {
  display: contents;
}

.context-actions__separator {
  height: 1px;
  margin: 5px 4px;
  background: var(--line);
}

.action-menu__message {
  padding: 8px 10px;
  color: var(--muted);
  white-space: nowrap;
}

.action-menu__message--error {
  color: var(--bad);
}

.command-palette-lock {
  overflow: hidden;
}

.command-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: max(72px, 10vh) 18px 24px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(3px);
}

.command-palette {
  width: min(680px, 100%);
  max-height: min(680px, calc(100vh - max(96px, 14vh)));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.command-palette__search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.command-palette__search-icon {
  color: var(--muted);
  font: 500 24px/1 var(--mono);
}

.command-palette__search input {
  width: 100%;
  min-height: 42px;
  padding: 8px 2px;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.command-palette__search input:focus {
  box-shadow: none;
}

.command-palette__search kbd {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font: 500 10px/1.4 var(--mono);
}

.command-palette__results {
  max-height: min(548px, calc(100vh - max(180px, 24vh)));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

.command-palette__group + .command-palette__group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.command-palette__group h3 {
  margin: 0;
  padding: 7px 10px 5px;
  color: var(--muted);
  font: 600 10px/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.command-palette__item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  width: 100%;
  min-height: 56px;
  padding: 8px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.command-palette__item:hover,
.command-palette__item[aria-selected="true"] {
  border-color: transparent;
  background: var(--color-accent-tint);
  color: var(--ink);
}

.command-palette__type {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  font: 650 12px/1 var(--mono);
}

.command-palette__copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.command-palette__copy strong,
.command-palette__copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-palette__copy strong {
  font-size: var(--font-size-sm);
}

.command-palette__copy span {
  color: var(--muted);
  font-size: var(--font-size-xs);
}

.command-palette__empty {
  display: grid;
  min-height: 128px;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.command-palette__empty strong {
  color: var(--ink);
}

.command-palette__empty--quiet {
  min-height: 88px;
}

.command-palette__empty--error strong {
  color: var(--bad);
}

.command-palette__empty button {
  min-height: 36px;
}

.identifier-cell {
  vertical-align: middle;
  white-space: nowrap;
  line-height: 1.25;
}

.leg-sn-with-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.identifier-cell > .technical-code {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  vertical-align: middle;
  line-height: 1.25;
}

.context-actions,
.context-form {
  display: grid;
  gap: 8px;
}

.context-actions button,
.context-form button {
  justify-content: flex-start;
}

.context-row {
  cursor: default;
}

.context-row:hover {
  background: var(--color-accent-tint);
}

.card-actions {
  margin-top: 8px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 64px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  font-stretch: 112.5%;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.section {
  margin-bottom: 18px;
}

.leg-history-section {
  margin-top: 4px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.leg-history-section summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 600;
  line-height: 1.4;
  color: var(--muted);
}

.leg-history-section summary:hover,
.leg-history-section summary:focus-visible {
  color: var(--ink);
}

.leg-history-section [data-leg-history-body] {
  padding-top: 8px;
}

.leg-history-filters {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
}

.leg-history-filters button,
.leg-history-more,
.leg-history-load-error button {
  width: auto;
  min-height: 0;
  padding: 3px 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  line-height: 1.25;
  cursor: pointer;
}

.leg-history-filters button[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
}

.leg-history-filters button:hover,
.leg-history-more:hover,
.leg-history-load-error button:hover {
  color: var(--ink);
  text-decoration: underline;
}

.leg-history-table-wrap { overflow-x: auto; }

.leg-history-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.35;
}

.leg-history-table th,
.leg-history-table td {
  padding: 4px 7px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.leg-history-table th {
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.leg-history-time,
.leg-history-actor { white-space: nowrap; }
.leg-history-time { width: 155px; font-variant-numeric: tabular-nums; }
.leg-history-actor { width: 130px; }
.leg-history-description { width: 100%; }
.leg-history-change-line { display: block; }
.leg-history-error-dot { color: var(--bad); font-size: 8px; margin-right: 5px; }
.leg-history-error-text { color: var(--bad); }
.leg-history-status { padding: 6px 7px; color: var(--muted); }
.leg-history-load-error button,
.leg-history-more { color: var(--ink); text-decoration: underline; }
.leg-history-more { margin-top: 5px; }

.panel {
  background: var(--dh-black);
  border: 1px solid var(--dh-black-lt);
  border-radius: 30px;
  padding: 18px;
  gap: 12px;
}

[data-theme="light"]
  .panel {
    background: var(--dh-white-lt);
    border: 1px solid var(--dh-lt-grey);    
  }

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid > button {
  justify-self: start;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric > span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 28px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.dashboard-counter,
.metric-hidden,
.metric-divider {
  display: inline-block;
  color: var(--accent);
}

.metric-divider {
  margin-inline: 3px;
  color: var(--muted);
}

.topbar > .icon-action {
  align-self: center;
}

.maturity-countdown-urgent {
  color: var(--bad);
  animation: maturity-countdown-pulse 1.35s ease-in-out infinite;
}

@keyframes maturity-countdown-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.38;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-shell {
    animation: none;
    background: var(--dh-red);
  }

  .context-overlay {
    transition: none;
    backdrop-filter: none;
  }

  .maestro-char {
    transition: none;
    animation: none;
  }

  .maturity-countdown-urgent {
    animation: none;
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--surface-2);
  color: var(--ink);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted);
}

.field input:read-only,
.field textarea:read-only,
.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: var(--bg);
  color: var(--muted);
}

.field input[type="checkbox"],
.field input[type="radio"] {
  accent-color: var(--accent);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.panel-heading p {
  margin-top: 4px;
}
.maestro-technical-data {
  min-width: 0;
  max-width: 100%;
}

.maestro-technical-data > summary {
  list-style: none;
  cursor: pointer;
}

.maestro-technical-data > summary::-webkit-details-marker {
  display: none;
}

.maestro-technical-data > summary::after {
  margin-left: 6px;
  color: var(--muted);
  content: "▾";
  transition: transform 120ms ease;
}

.maestro-technical-data[open] > summary::after {
  transform: rotate(180deg);
}

.maestro-technical-data__body {
  min-width: 0;
  max-width: 100%;
}

.raw-product-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.raw-product-field legend {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.raw-product-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.raw-product-option {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}

.raw-product-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.raw-product-option input[type="radio"] {
  flex: 0 0 auto;
  width: 20px;
  min-height: 20px;
  height: 20px;
  margin: 0;
}

/* MAESTRO ORDER PAGE: independent columns */

#view:has(> .order-page-grid) > .order-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 35fr) minmax(0, 65fr);
  gap: 24px;
  align-items: start;
  width: 100%;
  min-width: 0;
  margin-bottom: 24px;
}

#view:has(> .order-page-grid) .order-page-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

#view:has(> .order-page-grid) .order-page-column > .panel,
#view:has(> .order-page-grid) .order-page-column > .section {
  float: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  box-sizing: border-box;
}

#view:has(> .order-page-grid) #maestro-order-items-grid {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* MAESTRO: collapsible refund section */

#view:has(> .order-page-grid) .order-refund-details {
  width: 100%;
  min-width: 0;
}

#view:has(> .order-page-grid) .order-refund-details > summary {
  display: list-item;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  box-sizing: border-box;
}

#view:has(> .order-page-grid) .order-refund-details__body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-top: 12px;
  min-width: 0;
}

#view:has(> .order-page-grid) .order-refund-details__body > button {
  align-self: flex-end;
}

#view:has(> .order-page-grid) .order-refund-details__body > .panel {
  width: 100%;
  max-width: 100%;
  margin: 0;
  box-sizing: border-box;
}


@media (min-width: 921px) {
  #view:has(> .order-page-grid) {
    display: flow-root;
  }
}

@media (max-width: 920px) {
  #view:has(> .order-page-grid) > .order-page-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  #view:has(> .order-page-grid) .order-page-column {
    gap: 14px;
  }
}

option {
  background: var(--surface);
  color: var(--ink);
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
button:focus {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 1px;
}

button:focus-visible,
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: var(--table-font-size);
  background: var(--surface-2);
  font-weight: 300;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sort-header:hover,
.sort-header.is-active {
  color: var(--ink);
}

.sort-indicator {
  font-size: 11px;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--surface-2);
}

.linkish {
  border: 0;
  padding: 0;
  min-height: 0;
  width: auto;
  color: var(--accent);
  background: transparent;
  text-align: left;
  border-radius: 0;
}

.status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--table-font-size);
  white-space: nowrap;
}

.status.ok {
  background: var(--color-status-success-bg);
  color: var(--ok);
}

.status.warn {
  background: var(--color-status-warning-bg);
  color: var(--warn);
}

.status.bad {
  background: var(--color-status-danger-bg);
  color: var(--bad);
}

.status.operational.automatic {
  background: var(--color-status-automatic-bg);
  color: var(--color-status-automatic-text);
}

.status.operational.action {
  background: var(--color-status-warning-bg);
  color: var(--warn);
}

.status.operational.external {
  background: var(--color-status-external-bg);
  color: var(--color-status-external-text);
}

.status.operational.error {
  background: var(--color-status-danger-bg);
  color: var(--bad);
}

.status.operational.success {
  background: var(--color-status-success-bg);
  color: var(--ok);
}

.operational-status-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  width: fit-content;
  height: auto;
}

.operational-status-cell > .status {
  display: inline-flex;
  flex: 0 0 auto;
  align-self: flex-start;
  width: fit-content;
  height: 24px;
  min-height: 24px;
  padding: 3px 9px;
  line-height: 18px;
  white-space: nowrap;
  border-radius: 999px;
}

.operational-status-cell small {
  color: var(--muted);
  max-width: 240px;
}

.tracking-review-alert {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--color-error-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--color-error-bg);
  color: var(--bad);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.card h3 {
  margin: 0;
  font-size: 18px;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 16px;
}

.reference-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.reference-tabs button {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.reference-tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

.reference-tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.reference-content {
  display: grid;
  gap: 18px;
  max-width: 1100px;
  min-width: 0;
}

.reference-section { min-width: 0; }
.reference-section h2 { margin: 0 0 12px; font-size: 20px; }
.reference-section h3 { margin: 20px 0 8px; font-size: 16px; }
.reference-section p { max-width: 75ch; line-height: 1.55; }
.reference-section p:last-child { margin-bottom: 0; }
.reference-section li { margin: 7px 0; line-height: 1.5; }
.reference-note { border-left: 3px solid var(--accent); padding-left: 12px; }
.reference-version { font-family: var(--mono); }

.reference-formula {
  max-width: 100%;
  overflow-x: auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: clamp(16px, 2vw, 22px);
  white-space: nowrap;
}

.reference-formula sup,
.reference-formula sub { font-size: 0.65em; }
.reference-axis-label { margin-bottom: 0; font-size: 12px; color: var(--muted); }
.reference-chart { max-width: 100%; }
.reference-chart svg { display: block; width: 100%; height: auto; color: var(--muted); }
.reference-chart-grid { stroke: var(--line); stroke-width: 1; }
.reference-chart-axis { stroke: var(--muted); stroke-width: 1; }
.reference-chart-label { fill: currentColor; font-family: var(--maestro-font-ui); font-size: 12px; }
.reference-chart-curve { fill: none; stroke: var(--accent); stroke-width: 3; vector-effect: non-scaling-stroke; }
.reference-chart-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.reference-chart-focus { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.reference-chart-readout { color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.reference-chart--compact { display: none; }
.reference-calculator { display: grid; gap: 16px; margin: 20px 0; }
.reference-calculator-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.reference-calculator .field { min-width: 0; align-content: start; }
.reference-calculator .field input { min-width: 0; }
.reference-calculator .field input[aria-invalid="true"] { border-color: var(--bad); }
.reference-field-error { color: var(--bad); font-size: 12px; line-height: 1.4; }
.reference-field-error:empty { display: none; }
.reference-calculator > button { justify-self: start; min-height: 44px; padding-inline: 20px; }
.reference-calculator-result { display: grid; gap: 14px; min-width: 0; margin: 20px 0; }
.reference-calculator-result[hidden] { display: none; }
.reference-calculator-result h3 { margin: 6px 0 0; }
.reference-result-main { display: grid; gap: 4px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.reference-result-main > span { color: var(--muted); font-size: 13px; }
.reference-result-main > strong { color: var(--accent); font-family: var(--mono); font-size: clamp(30px, 5vw, 42px); font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.reference-result-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.reference-result-metrics .metric { min-width: 0; }
.reference-result-metrics .metric strong { font-size: clamp(17px, 2vw, 23px); overflow-wrap: anywhere; }
.reference-mass-chart { width: 100%; min-width: 0; }
.reference-mass-chart svg { display: block; width: 100%; height: auto; color: var(--muted); touch-action: none; }
.reference-mass-chart .reference-mass-svg--compact { display: none; }
.reference-mass-chart .reference-chart-readout { margin-top: 4px; }
.reference-documents { min-height: 280px; }
.reference-accuracy { min-width: 0; max-width: 1100px; }
.reference-accuracy h2 { margin-top: 0; }
.reference-accuracy-wrap { max-width: 100%; }
.reference-accuracy-table { font-variant-numeric: tabular-nums; }
.reference-accuracy-table :is(th, td) { white-space: nowrap; }
.reference-accuracy-table :is(th, td):first-child { width: 55px; }
.reference-accuracy-table :is(th, td):last-child { width: 35%; }
.reference-accuracy-table .reference-accuracy-detail td { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.reference-accuracy-number { font-variant-numeric: tabular-nums; text-decoration: underline; }
.reference-accuracy-pages { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.reference-accuracy-pages button { min-width: 76px; }

@media (max-width: 720px) {
  .reference-calculator-fields, .reference-result-metrics { grid-template-columns: minmax(0, 1fr); }
  .reference-calculator > button { width: 100%; }
  .reference-content { gap: 14px; }
  .reference-formula { padding: 12px; }
  .reference-chart--wide { display: none; }
  .reference-chart--compact { display: block; }
  .reference-mass-chart .reference-mass-svg--wide { display: none; }
  .reference-mass-chart .reference-mass-svg--compact { display: block; }
  .reference-accuracy-table { min-width: 0; table-layout: fixed; font-size: 11px; }
  .reference-accuracy-table :is(th, td) { padding: 9px 4px; white-space: normal; overflow-wrap: anywhere; }
  .reference-accuracy-table :is(th, td):first-child { width: 30px; }
  .reference-accuracy-table :is(th, td):nth-child(2),
  .reference-accuracy-table :is(th, td):nth-child(3) { width: 24%; }
  .reference-accuracy-table :is(th, td):last-child { width: auto; }
  .reference-accuracy-pages { justify-content: center; }
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

/* MAESTRO — карточка окорока: 50% / 50% */
.split:has(.leg-detail-actions) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Отступ перед историей взвешиваний */
.split.leg-detail-layout
  > .leg-detail-column:first-child
  > section.section.panel {
  margin-top: 24px;
}

/* Отступ перед историей окорока */
.split.leg-detail-layout
  > .leg-detail-column:last-child
  > section.leg-history-section {
  margin-top: 24px;
}

/* MAESTRO — действия окорока в две колонки */
.split:has(.leg-detail-actions) .leg-detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  align-content: start;
  align-items: start;
}

/* Компактная плашка статуса */
.leg-detail-actions > .status {
  justify-self: start;
  width: fit-content;
  max-width: 100%;
}

/* Кнопки сохраняют естественную ширину */
.leg-detail-actions > button {
  justify-self: start;
}

/* Поля ввода не выходят за пределы колонки */
.leg-detail-actions > .field {
  min-width: 0;
}

@media (max-width: 920px) {
  .split:has(.leg-detail-actions) {
    grid-template-columns: minmax(0, 1fr);
  }
  .split:has(.leg-detail-actions) .leg-detail-actions {
    grid-template-columns: minmax(0, 1fr);
  }


}

.leg-detail-actions > #leg-racks,
.leg-detail-actions > #print-leg-barcode {
  background: #fff;
  color: var(--color-muted);
  border-color: var(--line);
}

.leg-detail-actions > #leg-racks:hover,
.leg-detail-actions > #print-leg-barcode:hover {
  border-color: var(--accent);
}

.details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail {
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.detail > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.detail > strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.notice {
  border: 2px solid var(--dh-red-lt);
  background: transparent 100%;
  color: var(--dh-white);
  font-size: 14px;
  border-radius: 24px;
  padding: 12px;
}

[data-theme="light"]
  .notice {
    border: 2px solid var(--dh-red);
    background: var(--dh-white-lt);
    color: var(--dh-black);
  }

.error {
  border: 1px solid var(--color-error-border);
  background: var(--color-error-bg);
  color: var(--bad);
  font-size: 12px;
  border-radius: 36px;
  padding: 12px;
  position: relative;
  top: -24px;
}

.success {
  border: 1px solid var(--color-success-border);
  background: var(--color-success-bg);
  color: var(--ok);
  border-radius: 8px;
  padding: 12px;
}

.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
}

.scan-box {
  max-width: 620px;
}

.scan-input {
  font-size: 28px;
  min-height: 64px !important;
  font-weight: 300;
}

.dm-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 14px;
  align-items: start;
}

.dm-queue {
  display: grid;
  gap: 6px;
}

.dm-queue__row {
  display: grid;
  grid-template-columns: 28px minmax(110px, 1fr) minmax(100px, 1fr) auto 112px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.dm-queue__row.is-current {
  border-color: var(--accent);
}

.dm-capture-zone {
  display: grid;
  gap: 6px;
  min-height: 112px;
  align-content: center;
  padding: 16px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  outline: none;
}

.dm-capture-zone span {
  color: var(--muted);
}

.dm-capture-zone.is-armed {
  border-color: var(--ok);
  box-shadow: 0 0 0 3px var(--color-success-bg);
}

.dm-diagnostics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.technical-code-input::placeholder {
  font-family: var(--maestro-font-ui);
  font-weight: 300;
  font-stretch: 75%;
  letter-spacing: 0;
  text-transform: none;
}

.quick-layout {
  grid-template-columns: minmax(0, 1fr) 420px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-actions button {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  justify-content: center;
  text-align: center;
}

.quick-form {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.matrix-table table {
  min-width: 1120px;
}

.storefront-table th,
.storefront-table td {
  padding: 8px 9px;
  white-space: nowrap;
}

.storefront-item-title {
  display: none;
}

.storefront-quantity-edit { margin-left: 7px; vertical-align: middle; }

.storefront-switch {
  position: relative;
  display: inline-flex;
  width: 34px;
  height: 20px;
  min-height: 20px;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  transition: background 140ms ease, border-color 140ms ease;
}

.storefront-switch > span {
  position: absolute;
  left: 3px;
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: none;
  transition: transform 140ms ease, background 140ms ease;
}

.storefront-switch.is-on {
  border-color: var(--accent);
  background: var(--accent);
}

.storefront-switch.is-on > span {
  transform: translateX(14px);
  background: var(--accent-contrast, #fff);
}

.code-cell {
  max-width: 280px;
  min-width: 150px;
}

.code-cell .technical-code {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  vertical-align: middle;
}

.batch-legs-toggle {
  width: 26px;
  height: 26px;
  min-height: 26px;
  flex: 0 0 26px;
  padding: 0;
  border-color: transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.batch-legs-toggle:hover {
  border-color: var(--line);
  background: var(--color-accent-tint);
  color: var(--ink);
}

.batch-legs-toggle span {
  display: block;
  font-size: 13px;
  line-height: 1;
}

.batch-legs-row > td {
  padding: 0 12px 14px;
  background: var(--surface-2);
}

.batch-expanded-table {
  margin: 0;
}

.batch-leg-table {
  font-size: 12px;
}

.batch-leg-table > table,
.batch-expanded-table > table {
  width: max-content;
  min-width: max-content;
  table-layout: auto;
}

.batch-leg-table > table > thead > tr > th,
.batch-leg-table > table > tbody > tr > td,
.batch-expanded-table > table > thead > tr > th,
.batch-expanded-table > table > tbody > tr > td {
  white-space: nowrap;
}

.batch-leg-table th,
.batch-leg-table td {
  padding-top: 8px;
  padding-bottom: 8px;
  vertical-align: middle;
}

.compact-action-heading,
.compact-action-cell {
  width: 1%;
  min-width: 0;
  padding-inline: 5px !important;
  text-align: center;
  vertical-align: middle;
}

.batch-expand-placeholder::after {
  display: block;
  width: 30px;
  content: "";
}

.compact-action-cell > button {
  margin-inline: auto;
}

.batch-expanded-table table {
  margin: 0;
  font-size: 12px;
}

.batch-expanded-table th,
.batch-expanded-table td {
  padding: 7px 9px;
}

.batch-leg-row {
  opacity: 1;
}

.batch-leg-row--inactive {
  opacity: 0.5;
}

.batch-leg-actions {
  width: 42px;
  text-align: center;
}

.batch-leg-settings-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.batch-leg-settings-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.batch-leg-settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.batch-leg-settings-dialog form {
  padding: 20px;
}

.batch-leg-settings-options {
  display: grid;
  gap: 10px;
}

.batch-leg-settings-options label {
  display: flex;
  gap: 9px;
  align-items: center;
}

.confirm-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.confirm-dialog__body {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.confirm-dialog__body h2,
.confirm-dialog__body p {
  margin: 0;
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.output-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 8px;
  align-items: end;
}

.public-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.public-panel {
  width: min(680px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.order-heading-actions,
.order-actions,
.order-blockers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.order-blockers {
  min-width: 0;
  max-width: 100%;
}

.order-blockers > .status.warn {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.order-heading-actions {
  justify-content: space-between;
  margin-bottom: 24px;
}

.candidate-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1200px) {
  .candidate-list {
    grid-template-columns: 1fr;
  }
}

.candidate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: left;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-2);
}

/* MAESTRO — selectable candidate cards */

.order-page-column--right .candidate-row {
  position: relative;
  grid-template-columns: minmax(0, 1fr);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

/* Кнопка выбора занимает всю карточку */
.order-page-column--right .candidate-row__select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  z-index: 1;
}

/* Ссылка на окорок находится поверх кнопки */
.order-page-column--right .candidate-row__content a {
  position: relative;
  z-index: 2;
}

/* Подсветка при наведении */
.order-page-column--right .candidate-row:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
}

/* Подсветка при выборе с клавиатуры */
.order-page-column--right .candidate-row:has(
  .candidate-row__select:focus-visible
) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Нажатие */
.order-page-column--right .candidate-row:has(
  .candidate-row__select:active
) {
  border-color: var(--accent);
  background-color: var(--dh-red);
}

.candidate-row > div {
  display: grid;
  grid-template-columns: max-content max-content;
  column-gap: 12px;
  row-gap: 4px;
  align-items: center;
  min-width: 0;
}

.candidate-row span {
  font-size:12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.order-scan-diagnostics {
  margin-top: 4px;
}

.cdek-dialog {
  width: min(920px, calc(100vw - 32px));
}

.cdek-check-button {
  width: fit-content;
  max-width: 100%;
  white-space: normal;
}

.cdek-fixed-field {
  display: none !important;
}

.cdek-package-dimensions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.cdek-package-dimensions .field {
  min-width: 0;
}

.orders-list-table table {
  min-width: 620px;
  border-collapse: separate;
  border-spacing: 0;
}

.orders-list-table th,
.orders-list-table td {
  border-bottom: 0;
}

.orders-list-table thead th {
  border-bottom: 1px solid var(--line);
}

.orders-list-table tbody tr + tr td {
  border-top: 1px solid var(--line);
}

.orders-show-more {
  display: flex;
  justify-content: center;
}

.sku-stock-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sku-stock-filter button {
  min-height: 32px;
  padding: 6px 10px;
}

.sku-stock-filter button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--action-contrast);
}

.batch-view-switch {
  display: inline-flex;
  width: fit-content;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.batch-view-switch button {
  min-height: 26px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
}

.batch-view-switch button.active {
  border: 0;
  background: var(--accent);
  color: var(--action-contrast);
}

.batch-view-switch button:not(.active):hover {
  background: var(--color-accent-tint);
  color: var(--ink);
}

.batch-type-filter {
  display: inline-flex;
  width: fit-content;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.batch-type-filter button {
  min-height: 26px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
}

.batch-type-filter button.active {
  border: 0;
  background: var(--accent);
  color: var(--action-contrast);
}

.batch-type-filter button:not(.active):hover {
  background: var(--color-accent-tint);
  color: var(--ink);
}

.sku-stock-table {
  width: 100%;
  min-width: 100%;
  table-layout: auto;
}

.sku-stock-table th,
.sku-stock-table td {
  width: auto;
  white-space: normal;
}

.sku-stock-name {
  overflow-wrap: anywhere;
}

.sku-stock-number,
.sku-stock-availability-cell {
  text-align: center;
  white-space: nowrap;
}

.sku-stock-availability-cell {
  vertical-align: middle;
}

.sku-stock-availability.status {
  display: inline-grid;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
}

.sku-stock-table tr[hidden] {
  display: none;
}

.order-items-table table {
  min-width: 0;
  table-layout: auto;
}

.order-item-name {
  overflow-wrap: anywhere;
}

.order-items-table .status {
  gap: 6px;
  white-space: normal;
}

.panel.stack > h3 {
  font-size: 16px;
  line-height: 1.3;
}

.panel.stack > p {
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 920px) {
  
  .main {
    padding: 24px;
  }
  
  
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-x: clip;
  }

  .topbar {
    display: grid;
    margin-bottom: 24px;
  }

  .order-heading-actions {
    justify-content: flex-start;
    gap: 10px;
    margin-bottom: 24px;
  }

  .order-heading-actions button {
    min-height: 36px;
  }

  .order-heading-actions button:first-child {
    width: 36px;
    min-width: 36px;
    padding: 0;
  }

  .order-page-grid {
    display: block;
  }

  .order-page-grid > .panel {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }

  .order-summary {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .order-summary .detail {
    min-width: 0;
  }

  .order-summary .detail > strong {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 64px 36px;
    gap: 0;
    overflow: visible;
    height: auto;
  }

  .sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .brand {
    margin-right: auto;
    padding-bottom: 0;
    border-bottom: 0;
  }

  .brand-logo-sidebar {
    margin-left: 0;
    margin-right: 0;
  }

  .brand-logo img {
    height: 12px;
    max-height: 12px;
  }

  .sidebar-collapse-toggle {
    display: none;
  }

  .sidebar-collapsed .brand-logo-sidebar,
  .sidebar-collapsed .nav-label,
  .sidebar-collapsed .sidebar-search-label,
  .sidebar-collapsed .session small,
  .sidebar-collapsed .session .nav-label {
    display: inline;
  }

  .menu-toggle {
    display: inline-flex;
    flex-direction: column;
    flex: 0 0 auto;
  }

  .menu-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 7;
    display: flex;
    width: min(255px, calc(75vw - 31.5px));
    height: 100vh;
    padding: 18px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--sidebar-line);
    box-shadow: var(--shadow);
    transform: translateX(100%);
    transition: transform 180ms ease;
  }

  .sidebar.open .menu-panel {
    transform: translateX(0);
  }

  .sidebar.open + .menu-backdrop {
    display: block;
  }

  .menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 4;
    background: rgba(0, 0, 0, 0.48);
    border: 0;
    border-radius: 0;
    padding: 0;
  }

  .sidebar.open .menu-panel {
    gap: 12px;
  }

  .sidebar-search-trigger {
    flex: 0 0 auto;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .nav button {
    width: 100%;
  }

  .session {
    margin-top: 0;
  }

  .context-panel {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: min(72vh, 520px);
    border-radius: 8px;
  }

  .split,
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .details {
    grid-template-columns: 1fr;
  }

  .output-row {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .dm-workspace,
  .dm-diagnostics,
  .dm-queue__row {
    grid-template-columns: 1fr;
  }

  .raw-product-options {
    grid-template-columns: 1fr;
  }

  .candidate-row {
    grid-template-columns: 1fr;
  }

  .candidate-row button {
    width: fit-content;
  }

  .cdek-package-dimensions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    min-width: 0 !important;
  }

  .cdek-package-dimensions > .field {
    min-width: 0;
    width: auto;
    max-width: none;
  }
}

@media (max-width: 560px) {
 
  .command-palette-overlay {
    padding: 10px;
  }

  .command-palette {
    max-height: calc(100vh - 20px);
    border-radius: 10px;
  }

  .command-palette__results {
    max-height: calc(100vh - 94px);
  }

  .command-palette__search kbd {
    display: none;
  }

  .main {
    padding: 28px 16px;
    min-width: 0;
  }

  .topbar {
    display: grid;
    margin-bottom: 14px;
  }

  .topbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
  }

  .login-panel-head {
    align-items: center;
    justify-content: center;
  }

  .confirm-dialog__actions {
    display: grid;
  }

  .confirm-dialog__actions button {
    width: 100%;
  }

  .order-page-grid {
    gap: 14px;
    min-width: 0;
    max-width: 100%;
  }

  .order-page-grid .panel {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .order-page-grid .panel-heading h2 {
    font-size: 22px;
  }

  .order-page-grid .details {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
  }

  .order-page-grid .detail {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
  }

  .order-page-grid .detail > span {
    font-size: 12px;
  }

  .order-page-grid .detail > strong {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .order-page-grid .notice {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: 12px;
    line-height: 1.35;
  }

  .order-page-grid button {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

}
/* Address storage and inventory */
.storage-toolbar { display: grid; grid-template-columns: minmax(260px, auto); gap: 16px; margin-bottom: 18px; }
.storage-toolbar .panel, .storage-scan-form { margin: 0; }
.storage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
html:has(.spot-room-map) { scrollbar-gutter: stable; }
.racks-page { container-type: inline-size; }
.racks-page-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.rack-room-panel { min-width: 0; }
.rack-room-panel > h2 { margin: 0 0 18px; }
.racks-page-layout .spot-map-racks { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 488px; }
/* 800px leaves about 70px per rack side after two panel paddings and gaps. */
@container (min-width: 800px) {
  .racks-page-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .racks-page-layout { grid-template-columns: minmax(0, 1fr); }
}
.spot-room-map { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: stretch; }
.spot-map-row { min-width: 0; }
.spot-map-racks { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); grid-template-rows: minmax(80px, 1fr); gap: 24px; }
.spot-rack { border: 1px solid var(--line); border-radius: 14px; width: min(100%, 104px); min-width: 0; min-height: calc(40px * var(--rack-sides, 2)); overflow: hidden; background: var(--surface-2); transition: opacity .18s ease, box-shadow .18s ease; }
.spot-rack--row-1 { grid-column: 1; justify-self: start; }
.spot-rack--row-2 { grid-column: 2; justify-self: center; }
.spot-rack--row-3 { grid-column: 3; justify-self: center; }
.spot-rack--row-4 { grid-column: 4; justify-self: end; }
.spot-rack-sides { display: grid; grid-template-rows: repeat(var(--rack-sides, 2), minmax(0, 1fr)); height: 100%; }
.spot-side { width: 100%; min-height: 0; padding: 2px 4px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; line-height: 1; text-align: center; border: 0; border-radius: 0; background: transparent; }
.spot-side + .spot-side { border-top: 1px solid var(--line); }
.spot-side strong { font-family: var(--mono, monospace); font-size: 18px; letter-spacing: .08em; }
.spot-side span { font-size: 12px; color: var(--muted); }
.spot-side.is-pass { border-color: #2f9e65; }
.spot-side.has-discrepancy { border-color: #d58a13; background: color-mix(in srgb, #d58a13 12%, var(--panel)); }
.spot-dialog-lock { overflow: hidden; }
.spot-dialog {
  width: fit-content;
  min-width: min(560px, calc(100vw - 48px));
  max-width: min(760px, calc(100vw - 48px));
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.spot-dialog[open] { display: flex; flex-direction: column; }
.spot-dialog::backdrop { background: rgba(0, 0, 0, .5); backdrop-filter: blur(4px); }
.spot-dialog .spot-card { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 16px; margin: 0; border: 0; border-radius: 0; }
.spot-card-heading-actions { display: flex; align-items: flex-start; gap: 12px; }
.spot-card-heading-actions button { font-size: 20px; line-height: 1; }
.spot-dialog .spot-occupancy { white-space: nowrap; }
.spot-dialog .spot-card-actions { margin: 10px 0 12px; }
.spot-dialog .table-wrap { min-width: 0; min-height: 0; max-width: 100%; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; }
.spot-dialog .table-wrap > table { min-width: max-content; }
.spot-dialog .table-wrap :is(th, td) { padding: 8px 10px; }
@media (max-height: 480px) {
  .spot-dialog .spot-card { padding: 10px; }
  .spot-dialog .panel-heading h2 { font-size: 18px; }
  .spot-dialog .panel-heading p { font-size: 12px; }
  .spot-dialog .spot-occupancy { font-size: 18px; }
  .spot-dialog .spot-card-actions { gap: 6px; margin: 6px 0 8px; }
  .spot-dialog .spot-card-actions button { padding: 4px 6px; font-size: 12px; }
}
.spot-card-actions, .storage-final-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.spot-occupancy { font-size: 24px; }
.inventory-mode-dialog { width: min(620px, calc(100vw - 32px)); }
.inventory-mode-card { text-align: left; padding: 18px; display: grid; gap: 6px; }
.inventory-mode-card strong { font-size: 17px; }
.inventory-mode-card span { color: var(--muted); }
.inventory-summary { display: grid; grid-template-columns: repeat(8, minmax(100px, 1fr)); gap: 8px; margin: 0 0 16px; }
.inventory-summary > div, .move-flow > div { display: grid; gap: 5px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.inventory-summary span, .move-flow span { color: var(--muted); font-size: 12px; }
.inventory-summary strong, .move-flow strong { font-size: 20px; }
.inventory-missing { padding: 9px 0; border-top: 1px solid var(--line); }
.batch-inventory-guide ol { margin: 10px 0 0 22px; display: grid; gap: 7px; }
.move-flow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.move-leg { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }

@media (min-width: 761px) {
  .spot-map-racks { grid-template-columns: repeat(4, 104px); justify-content: start; column-gap: 24px; }
}

.batch-view-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.batch-leg-search {
  position: relative;
  z-index: 20;
  align-items: start;
}

.batch-leg-search-field {
  position: relative;
  width: min(100%, 720px);
  flex: 0 1 720px;
}

.batch-leg-search-input-wrap {
  position: relative;
}

.batch-leg-search-input-wrap input {
  padding-right: 42px;
}

.batch-leg-search-clear {
  position: absolute;
  top: 50%;
  right: 5px;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.batch-leg-search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  z-index: 100;
  max-height: 352px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 10px);
  background: var(--surface);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.batch-leg-search-suggestions::-webkit-scrollbar {
  width: 8px;
}

.batch-leg-search-suggestions::-webkit-scrollbar-track {
  background: transparent;
}

.batch-leg-search-suggestions::-webkit-scrollbar-thumb {
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--line);
}

.batch-leg-search-group + .batch-leg-search-group {
  border-top: 1px solid var(--line);
}

.batch-leg-search-empty {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
}

.batch-leg-search-group-title {
  display: none;
}

.batch-leg-search-option {
  width: 100%;
  min-height: 0;
  display: grid;
  gap: 3px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  background: transparent;
  color: var(--ink);
}

.batch-leg-search-option:last-child {
  border-bottom: 0;
}

.batch-leg-search-option:hover,
.batch-leg-search-option[aria-selected="true"] {
  border-color: var(--line);
  background: var(--color-accent-tint);
}

.batch-leg-search-option span {
  color: var(--muted);
  font-size: 12px;
}

.batch-leg-group-divider td {
  padding-top: 16px;
  padding-bottom: 7px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.maestro-data-grid-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.maestro-data-grid__toolbar {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 8px;
}

.maestro-data-grid__toolbar > button,
.maestro-data-grid__columns > summary {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.maestro-data-grid__toolbar > button:hover,
.maestro-data-grid__columns > summary:hover,
.maestro-data-grid__columns[open] > summary {
  border-color: var(--accent);
  color: var(--ink);
}

.maestro-data-grid__columns {
  position: relative;
}

.maestro-data-grid__columns > summary {
  list-style: none;
}

.maestro-data-grid__columns > summary::-webkit-details-marker {
  display: none;
}

.maestro-data-grid__columns > summary::after {
  margin-left: 6px;
  color: var(--muted);
  content: "▾";
}

.maestro-data-grid__columns[open] > summary::after {
  transform: rotate(180deg);
}

.maestro-data-grid__columns-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  width: min(360px, calc(100vw - 40px));
  max-height: min(60vh, 480px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.maestro-data-grid__column-control {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 148px;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
}

.maestro-data-grid__column-control:last-child {
  border-bottom: 0;
}

.maestro-data-grid__column-control label {
  display: flex;
  min-width: 0;
  gap: 7px;
  align-items: center;
  color: var(--ink);
  font-size: 12px;
}

.maestro-data-grid__column-control label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.maestro-data-grid__column-control select {
  min-height: 29px;
  padding: 4px 7px;
  font-size: 11px;
}

.maestro-data-grid__engine {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.maestro-data-grid__engine .ag-root-wrapper {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.maestro-data-grid__engine .ag-header {
  color: var(--muted);
  background: var(--surface-2);
}

.maestro-data-grid__engine .ag-header-cell-label {
  gap: 5px;
}

.maestro-data-grid__engine .ag-header-cell-moving,
.maestro-data-grid__engine .ag-header-cell.ag-column-moving {
  background: var(--color-accent-tint);
}

.maestro-data-grid__engine .ag-header-cell-resize {
  right: -5px;
  z-index: 4;
  width: 12px;
  cursor: col-resize;
  touch-action: none;
}

.maestro-data-grid__engine .ag-header-cell-resize::after {
  width: 1px;
  height: 56%;
  background: var(--line);
  transition: width 100ms ease, background 100ms ease;
}

.maestro-data-grid__engine .ag-header-cell:hover .ag-header-cell-resize::after,
.maestro-data-grid__engine .ag-header-cell-resize:hover::after {
  width: 2px;
  background: var(--accent);
}

.maestro-data-grid__engine .ag-row {
  color: var(--ink);
  background: var(--surface);
}

.maestro-data-grid__engine .ag-row-hover:not(.maestro-data-grid__divider-row) {
  background: var(--color-accent-tint);
}

.maestro-data-grid__engine .ag-cell {
  display: flex;
  overflow: hidden;
  align-items: center;
  line-height: var(--table-line-height);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.maestro-data-grid__engine .ag-cell-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.maestro-data-grid__cell-renderer {
  display: inline-flex;
  min-width: 0;
  align-items: center;
}

.maestro-data-grid__engine .ag-pinned-left-header,
.maestro-data-grid__engine .ag-pinned-left-cols-container,
.maestro-data-grid__engine .ag-grid-pinned-left-cells {
  border-right: 1px solid var(--line);
  box-shadow: 5px 0 10px color-mix(in srgb, var(--bg) 18%, transparent);
}

.maestro-data-grid__engine .ag-pinned-right-header,
.maestro-data-grid__engine .ag-pinned-right-cols-container,
.maestro-data-grid__engine .ag-grid-pinned-right-cells {
  border-left: 1px solid var(--line);
  box-shadow: -5px 0 10px color-mix(in srgb, var(--bg) 18%, transparent);
}

.maestro-data-grid__engine .ag-row.batch-leg-row--inactive {
  opacity: 0.5;
}

.maestro-data-grid__engine .ag-full-width-row {
  background: var(--surface);
}

.maestro-data-grid__engine .ag-row.batch-leg-row,
.maestro-data-grid__engine .ag-row.batch-status-row {
  background: var(--surface-2);
}

.batch-tree-leg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding-left: 12px;
}

.batch-tree-leg [data-context-id] {
  flex: 0 0 auto;
}

.batch-grid-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 4px;
  color: var(--muted);
  font-size: 12px;
}

.batch-grid-pager label,
.batch-grid-pager__buttons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.batch-grid-pager select,
.batch-grid-pager button {
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.batch-grid-pager__buttons { margin-left: auto; }
.batch-grid-pager button:disabled { opacity: 0.45; }
.batch-grid-pager__error { color: var(--bad); }

.maestro-data-grid__group-divider {
  display: flex;
  height: 100%;
  align-items: flex-end;
  padding: 10px 12px 5px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
}

.maestro-data-grid__engine .ag-overlay,
.maestro-data-grid__engine .ag-popup {
  font-family: var(--maestro-font-ui);
}

@media (max-width: 760px) {
  .batch-leg-search-field {
    width: 100%;
  }

  .batch-grid-pager__buttons { margin-left: 0; }
}

@media (min-width: 921px) {
  .batch-view-controls {
  gap: 16px;
  align-items: center;
  }
  .storefront-item-title { display: table-cell; }

  .batch-legs-toggle {
    width: 26px;
    height: 26px;
    min-height: 26px;
    flex-basis: 26px;
    border-radius: 6px;
    display: inline-grid;
    place-items: center;
    line-height: 1;
  }

  .batch-expand-placeholder::after { width: 32px; }
}

@media (max-width: 1180px) {
  .racks-page-layout .spot-map-racks { max-width: 456px; }
  @media (min-width: 761px) {
    .spot-map-racks { grid-template-columns: repeat(4, 96px); }
  }
  .spot-rack { width: min(100%, 96px); min-height: 74px; }
  .inventory-summary { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 760px) {
  .storage-toolbar { grid-template-columns: 1fr; }
  .racks-page-layout { gap: 16px; }
  .racks-page-layout .spot-map-racks { max-width: 336px; }
  .spot-room-map { gap: 16px; }
  .spot-map-racks { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: minmax(96px, 1fr); gap: 16px; }
  .spot-rack { width: min(100%, 72px); min-height: 96px; }
  .inventory-summary { grid-template-columns: repeat(2, 1fr); }
  .move-flow { grid-template-columns: 1fr; }
}

/* Read-only hamon drying analytics */
.drying-forecast-cell { text-align: right; font-variant-numeric: tabular-nums; }
.drying-forecast-value { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.drying-forecast-value--empty { color: var(--muted); text-decoration: none; }
.drying-forecast-value--alert { color: #E53935; animation: drying-forecast-blink 0.6s infinite; }
@keyframes drying-forecast-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .drying-forecast-value--alert { animation: none; } }
.drying-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.drying-metric { display: grid; gap: 5px; }
.drying-metric span { color: var(--muted); font-size: 12px; }
.drying-metric strong { font-family: var(--mono, monospace); font-size: 24px; }
.drying-chart-wrap { overflow-x: auto; padding-bottom: 4px; }
.drying-chart { display: block; width: 100%; min-width: 680px; color: var(--muted); }
.drying-chart-axis { stroke: var(--line); stroke-width: 1; }
.drying-chart-segment { stroke: var(--accent); stroke-linecap: round; }
.drying-chart-point { fill: var(--accent); stroke: var(--surface); stroke-width: 2; cursor: help; }
.drying-chart-point:focus { outline: none; stroke: var(--ink); stroke-width: 3; }
.drying-chart-month, .drying-chart-count, .drying-chart-value { fill: currentColor; font-family: var(--mono, monospace); text-anchor: middle; }
.drying-chart-month { font-size: 12px; }
.drying-chart-count { font-size: 10px; }
.drying-chart-value { font-size: 11px; text-anchor: start; }
.drying-table td { white-space: nowrap; }

@media (max-width: 760px) {
  .drying-summary { grid-template-columns: 1fr; }
}

/* Shared responsive table policy. Column roles are assigned by table-layout.js
   after each native table is mounted; renderers retain their current markup and
   data semantics. The primary text role receives spare width, while technical
   columns size to useful content rather than their longer headers. */
.table-wrap {
  overscroll-behavior-x: contain;
}

.table-wrap > table[data-table-layout="responsive"] {
  width: 100%;
  min-width: 0;
  table-layout: auto;
  font-size: var(--table-font-size);
  line-height: var(--table-line-height);
}

.table-wrap > table[data-table-layout="responsive"] :is(th, td) {
  min-width: 0;
}

.table-wrap > table[data-table-layout="responsive"] thead th {
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: auto;
  line-height: var(--table-header-line-height);
  font-size: var(--table-font-size);
}

.table-wrap > table[data-table-layout="responsive"] tbody td {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-wrap > table[data-table-layout="responsive"] :is(th, td)[data-table-column-type="text"] {
  min-width: 0;
}

.table-wrap > table[data-table-layout="responsive"] th[data-table-grow="true"] {
  width: 100%;
}

.table-wrap > table[data-table-layout="responsive"] :is(th, td)[data-table-column-type="number"],
.table-wrap > table[data-table-layout="responsive"] :is(th, td)[data-table-column-type="date"],
.table-wrap > table[data-table-layout="responsive"] :is(th, td)[data-table-column-type="status"],
.table-wrap > table[data-table-layout="responsive"] :is(th, td)[data-table-column-type="boolean"],
.table-wrap > table[data-table-layout="responsive"] :is(th, td)[data-table-column-type="code"],
.table-wrap > table[data-table-layout="responsive"] :is(th, td)[data-table-column-type="actions"] {
  width: 1%;
}

/* Header labels may wrap, but semantic minimums prevent character-by-character
   columns while keeping the minimum independent of a particular label length. */
.table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="number"] {
  min-width: 3.5rem;
}

.table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="date"] {
  min-width: 4.75rem;
}

.table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="status"],
.table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="boolean"] {
  min-width: 4.5rem;
}

.table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="code"] {
  min-width: 5rem;
}

.table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="actions"] {
  min-width: 5.25rem;
}

.table-wrap > table[data-table-layout="responsive"] tbody :is(td[data-table-column-type="number"], td[data-table-column-type="date"], td[data-table-column-type="status"], td[data-table-column-type="boolean"], td[data-table-column-type="code"], td[data-table-column-type="actions"]) {
  white-space: nowrap;
}

.table-wrap > table[data-table-layout="responsive"] tbody td[data-table-column-type="code"] {
  overflow: visible;
  text-overflow: clip;
}

.table-wrap > table[data-table-layout="responsive"] .technical-code,
.table-wrap > table[data-table-layout="responsive"] .status {
  max-width: 100%;
  line-height: inherit;
}

/* Explicit multi-line product metadata is intentional, not a width-induced wrap. */
.table-wrap > table[data-table-layout="responsive"] .order-item-name {
  white-space: normal;
}

.order-items-table > table[data-table-layout="responsive"] .status {
  white-space: nowrap;
}

/* These tables have more independent functional columns than a phone can show
   legibly. Their minimums are deliberate responsive fallbacks, not legacy
   percentage geometry. */
.warehouse-table[data-table-layout="responsive"] {
  min-width: 680px;
}

.storefront-table[data-table-layout="responsive"] {
  min-width: 680px;
}

.order-items-table > table[data-table-layout="responsive"] {
  min-width: 640px;
}

.drying-table[data-table-layout="responsive"] {
  min-width: 640px;
}

/* The expandable batch hierarchy needs its controls and identifiers intact;
   it keeps its existing content-width behavior and the wrapper supplies scroll
   only when its actual columns no longer fit. */
.batch-leg-table > table[data-table-layout="responsive"],
.batch-expanded-table > table[data-table-layout="responsive"] {
  width: max-content;
  min-width: max-content;
}

.batch-leg-table > table[data-table-layout="responsive"] th,
.batch-leg-table > table[data-table-layout="responsive"] td,
.batch-expanded-table > table[data-table-layout="responsive"] th,
.batch-expanded-table > table[data-table-layout="responsive"] td {
  font-size: var(--table-font-size-compact);
}

@media (max-width: 560px) {
  .table-wrap > table[data-table-layout="responsive"] {
    font-size: var(--table-font-size-compact);
  }

  .table-wrap > table[data-table-layout="responsive"] :is(th, td) {
    padding: 8px;
  }

  .table-wrap > table[data-table-layout="responsive"] thead th {
    font-size: var(--table-font-size-compact);
  }

  .table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="number"] {
    min-width: 3rem;
  }

  .table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="date"],
  .table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="status"],
  .table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="boolean"],
  .table-wrap > table[data-table-layout="responsive"] thead th[data-table-column-type="code"] {
    min-width: 3.75rem;
  }

  .compact-action-heading,
  .compact-action-cell {
    padding-inline: 4px !important;
  }
}

/* MAESTRO LEG WEIGHT FILTER */

.leg-weight-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  align-self: end;
  min-height: 38px;
  cursor: pointer;
  user-select: none;
}

.leg-weight-toggle > input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.leg-weight-toggle__track {
  position: relative;
  display: inline-flex;
  width: 34px;
  height: 20px;
  flex: 0 0 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  transition: background 140ms ease, border-color 140ms ease;
}

.leg-weight-toggle__thumb {
  position: absolute;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 140ms ease, background 140ms ease;
}

.leg-weight-toggle > input:checked + .leg-weight-toggle__track {
  border-color: var(--accent);
  background: var(--accent);
}

.leg-weight-toggle > input:checked
  + .leg-weight-toggle__track
  .leg-weight-toggle__thumb {
  transform: translateX(14px);
  background: var(--accent-contrast, #fff);
}

.leg-filter-secondary-row {
  flex: 1 0 100%;
  display: flex;
  align-items: end;
  gap: 18px;
  width: 100%;
  margin-top: 4px;
}

.leg-age-filter {
  flex: 0 0 210px;
}

.leg-weight-range {
  flex: 1 1 520px;
  width: auto;
  min-width: 320px;
  padding-top: 0;
}

.leg-weight-range[hidden] {
  display: none;
}

.leg-weight-range__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: var(--font-size-sm);
}

.leg-weight-range__header strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--font-size-sm);
  font-weight: 500;
  white-space: nowrap;
}

.leg-dual-range {
  --range-start: 0%;
  --range-end: 100%;

  position: relative;
  width: 100%;
  height: 32px;
}

.leg-dual-range__rail,
.leg-dual-range__selection {
  position: absolute;
  top: 50%;
  height: 4px;
  border-radius: 999px;
  transform: translateY(-50%);
  pointer-events: none;
}

.leg-dual-range__rail {
  right: 0;
  left: 0;
  background: var(--line);
}

.leg-dual-range__selection {
  left: var(--range-start);
  right: calc(100% - var(--range-end));
  background: var(--accent);
}

.leg-dual-range__input {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  pointer-events: none;
}

.leg-dual-range__input--max {
  z-index: 4;
}

.leg-dual-range__input::-webkit-slider-runnable-track {
  height: 4px;
  border: 0;
  background: transparent;
}

.leg-dual-range__input::-moz-range-track {
  height: 4px;
  border: 0;
  background: transparent;
}

.leg-dual-range__input::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  cursor: grab;
  pointer-events: auto;
}

.leg-dual-range__input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  cursor: grab;
  pointer-events: auto;
}

.leg-dual-range__input:active::-webkit-slider-thumb {
  cursor: grabbing;
}

.leg-dual-range__input:active::-moz-range-thumb {
  cursor: grabbing;
}

.leg-dual-range__input:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.leg-dual-range__input:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.leg-dual-range__scale {
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--font-size-sm);
}

@media (max-width: 900px) {
  .leg-filter-secondary-row {
    flex-wrap: wrap;
  }

  .leg-weight-range {
    flex-basis: 100%;
  }
}

@media (max-width: 760px) {
  .leg-filter-secondary-row {
    align-items: stretch;
  }

  .leg-age-filter {
    flex: 1 0 100%;
  }

  .leg-weight-range {
    width: 100%;
    min-width: 0;
  }
}

/* Страница заказа: данные блока «О заказе» одной колонкой */
.order-summary {
  grid-template-columns: 1fr;
}
.sku-forecast-panel { margin-top: 22px; min-width: 0; }
.sku-forecast-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sku-forecast-heading h2 { margin: 0 0 4px; }
.sku-forecast-heading p { margin: 0; }
.sku-forecast-heading button { flex: none; }
.sku-forecast-metrics { margin-top: 16px; }
.sku-forecast-metrics .metric strong { font-size: 23px; }
.sku-forecast-panel [data-sku-forecast-status] { min-height: 1.4em; }
.sku-forecast-panel .maestro-data-grid__engine .ag-row.sku-forecast-row--empty { opacity: 0.5; }
.sku-forecast-panel .maestro-data-grid__engine .ag-row.sku-forecast-row--critical,
.sku-forecast-panel .maestro-data-grid__engine .ag-row.sku-forecast-row--critical .ag-cell {
  background: color-mix(in srgb, #c23b4d 18%, var(--surface));
  color: var(--ink);
}
.sku-forecast-panel .maestro-data-grid__engine .ag-row.sku-forecast-row--critical { box-shadow: inset 3px 0 #c23b4d; }
.sku-forecast-toggle { min-width: 30px; min-height: 26px; padding: 0 5px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.sku-forecast-toggle:hover, .sku-forecast-toggle:focus-visible { color: #c23b4d; }
.sku-forecast-sku-cell { display: flex; flex-direction: column; min-width: 0; }
.sku-forecast-mobile-summary { display: none; }
.sku-forecast-bars { display: flex; flex-direction: column; justify-content: center; gap: 3px; width: 130px; height: 26px; }
.sku-forecast-bar { display: block; height: 5px; min-width: 0; border-radius: 3px; }
.sku-forecast-bar--fact { background: var(--ink); }
.sku-forecast-bar--predicted { background: #c23b4d; }
.sku-forecast-detail { width: 100%; height: 100%; padding: 10px 14px; overflow: hidden; background: var(--surface-2); }
.sku-forecast-detail-scroll { width: 100%; max-height: 174px; overflow: auto; }
.sku-forecast-detail table, .sku-forecast-missing table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sku-forecast-detail th, .sku-forecast-detail td, .sku-forecast-missing th, .sku-forecast-missing td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.sku-forecast-detail p { margin: 7px 0 0; font-size: 12px; }
.sku-forecast-missing { margin-top: 13px; }
.sku-forecast-missing summary { cursor: pointer; color: var(--ink); }
.sku-forecast-missing .sku-forecast-detail-scroll { max-height: 240px; margin-top: 8px; }
@media (max-width: 760px) {
  .sku-forecast-heading { flex-wrap: wrap; }
  .sku-forecast-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .sku-forecast-panel { padding: 12px; }
  .sku-forecast-mobile-summary { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; }
  .sku-forecast-row--critical .sku-forecast-mobile-summary { color: var(--ink); }
}

.drying-publication-guard-panel { margin-top: 22px; min-width: 0; }
.drying-publication-guard-panel h2 { margin: 0 0 4px; }
.drying-publication-guard-panel > p.muted { margin: 0 0 14px; }
.drying-publication-guard-list { display: flex; flex-direction: column; gap: 14px; }
.drying-publication-guard-item { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.drying-publication-guard-item__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.drying-publication-guard-item .details { margin-bottom: 6px; }
.drying-publication-guard-item p { margin: 6px 0; font-size: var(--table-font-size); }
.drying-publication-block-legs { margin: 6px 0; padding-left: 18px; font-size: var(--table-font-size); }
.drying-publication-block-legs li { margin: 2px 0; }
.drying-publication-block-badge { margin-left: 6px; cursor: default; white-space: nowrap; }


/* Leg detail: sale blocking notice in topbar */
.topbar .leg-topbar-notice {
  flex: 0 1 50%;
  min-width: 0;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}

@media (max-width: 920px) {
  .topbar .leg-topbar-notice {
    width: 100%;
  }
}

/* BEGIN MAESTRO COMPACT MOBILE HEADER 2026-10-26 */
/* Legacy MAESTRO only. Keep tablet and desktop layouts unchanged. */
@media (max-width: 768px) {
  /* Remove the tall sidebar header from document flow. */
  .app,
  .app.sidebar-collapsed {
    display: block;
  }

  .app .sidebar,
  .app.sidebar-collapsed .sidebar {
    position: fixed;
    top: calc(14px + env(safe-area-inset-top));
    right: 14px;
    bottom: auto;
    left: auto;
    z-index: 9;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    margin: 0;
    padding: 0;
    gap: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .app .sidebar-head {
    display: block;
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    margin: 0;
  }

  /* Only hide the duplicate wordmark in the collapsed mobile header.
     The navigation itself remains fully available in .menu-panel. */
  .app .sidebar-head > .brand {
    display: none;
  }

  .app .menu-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-sizing: border-box;
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 8px;
    margin: -8px;
    border: 1px solid var(--dh-white);
    border-radius: 14px;
    background: var(--dh-black-lt);
    color: var(--dh-lt-grey);
    cursor: pointer;
    opacity: 1;
    transition: opacity 350ms ease, background-color 200ms ease;
  }

  .app .menu-toggle > span {
    width: 18px;
    height: 2px;
    flex: 0 0 2px;
    border-radius: 2px;
    background: currentColor;
  }

  .app .menu-toggle:hover {
    background: var(--dh-black-lt, #2e2a38);
  }

  .menu-toggle.is-scrolling-down {
    opacity: 0.5;
  }

  .app .menu-toggle:focus-visible {
    outline: 2px solid var(--focus, var(--accent));
    outline-offset: 2px;
  }

  /* Reserve room so a long heading never sits behind the floating button. */
  .app .main .topbar {
    min-height: 42px;
    padding-right: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu-toggle {
    transition: none;
  }
}
/* END MAESTRO COMPACT MOBILE HEADER 2026-10-26 */
/* MAESTRO · Order / CDEK status headings */

.order-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.order-card-heading h2 {
  margin: 0;
}

.order-card-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.order-card-status .status {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  width: fit-content;
  white-space: nowrap;
}

.cdek-statuses {
  flex-direction: row;
  gap: 6px;
}

@media (max-width: 480px) {
  .order-card-heading {
    flex-wrap: wrap;
  }

  .order-card-status {
    justify-content: flex-start;
  }
}
/* Reference documents: isolated informational cards and clipboard controls. */
.reference-documents { min-width: 0; font-family: var(--maestro-font-ui); }
.reference-documents-help { margin: 0; }
.reference-copy-status { min-height: 1.5em; margin: 8px 0 16px; font-size: 13px; }
.reference-copy-status.is-error { color: var(--bad); }
.reference-document-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.reference-document-grid > :first-child { grid-row: span 2; }
.reference-document-card { min-width: 0; border-radius: 20px; }
.reference-document-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.reference-document-heading h2, .reference-document-files > h2 { font: 600 18px/1.4 var(--maestro-font-ui); margin: 0; }
.reference-copy-all { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; font: 500 12px/1.4 var(--maestro-font-ui); padding: 8px; }
.reference-document-section { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.reference-document-section h3 { font: 600 13px/1.5 var(--maestro-font-ui); margin: 0 0 12px; }
.reference-document-section dl, .reference-document-field dd { margin: 0; }
.reference-document-field + .reference-document-field { margin-top: 12px; }
.reference-document-field dt { color: var(--muted); font: 400 12px/1.5 var(--maestro-font-ui); margin-bottom: 4px; }
.reference-copy-value { width: 100%; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; text-align: left; padding: 8px 10px; background: transparent; border: 1px solid transparent; border-radius: 8px; font: 400 13px/1.65 var(--mono); color: var(--ink); }
.reference-copy-value > span:first-child { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.reference-copy-icon { flex: 0 0 16px; color: var(--muted); padding-top: 2px; }
.reference-copy-value:hover, .reference-copy-value:focus-visible { border-color: var(--muted); background: var(--surface-2); }
.reference-copy-value.is-copied, .reference-copy-all.is-copied { border-color: var(--muted); background: var(--surface-2); }
.reference-copy-value.is-copied .reference-copy-icon::after { content: "✓"; }
.reference-copy-value.is-copied .reference-copy-icon svg { display: none; }
.reference-document-files { margin-top: 24px; }
.reference-document-files > h2 { margin-bottom: 14px; }
.reference-document-files .reference-document-section dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.reference-document-files .reference-document-field + .reference-document-field { margin-top: 0; }
.reference-document-download { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reference-document-pending { color: var(--muted); margin: 0; font-size: 13px; }
@media (max-width: 760px) {
  .reference-document-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .reference-document-grid > :first-child { grid-row: auto; }
  .reference-document-heading { flex-wrap: wrap; }
  .reference-document-files .reference-document-section dl { grid-template-columns: minmax(0, 1fr); }
  .reference-document-download { align-items: flex-start; flex-direction: column; }
  .reference-copy-value { min-height: 44px; }
}


/* MAESTRO LOGOUT MATCHES THEME TOGGLE */

.session .session-logout {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 18px;
  border-color: var(--accent);
  background: var(--color-line-dark);
  color: var(--action-contrast);
  font-weight: 300;
  display: inline-grid;
  place-items: center;
}

.session .session-logout:hover {
  border-color: var(--accent-strong);
  background: var(--color-line-dark);
}

.session .session-logout svg {
  width: 22px;
  height: 22px;
}
.scale-page { display: grid; gap: 1rem; max-width: 960px; }
.scale-page [hidden] { display: none !important; }
.scale-flow-title { margin: 0; }
.scale-steps { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin: 0; padding: 0; }
.scale-steps li { padding: .4rem .65rem; border: 1px solid var(--border, #555); border-radius: .45rem; }
.scale-steps li[aria-current="step"] { border-color: var(--accent, #b99762); font-weight: 700; }
.scale-modes { display: flex; flex-wrap: wrap; gap: .5rem; }
.scale-modes button[aria-pressed="true"] { background: var(--accent, #b99762); color: #121212; border-color: transparent; }
.scale-cards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.scale-reading { display: grid; gap: .35rem; align-content: center; text-align: center; min-height: 180px; }
.scale-reading strong { font-size: clamp(2.5rem, 9vw, 5rem); line-height: 1.1; font-variant-numeric: tabular-nums; }
.scale-details { display: grid; gap: .75rem; }
.scale-details > div { display: flex; justify-content: space-between; gap: .5rem; }
.scale-work { display: grid; gap: 1rem; }
.scale-input { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.scale-input label { flex: 1 1 230px; display: grid; gap: .3rem; }
.scale-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.scale-actions a { text-decoration: underline; }
.scale-error { color: #f29b9b; font-weight: 600; }
#scale-video { width: 100%; max-height: 280px; object-fit: cover; border-radius: .6rem; background: #111; }
.scale-queue { list-style: none; padding: 0; margin: .75rem 0; display: grid; gap: .3rem; }
.scale-queue li { display: flex; justify-content: space-between; gap: .75rem; padding: .5rem .65rem; border: 1px solid var(--border, #555); border-radius: .45rem; }
.scale-queue li.active { border-color: var(--accent, #b99762); }
.scale-queue li.done { opacity: .65; }
@media (max-width: 640px) {
  .scale-cards { grid-template-columns: 1fr; }
  .scale-input button, .scale-actions button { min-height: 44px; }
}

/* MAESTRO: reference shortcut alongside theme toggle */
/* Reference shares the exact base and hover rules of .theme-toggle. */
.session-actions-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.session .session-reference {
  flex: 0 0 48px;
}

.session .session-reference .nav-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
}

.session .session-reference .nav-icon svg {
  width: 22px;
  height: 22px;
}

.session .session-reference.active {
  background: var(--color-accent-tint);
  color: var(--nav-active-ink);
}

/* The narrow collapsed sidebar cannot fit three 48px buttons in one row. */
.sidebar-collapsed .session-actions {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.sidebar-collapsed .session-actions-right {
  flex-direction: column;
  margin-left: 0;
}


/* MAESTRO MAIN FOUR-COLUMN GRID */

.main {
  box-sizing: border-box;
  width: 100%;
  max-width: 1284px;
  margin-inline: auto;

  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 24px;
  align-content: start;
}

.main > .topbar,
.main > #view {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
}

.main > #view {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 0;
}

.main > #view > * {
  grid-column: 1 / -1;
  min-width: 0;
}

/* Планшеты */
@media (min-width: 761px) and (max-width: 1200px) {
  .main,
  .main > #view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
  }
}

/* Мобильные */
@media (max-width: 760px) {
  .main,
  .main > #view {
    grid-template-columns: minmax(0, 1fr);
    column-gap: 0;
  }
}


/* MAESTRO WEIGHING TWO-COLUMN LAYOUT */

.scale-page {
  width: 100%;
  max-width: none;
  min-width: 0;

  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

/* Сессия и этапы остаются над рабочими колонками. */
.scale-page > #scale-session-panel {
  grid-column: 1 / -1;
  grid-row: 1;
}
.scale-page > .scale-flow-title { grid-column: 1 / -1; grid-row: 2; }
.scale-page > .scale-steps { grid-column: 1 / -1; grid-row: 3; }

/* Левая колонка: весы + параметры */
.scale-page > .scale-cards {
  grid-column: 1;
  grid-row: 4 / span 2;

  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-content: start;

  min-width: 0;
}

.scale-page .scale-reading,
.scale-page .scale-details {
  width: 100%;
  min-width: 0;
}

/* Правая колонка: рабочая панель */
.scale-page > .scale-work {
  grid-column: 2;
  grid-row: 4;

  width: 100%;
  min-width: 0;
}

/* Правая колонка: группа окороков */
.scale-page > .panel:last-child {
  grid-column: 2;
  grid-row: 5;

  width: 100%;
  min-width: 0;
}

/* Информация об автоматическом сохранении */
.scale-page > #scale-commit-status {
  grid-column: 1 / -1;
  grid-row: 6;
  margin: 0;
}

/* Адаптивность */
@media (max-width: 920px) {
  .scale-page {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .scale-page > .scale-cards {
    grid-column: 1;
    grid-row: 4;
    gap: 16px;
  }

  .scale-page > .scale-work {
    grid-column: 1;
    grid-row: 5;
  }

  .scale-page > .panel:last-child {
    grid-column: 1;
    grid-row: 6;
  }

  .scale-page > #scale-commit-status {
    grid-column: 1;
    grid-row: 7;
  }
}


/* MAESTRO MOBILE WEIGHING PANEL ORDER */
@media (max-width: 920px) {
  .scale-page > .scale-cards {
    display: contents;
  }

  .scale-page .scale-reading {
    grid-column: 1;
    grid-row: 4;
  }

  .scale-page > .panel:last-child {
    grid-column: 1;
    grid-row: 5;
  }

  .scale-page > .scale-work {
    grid-column: 1;
    grid-row: 6;
  }

  .scale-page .scale-details {
    grid-column: 1;
    grid-row: 7;
  }

  .scale-page > #scale-commit-status {
    grid-column: 1;
    grid-row: 8;
  }
}



/* MAESTRO SAFARI CAMERA FRAME FIX */

@media (max-width: 760px) {

  .scale-page #scale-video:not([hidden]) {
    display: block;
    box-sizing: border-box;

    width: min(100%, 320px);
    height: auto;
    aspect-ratio: 1 / 1;

    min-width: 0;
    max-width: 100%;
    max-height: none;

    margin-inline: auto;
    justify-self: center;

    object-fit: cover;
    object-position: center;

    background: #111;
    border-radius: 12px;
    overflow: hidden;
  }

  .scale-page #scale-video[hidden] {
    display: none !important;
  }
}



/* MAESTRO LEGS GRID FIX 20261103 */

.legs-grid-region {
  display: block;
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.legs-grid-region #maestro-legs-grid {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.legs-grid-region .maestro-data-grid-shell,
.legs-grid-region .maestro-data-grid__engine {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.legs-grid-region .legs-grid-pager {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  clear: both;
}
