:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-elevated: #0f141b;
  --surface: #121821;
  --surface-strong: #171f2a;
  --surface-muted: #1b2430;
  --surface-hover: #202b38;
  --text: #eef3f8;
  --text-soft: #c4ced8;
  --muted: #8b98a8;
  --line: #263241;
  --line-strong: #344253;
  --green: #4da778;
  --green-soft: rgba(77, 167, 120, 0.16);
  --blue: #6aa7d8;
  --blue-soft: rgba(106, 167, 216, 0.14);
  --amber: #d8a24d;
  --amber-soft: rgba(216, 162, 77, 0.16);
  --red: #e07171;
  --red-soft: rgba(224, 113, 113, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  --field-bg: #0d131a;
  --placeholder: #667384;
  --header-bg: rgba(15, 20, 27, 0.92);
  --sidebar-bg: #0d131a;
  --body-glow: rgba(77, 167, 120, 0.08);
  --toolbar-bg: rgba(18, 24, 33, 0.72);
  --subtle-fill: rgba(255, 255, 255, 0.02);
  --row-fill: rgba(255, 255, 255, 0.018);
  --row-hover: rgba(255, 255, 255, 0.025);
  --active-text: #dceeff;
  --badge-text: #b9dcff;
  --warning-text: #f1c982;
  --primary-text: #b9f0d1;
  --danger-text: #ffb8b8;
}

body.light-mode {
  color-scheme: light;
  --bg: #eef2f6;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-strong: #f9fbfd;
  --surface-muted: #f1f5f9;
  --surface-hover: #e8eef5;
  --text: #111827;
  --text-soft: #243244;
  --muted: #5f6f82;
  --line: #d5dde8;
  --line-strong: #b9c5d4;
  --green: #27764e;
  --green-soft: rgba(39, 118, 78, 0.1);
  --blue: #236a9a;
  --blue-soft: rgba(35, 106, 154, 0.1);
  --amber: #96610f;
  --amber-soft: rgba(150, 97, 15, 0.11);
  --red: #b93636;
  --red-soft: rgba(185, 54, 54, 0.09);
  --shadow: 0 12px 30px rgba(20, 32, 48, 0.08);
  --field-bg: #ffffff;
  --placeholder: #8a95a3;
  --header-bg: rgba(255, 255, 255, 0.94);
  --sidebar-bg: #ffffff;
  --body-glow: rgba(35, 106, 154, 0.08);
  --toolbar-bg: rgba(255, 255, 255, 0.78);
  --subtle-fill: rgba(36, 50, 68, 0.035);
  --row-fill: #ffffff;
  --row-hover: rgba(35, 106, 154, 0.055);
  --active-text: #164f78;
  --badge-text: #175b86;
  --warning-text: #83540d;
  --primary-text: #1e6543;
  --danger-text: #9d2c2c;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at top left, var(--body-glow), transparent 30vw),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.toast-stack {
  display: grid;
  gap: 10px;
  max-width: min(420px, calc(100vw - 24px));
  pointer-events: none;
  position: fixed;
  right: 16px;
  top: 92px;
  width: 100%;
  z-index: 80;
}

.toast {
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  pointer-events: auto;
}

.toast strong {
  font-size: 13px;
}

.toast p {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.35;
  margin: 0;
  white-space: pre-line;
}

.toast.success {
  border-left-color: var(--green);
}

.toast.warning {
  border-left-color: var(--amber);
}

.toast.error {
  border-left-color: var(--red);
}

.modal-root {
  align-items: center;
  background: rgba(0, 0, 0, 0.52);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 90;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-height: min(680px, calc(100vh - 36px));
  max-width: min(520px, 100%);
  overflow: auto;
  padding: 18px;
  width: 100%;
}

.modal-card h3 {
  color: var(--text);
  font-size: 18px;
  margin: 0;
}

.modal-card p {
  color: var(--text-soft);
  line-height: 1.45;
  margin: 0;
  white-space: pre-line;
}

.modal-card label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

button,
select,
input {
  font: inherit;
}

button {
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

input,
select {
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 34px;
  outline: none;
  padding: 7px 9px;
  width: 100%;
}

input::placeholder {
  color: var(--placeholder);
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(106, 167, 216, 0.12);
}

.login-screen {
  align-items: center;
  background: var(--bg);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: linear-gradient(180deg, var(--surface-strong), var(--surface));
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-width: 380px;
  padding: 28px;
  width: 100%;
}

.login-card img {
  height: 58px;
  justify-self: start;
  object-fit: contain;
}

.login-card h1 {
  font-size: 22px;
  margin: 0;
}

.login-card label,
.form-grid label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
}

.remember-login {
  align-items: center;
  color: var(--text-soft);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  justify-content: start;
  line-height: 1.25;
}

.remember-login input {
  accent-color: var(--green);
  flex: 0 0 auto;
  height: 18px;
  margin: 0;
  min-height: auto;
  width: 18px;
}

.app-header {
  align-items: center;
  backdrop-filter: blur(18px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 74px;
  padding: 14px 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header h1,
.toolbar h2 {
  color: var(--text);
  font-size: 21px;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 2px 0 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.role-switcher {
  align-items: center;
  color: var(--text-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.role-switcher label {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
}

.role-switcher select {
  width: auto;
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 74px);
  transition: grid-template-columns 0.16s ease;
}

.sidebar-collapsed .layout {
  grid-template-columns: 70px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 10px;
  position: sticky;
  top: 74px;
  height: calc(100vh - 74px);
  overflow: auto;
}

.sidebar button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text-soft);
  cursor: pointer;
  display: flex;
  min-height: 34px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.sidebar-toggle {
  background: var(--surface-muted) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  font-weight: 850;
  justify-content: center;
  margin-bottom: 8px;
}

.sidebar-collapsed .sidebar button:not(.sidebar-toggle) {
  font-size: 0;
  justify-content: center;
  padding: 8px 4px;
}

.sidebar-collapsed .sidebar button:not(.sidebar-toggle)::before {
  content: attr(data-short);
  font-size: 12px;
  font-weight: 900;
}

.sidebar-collapsed .sidebar-toggle {
  font-size: 12px;
  padding-inline: 4px;
}

.sidebar button:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.sidebar button.active {
  background: var(--blue-soft);
  border-color: color-mix(in srgb, var(--blue) 26%, transparent);
  color: var(--active-text);
  font-weight: 850;
}

.content {
  min-width: 0;
  padding: 18px;
}

.toolbar {
  align-items: center;
  background: var(--toolbar-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 14px;
}

.view {
  display: none;
  min-width: 0;
}

.active-view {
  display: block;
}

.metric-grid,
.panel-grid {
  display: grid;
  gap: 12px;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin-bottom: 12px;
}

.panel-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.metric,
.panel,
.form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 118px;
  padding: 18px;
}

.metric span {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-icon {
  align-items: center;
  background: var(--blue-soft);
  border: 1px solid color-mix(in srgb, var(--blue) 24%, transparent);
  border-radius: 6px;
  color: var(--badge-text);
  display: inline-flex;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  min-width: 30px;
  padding: 0 6px;
}

.metric[data-metric-tone="purchase"] .metric-icon {
  background: var(--subtle-fill);
  border-color: var(--line);
  color: var(--text-soft);
}

.metric[data-metric-tone="cost"] .metric-icon,
.trend-legend .cost {
  background: var(--blue-soft);
  border-color: color-mix(in srgb, var(--blue) 24%, transparent);
  color: var(--badge-text);
}

.metric[data-metric-tone="revenue"] .metric-icon,
.metric[data-metric-tone="success"] .metric-icon,
.trend-legend .revenue {
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 24%, transparent);
  color: var(--primary-text);
}

.metric[data-metric-tone="danger"] .metric-icon {
  background: var(--red-soft);
  border-color: color-mix(in srgb, var(--red) 24%, transparent);
  color: var(--danger-text);
}

.metric strong {
  color: var(--text);
  display: block;
  font-size: 32px;
  line-height: 1.15;
  margin-top: 11px;
}

.metric-trend {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 850;
  margin-top: 9px;
}

.metric-trend.up {
  color: var(--primary-text);
}

.metric-trend.down {
  color: var(--danger-text);
}

.metric-trend.flat {
  color: var(--muted);
}

.panel {
  padding: 14px;
}

.dashboard-trend-panel {
  margin-bottom: 12px;
  padding: 16px;
}

.dashboard-trend-header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.trend-legend span {
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 8px;
}

.trend-chart {
  display: block;
  height: 190px;
  margin-top: 8px;
  width: 100%;
}

.trend-grid line {
  stroke: var(--line);
  stroke-dasharray: 4 5;
}

.trend-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.trend-line.revenue {
  stroke: var(--green);
}

.trend-line.cost {
  stroke: var(--blue);
}

.trend-hotspot {
  cursor: help;
  fill: color-mix(in srgb, var(--text) 8%, transparent);
  stroke: color-mix(in srgb, var(--text) 22%, transparent);
  stroke-width: 1;
}

.trend-hotspot:hover {
  fill: color-mix(in srgb, var(--green) 24%, transparent);
  stroke: var(--green);
}

.trend-labels text {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-anchor: middle;
}

.panel h3,
.form-panel h3 {
  color: var(--text);
  font-size: 15px;
  margin: 0 0 10px;
}

.muted-text {
  color: var(--muted);
  margin: 0 0 10px;
}

.empty-dashboard-state {
  background: var(--subtle-fill);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text-soft);
  font-weight: 800;
  margin: 0;
  padding: 10px 12px;
}

.stock-detail-panel {
  margin-top: 12px;
}

.planego-tabs-panel {
  margin-bottom: 12px;
}

.planego-control-tabs button {
  min-width: 170px;
}

.planego-missing-price,
.stock-equivalent-warning {
  color: #ff8f8f;
  font-weight: 800;
}

.form-panel {
  margin-bottom: 12px;
  padding: 14px;
}

.dashboard-filter-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  padding: 12px;
}

.edit-panel {
  border-color: rgba(77, 167, 120, 0.55);
  box-shadow: 0 0 0 1px rgba(77, 167, 120, 0.08), var(--shadow);
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  min-width: 0;
}

.dashboard-filter-main {
  align-items: center;
  display: grid;
  gap: 9px;
  grid-template-columns: auto minmax(180px, 1.2fr) minmax(170px, 1fr) minmax(120px, 0.7fr) auto;
  min-width: 0;
}

.dashboard-filter-main label,
.dashboard-custom-dates label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 5px;
  min-width: 0;
}

.dashboard-filter-main button {
  align-self: end;
  min-height: 34px;
}

.site-pill {
  align-self: end;
  background: var(--subtle-fill);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  min-height: 34px;
  padding: 8px 12px;
  white-space: nowrap;
}

.dashboard-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.dashboard-quick-actions button {
  min-height: 30px;
  padding: 6px 9px;
}

.dashboard-custom-dates {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  margin-top: 9px;
}

.filter-check-grid {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-right: 2px;
}

.filter-check-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-check-grid.weeks {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.search-field {
  display: block;
  position: relative;
}

.search-field input {
  padding-right: 38px;
  width: 100%;
}

.search-icon-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--blue);
  cursor: pointer;
  display: inline-flex;
  font-size: 15px;
  height: calc(100% - 2px);
  justify-content: center;
  min-height: 30px;
  position: absolute;
  right: 1px;
  top: 1px;
  width: 34px;
}

.search-icon-button:hover {
  background: var(--surface-hover);
}

.unit-checks {
  align-items: center;
  background: var(--subtle-fill);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 9px;
}

.unit-checks strong {
  color: var(--text-soft);
  font-size: 12px;
}

.unit-checks label,
.inline-check {
  align-items: center;
  color: var(--text-soft);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  line-height: 1.25;
}

.unit-checks input,
.inline-check input {
  accent-color: var(--green);
  flex: 0 0 auto;
  height: 16px;
  margin: 0;
  min-height: auto;
  width: 16px;
}

.bulk-check {
  background: var(--subtle-fill);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 34px;
  padding: 7px 10px;
}

.form-actions {
  align-items: end;
  display: flex;
}

.list {
  display: grid;
  gap: 8px;
}

.list-row {
  align-items: center;
  background: var(--row-fill);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 9px 10px;
}

.badge {
  background: var(--blue-soft);
  border: 1px solid color-mix(in srgb, var(--blue) 22%, transparent);
  border-radius: 999px;
  color: var(--badge-text);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  padding: 4px 7px;
}

.badge.warning {
  background: var(--amber-soft);
  border-color: color-mix(in srgb, var(--amber) 24%, transparent);
  color: var(--warning-text);
}

.badge.success {
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 24%, transparent);
  color: var(--primary-text);
}

.email-status-cell {
  display: grid;
  gap: 4px;
  min-width: 130px;
  white-space: normal;
}

.data-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-collapse: separate;
  border-radius: var(--radius);
  border-spacing: 0;
  box-shadow: var(--shadow);
  min-width: min(760px, 100%);
  width: 100%;
}

.table-shell {
  border-radius: var(--radius);
  margin-bottom: 12px;
  max-width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

.data-table td {
  color: var(--text-soft);
  font-size: 13px;
}

.data-table .col-number {
  text-align: right;
}

.data-table .col-actions {
  min-width: 140px;
}

.order-lines-summary {
  display: grid;
  gap: 6px;
  min-width: 360px;
}

.compact-document-lines {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 220px;
}

.compact-document-lines .order-lines-summary {
  flex: 1 1 100%;
  margin-top: 2px;
}

.compact-detail-button {
  min-height: 28px;
  padding: 5px 9px;
}

.single-article-label {
  color: var(--text-soft);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.order-line-summary {
  align-items: center;
  background: var(--subtle-fill);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(190px, 1fr) minmax(132px, auto) minmax(116px, auto) minmax(72px, auto);
  padding: 7px 8px;
}

.order-line-article {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.order-line-article strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
  white-space: normal;
}

.order-line-article span {
  color: var(--muted);
  font-size: 11px;
}

.order-line-detail,
.order-line-quantity,
.order-line-prices {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
}

.order-line-prices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.order-line-prices span {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  padding: 3px 7px;
}

.order-line-quantity {
  text-align: right;
}

.data-table tr:hover td {
  background: var(--row-hover);
  color: var(--text);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table input,
.data-table select {
  min-height: 30px;
}

.action-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.primary-action,
.secondary-action,
.danger {
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  min-height: 34px;
  padding: 7px 11px;
}

.primary-action {
  background: var(--green-soft);
  border: 1px solid color-mix(in srgb, var(--green) 35%, transparent);
  color: var(--primary-text);
}

.primary-action:hover {
  background: color-mix(in srgb, var(--green) 18%, transparent);
  border-color: color-mix(in srgb, var(--green) 52%, transparent);
}

.danger {
  background: var(--red-soft);
  border: 1px solid color-mix(in srgb, var(--red) 28%, transparent);
  color: var(--danger-text);
}

.secondary-action {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  color: var(--text-soft);
}

.secondary-action:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--text);
}

.danger:hover {
  background: color-mix(in srgb, var(--red) 16%, transparent);
  border-color: color-mix(in srgb, var(--red) 46%, transparent);
}

.primary-action:disabled,
.secondary-action:disabled,
.danger:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

body.light-mode .primary-action {
  border-color: rgba(47, 139, 93, 0.28);
  color: #1f6f49;
}

body.light-mode .primary-action:hover {
  background: rgba(47, 139, 93, 0.18);
  border-color: rgba(47, 139, 93, 0.44);
}

body.light-mode .danger {
  border-color: rgba(191, 66, 66, 0.24);
  color: #a83232;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .dashboard-filter-main {
    grid-template-columns: auto repeat(3, minmax(150px, 1fr)) auto;
  }
}

@media (max-width: 900px) {
  .app-header,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar-collapsed .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    align-items: center;
    border-bottom: 1px solid var(--line);
    border-right: 0;
    display: flex;
    flex-direction: row;
    gap: 8px;
    height: 64px !important;
    min-height: 64px;
    max-height: 64px;
    overflow-y: hidden;
    overflow-x: auto;
    padding: 10px 12px;
    position: static;
    scrollbar-width: thin;
  }

  .sidebar button {
    align-self: center;
    flex: 0 0 auto;
    font-size: inherit;
    height: 44px;
    max-height: 44px;
    min-height: 40px;
    padding: 8px 12px;
    text-align: center;
    white-space: nowrap;
    width: auto;
  }

  .sidebar-toggle {
    display: none !important;
  }

  .sidebar-collapsed .sidebar button:not(.sidebar-toggle) {
    font-size: inherit;
    padding: 8px 12px;
  }

  .sidebar-collapsed .sidebar button:not(.sidebar-toggle)::before {
    content: none;
  }

  .content {
    padding: 12px;
  }

  .form-grid,
  .dashboard-filter-main,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .filter-check-grid,
  .filter-check-grid.compact,
  .filter-check-grid.weeks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-pill,
  .dashboard-filter-main button {
    justify-self: stretch;
    text-align: center;
  }

  .role-switcher {
    justify-content: flex-start;
    width: 100%;
  }

  .role-switcher label {
    flex: 1 1 190px;
  }

  .role-switcher select {
    min-width: 120px;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .toast-stack {
    left: 12px;
    max-width: calc(100vw - 24px);
    right: 12px;
    top: 12px;
  }

  .modal-root {
    align-items: end;
    padding: 10px;
  }

  .modal-card {
    max-height: calc(100vh - 20px);
    padding: 16px;
  }

  body {
    background: var(--bg);
  }

  .login-screen {
    padding: 14px;
  }

  .login-card {
    border-radius: 8px;
    padding: 20px;
  }

  .app-header {
    padding: 12px;
  }

  .app-header h1,
  .toolbar h2 {
    font-size: 18px;
  }

  .toolbar,
  .form-panel,
  .panel,
  .metric {
    padding: 12px;
  }

  input,
  select,
  .primary-action,
  .secondary-action,
  .danger {
    min-height: 42px;
  }

  .form-actions,
  .action-row,
  .import-actions {
    align-items: stretch;
    width: 100%;
  }

  .form-actions > button,
  .action-row > button,
  .import-actions > button {
    flex: 1 1 140px;
  }

  .import-actions > .bulk-check {
    flex: 1 1 180px;
    min-height: 42px;
  }

  .list-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .table-shell {
    overflow: visible;
  }

  .data-table {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    min-width: 0;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    overflow: hidden;
  }

  .data-table td {
    align-items: flex-start;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    min-height: 38px;
    padding: 9px 10px;
    text-align: left;
    white-space: normal;
  }

  .data-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 10px;
    font-weight: 900;
    line-height: 1.25;
    text-transform: uppercase;
  }

  .data-table td.col-actions {
    display: block;
    min-width: 0;
  }

  .data-table td.col-actions::before {
    display: block;
    margin-bottom: 7px;
  }

  .data-table .col-number {
    text-align: left;
  }

  .order-lines-summary {
    min-width: 0;
  }

  .compact-document-lines {
    min-width: 0;
  }

  .order-line-summary {
    gap: 6px;
    grid-template-columns: 1fr;
  }

  .order-line-quantity {
    text-align: left;
  }

  .data-table tr:last-child td {
    border-bottom: 1px solid var(--line);
  }

  .data-table tr td:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 460px) {
  .content {
    padding: 10px;
  }

  .sidebar {
    padding-inline: 10px;
  }

  .role-switcher > span,
  .role-switcher > label,
  .role-switcher > button {
    flex: 1 1 100%;
  }

  .data-table td {
    grid-template-columns: 1fr;
  }

  .data-table td::before {
    margin-bottom: -2px;
  }

  .data-table .col-optional {
    display: none;
  }
}
