:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --panel: #ffffff;
  --ink: #000000;
  --muted: #5f5f5b;
  --line: #deded8;
  --line-strong: #c7c7bf;
  --soft: #eeeeea;
  --accent: #000000;
  --brand-accent: #f88051;
  --sidebar-bg: #000000;
  --accent-2: #8c5a16;
  --accent-3: #232323;
  --danger: #a61b14;
  --ok: #177345;
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-collapsed: 80px;
  --sidebar-expanded: 260px;
  --shadow: none;
  --title-font: "Big Shoulders Display", Impact, "Arial Narrow", sans-serif;
  --body-font: Chivo, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--body-font);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  font-size: 14px;
}

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

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius-sm);
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

button:hover {
  background: #000;
  color: #fff;
  border-color: #000;
  transform: none;
}

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

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

.sidebar {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 16px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-collapsed);
  height: 100vh;
  height: 100dvh;
  z-index: 5;
  display: grid;
  grid-template-rows: 150px minmax(0, 1fr) auto;
  gap: 14px;
  overflow: hidden;
  transition: width 0.2s ease, box-shadow 0.2s ease;
}

.sidebar:hover,
.sidebar:focus-within {
  width: var(--sidebar-expanded);
  box-shadow: 18px 0 40px rgba(0, 0, 0, 0.16);
}

.brand {
  display: grid;
  justify-items: stretch;
  align-content: stretch;
  height: 150px;
  padding: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.brand-collapsed,
.brand-expanded {
  min-width: 0;
}

.brand-collapsed {
  display: grid;
  place-items: center;
  width: var(--sidebar-collapsed);
  height: 100%;
  justify-self: start;
}

.brand-collapsed img {
  display: block;
  height: auto;
  width: 36px;
  max-width: 36px;
  border-radius: 0;
  object-fit: contain;
}

.brand-expanded {
  display: none;
  grid-template-rows: minmax(0, 112px) auto;
  gap: 4px;
  place-items: center;
  align-content: center;
  height: 100%;
  width: var(--sidebar-expanded);
  margin-inline: 0;
  text-align: center;
}

.sidebar:hover .brand,
.sidebar:focus-within .brand {
  justify-items: stretch;
  height: 150px;
}

.sidebar:hover .brand-collapsed,
.sidebar:focus-within .brand-collapsed {
  display: none;
}

.sidebar:hover .brand-expanded,
.sidebar:focus-within .brand-expanded {
  display: grid;
}

.brand-expanded img {
  display: block;
  width: 112px;
  max-width: 112px;
  height: auto;
  filter: invert(1);
}

.brand-expanded span {
  color: #d8d8d2;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-stack {
  display: grid;
  min-width: 0;
  min-height: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 8px;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
  scrollbar-width: thin;
}

.nav-stack::-webkit-scrollbar {
  width: 6px;
}

.nav-stack::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

.nav {
  display: grid;
  align-content: start;
  gap: 6px;
  margin-top: 0;
  grid-area: 1 / 1;
}

.nav button {
  color: #fff;
  background: transparent;
  border-color: transparent;
  border-radius: 10px;
  text-align: left;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 0;
  font-size: 12px;
  text-transform: uppercase;
  position: relative;
}

.nav-collapsed {
  display: grid;
  width: var(--sidebar-collapsed);
}

.nav-expanded {
  display: none;
}

.sidebar:hover .nav-collapsed,
.sidebar:focus-within .nav-collapsed {
  display: none;
}

.sidebar:hover .nav-expanded,
.sidebar:focus-within .nav-expanded {
  display: grid;
}

.nav-collapsed button {
  display: grid;
  place-items: center;
  width: var(--sidebar-collapsed);
  padding: 0;
}

.nav-expanded button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 9px;
  width: calc(var(--sidebar-expanded) - 24px);
  margin: 0 12px;
  padding: 0 10px 0 0;
}

.nav button.active::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--brand-accent);
  opacity: 1;
}

.nav-collapsed button.active::before {
  display: none;
}

.nav button:hover,
.nav button.active {
  color: #fff;
  background: transparent;
  border-color: transparent;
  transform: none;
}

.nav-expanded button:hover,
.nav-expanded button.active {
  background: rgba(255, 255, 255, 0.09);
}

.nav button span:first-child {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  font-size: 12px;
  line-height: 1;
  justify-self: center;
}

.nav button.active span:first-child,
.nav button:hover span:first-child {
  background: var(--brand-accent);
  color: #000;
}

.nav-expanded button span:last-child {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  justify-self: start;
  transition: opacity 0.14s ease, max-width 0.2s ease;
}

.sidebar:hover .nav-expanded button span:last-child,
.sidebar:focus-within .nav-expanded button span:last-child {
  opacity: 1;
  max-width: 180px;
}

.cloud-status {
  align-self: end;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  margin-top: 0;
  padding: 14px 8px 0;
  display: none;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}

.sidebar:hover .cloud-status,
.sidebar:focus-within .cloud-status {
  display: grid;
  opacity: 1;
  pointer-events: auto;
}

.cloud-status span,
.cloud-status small {
  overflow-wrap: anywhere;
}

.cloud-status small {
  color: #d8d8d2;
}

.cloud-status button {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}

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

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 14px;
}

.login-panel h1 {
  margin: 0;
}

.login-logo {
  display: block;
  width: min(260px, 100%);
  height: auto;
}

.login-panel p {
  color: var(--muted);
  margin: 6px 0 0;
}

.auth-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fafbf9;
  display: grid;
  gap: 4px;
}

.auth-box h2 {
  font-size: 18px;
  margin: 0;
}

.auth-box p {
  margin: 0;
  font-size: 13px;
}

.main {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
  grid-column: 2;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.title h1 {
  margin: 0;
  font-family: var(--title-font);
  font-size: clamp(34px, 4vw, 54px);
  line-height: 0.9;
  text-transform: uppercase;
  letter-spacing: 0;
}

.title p {
  margin: 6px 0 0;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.actions-spacer {
  flex: 1 1 auto;
}

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

.primary:hover {
  background: #fff;
  color: #000;
}

.ghost {
  background: transparent;
}

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

.mobile-menu-button,
.mobile-menu-scrim {
  display: none;
}

.mobile-menu-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  align-self: start;
}

.mobile-menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

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

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

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

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

.panel,
.metric,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
  min-width: 0;
  max-width: 100%;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
}

.panel-head h2 {
  font-family: var(--title-font);
  font-size: 28px;
  line-height: 0.95;
  text-transform: uppercase;
}

.panel-head h3 {
  font-family: var(--title-font);
  font-size: 23px;
  line-height: 1;
  text-transform: uppercase;
}

.metric {
  padding: 14px;
  min-height: 104px;
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-family: var(--title-font);
  font-size: 42px;
  line-height: 0.9;
}

.metric small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: minmax(200px, 1.4fr) repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.purchase-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.purchase-tab-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.purchase-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.purchase-tabs button {
  min-height: 34px;
}

.purchase-tab-list button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.purchase-select-cell {
  width: 42px;
  text-align: right;
}

.purchase-check {
  width: 15px;
  height: 15px;
  min-height: 0;
  padding: 0;
  accent-color: var(--ink);
}

.icon-button {
  width: 34px;
  min-width: 34px;
  padding: 0;
  text-align: center;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 82px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

label span {
  color: var(--muted);
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: #000;
  background: #eeeeea;
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

tr:hover td {
  background: #f6f6f2;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  background: var(--soft);
  color: var(--accent-3);
  white-space: nowrap;
  max-width: 100%;
}

.pill.ok {
  color: var(--ok);
  background: #e6f6ed;
}

.pill.warn {
  color: var(--accent-2);
  background: #fff1eb;
}

.pill.danger {
  color: var(--danger);
  background: #fff0ee;
  border: 0;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(7, minmax(185px, 1fr));
  gap: 12px;
  overflow: auto;
  max-width: 100%;
  padding-bottom: 6px;
}

.lane {
  border: 1px solid var(--line);
  background: #f9faf8;
  border-radius: 8px;
  padding: 10px;
  min-height: 250px;
}

.lane h3 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin: 0 0 10px;
  font-size: 14px;
}

.order-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
}

.order-card strong {
  font-size: 14px;
}

.order-card small {
  color: var(--muted);
}

.order-card .pill {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
  width: fit-content;
}

.lane-pager {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  gap: 6px;
  align-items: center;
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.lane-pager button {
  min-height: 30px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.item-pick-pill {
  align-items: center;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  border: 1px solid rgba(16, 32, 30, 0.18);
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font-weight: 700;
  line-height: 1.2;
}

.workflow-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
  overflow: auto;
  padding-bottom: 6px;
  align-items: start;
}

.workflow-column {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eeeeea;
  padding: 8px;
  min-height: 260px;
  align-self: start;
}

.workflow-column-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.workflow-column-head h3 {
  margin: 0;
  font-family: var(--title-font);
  font-size: 22px;
  line-height: 0.95;
  text-transform: uppercase;
}

.workflow-column-head small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.workflow-cards {
  display: grid;
  gap: 8px;
  align-content: start;
  align-items: start;
  justify-items: stretch;
}

.workflow-order-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  overflow: hidden;
  width: 100%;
}

.workflow-order-card summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  padding: 8px;
  cursor: pointer;
  list-style: none;
}

.workflow-order-card summary::-webkit-details-marker {
  display: none;
}

.workflow-order-card summary strong,
.workflow-order-card summary small {
  display: block;
}

.workflow-order-card summary small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workflow-order-card summary button {
  flex: 0 0 auto;
}

.workflow-progress {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 10px 10px;
}

.workflow-items {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #fbfcfa;
}

.workflow-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: #fff;
}

.workflow-item-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.2;
}

.workflow-item-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.workflow-item-row button {
  min-width: 88px;
}

.workflow-item-actions {
  display: grid;
  gap: 6px;
  align-self: stretch;
  align-content: end;
}

.orders-list {
  display: grid;
  gap: 12px;
}

.order-group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: clip;
}

.order-group summary {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px;
  cursor: pointer;
  list-style: none;
}

.order-group summary::-webkit-details-marker {
  display: none;
}

.order-group summary strong,
.order-group summary span {
  display: block;
}

.order-group summary span {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.summary-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: end;
}

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

.item-card {
  border: 1px solid var(--line);
  background: #fbfcfa;
  border-radius: var(--radius-sm);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.item-card span,
.order-meta {
  color: var(--muted);
  font-size: 13px;
}

.mini-status {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.order-meta {
  border-top: 1px solid var(--line);
  padding: 10px 14px 14px;
}

.linked-payments {
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 13px;
}

.linked-payments span {
  color: var(--muted);
  background: var(--soft);
  border-radius: 999px;
  padding: 4px 9px;
}

.inline-head {
  margin-top: 18px;
}

.editor-items {
  display: grid;
  gap: 12px;
}

.editor-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfa;
}

.compact-table table {
  min-width: 520px;
}

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

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

.variables-grid textarea {
  min-height: 138px;
  resize: vertical;
  line-height: 1.35;
}

.edit-table input {
  min-height: 32px;
  padding: 6px 28px 6px 8px;
}

.edit-cell {
  position: relative;
  display: block;
}

.edit-cell::after {
  content: "✎";
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.edit-cell:hover::after,
.edit-cell:focus-within::after {
  opacity: 1;
}

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

.form-grid .wide {
  grid-column: span 2;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 18, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
  overscroll-behavior: contain;
}

.modal {
  width: min(980px, 100%);
  max-height: 92vh;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
  padding: 18px;
}

.order-editor-modal {
  padding-bottom: 0;
}

.editor-sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 16px -18px 0;
  padding: 12px 18px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), var(--panel) 28%);
  border-top: 1px solid var(--line);
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) minmax(96px, auto);
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 12px;
  background: var(--soft);
  border-radius: 999px;
  overflow: hidden;
}

.bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.bar.negative {
  background: var(--danger);
}

.net-bar.net-positive {
  background: var(--ok);
}

.net-bar.net-negative {
  background: var(--danger);
}

.positive-text {
  color: var(--ok);
}

.breakdown {
  display: grid;
  grid-template-columns: minmax(150px, 0.35fr) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.pie-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.pie {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 8px solid #fff;
  box-shadow: inset 0 0 0 1px var(--line), 0 8px 18px rgba(15, 23, 42, 0.08);
}

.pie.expense {
  filter: saturate(0.95);
}

.pie-total {
  display: grid;
  justify-items: center;
  gap: 2px;
  text-align: center;
}

.pie-total span {
  color: var(--muted);
  font-size: 12px;
}

.pie-total strong {
  font-size: 16px;
}

.negative-text {
  color: var(--danger);
}

.danger-text {
  color: var(--danger);
}

.success-text {
  color: var(--ok);
}

.period-filter {
  display: grid;
  grid-template-columns: minmax(150px, auto) repeat(2, minmax(130px, auto));
  gap: 8px;
  align-items: center;
}

.finance-filters {
  grid-template-columns: minmax(220px, 1.4fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr);
  margin-bottom: 14px;
}

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

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

.report-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.finance-table {
  min-width: 860px;
}

.stock-table {
  min-width: 820px;
}

.stock-table th:nth-child(n + 3),
.stock-table td:nth-child(n + 3) {
  text-align: right;
  white-space: nowrap;
}

.stock-table code,
.compact-table code {
  font-size: 12px;
  white-space: nowrap;
}

.stock-row td:first-child {
  border-left: 4px solid transparent;
}

.stock-row.stock-ok td:first-child {
  border-left-color: var(--ok);
}

.stock-row.stock-warn td:first-child {
  border-left-color: var(--accent-2);
}

.stock-row.stock-danger td:first-child {
  border-left-color: var(--danger);
}

.stock-accordion .receive-group > summary {
  border-left: 4px solid transparent;
}

.stock-manual-table {
  min-width: 900px;
}

.stock-manual-table th:nth-child(4),
.stock-manual-table td:nth-child(4) {
  width: 110px;
}

.finance-hint {
  margin: 12px 0 0;
  font-size: 13px;
}

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

.accounting-table th,
.accounting-table td {
  white-space: nowrap;
}

.total-row td {
  background: #f2f6f3;
  border-top: 2px solid var(--line);
}

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

.receive-table {
  min-width: 720px;
}

.receive-table input {
  width: 92px;
}

.receive-accordion {
  display: grid;
  gap: 10px;
}

.receive-group,
.receive-color {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  overflow: hidden;
}

.receive-group summary,
.receive-color summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
}

.receive-group summary::-webkit-details-marker,
.receive-color summary::-webkit-details-marker {
  display: none;
}

.receive-group summary::before,
.receive-color summary::before {
  content: "+";
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  color: var(--accent);
  background: #fff;
  flex: 0 0 auto;
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1;
  text-align: center;
}

.receive-group[open] > summary::before,
.receive-color[open] > summary::before {
  content: "-";
}

.receive-group summary > span:first-of-type,
.receive-color summary > span:first-of-type {
  flex: 1 1 auto;
}

.receive-colors {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.receive-color {
  background: #fff;
}

.receive-color .table-wrap {
  border-width: 1px 0 0;
  border-radius: 0;
}

.receive-size-table {
  min-width: 640px;
}

.quote-result {
  display: grid;
  gap: 12px;
}

.quote-lines {
  display: grid;
  gap: 12px;
}

.quote-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.quote-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  font-weight: 700;
}

.quote-option input {
  width: 16px;
  height: 16px;
}

.quote-total {
  background: #000;
  color: white;
  border-radius: var(--radius);
  padding: 18px;
}

.quote-total span {
  color: #b9c8c4;
}

.quote-total strong {
  display: block;
  font-size: 34px;
  margin-top: 4px;
}

.danger-metric {
  border-color: #ffb4aa;
  background: #fff5f3;
}

.danger-metric strong {
  color: var(--danger);
}

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

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    width: auto;
    padding: 10px;
    z-index: 8;
    grid-template-rows: auto auto;
  }

  .sidebar:hover,
  .sidebar:focus-within {
    width: auto;
    box-shadow: none;
  }

  .main {
    grid-column: auto;
    padding-bottom: 96px;
  }

  .brand {
    grid-template-columns: auto 1fr;
    align-items: center;
    height: auto;
    padding: 0 2px 10px;
  }

  .brand-collapsed {
    display: none;
  }

  .brand-expanded {
    display: grid;
    width: 100%;
  }

  .brand-expanded img {
    width: 122px;
    max-width: 122px;
  }

  .brand-expanded span {
    justify-self: end;
  }

  .nav-collapsed {
    display: none;
  }

  .nav-expanded {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .nav-expanded button {
    flex: 0 0 auto;
    width: auto;
    min-height: 38px;
    white-space: nowrap;
    justify-content: start;
    display: flex;
    padding: 0 10px;
    grid-template-columns: none;
  }

  .nav-expanded button span:last-child {
    opacity: 1;
    max-width: none;
  }

  .cloud-status {
    display: none;
  }

  .filters,
  .finance-filters,
  .breakdown,
  .cost-edit-grid,
  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .production-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 14px 10px 20px;
    gap: 12px;
  }

  .topbar,
  .panel-head {
    display: grid;
  }

  .nav,
  .filters,
  .finance-filters,
  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .production-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(82vw, 292px);
    height: 100vh;
    height: 100dvh;
    padding: 14px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-top: 0;
    transform: translateX(-104%);
    transition: transform 0.2s ease;
    z-index: 20;
  }

  .app-shell.menu-open .sidebar {
    transform: translateX(0);
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.18);
  }

  .brand {
    display: grid;
    justify-items: start;
    grid-template-columns: 1fr;
    height: auto;
    padding: 8px 4px 14px;
  }

  .brand-expanded img {
    width: 156px;
    max-width: 156px;
  }

  .brand-expanded span {
    justify-self: start;
  }

  .nav-collapsed {
    display: none;
  }

  .nav-expanded {
    display: grid;
    overflow: visible;
    padding-bottom: 0;
  }

  .nav-expanded button {
    width: 100%;
    min-width: 0;
    justify-content: start;
    display: flex;
    min-height: 44px;
    padding: 0 12px;
    font-size: 12px;
    grid-template-columns: none;
  }

  .nav-expanded button span:first-child {
    display: inline-grid;
  }

  .nav-expanded button span:last-child {
    opacity: 1;
    max-width: none;
  }

  .cloud-status {
    display: grid;
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu-scrim {
    display: none;
    position: fixed;
    inset: 0;
    border: 0;
    border-radius: 0;
    min-height: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.32);
    z-index: 15;
  }

  .mobile-menu-scrim:hover {
    background: rgba(0, 0, 0, 0.32);
    transform: none;
  }

  .app-shell.menu-open .mobile-menu-scrim {
    display: block;
  }

  .mobile-menu-button {
    display: inline-grid;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
  }

  .title h1 {
    font-size: 40px;
  }

  .title {
    min-width: 0;
  }

  .actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .actions button {
    flex: 1 1 auto;
  }

  .metric {
    min-height: 88px;
  }

  .metric strong {
    font-size: 36px;
  }

  .workflow-board {
    grid-template-columns: repeat(5, minmax(82vw, 1fr));
  }

  .form-grid .wide {
    grid-column: auto;
  }

  .kanban {
    grid-template-columns: repeat(7, 82vw);
  }

  .stock-manual-table {
    min-width: 760px;
  }

  .order-group summary,
  .summary-actions {
    display: grid;
    justify-content: stretch;
  }

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