:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #eef3f7;
  --line: #d8e0e7;
  --text: #16202a;
  --muted: #637282;
  --blue: #1f6feb;
  --green: #15803d;
  --orange: #b45309;
  --warning-bg: #fff7ed;
  --warning-line: #fdba74;
  --red: #b91c1c;
  --shadow: 0 1px 2px rgba(20, 32, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.boot-panel,
.login {
  width: min(420px, calc(100vw - 32px));
  margin: 12vh auto 0;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.boot-title,
.login h1 {
  margin: 0 0 10px;
  font-size: 22px;
}

.login form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 5px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

textarea {
  min-height: 42px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(31, 111, 235, 0.18);
  border-color: var(--blue);
}

.layout {
  display: grid;
  grid-template-columns: 224px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 160ms ease;
}

.layout.sidebar-collapsed {
  grid-template-columns: 58px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 14px;
  background: #16202a;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  transition: padding 160ms ease;
}

.sidebar.collapsed {
  padding: 12px 8px;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-copy {
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 20px;
  margin-bottom: 3px;
}

.brand span {
  color: #aebdcc;
  font-size: 12px;
}

.sidebar-controls {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

.sidebar-icon-button {
  width: 25px;
  height: 25px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  background: transparent;
  color: #dbe5ee;
  cursor: pointer;
}

.sidebar-icon-button.active {
  background: #dbe5ee;
  color: #16202a;
}

.sidebar.collapsed .brand {
  display: grid;
  justify-content: center;
}

.sidebar.collapsed .brand-copy,
.sidebar.collapsed #sidebar-pin,
.sidebar.collapsed .sidebar-footer {
  display: none;
}

.sidebar.collapsed .nav button {
  width: 40px;
  min-height: 38px;
  padding: 8px 4px;
  text-align: center;
}

.sidebar.collapsed .nav button span {
  display: none;
}

.sidebar.collapsed .nav button::before {
  content: attr(data-short);
  font-weight: 700;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav button {
  text-align: left;
  color: #dbe5ee;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 9px 10px;
  cursor: pointer;
}

.nav button:hover,
.nav button.active {
  background: #253444;
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.release-box {
  display: grid;
  gap: 2px;
  padding: 6px 10px;
  color: #9fb0c0;
  font-size: 11px;
  line-height: 1.25;
}

.release-box strong {
  color: #dbe5ee;
  font-size: 12px;
}

.user-box {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #dbe5ee;
}

.content {
  min-width: 0;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

.button:hover {
  border-color: #b6c3cf;
}

.button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.button.small {
  padding: 5px 8px;
  font-size: 12px;
}

.button.danger {
  color: var(--red);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
}

.filter-field {
  display: grid;
  gap: 5px;
}

.filter-field span {
  color: var(--muted);
  font-size: 12px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 13px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 26px;
}

.dashboard-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-metric {
  position: relative;
  min-height: 112px;
}

.dashboard-drilldown-trigger {
  cursor: pointer;
}

.dashboard-drilldown-trigger:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.metric-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.metric-heading strong {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
}

.metric-heading small {
  flex: 0 0 auto;
  margin: 0;
}

.metric-heading-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.metric-refresh-button {
  display: inline-grid;
  width: 27px;
  height: 27px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--blue);
  cursor: pointer;
}

.metric-refresh-button:hover {
  border-color: var(--blue);
  background: #eff6ff;
}

.metric-refresh-button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.metric-refresh-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.metric-refresh-button > span {
  color: inherit;
  font-size: 18px;
  line-height: 1;
}

.metric-refresh-button.busy > span {
  animation: metric-refresh-spin 0.8s linear infinite;
}

@keyframes metric-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.forecast-rule-modal {
  width: min(1180px, calc(100vw - 32px));
}

.forecast-rule-modal .rule-modal-header {
  padding: 10px 14px;
}

.forecast-rule-modal .rule-modal-header h2 {
  margin: 0 0 2px;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.forecast-rule-modal .rule-modal-header p {
  font-size: 12px;
}

.forecast-rule-modal .rule-modal-header > div:first-child {
  min-width: 0;
}

.forecast-rule-modal .eyebrow {
  display: none;
}

.forecast-rule-modal .modal-close {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
}

.forecast-rule-modal .rule-modal-form {
  padding: 9px 14px 12px;
}

.forecast-safety-strip {
  padding: 6px 8px;
  border-left: 3px solid #f59e0b;
  background: #fff7ed;
  color: #92400e;
  font-size: 12px;
  line-height: 1.35;
}

.forecast-tabs {
  display: flex;
  gap: 4px;
  margin: 8px 0;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.forecast-tab {
  min-height: 34px;
  padding: 7px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.forecast-tab.active {
  border-bottom-color: var(--blue);
  color: var(--text);
  font-weight: 600;
}

.forecast-tab-panel {
  min-height: 180px;
}

.forecast-tab-panel[hidden] {
  display: none;
}

.forecast-products-wrap {
  max-height: min(52vh, 560px);
}

.forecast-maximums-wrap {
  overflow: visible;
}

.forecast-products-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.forecast-settings-table {
  min-width: 0;
}

.forecast-settings-table th:first-child,
.forecast-settings-table td:first-child {
  width: 30%;
}

.forecast-settings-table th:nth-child(2),
.forecast-settings-table td:nth-child(2) {
  width: 17%;
}

.forecast-settings-table th:nth-child(3),
.forecast-settings-table td:nth-child(3) {
  width: 16%;
}

.forecast-maximums-table {
  min-width: 0;
}

.forecast-result-table {
  min-width: 0;
}

.forecast-products-table input,
.forecast-products-table select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.forecast-products-table th,
.forecast-products-table td {
  white-space: normal;
  overflow-wrap: anywhere;
}

.forecast-percent-source {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.forecast-percent-source.source-manual {
  color: #9a5a08;
}

.forecast-panel-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.forecast-schedule-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 8px;
}

.forecast-schedule-strip > div {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.forecast-schedule-strip span,
.forecast-schedule-strip small {
  color: var(--muted);
  font-size: 11px;
}

.forecast-schedule-strip strong,
.forecast-schedule-strip small {
  overflow-wrap: anywhere;
}

.forecast-bulk-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px auto auto;
  align-items: end;
  gap: 8px;
  margin: 0 0 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.forecast-bulk-controls .compact-field {
  margin: 0;
}

.prk-logistics-table td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.prk-logistics-table th:nth-child(1) {
  width: 72px;
}

.prk-logistics-table th:nth-child(2) {
  width: 108px;
}

.prk-logistics-table th:nth-child(5) {
  width: 150px;
}

.delivery-settings-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.delivery-settings-panel,
.supplier-minimum-panel {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.delivery-settings-panel .forecast-panel-note,
.supplier-minimum-panel .forecast-panel-note {
  justify-content: flex-start;
}

.delivery-schedule-source {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 10px;
  border-left: 3px solid #1f7a4f;
  background: #eef8f2;
}

.delivery-schedule-source span,
.delivery-days-field small {
  color: var(--muted);
}

.delivery-days-field {
  grid-column: 1 / -1;
}

.delivery-day-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.delivery-day-options label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.delivery-day-options input {
  width: 16px;
  min-width: 16px;
}

.delivery-time-fields,
.supplier-minimum-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.forecast-limit-groups {
  display: grid;
  gap: 8px;
}

.forecast-limit-group {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(220px, 1fr) 32px;
  align-items: end;
  gap: 8px;
}

.forecast-limit-value {
  margin: 0;
}

.forecast-store-picker {
  position: relative;
}

.forecast-store-picker summary {
  width: 100%;
  min-height: 36px;
  padding: 8px 28px 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  list-style: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forecast-store-picker summary::-webkit-details-marker {
  display: none;
}

.forecast-store-picker summary::after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 9px;
  color: var(--muted);
}

.forecast-store-options {
  position: absolute;
  z-index: 20;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  padding: 9px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 8px 20px rgb(15 23 42 / 14%);
}

.forecast-store-actions {
  position: sticky;
  top: -9px;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: -9px -9px 5px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.forecast-store-actions .button {
  min-height: 30px;
  padding: 5px 7px;
  white-space: normal;
}

.forecast-store-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  cursor: pointer;
}

.forecast-store-options label.disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.forecast-store-options input {
  width: 16px;
  min-width: 16px;
}

.forecast-limit-remove {
  width: 32px;
  height: 36px;
}

.forecast-limit-add {
  margin-top: 8px;
}

.dashboard-metric.ok {
  border-color: #b7e4c7;
}

.dashboard-metric.warn {
  border-color: #fdba74;
}

.dashboard-metric.bad {
  border-color: #fecaca;
}

.dashboard-metric small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.35;
}

.calculation-snapshot-state {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.calculation-snapshot-state.stale,
.calculation-snapshot-state.unavailable {
  color: #995a00;
}

.metric-tip {
  display: none;
  position: absolute;
  left: 10px;
  top: calc(100% + 8px);
  width: min(560px, calc(100vw - 300px));
  max-height: 380px;
  overflow: auto;
  z-index: 20;
  padding: 12px 14px;
  background: #111827;
  color: #f8fafc;
  border-radius: 8px;
  box-shadow: 0 16px 38px rgba(17, 24, 39, 0.24);
}

.dashboard-metric:not(.metric-split):hover > .metric-tip,
.dashboard-metric:not(.metric-split):focus > .metric-tip,
.metric-value-part:hover > .metric-tip,
.metric-value-part:focus > .metric-tip {
  display: block;
}

.metric-split-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.metric-split-values.has-overdue {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-split-values.parts-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-split-values.parts-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-split-values.parts-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-value-part {
  position: relative;
  min-width: 0;
  outline: none;
  cursor: help;
}

.metric-value-part strong {
  margin: 0;
  font-size: 24px;
  line-height: 1;
  text-decoration: underline dotted;
  text-underline-offset: 4px;
}

.metric-value-part small {
  margin-top: 7px;
  font-size: 11px;
}

.metric-value-part.warn strong {
  color: #b45309;
}

.metric-value-part.ok strong {
  color: #17633b;
}

.metric-value-part .metric-tip {
  left: 0;
  top: calc(100% + 8px);
  min-width: min(520px, calc(100vw - 300px));
}

.metric-tip strong {
  margin: 0 0 8px;
  font-size: 13px;
}

.metric-tip ul {
  margin: 0;
  padding-left: 18px;
}

.metric-tip li {
  margin: 0 0 6px;
  line-height: 1.35;
  white-space: normal;
}

.panel {
  margin-top: 12px;
  overflow: hidden;
}

.panel-header {
  padding: 11px 13px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 13px;
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-list.compact {
  gap: 6px;
}

.status-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.source-grid {
  display: grid;
  gap: 6px;
}

.source-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) auto 100px minmax(260px, 2fr);
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.source-footnote {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.cycle-matrix-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.cycle-top-scroll {
  position: sticky;
  top: 0;
  z-index: 8;
  width: 100%;
  height: 17px;
  margin-bottom: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
}

.cycle-top-scroll > div {
  height: 1px;
}

.cycle-horizon-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.cycle-horizon-control label {
  display: grid;
  grid-template-columns: auto minmax(120px, 220px) auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}

.cycle-horizon-control output,
.cycle-horizon-control small {
  color: var(--muted);
  font-size: 12px;
}

.cycle-actor-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
}

.cycle-actor-legend span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.cycle-order-pool {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid #efc273;
  border-radius: 7px;
  background: #fffaf0;
}

.cycle-order-pool-head,
.cycle-order-card-main,
.cycle-allocation-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.cycle-order-pool-head > div > strong,
.cycle-order-pool-head > div > span,
.cycle-order-card-main strong,
.cycle-order-card-main span,
.cycle-order-card-main small {
  display: block;
}

.cycle-order-pool-head > div > span,
.cycle-order-card-main span,
.cycle-order-card-main small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.cycle-order-pool-list {
  display: grid;
  gap: 8px;
  margin-top: 9px;
}

.cycle-order-pool-card {
  padding: 10px;
  border: 1px solid #e4c895;
  border-left: 4px solid #d88917;
  border-radius: 6px;
  background: #fff;
}

.cycle-order-pool-card.linked {
  border-left-color: #208653;
}

.cycle-order-card-state {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  align-items: center;
}

.cycle-order-suggestion {
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 5px;
  background: #eef6fd;
  font-size: 12px;
}

.cycle-order-suggestion strong,
.cycle-order-suggestion span {
  display: block;
}

.cycle-order-suggestion span {
  margin-top: 3px;
  color: var(--muted);
}

.cycle-order-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.cycle-order-links > span {
  padding: 5px 7px;
  border-radius: 5px;
  background: #edf9f2;
  color: #17633b;
  font-size: 12px;
}

.cycle-order-links .unlinked-text {
  background: #fff3dc;
  color: #995a00;
}

.cycle-order-allocation-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #ead8b8;
}

.cycle-allocation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.cycle-allocation-grid label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8fafc;
}

.cycle-allocation-grid label > span {
  font-size: 12px;
  font-weight: 600;
}

.cycle-allocation-grid label > small {
  color: var(--muted);
  font-size: 11px;
}

.cycle-allocation-grid input {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 82px;
}

.cycle-allocation-footer {
  margin-top: 9px;
  font-size: 12px;
}

.cycle-allocation-footer .invalid {
  color: #b42318;
  font-weight: 700;
}

.cycle-matrix {
  display: grid;
  align-items: stretch;
}

.cycle-matrix-corner,
.cycle-date-header {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #edf3f7;
}

.cycle-matrix-corner {
  left: 0;
  z-index: 5;
  font-weight: 700;
}

.cycle-date-header strong,
.cycle-date-header span {
  display: block;
}

.cycle-date-header span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.cycle-date-header.today {
  background: #dcf4e7;
  color: #17633b;
}

.cycle-row-label {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 0;
  padding: 11px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.cycle-row-label > strong,
.cycle-row-label > span,
.cycle-row-label > small {
  display: block;
}

.cycle-row-label > span,
.cycle-row-label > small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.cycle-label-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.cycle-correction-summary {
  margin-top: 9px;
  padding: 7px;
  border: 1px solid #f1c67b;
  border-radius: 6px;
  background: #fff8e8;
  font-size: 11px;
}

.cycle-correction-summary strong,
.cycle-correction-summary span,
.cycle-correction-summary em {
  display: block;
  margin-top: 2px;
  font-style: normal;
}

.cycle-correction-summary strong {
  margin: 0 0 4px;
  color: #8a570d;
}

.cycle-correction-summary .positive {
  color: #167746;
  font-weight: 700;
}

.cycle-correction-summary .negative {
  color: #b42318;
  font-weight: 700;
}

.cycle-day {
  min-height: 132px;
  padding: 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.cycle-day.empty {
  background: #fbfcfd;
}

.cycle-day.today {
  background: #f1faf5;
}

.cycle-day .cycle-step + .cycle-step {
  margin-top: 6px;
}

.cycle-day .cycle-step + .cycle-correction-card,
.cycle-day .cycle-correction-card + .cycle-step {
  margin-top: 6px;
}

.cycle-correction-card {
  padding: 9px;
  border: 1px solid #f1c67b;
  border-top: 3px solid #d88917;
  border-radius: 6px;
  background: #fff8e8;
}

.cycle-correction-card > strong {
  display: block;
  margin-bottom: 7px;
  color: #7a4a08;
}

.cycle-correction-event + .cycle-correction-event {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid #f1d9ad;
}

.cycle-correction-event b,
.cycle-correction-event span,
.cycle-correction-event small {
  display: block;
  font-size: 12px;
}

.cycle-correction-event span,
.cycle-correction-event small {
  margin-top: 2px;
  color: var(--muted);
}

.cycle-step {
  min-height: 112px;
  padding: 9px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  border-radius: 6px;
  background: #fff;
}

.cycle-step span,
.cycle-step small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.cycle-step strong {
  display: block;
  margin: 0 0 7px;
  line-height: 1.3;
}

.cycle-step.muted-step {
  border-top-color: var(--line);
  opacity: 0.65;
}

.cycle-step.completed {
  border-top-color: #94a3b8;
  background: #f8fafc;
}

.cycle-step.active {
  border-color: #86d7aa;
  border-top-color: #159455;
  background: #edf9f2;
  box-shadow: inset 0 0 0 1px #c6edd7;
}

.cycle-step.upcoming {
  border-top-color: #4f8bc9;
  background: #fff;
}

.cycle-step.actor-manager,
.cycle-actor-legend .actor-manager {
  border-color: #a8c7e8;
  border-top-color: #3979b8;
  background: #eef6fd;
}

.cycle-step.actor-supplier,
.cycle-actor-legend .actor-supplier {
  border-color: #9dd7b5;
  border-top-color: #21804b;
  background: #eef9f2;
}

.cycle-step.actor-courier,
.cycle-actor-legend .actor-courier {
  border-color: #e8c17c;
  border-top-color: #b7791f;
  background: #fff8e8;
}

.cycle-step.actor-cook,
.cycle-actor-legend .actor-cook {
  border-color: #d6b2d5;
  border-top-color: #8f4e8c;
  background: #fbf3fb;
}

.today-role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.today-role-column {
  min-width: 0;
  border: 1px solid #d8e2ec;
  border-top-width: 3px;
  padding: 10px;
  background: #fff;
}

.today-role-column.actor-manager { border-top-color: #3979b8; }
.today-role-column.actor-cook { border-top-color: #8f4e8c; }
.today-role-column.actor-courier { border-top-color: #b7791f; }

.today-role-column h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

@media (max-width: 720px) {
  .draft-readiness ul,
  .draft-delete-summary {
    grid-template-columns: 1fr;
  }
}

.today-task-groups {
  display: grid;
  gap: 8px;
}

.today-task-group {
  overflow: hidden;
  border: 1px solid #dfe7ef;
  border-radius: 6px;
  background: #fbfdff;
}

.today-task-group-head {
  display: flex;
  width: 100%;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 9px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.today-task-group-head > span:first-child {
  display: grid;
  gap: 2px;
  color: inherit;
}

.today-task-group-head:hover strong,
.today-task-group-head:focus-visible strong {
  color: var(--accent);
}

.today-task-group-body {
  display: grid;
  gap: 8px;
  padding: 0 9px 9px;
  border-top: 1px solid #e5ebf1;
}

.today-task-group-body ul {
  padding-top: 8px;
}

.today-task-group-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.today-role-column ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.today-role-column li {
  display: grid;
  gap: 2px;
  padding-top: 7px;
  border-top: 1px solid #e5ebf1;
}

.today-role-column li:first-child {
  padding-top: 0;
  border-top: 0;
}

.today-task-link {
  display: grid;
  width: 100%;
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.today-task-link:hover strong,
.today-task-link:focus-visible strong {
  color: var(--accent);
  text-decoration: underline;
}

.today-role-column span,
.today-role-column small {
  color: #65778a;
  line-height: 1.3;
}

.role-task-coverage {
  display: inline-flex;
  width: max-content;
  padding: 1px 6px;
  border-radius: 999px;
  background: #edf3f8;
  color: #52687c !important;
  font-weight: 700;
}

.role-task-coverage.confirmed {
  background: #e3f5e9;
  color: #21693b !important;
}

.role-task-coverage:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tomorrow-task-heading,
.tomorrow-courier-preview,
.tomorrow-courier-preview > div,
.tomorrow-courier-preview form {
  display: flex;
  align-items: center;
}

.tomorrow-task-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.tomorrow-task-heading strong {
  color: var(--text);
}

.tomorrow-courier-preview {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border: 1px dashed #d5a248;
  border-radius: 7px;
  background: #fffaf0;
}

.tomorrow-courier-preview > div {
  display: grid;
  flex: 1 1 240px;
  gap: 2px;
}

.tomorrow-courier-preview > div span,
.tomorrow-courier-preview > small {
  color: var(--muted);
  font-size: 12px;
}

.tomorrow-courier-preview form {
  flex: 2 1 430px;
  gap: 7px;
}

.tomorrow-courier-preview input {
  min-width: 0;
}

.tomorrow-courier-preview input[name="title"] {
  flex: 2 1 220px;
}

.tomorrow-courier-preview > small {
  flex-basis: 100%;
}

@media (max-width: 900px) {
  .today-role-grid {
    grid-template-columns: 1fr;
  }

  .cycle-horizon-control,
  .tomorrow-task-heading,
  .tomorrow-courier-preview form {
    align-items: stretch;
    flex-direction: column;
  }

  .cycle-horizon-control label {
    width: 100%;
    grid-template-columns: 1fr auto;
  }

  .cycle-horizon-control input {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }
}

.cycle-step.completed {
  filter: saturate(0.55);
}

.acceptance-state {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid currentColor;
  color: #17633b !important;
  font-weight: 600;
}

.cycle-actual {
  margin-top: 5px;
  color: #335a78 !important;
  font-weight: 600;
}

.cycle-mass-tip {
  position: relative;
  display: inline-block;
  margin-left: 3px;
  color: #174f77;
  border-bottom: 1px dotted currentColor;
  cursor: help;
}

.cycle-detail-tip {
  display: none;
  width: min(360px, calc(100vw - 48px));
  padding: 10px;
  border-radius: 6px;
  background: #111b2b;
  color: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.25);
  font-weight: 400;
}

.cycle-detail-tip-portal {
  position: fixed;
  z-index: 10010;
  display: block;
  max-height: calc(100vh - 24px);
  overflow: auto;
  pointer-events: none;
}

.cycle-detail-tip strong {
  margin-bottom: 7px;
}

.cycle-detail-tip ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cycle-detail-tip li {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  padding: 4px 0;
}

.cycle-order-detail-tip li {
  grid-template-columns: 82px 1fr;
}

.cycle-order-tip-trigger {
  margin-left: 0;
}

.acceptance-state.pending {
  color: #9a5a08 !important;
}

.acceptance-state.attention {
  color: #b42318 !important;
}

.allocation-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.allocation-enabled {
  grid-column: 1 / -1;
}

.primary-editor-list {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.primary-editor-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
}

.primary-editor-title strong,
.primary-editor-title span {
  display: block;
}

.primary-editor-title span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.primary-editor-row,
.auxiliary-editor-row {
  display: grid;
  grid-template-columns:
    minmax(190px, 1fr)
    minmax(240px, 1.25fr)
    minmax(180px, 0.65fr)
    minmax(125px, 0.42fr)
    minmax(130px, 0.48fr)
    34px;
  gap: 10px;
  align-items: end;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.primary-editor-row .field,
.primary-editor-row select,
.primary-editor-row input,
.auxiliary-editor-row .field,
.auxiliary-editor-row select {
  min-width: 0;
}

.auxiliary-editor-row {
  grid-column: 1 / -1;
  padding: 10px 0 0;
  border-top: 0;
}

.primary-remove {
  width: 34px;
  height: 34px;
  font-size: 20px;
}

.product-picker {
  grid-column: span 2;
}

.product-picker select[multiple] {
  min-height: 190px;
}

.allocation-save {
  justify-self: start;
}

.allocation-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
}

[hidden] {
  display: none !important;
}

.allocation-identifiers strong {
  text-align: right;
}

.max-stock-table {
  min-width: 1780px;
}

.max-stock-table th:first-child,
.max-stock-table td:first-child {
  width: 92px;
  text-align: center;
}

.max-stock-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.max-stock-table select {
  min-width: 210px;
  padding: 6px 8px;
}

.max-stock-table .table-head-filter {
  width: 100%;
  min-width: 0;
  margin-top: 6px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
}

.table-sort-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.table-sort-direction {
  color: var(--muted);
  font-size: 13px;
}

.max-stock-table input[type="number"] {
  min-width: 130px;
  padding: 6px 8px;
}

.max-stock-process {
  min-width: 270px;
  white-space: normal;
}

.max-stock-process strong,
.max-stock-process small {
  display: block;
}

.product-exception {
  display: grid;
  gap: 6px;
  min-width: 340px;
  padding: 8px;
  border: 1px solid var(--warning-line);
  background: var(--warning-bg);
}

.process-exception {
  background: var(--warning-bg);
  border-color: var(--warning-line);
}

.product-exception span {
  white-space: normal;
}

.product-exception input[type="number"] {
  min-width: 70px;
  width: 70px;
}

.max-stock-process small {
  margin-top: 4px;
  color: var(--muted);
}

.max-stock-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.max-stock-add-row select {
  min-width: min(620px, 70vw);
}

.exception-editor {
  display: grid;
  min-width: 310px;
  gap: 6px;
}

.exception-editor select {
  min-width: 0;
  width: 100%;
}

.threshold-field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.threshold-field input[type="number"] {
  min-width: 74px;
  width: 74px;
}

.result-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
}

.result-error {
  color: var(--red);
}

.max-stock-results-wrap {
  max-height: 520px;
  border: 1px solid var(--line);
}

.max-stock-results {
  min-width: 1080px;
}

.max-stock-results td:nth-child(2),
.max-stock-results td:nth-child(3) {
  white-space: normal;
  min-width: 220px;
}

.max-stock-results td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.max-stock-results .result-warning td {
  background: var(--warning-bg);
}

.max-stock-process-results {
  min-width: 900px;
}

.max-stock-results.max-stock-process-results td:nth-child(3),
.max-stock-results.max-stock-process-results td:nth-child(4) {
  min-width: 70px;
  white-space: nowrap;
}

.max-stock-process-results td:last-child {
  width: 1%;
  white-space: nowrap;
}

.max-stock-overview-table {
  min-width: 1040px;
  table-layout: fixed;
}

.max-stock-overview-table th:nth-child(1) {
  width: 25%;
}

.max-stock-overview-table th:nth-child(2) {
  width: 10%;
}

.max-stock-overview-table th:nth-child(3) {
  width: 16%;
}

.max-stock-overview-table th:nth-child(4) {
  width: 14%;
}

.max-stock-overview-table th:nth-child(5) {
  width: 17%;
}

.max-stock-overview-table th:nth-child(6) {
  width: 14%;
}

.max-stock-overview-table th:nth-child(7) {
  width: 44px;
}

.max-stock-overview-table td {
  vertical-align: middle;
  overflow-wrap: anywhere;
  white-space: normal;
}

.max-stock-overview-table td:nth-child(3),
.max-stock-overview-table td:nth-child(5) {
  white-space: normal;
}

.max-stock-overview-table .max-stock-process {
  min-width: 0;
}

.max-stock-overview-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.max-stock-overview-table .row-actions {
  width: 46px;
  text-align: center;
}

.settings-button {
  width: 34px;
  height: 34px;
  font-size: 17px;
}

.compact-actions {
  padding-top: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(15 23 42 / 48%);
}

.rule-modal {
  width: min(900px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgb(15 23 42 / 25%);
}

.dashboard-drilldown-modal {
  width: min(1460px, calc(100vw - 48px));
}

.dashboard-drilldown-modal-body {
  padding: 16px 20px 20px;
}

.dashboard-drilldown-table-wrap {
  max-height: calc(100vh - 190px);
}

.dashboard-drilldown-table {
  min-width: 1120px;
}

.dashboard-drilldown-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-2);
}

.dashboard-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.dashboard-table-primary-actions,
.dashboard-table-results,
.dashboard-table-filter-sort {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-table-filter-header {
  overflow: visible;
}

.dashboard-table-filter-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.dashboard-table-filter-trigger.active {
  color: var(--blue);
}

.dashboard-table-filter-active-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--blue);
}

.dashboard-table-filter-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(20, 32, 44, 0.2);
  color: var(--text);
  font-weight: 400;
}

.dashboard-table-filter-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-table-filter-sort .button.active {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
}

.dashboard-table-filter-search {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 12px;
}

.dashboard-table-filter-search label {
  display: grid;
  min-width: min(420px, 100%);
  flex: 1 1 320px;
  gap: 5px;
}

.dashboard-table-filter-search input {
  width: 100%;
  box-sizing: border-box;
}

.dashboard-table-filter-values {
  display: grid;
  max-height: 180px;
  gap: 5px;
  overflow: auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.dashboard-table-filter-values label {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 3px 1px;
  font-size: 13px;
  cursor: pointer;
}

.dashboard-table-filter-values input {
  margin-top: 2px;
}

.dashboard-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 190px;
}

.dashboard-row-actions .button {
  white-space: nowrap;
}

.forecast-approval-backdrop {
  z-index: 60;
}

.forecast-approval-modal {
  width: min(1500px, calc(100vw - 48px));
}

.forecast-approval-modal-body {
  display: grid;
  gap: 14px;
  padding: 16px 20px 20px;
}

.forecast-approval-selection {
  display: grid;
  max-height: min(55vh, 540px);
  gap: 8px;
  overflow: auto;
}

.forecast-approval-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

.forecast-approval-choice span,
.forecast-approval-choice small,
.forecast-approval-order header div,
.forecast-approval-order header small {
  display: block;
}

.forecast-approval-form,
.forecast-approval-order,
.forecast-approval-summary,
.forecast-approval-confirmation {
  display: grid;
  gap: 10px;
}

.forecast-approval-order {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.forecast-approval-order > header,
.forecast-approval-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.forecast-approval-table {
  min-width: 1180px;
}

.forecast-approval-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-2);
}

.forecast-approval-table td:first-child {
  min-width: 200px;
}

.forecast-confirmed-input {
  width: 130px;
}

.forecast-approval-formula {
  max-width: 360px;
  margin-top: 5px;
}

.forecast-approval-formula summary {
  color: var(--blue);
  cursor: pointer;
}

.forecast-approval-formula code {
  white-space: normal;
}

.forecast-approval-confirmation {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.rule-modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.rule-modal-header h2 {
  margin: 2px 0 4px;
  font-size: 20px;
}

.rule-modal-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.modal-close {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  font-size: 20px;
}

.rule-modal-form {
  padding: 18px 20px 20px;
}

.rule-modal .inline-check {
  align-items: flex-start;
  white-space: normal;
}

.rule-modal .inline-check input {
  flex: 0 0 auto;
  margin-top: 2px;
}

.rule-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.rule-span-2 {
  grid-column: 1 / -1;
}

.rule-modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-top: 18px;
}

.rule-modal-actions > div {
  display: flex;
  gap: 8px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.current-order-actions {
  justify-content: space-between;
}

.current-workspace-header {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.current-workspace-header h2 {
  margin: 3px 0 5px;
}

.current-workspace-header p {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
}

.current-workspace-header.compact {
  margin-top: 16px;
  padding: 12px 16px;
}

.current-workspace-header.compact h2 {
  margin: 0 0 3px;
  font-size: 18px;
}

.acceptance-panel-heading,
.acceptance-point-title,
.acceptance-breadcrumbs {
  display: flex;
  align-items: center;
}

.acceptance-panel-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.acceptance-panel-heading p {
  margin: 0;
  color: var(--muted);
}

.acceptance-point-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.acceptance-point-card {
  display: grid;
  gap: 12px;
  min-height: 126px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.acceptance-point-card:hover,
.acceptance-point-card:focus-visible {
  border-color: var(--blue);
  box-shadow: var(--shadow);
}

.acceptance-point-title {
  justify-content: space-between;
  gap: 10px;
}

.acceptance-point-title > strong {
  font-size: 17px;
}

.acceptance-point-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 12px;
  color: var(--muted);
  font-size: 12px;
}

.acceptance-point-metrics span {
  display: grid;
  gap: 2px;
}

.acceptance-point-metrics strong {
  color: var(--text);
  font-size: 18px;
}

.acceptance-point-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.acceptance-point-row {
  display: inline-flex;
  min-width: max-content;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  text-align: center;
  cursor: pointer;
}

.acceptance-point-row:hover,
.acceptance-point-row:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(29, 108, 181, 0.12);
}

.acceptance-point-row.active {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
}

.acceptance-point-row > span:first-child {
  min-width: 0;
  white-space: nowrap;
}

.acceptance-overdue-dot {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.acceptance-breadcrumbs {
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
}

.acceptance-breadcrumbs strong {
  color: var(--text);
}

.acceptance-order-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 0.45fr);
  gap: 10px;
  margin-bottom: 12px;
}

.order-card-breadcrumbs {
  padding: 12px 18px 0;
}

.order-card-breadcrumbs .button:last-child {
  margin-left: auto;
}

.order-card-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.order-card-summary > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}

.order-card-summary span {
  color: var(--muted);
  font-size: 11px;
}

.order-card-summary strong {
  overflow-wrap: anywhere;
}

.manual-order-primary-action {
  flex: 0 0 auto;
  min-height: 42px;
}

.current-workspace-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.current-workspace-tabs .button {
  flex: 0 0 auto;
}

.current-operations-dashboard {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.panel-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.panel-title-row h2 {
  margin: 3px 0 0;
}

.panel-title-row small {
  color: var(--muted);
}

.operation-metric-grid,
.operational-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}

.operation-metric {
  min-height: 78px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.operation-metric:hover,
.operation-point:hover,
.today-task:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow);
}

.operation-metric strong {
  display: block;
  margin-bottom: 5px;
  font-size: 24px;
}

.operation-metric span {
  color: var(--muted);
  font-size: 12px;
}

.operation-metric.warn {
  border-color: var(--warning-line);
  background: var(--warning-bg);
}

.operation-metric.bad {
  border-color: #fca5a5;
  background: #fef2f2;
}

.operational-counts {
  margin-bottom: 12px;
}

.operational-counts .operation-metric {
  min-height: 64px;
}

.operational-counts .operation-metric strong {
  font-size: 20px;
}

.operation-point-list,
.today-task-list,
.operation-summary-list {
  display: grid;
  gap: 7px;
}

.operation-point,
.today-task {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.operation-point span,
.today-task span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.operation-summary-list span {
  padding: 6px 0;
}

.current-supplemental {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.current-supplemental > summary {
  cursor: pointer;
  font-weight: 700;
}

.current-supplemental[open] > summary {
  margin-bottom: 14px;
}

.current-order-filters {
  grid-template-columns: minmax(240px, 1.2fr) minmax(260px, 1fr) minmax(180px, 0.6fr);
  margin-bottom: 10px;
}

.process-filter-header {
  position: relative;
  overflow: visible;
}

.process-filter-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.process-filter-trigger.active {
  color: var(--blue);
}

.process-filter-active-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--blue);
}

.process-filter-menu {
  position: absolute;
  z-index: 12;
  top: calc(100% - 2px);
  left: 8px;
  display: grid;
  width: min(330px, calc(100vw - 48px));
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(20, 32, 44, 0.2);
  color: var(--text);
  font-weight: 400;
}

.process-filter-sort-actions,
.process-filter-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.process-filter-sort-actions .button.active {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
}

.process-filter-search,
.process-filter-amount input {
  width: 100%;
  box-sizing: border-box;
}

.process-filter-list {
  display: grid;
  max-height: 240px;
  gap: 5px;
  overflow: auto;
}

.process-filter-option {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 4px 2px;
  font-size: 13px;
  cursor: pointer;
}

.process-filter-option input {
  margin-top: 2px;
}

.process-filter-amount {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.process-filter-amount label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.process-filter-amount .button {
  grid-column: 1 / -1;
  justify-self: start;
}

.current-orders-table {
  min-width: 980px;
}

.current-orders-table td {
  vertical-align: middle;
}

.current-orders-table td small,
.order-items-table td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.current-orders-table td:last-child {
  width: 82px;
  text-align: right;
}

.current-order-action-wrap,
.deficits-table-wrap {
  max-height: 540px;
  overflow: auto;
}

.current-order-action-table {
  min-width: 1500px;
}

.current-order-action-table th:last-child,
.current-order-action-table td:last-child {
  position: sticky;
  right: 0;
  min-width: 290px;
  background: var(--panel);
  box-shadow: -8px 0 12px rgba(20, 32, 44, 0.08);
}

.current-order-action-table th:last-child {
  z-index: 3;
  background: var(--panel-2);
}

.current-order-action-table td:last-child {
  z-index: 2;
}

.deficits-table {
  min-width: 1500px;
}

.current-order-row-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(108px, 1fr));
  gap: 6px;
}

.current-order-row-actions .button {
  white-space: nowrap;
}

.table-sort-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.table-sort-button:hover {
  color: var(--blue);
}

.decision-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.decision-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.decision-card > span:not(.badge) {
  color: var(--muted);
}

.current-process-orders-table {
  min-width: 1050px;
}

.current-process-orders-table th:nth-child(1) {
  width: 31%;
}

.current-process-orders-table th:nth-child(2) {
  width: 145px;
}

.current-process-orders-table th:nth-child(3) {
  width: 22%;
}

.current-process-orders-table th:nth-child(4),
.current-process-orders-table th:nth-child(5) {
  width: 165px;
}

.process-orders-modal {
  display: flex;
  width: min(1240px, calc(100vw - 48px));
  overflow: hidden;
  flex-direction: column;
}

.process-orders-modal-body {
  min-height: 0;
  padding: 16px 20px 20px;
  overflow: auto;
}

.process-card-refresh {
  display: grid;
  flex: 0 0 auto;
  gap: 3px;
  margin-left: auto;
  justify-items: end;
  color: var(--text);
  font-size: 13px;
}

.process-card-refresh small {
  color: var(--muted);
}

.process-card-refresh .button {
  margin-top: 5px;
}

.process-store-orders {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.process-store-order {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.process-store-order.attention {
  border-color: #e3b95d;
  background: #fffdf7;
}

.process-store-order > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 13px 16px;
  cursor: pointer;
}

.process-store-order > summary::marker {
  color: var(--muted);
}

.process-store-order > summary span {
  display: grid;
  gap: 3px;
}

.process-store-order > summary span:last-child {
  justify-items: end;
}

.process-store-order > summary small {
  color: var(--muted);
}

.process-store-order-body {
  padding: 0 16px 14px;
  border-top: 1px solid var(--line);
}

.process-order-items-wrap {
  max-height: 390px;
  margin-top: 14px;
  overflow: auto;
}

.process-order-items-table {
  min-width: 1080px;
}

.process-order-items-table th:first-child {
  width: 25%;
}

.process-order-items-table td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.process-forecast-value {
  position: relative;
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  border-bottom: 1px dotted var(--muted);
  cursor: help;
  outline: none;
  white-space: nowrap;
}

.process-forecast-value > strong {
  color: var(--accent);
  font-size: 15px;
}

.process-forecast-value > small {
  display: inline;
  margin: 0;
}

.process-forecast-tooltip {
  display: none;
  width: 310px;
  padding: 11px 13px;
  border-radius: 8px;
  background: #111827;
  box-shadow: 0 14px 32px rgb(15 23 42 / 28%);
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
}

.process-forecast-tooltip > span,
.process-forecast-tooltip > strong {
  display: block;
}

.process-forecast-tooltip > strong {
  margin-bottom: 5px;
}

.process-forecast-formula-total {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgb(248 250 252 / 24%);
}

.process-order-formula-total {
  margin-top: 6px;
  color: #bfdbfe;
}

.process-forecast-tooltip-portal {
  position: fixed;
  z-index: 10000;
  display: block;
  pointer-events: none;
}

.process-store-order-footer {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  color: var(--muted);
}

.process-order-inline-form {
  margin: 0;
}

.process-inline-quantity {
  width: 150px;
  grid-template-columns: 30px 82px 30px;
}

.process-inline-quantity input {
  width: 82px;
  height: 30px;
}

.process-inline-quantity .icon-button {
  width: 30px;
  height: 30px;
}

.process-quantity-recommendation {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  white-space: nowrap;
}

.process-order-inline-total {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.order-modal {
  display: flex;
  width: min(1180px, calc(100vw - 48px));
  overflow: hidden;
  flex-direction: column;
}

.order-modal-form {
  display: flex;
  min-height: 0;
  padding: 16px 20px 20px;
  flex-direction: column;
  overflow: auto;
}

.order-modal-loading {
  padding: 42px 20px;
  color: var(--muted);
  text-align: center;
}

.order-items-wrap {
  max-height: calc(100vh - 285px);
  overflow: auto;
}

.order-items-table {
  min-width: 860px;
}

.order-items-table th:nth-child(1) {
  width: 34%;
}

.order-items-table th:nth-child(4) {
  width: 190px;
}

.acceptance-quantity-input {
  width: 130px;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  text-align: right;
}

.delivery-workbench {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #e3b95d;
  border-radius: 8px;
  background: #fffaf0;
}

.delivery-workbench-heading {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.delivery-workbench-heading > div {
  display: grid;
  gap: 3px;
}

.delivery-workbench-heading span {
  color: var(--muted);
  font-size: 13px;
}

.delivery-sequence-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.delivery-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
}

.delivery-summary-grid > div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.delivery-summary-grid span {
  color: var(--muted);
  font-size: 12px;
}

.delivery-summary-grid strong {
  font-size: 17px;
}

.manual-order-preview-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(210px, 1fr));
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.manual-order-preview-form .button {
  align-self: end;
  justify-self: start;
}

.manual-order-composer-modal {
  display: flex;
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  box-sizing: border-box;
  overflow: hidden;
  overflow-x: hidden;
  flex-direction: column;
}

.manual-order-composer-modal .rule-modal-form {
  min-height: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
}

.manual-order-composer-modal .rule-modal-form > *,
.manual-order-form-grid > *,
.manual-order-technical-grid > * {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.manual-order-composer-modal input,
.manual-order-composer-modal select,
.manual-order-composer-modal textarea {
  max-width: 100%;
  box-sizing: border-box;
}

.manual-order-composer-modal .rule-modal-actions {
  position: sticky;
  z-index: 3;
  bottom: -20px;
  margin: 16px -20px -20px;
  padding: 12px 20px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.manual-order-composer-modal .rule-modal-actions > div {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.draft-bulk-actions,
.draft-row-actions,
.draft-duplicate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.local-drafts-table {
  min-width: 1180px;
}

.local-drafts-table td {
  vertical-align: top;
  white-space: normal;
}

.local-drafts-table td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.draft-readiness {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.draft-readiness-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.draft-readiness ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.draft-readiness li {
  display: flex;
  gap: 6px;
  color: var(--muted);
}

.draft-readiness li.ready {
  color: #17633b;
}

.draft-readiness p {
  margin: 0;
  color: var(--red);
}

.draft-delete-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.local-draft-delete-modal {
  width: min(720px, calc(100vw - 32px));
}

.manual-order-type {
  margin-bottom: 12px;
  color: var(--muted);
}

.manual-order-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.manual-supplier-field {
  grid-row: span 2;
}

.manual-supplier-field input[type="search"] {
  margin-bottom: 6px;
}

.field-error {
  color: var(--red) !important;
}

.manual-order-form-grid textarea {
  resize: vertical;
}

.manual-order-coverage {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.manual-order-coverage > div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.manual-order-coverage span {
  color: var(--muted);
  font-size: 12px;
}

.manual-order-coverage strong {
  font-size: 17px;
}

.manual-order-summary-line {
  margin: 2px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  overflow-wrap: anywhere;
}

.manual-excess-warning {
  margin: 0;
  overflow-wrap: anywhere;
}

.manual-excess-warning[hidden] {
  display: none !important;
}

.manual-excess-confirm {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 9px;
  font-weight: 700;
}

.manual-excess-confirm input {
  flex: 0 0 auto;
  margin-top: 2px;
}

.manual-excess-warning small {
  display: block;
  margin-top: 7px;
}

.manual-excess-warning small[hidden] {
  display: none;
}

.manual-order-technical {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.manual-order-technical > summary {
  cursor: pointer;
  font-weight: 700;
}

.manual-order-technical-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.technical-error-code,
.productive-disabled-note {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.productive-confirmation {
  display: grid;
  gap: 14px;
  padding: 18px;
  margin-top: 14px;
  border: 1px solid color-mix(in srgb, var(--red) 42%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--red) 5%, var(--surface));
}

.productive-confirmation h3 {
  margin: 0;
}

.productive-confirmation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.productive-confirmation-grid div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.productive-confirmation-grid span,
.productive-confirmation-actions small {
  color: var(--muted);
  font-size: 12px;
}

.productive-confirmation-grid strong {
  overflow-wrap: anywhere;
}

.productive-confirmation-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 700;
}

.productive-confirmation-check input {
  margin-top: 3px;
}

.productive-confirmation-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.writer-danger {
  border-color: color-mix(in srgb, var(--red) 45%, var(--line));
}

.rule-modal-actions > div {
  text-align: right;
}

.acceptance-main-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.acceptance-comment {
  margin-top: 12px;
}

.acceptance-result {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.acceptance-result-line {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.result-warning-text {
  color: var(--red);
}

.result-ok-text {
  color: var(--green);
}

.acceptance-technical .manual-order-technical-grid > div {
  display: grid;
  gap: 3px;
  overflow-wrap: anywhere;
}

.acceptance-technical .manual-order-technical-grid span {
  color: var(--muted);
  font-size: 12px;
}

.current-context-details {
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.current-context-details > summary {
  cursor: pointer;
  font-weight: 700;
}

.current-context-details > div,
.current-context-details > section {
  margin-top: 12px;
}

.rejection-preview-modal {
  width: min(720px, calc(100vw - 32px));
}

.rejection-preview-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.rejection-preview-summary > div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.rejection-preview-summary span,
.rejection-preview-summary strong {
  display: block;
}

.rejection-preview-summary span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.quantity-editor {
  display: grid;
  width: 174px;
  grid-template-columns: 34px 98px 34px;
  gap: 4px;
  align-items: center;
}

.quantity-editor input {
  width: 98px;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  text-align: right;
}

.quantity-editor .icon-button {
  width: 34px;
  height: 34px;
}

.order-total-bar {
  display: flex;
  gap: 26px;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}

.order-total-bar > div {
  display: grid;
  gap: 2px;
}

.order-total-bar span:not(.badge) {
  color: var(--muted);
  font-size: 12px;
}

.order-total-bar strong {
  font-size: 18px;
}

@media (max-width: 800px) {
  .current-workspace-header {
    align-items: stretch;
    flex-direction: column;
  }

  .decision-grid,
  .delivery-summary-grid,
  .manual-order-preview-form,
  .manual-order-form-grid,
  .manual-order-coverage,
  .manual-order-technical-grid,
  .rejection-preview-summary,
  .acceptance-order-filters,
  .order-card-summary {
    grid-template-columns: 1fr;
  }

  .panel-title-row,
  .operation-point,
  .today-task,
  .acceptance-panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .operation-point span,
  .today-task span {
    text-align: left;
  }
}

.product-rules-field {
  min-width: 0;
}

.product-rules-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.product-rules-heading > div {
  display: grid;
  gap: 3px;
}

.product-rules-heading span:not(.badge) {
  color: var(--muted);
  font-size: 12px;
}

.product-rules-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.product-rules-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.product-rules-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
}

.product-rules-table th,
.product-rules-table td {
  padding: 8px;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: anywhere;
}

.product-rules-table td:first-child {
  width: 26%;
}

.product-rules-table td:nth-child(2) {
  width: 18%;
}

.product-rules-table td:nth-child(3) {
  width: 13%;
}

.product-rules-table td:nth-child(4) {
  width: 15%;
}

.product-rules-table td:nth-child(5) {
  width: 20%;
}

.product-rules-table td:nth-child(6) {
  width: 8%;
}

.product-rules-table td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.product-rules-table select,
.product-rules-table input {
  width: 100%;
  min-width: 0;
}

.manual-action {
  display: block;
  margin-top: 5px;
  color: var(--red);
}

.result-action-notice {
  border-color: var(--warning);
  color: var(--red);
  font-weight: 600;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.two-col .panel {
  margin-top: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: #3d4d5d;
  font-size: 12px;
  z-index: 1;
}

td.wrap {
  white-space: normal;
  min-width: 240px;
}

.cell-input {
  min-width: 220px;
  padding: 6px 8px;
  font-size: 12px;
}

.message-input {
  min-width: 300px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.inline-check input {
  width: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e7eef6;
  color: #34495e;
  font-size: 12px;
}

.badge.ok {
  background: #dcfce7;
  color: var(--green);
}

.badge.warn {
  background: #ffedd5;
  color: var(--orange);
}

.badge.bad {
  background: #fee2e2;
  color: var(--red);
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--red);
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.notice {
  padding: 10px 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #8a4b13;
  border-radius: 8px;
  margin-bottom: 12px;
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .metric-split-values.parts-4,
  .metric-split-values.parts-5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-tip {
    width: min(520px, calc(100vw - 40px));
  }

  .filters {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .allocation-form {
    grid-template-columns: 1fr;
  }

  .allocation-enabled,
  .primary-editor-list,
  .auxiliary-editor-row,
  .product-picker {
    grid-column: auto;
  }

  .primary-editor-row,
  .auxiliary-editor-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .allocation-grid-spacer {
    display: none;
  }

  .primary-remove {
    justify-self: end;
  }

  .source-row {
    grid-template-columns: 1fr;
  }

  .forecast-schedule-strip {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 12px;
  }

  .allocation-form .inline-check {
    align-items: flex-start;
    white-space: normal;
  }

  .primary-editor-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-editor-row,
  .auxiliary-editor-row {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 8px;
  }

  .rule-modal {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .manual-order-composer-modal {
    width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
  }

  .rule-modal-header,
  .rule-modal-form {
    padding: 14px;
  }

  .rule-form-grid {
    grid-template-columns: 1fr;
  }

  .delivery-settings-fields,
  .delivery-time-fields,
  .supplier-minimum-fields,
  .forecast-limit-group,
  .forecast-bulk-controls {
    grid-template-columns: 1fr;
  }

  .forecast-limit-remove {
    justify-self: end;
  }

  .rule-span-2 {
    grid-column: auto;
  }

  .rule-modal-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .rule-modal-actions > div {
    justify-content: flex-end;
  }

  .manual-order-composer-modal .rule-modal-actions {
    bottom: -14px;
    margin: 14px -14px -14px;
    padding: 12px 14px 14px;
  }

  .section-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .process-orders-modal {
    width: calc(100vw - 16px);
  }

  .process-orders-modal .rule-modal-header {
    flex-wrap: wrap;
  }

  .process-card-refresh {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-items: start;
  }

  .process-orders-modal-body {
    padding: 12px;
  }

  .process-store-order > summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .process-store-order > summary span:last-child {
    justify-items: start;
  }

  .process-store-order-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .allocation-identifiers .status-row {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  }

  .allocation-identifiers strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .metric-split-values.parts-4,
  .metric-split-values.parts-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-split {
    position: relative;
  }

  .metric-split .metric-value-part {
    position: static;
  }

  .metric-split .metric-tip {
    left: 0;
    right: 0;
    width: auto;
    min-width: 0;
    max-width: 100%;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .nav {
    grid-template-columns: 1fr 1fr;
  }

  .productive-confirmation-grid {
    grid-template-columns: 1fr;
  }
}
