:root {
  --pine: #14342c;
  --pine-deep: #0e241f;
  --moss: #2f6b52;
  --copper: #b5683a;
  --copper-dark: #8d4c28;
  --paper: #f4efe6;
  --glass: #e7f0ea;
  --ink: #1b241f;
  --muted: #5c6b63;
  --line: #d4ddd6;
  --white: #fffcf7;
  --shadow: 0 10px 30px rgba(20, 52, 44, 0.08);
  --radius: 14px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --tap: 44px;
  --sidebar: 250px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 80% -10%, rgba(47, 107, 82, 0.12), transparent 60%),
    var(--paper);
}
img, svg, canvas, video { max-width: 100%; }
button, a, input, select, textarea { touch-action: manipulation; }

a { color: var(--moss); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}
html.nav-collapsed .shell { grid-template-columns: minmax(0, 1fr); }
html.nav-collapsed .sidebar { display: none; }

.sidebar {
  background: linear-gradient(180deg, var(--pine-deep), var(--pine));
  color: #e7f0ea;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand, .brand-login {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.brand strong, .brand-login strong { display: block; font-size: 1.05rem; letter-spacing: 0.04em; }
.brand small, .brand-login small { color: #b7c9c0; }
.brand-mark { color: #e3c39a; }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  color: #d7e6de;
  text-decoration: none;
  padding: 12px 14px;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  border-radius: 10px;
}
.nav a.is-active, .nav a:hover {
  background: rgba(255,255,255,0.08);
  color: white;
  text-decoration: none;
}

.sidebar-foot { margin-top: auto; font-size: 0.9rem; color: #b7c9c0; }
.sidebar-foot .linkish { min-height: var(--tap); display: inline-flex; align-items: center; }
.linkish {
  background: none;
  border: 0;
  color: #e3c39a;
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.linkish:hover { text-decoration: underline; }

.main { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,252,247,0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-start {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  flex: 0 0 auto;
}
.nav-toggle:hover { border-color: var(--moss); }
.nav-toggle-icon {
  width: 18px;
  height: 14px;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 50% / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 100% / 100% 2px no-repeat;
}
.nav-backdrop { display: none; }
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.lang-switch, .price-switch, .org-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.lang-switch label, .price-switch label, .org-switch label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.org-switch { flex: 1 1 220px; }
.org-switch select { min-width: 0; flex: 1 1 auto; }
.choice-entry {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.choice-entry legend { font-weight: 650; }
.choice-entry ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; gap: 16px; flex-wrap: wrap; }
.choice-entry li label, .choice-entry label { display: flex; align-items: center; gap: 6px; font-weight: 600; }

.qty-field {
  width: 4.75rem;
  min-width: 4.75rem;
  text-align: right;
  padding: 6px 8px;
  appearance: textfield;
  -moz-appearance: textfield;
}
.qty-field::-webkit-outer-spin-button,
.qty-field::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}
.component-search { position: relative; margin-bottom: 14px; }
.component-search-bar { margin-bottom: 0; }
.component-search-bar .field { min-width: min(320px, 100%); flex: 1; }
.component-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 12;
  list-style: none;
  margin: 0;
}
.component-results button,
.component-matches li {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.component-results button:hover { background: var(--glass); }
.component-matches {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.component-matches li {
  cursor: default;
  border: 1px solid var(--line);
  background: var(--white);
}
.component-matches li > div { flex: 1; min-width: 0; }
table.components .thumb-cell { width: 56px; }
.login-lang { margin-top: 12px; }
select,
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
textarea,
.field {
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: var(--tap);
  color: var(--ink);
  max-width: 100%;
}
select:focus,
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
textarea:focus,
.field:focus {
  outline: 2px solid rgba(47,107,82,0.35);
  border-color: var(--moss);
}
input[type="checkbox"],
input[type="radio"] {
  width: 1.1rem;
  height: 1.1rem;
  min-width: 1.1rem;
  min-height: 1.1rem;
  margin: 0;
  padding: 0;
  flex: none;
  accent-color: var(--moss);
}

.content { padding: 28px; max-width: 1280px; }
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--copper);
  margin: 0 0 6px;
}
h1 { margin: 0 0 6px; font-size: 1.9rem; letter-spacing: -0.02em; }
.lede { margin: 0; color: var(--muted); max-width: 62ch; }
.page-sku {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 650;
  font-family: var(--mono);
  letter-spacing: 0;
}
.lede a { color: var(--moss); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.record-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--line);
}
.record-tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 10px 16px;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.record-tabs a:hover { color: var(--ink); text-decoration: none; }
.record-tabs a.is-active {
  color: var(--pine);
  border-bottom-color: var(--moss);
}
.history-action {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--glass);
  color: var(--pine);
}
.history-action-viewed { color: var(--muted); }
.history-action-edited,
.history-action-note { color: var(--moss); }
.history-action-status { color: var(--copper-dark); background: #f7ece4; }
.history-action-created { color: var(--pine); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  min-height: var(--tap);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--moss); }
.btn-primary {
  background: var(--moss);
  border-color: var(--moss);
  color: white;
}
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat-grid.compact { grid-template-columns: repeat(4, 1fr); }
.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat span { color: var(--muted); font-size: 0.85rem; }
.stat strong { display: block; font-size: 1.6rem; margin: 4px 0; }
.stat small { color: var(--muted); }
.stat .invoice-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  border-bottom: 1px solid currentColor;
}
.stat .invoice-link:hover { color: var(--ink); }
.stat-multi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 1.05rem !important;
  font-family: var(--mono);
}
.page-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
}
.page-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px 10px;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.page-tab:hover { color: var(--ink); }
.page-tab.is-active {
  color: var(--moss);
  border-bottom-color: var(--moss);
}
.chart-panel-wide { grid-column: 1 / -1; }
.chart-panel-wide canvas { height: 320px !important; }
.period-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.chart-panel { margin-bottom: 0; }
.chart-panel canvas { width: 100%; height: 280px !important; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; }

.split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
.choice-split {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: stretch;
}
.choice-split .panel { margin: 0; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

.table-wrap { overflow-x: visible; max-width: 100%; }
table.data { width: 100%; border-collapse: collapse; table-layout: auto; }
table.data th {
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
}
table.data td {
  padding: 10px;
  border-bottom: 1px solid #edf1ee;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.num { text-align: right; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.strong { font-weight: 650; color: var(--ink); overflow-wrap: anywhere; }
.tiny { color: var(--muted); font-size: 0.85rem; }
.muted { color: var(--muted); }
.empty { padding: 20px; color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.78rem;
  background: var(--glass);
  color: var(--pine);
}
.badge-lg { padding: 6px 12px; font-size: 0.9rem; }
.badge-processing, .badge-ok { background: #dcefe4; color: #1c5a3c; }
.badge-completed, .badge-finished { background: #e4eee8; color: #35584a; }
.badge-on-hold, .badge-pending, .badge-warn { background: #f8ead7; color: #8a4f1c; }
.badge-in-production { background: #d8efe8; color: #1c5a3c; }
.badge-sent { background: #dce4f8; color: #1a4e8c; }
.badge-cancelled, .badge-failed, .badge-trash, .badge-error { background: #f8dcd8; color: #8a2e24; }
.badge-refunded { background: #e6e4f2; color: #433a78; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.filters .field,
.filters input:not([type="checkbox"]):not([type="radio"]),
.filters select {
  min-width: min(100%, 160px);
  flex: 1 1 160px;
}
.filter-popup { position: relative; flex: 0 1 auto; }
.filter-popup-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 180px;
  max-width: 260px;
  min-height: var(--tap);
  font: inherit;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.filter-popup-toggle:hover, .filter-popup-toggle[aria-expanded="true"] {
  border-color: var(--moss);
}
.filter-popup-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  flex: 0 0 auto;
}
.filter-popup-summary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}
.filter-popup-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: min(22rem, calc(100vw - 24px));
  max-height: 280px;
  overflow: auto;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.filter-popup-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--ink);
  cursor: pointer;
}
.filter-popup-option:hover { background: var(--glass); }
.filter-popup-option input {
  margin: 0.15rem 0 0;
  flex: none;
}
.filter-popup-option span {
  min-width: 0;
  flex: 1 1 auto;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.address-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.address-icon { color: var(--moss); flex: 0 0 auto; }
.address-split { grid-template-columns: 1fr 1fr; }
.autotranslated {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--glass);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  vertical-align: middle;
}

.store-status { list-style: none; margin: 0; padding: 0; }
.store-status li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf1ee;
}
.store-status small { display: block; color: var(--muted); }

.meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.meta-chips li {
  background: var(--glass);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.78rem;
}

.kv { margin: 0; }
.kv > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #edf1ee;
  min-width: 0;
}
.kv dt { color: var(--muted); flex: 0 0 auto; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.kv .grand { font-weight: 700; }
.address { font-style: normal; line-height: 1.45; }
.address-block { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.maps-link { margin-top: 2px; }
.plain { margin: 0; padding-left: 18px; }
.note p { margin: 8px 0 0; }
.price-entry-compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: 0 0 14px;
  padding: 6px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.price-entry-compact legend {
  padding: 0 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
.price-entry-compact ul {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.price-entry-compact li { margin: 0; }
.invoice-preview { margin-top: 14px; }
.live-search { position: relative; }
.selected-customer { margin: 0 0 12px; }
.line-remove { white-space: nowrap; }
.line-remove input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
[data-line-row][hidden] { display: none; }
.note-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.note-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--white);
}
.note-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.note-body { white-space: pre-wrap; margin: 0; }
.note-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.company-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.company-card .kv > div { align-items: flex-start; }
.company-card .kv dd { text-align: right; }
.company-card h2 { display: flex; align-items: center; gap: 8px; }
.shop-links h2 { font-size: 1rem; margin: 0 0 8px; }
.form-grid label, .stack label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.has-error input, .has-error select, .has-error textarea { border-color: #c45c4b; }
.field-error { color: #a33a2c; font-size: 0.85rem; }
.sku-field {
  display: flex;
  gap: 8px;
  align-items: center;
}
.sku-field .field { flex: 1; min-width: 0; }
.sku-field .btn { flex: 0 0 auto; white-space: nowrap; }
.inline { flex-direction: row !important; align-items: center; gap: 8px !important; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.inline-actions { display: flex; gap: 8px; margin-top: 12px; }

.messages { padding: 12px 28px 0; }
.flash {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.flash-success { background: #dcefe4; }
.flash-error, .flash-error { background: #f8dcd8; }
.flash-warning { background: #f8ead7; }

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 16px;
}
.pager a,
.pager .pager-current,
.pager .pager-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}
.pager a:hover {
  border-color: var(--moss);
  text-decoration: none;
}
.pager .pager-current {
  background: var(--moss);
  border-color: var(--moss);
  color: #fff;
}
.pager .pager-ellipsis {
  border: 0;
  background: transparent;
  min-width: 1.4rem;
  padding: 0 4px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.12em;
}
.pager .pager-prev,
.pager .pager-next {
  padding: 0 14px;
}
.pill {
  background: var(--glass);
  border-radius: 999px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(160deg, var(--pine-deep), var(--pine) 45%, #1d4f40);
}
.login-card {
  width: min(420px, 92vw);
  background: var(--white);
  color: var(--ink);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.18);
}
.login-card h1 { margin: 18px 0 6px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-card input { width: 100%; }

code { font-family: var(--mono); font-size: 0.85em; }

.btn-ghost {
  background: transparent;
}
.btn-compact {
  padding: 8px 14px;
  font-size: 0.95rem;
  border-radius: 8px;
  min-height: var(--tap);
}
.btn-compact.is-open {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.catalog .thumb-cell { width: 64px; }
.thumb-stack {
  display: flex;
  align-items: center;
  gap: 6px;
}
.thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--glass);
  display: block;
}
.thumb-lg {
  width: 56px;
  height: 56px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 10px;
}
.thumb-empty {
  background: repeating-linear-gradient(45deg, #e7f0ea, #e7f0ea 6px, #f4efe6 6px, #f4efe6 12px);
}
.catalog-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.catalog-expand td {
  background: #f7faf8;
  padding: 8px 12px 14px 48px;
}
.expand-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nested-table { background: var(--white); border-radius: 10px; }
.catalog-row.is-nested td { background: transparent; }
.price-sale { color: var(--copper-dark); font-weight: 650; }
.flag {
  display: inline-block;
  width: 28px;
  height: 21px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(20, 52, 44, 0.18);
  flex: 0 0 auto;
  max-width: none;
  background: #d9e2dc;
  vertical-align: middle;
}
.flag-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  max-width: 11rem;
}
.num.shops-cell {
  text-align: right;
}
.num.shops-cell .flag-group {
  justify-content: flex-end;
}
.shop-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.country-cell {
  width: 3.2rem;
  text-align: center;
}
.status-cell,
.status-cell .badge {
  white-space: nowrap;
  overflow-wrap: normal;
}
.order-status-form .badge {
  white-space: nowrap;
}
.order-total {
  white-space: nowrap;
  overflow-wrap: normal;
}
.order-total .tiny {
  margin-top: 2px;
}
.order-expand-toggle svg { transition: transform 0.15s ease; }
.order-expand-toggle.is-open svg { transform: rotate(90deg); }
.order-expand-toggle.is-open {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

h1 .thumb-lg { margin-bottom: 0; }

.order-expand { margin-bottom: 12px; }
.prod-cell { overflow: visible; }
.prod-form {
  margin: 0;
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.prod-status {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  min-width: 9.4rem;
  min-height: var(--tap);
  text-align: center;
}
.prod-status[aria-expanded="true"] { box-shadow: 0 0 0 2px rgba(47, 107, 82, 0.28); }
.prod-status.is-frozen, .prod-status[aria-disabled="true"] { cursor: default; opacity: 0.82; }
.prod-pending_approval { background: #f8ead7; color: #8a4f1c; }
.prod-approved { background: #d4e4f8; color: #1a4e8c; }
.prod-in_production { background: #d8efe8; color: #1c5a3c; }
.prod-completed { background: #e4eee8; color: #35584a; }
.prod-popup-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 16rem;
  width: max-content;
  max-width: min(22rem, calc(100vw - 16px));
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.prod-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.prod-option:disabled { opacity: 0.55; cursor: not-allowed; }
.prod-option:disabled:hover { background: transparent; }
.order-status-form {
  margin: 0;
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.order-status-form .badge {
  cursor: pointer;
  font: inherit;
  border: 0;
}
.order-status-form .badge[aria-expanded="true"] { box-shadow: 0 0 0 2px rgba(47, 107, 82, 0.28); }
.prod-option.is-selected { background: #e7f0ea; }
.prod-option-label { font-size: 0.9rem; font-weight: 650; }
.prod-option-help { font-size: 0.75rem; color: var(--muted); line-height: 1.3; }
.warehouse-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  color: var(--moss);
  vertical-align: -2px;
}
.stock-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 24px;
}
.stock-modal[hidden] { display: none; }
.stock-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 36, 31, 0.48);
}
.stock-modal-panel {
  position: relative;
  width: min(42rem, 100%);
  max-height: 80vh;
  overflow: auto;
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  z-index: 1;
}
.stock-source-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.stock-source-heading .stock-source-name {
  font-size: 1.05rem;
}
.stock-source-ordered,
.stock-source-help {
  margin: 6px 0 0;
}
.stock-source-row fieldset {
  margin: 8px 0 0;
  border: 0;
  padding: 0;
}
.stock-source-use {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7f8f6;
}
.stock-source-kind {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--moss);
  margin-bottom: 4px;
}
.stock-source-name {
  font-weight: 650;
  line-height: 1.3;
}
.stock-source-sku {
  margin-top: 2px;
  font-size: 0.85rem;
  color: var(--muted);
}
.stock-source-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 600;
}
.stock-source-qty-field {
  width: 4.6rem;
  min-height: 2.6rem;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
}
.stock-source-qty-unit {
  color: var(--muted);
  font-size: 0.85rem;
}
.shipment-table {
  width: 100%;
}
.shipment-table th:first-child,
.shipment-table td:first-child {
  width: 2.2rem;
  text-align: center;
}
.shipment-tracking {
  display: grid;
  gap: 4px;
}
.shipment-tracking small {
  color: var(--muted);
}
.line-items .thumb-cell { width: 56px; }
.line-items-wrap { overflow-x: auto; }
.line-items {
  min-width: 70rem;
}
.line-items th,
.line-items td.line-sku,
.line-items td.line-attr,
.line-items td.line-qty {
  white-space: nowrap;
  overflow-wrap: normal;
}
.line-items td.line-qty {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.bundle-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  border: 0;
  background: transparent;
  color: var(--moss);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  padding: 0;
}
.bundle-toggle svg { transition: transform 0.15s ease; }
.bundle-toggle.is-open svg { transform: rotate(90deg); }
.bundle-expand td {
  background: #f7faf8;
  padding: 8px 12px 14px 48px;
}
.bundle-panel { max-width: 100%; }
.bundle-panel .muted { margin: 0 0 10px; }
.bundle-add { margin-top: 12px; max-width: 420px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--moss);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: var(--glass); }
.icon-btn-danger { color: var(--copper-dark); }
.bundle-actions { white-space: nowrap; width: 1%; }
.bundle-component-row.is-editing [data-qty-display],
.bundle-component-row.is-editing [data-component-edit],
.bundle-component-row.is-editing [data-component-remove] { display: none; }
.bundle-component-row.is-editing [data-qty-input],
.bundle-component-row.is-editing [data-component-done] { display: inline-flex; }
.bundle-component-row.is-editing [data-qty-input] { display: inline-block; }

@media (max-width: 1100px) {
  .stat-grid, .stat-grid.compact, .chart-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1023px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  html.nav-collapsed .sidebar { display: flex; }
  html.nav-js .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(20rem, 90vw);
    height: 100dvh;
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    overflow: auto;
    padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }
  html.nav-js.nav-open .sidebar { transform: none; }
  html.nav-js .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(14, 36, 31, 0.48);
    z-index: 30;
  }
  html.nav-js.nav-open .nav-backdrop { display: block; }
  .topbar, .content, .messages {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .topbar {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .topbar-start, .topbar-meta {
    width: 100%;
    flex-wrap: wrap;
  }
  .topbar-meta { justify-content: flex-start; }
  .org-switch, .lang-switch, .price-switch { width: 100%; }
  .content { padding-top: 16px; padding-bottom: 24px; }
  .page-head { flex-direction: column; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .stat-grid, .stat-grid.compact, .split, .form-grid, .chart-grid { grid-template-columns: 1fr; }
  .catalog-expand td { padding-left: 12px; }
  .flag-group { max-width: none; }
  .num.shops-cell { text-align: left; }
  .num.shops-cell .flag-group { justify-content: flex-start; }

  table.data thead { display: none; }
  table.data, table.data tbody { display: block; width: 100%; }
  table.data > tbody > tr {
    display: block;
    width: 100%;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 10px 12px;
    box-shadow: var(--shadow);
  }
  table.data > tbody > tr.catalog-expand {
    margin-top: -4px;
    background: #f7faf8;
  }
  table.data > tbody > tr > td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border: 0;
    padding: 8px 0;
    width: 100%;
    text-align: left;
  }
  table.data > tbody > tr > td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 36%;
    max-width: 9rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  table.data > tbody > tr > td[colspan],
  table.data > tbody > tr > td.thumb-cell {
    display: block;
  }
  table.data > tbody > tr > td.catalog-actions,
  table.data > tbody > tr > td:has(.prod-status) {
    display: flex;
    justify-content: stretch;
  }
  table.data > tbody > tr > td.catalog-actions .btn,
  .prod-status {
    flex: 1 1 auto;
    width: 100%;
    min-height: 52px;
    font-size: 1.05rem;
    border-radius: 12px;
  }
  table.data > tbody > tr > td.catalog-actions .icon-btn {
    flex: 0 0 auto;
    width: 44px;
    min-height: 44px;
  }
  .nested-table { overflow: visible; }
}

@media (max-width: 640px) {
  h1 { font-size: 1.55rem; }
  .stat { padding: 14px; }
  .stat strong { font-size: 1.35rem; }
  .login-card { width: min(420px, calc(100vw - 24px)); padding: 22px; }
  .stock-source-use {
    padding: 12px;
  }
  .stock-source-qty-field {
    width: 5.2rem;
    min-height: 3rem;
    font-size: 1.25rem;
  }
}
