:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --line: #d7d7dc;
  --line-soft: #ececf0;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --blue: #0071e3;
  --blue-dark: #005bb5;
  --red: #b42318;
  --green: #16794c;
  --amber: #946200;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(245, 245, 247, 0.95)),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 14px;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.48;
}

a {
  color: var(--blue);
  font-weight: 650;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

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

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 24px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: 30px;
  line-height: 1.08;
}

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

h3 {
  font-size: 15px;
}

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

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.form-stack {
  display: grid;
  gap: 14px;
}

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

.simple-product-form {
  grid-template-columns: 1fr;
}

.form-grid .wide,
.form-stack .wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.country-picker,
.inline-picker {
  position: relative;
}

.country-options,
.picker-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  max-height: 230px;
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.country-options button,
.picker-options button {
  width: 100%;
  min-height: 30px;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  padding: 0 9px;
  text-align: left;
}

.country-options button:hover,
.picker-options button:hover {
  background: #f5f5f7;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.16);
}

.primary,
.ghost,
.segmented button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.primary:hover {
  background: var(--blue-dark);
}

.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
}

.ghost.danger {
  color: var(--red);
}

.ghost.danger:hover {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff1ee;
}

.error-text {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 52px 1fr;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(215, 215, 220, 0.9);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
}

.topbar > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.workspace {
  --left: 44%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, var(--left)) 8px minmax(390px, 1fr);
  padding: 14px;
  overflow: hidden;
}

.left-pane,
.right-pane {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.left-pane {
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: 14px 0 0 14px;
}

.right-pane {
  display: grid;
  grid-template-rows: auto auto 1fr;
  border-radius: 0 14px 14px 0;
}

.splitter {
  cursor: col-resize;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.splitter:hover {
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
}

.pane-head {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line-soft);
}

#formHost {
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 22px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
}

.tabs button {
  min-width: 78px;
  min-height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tabs button.active {
  background: #1d1d1f;
  color: #fff;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.list-toolbar input {
  max-width: 260px;
  min-height: 34px;
  background: #f5f5f7;
}

.list-toolbar-right,
.list-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-toolbar-right {
  margin-left: auto;
}

.list-actions button {
  min-width: 64px;
}

.stock-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stock-adjust-input {
  width: 82px;
  min-height: 30px;
  padding: 6px 8px;
}

.list-host {
  min-height: 0;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  height: 36px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(250, 250, 252, 0.96);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

td.note-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.amount-positive {
  color: var(--green);
  font-weight: 800;
}

.amount-negative {
  color: #d70015;
  font-weight: 800;
}

.dashboard-filter-panel {
  align-content: start;
}

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

.dashboard-summary div {
  display: grid;
  gap: 4px;
  min-height: 68px;
  align-content: center;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #f5f5f7;
}

.dashboard-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-summary strong {
  font-size: 24px;
}

.dashboard-list {
  display: grid;
  gap: 18px;
  padding-bottom: 20px;
}

.dashboard-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line-soft);
}

.dashboard-list section {
  border-bottom: 1px solid var(--line-soft);
}

.compact-empty {
  min-height: 120px;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: rgba(0, 113, 227, 0.045);
}

.clickable-row.selected td {
  background: rgba(0, 113, 227, 0.09);
}

.thumb-cell {
  min-width: 180px;
}

.product-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 4px;
}

.product-actions .primary,
.product-actions .ghost {
  min-width: 74px;
}

.system-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.product-preview-strip {
  min-height: 58px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(245, 245, 247, 0.62);
}

.product-preview-strip .thumb-button {
  width: 150px;
  height: 150px;
}

.product-note {
  min-height: 118px;
}

.order-items-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(245, 245, 247, 0.55);
}

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

[data-order-items] {
  display: grid;
  gap: 10px;
}

.order-item-row {
  display: grid;
  grid-template-columns: 150px minmax(240px, 1fr);
  align-items: stretch;
  gap: 12px;
  min-width: 430px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #fff;
}

.order-product-preview {
  width: 150px;
  min-height: 150px;
  display: grid;
  place-items: center;
  align-self: start;
}

.order-product-preview .thumb-button {
  width: 150px;
  height: 150px;
}

.compact-product {
  display: block;
}

.mini-placeholder {
  display: inline-grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.order-item-fields {
  display: grid;
  align-content: start;
  gap: 12px;
}

.order-item-field-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px;
  gap: 10px;
}

.icon-action {
  align-self: start;
  justify-self: start;
}

.two-field-row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
}

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

.paired-textareas textarea {
  min-height: 110px;
}

.shipping-summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.locked-context input,
.locked-context textarea {
  background: #f5f5f7;
  color: var(--text);
}

.locked-context.shipping-order-products {
  background: #f5f5f7;
}

.shipping-order-products > div:last-child {
  display: grid;
  gap: 10px;
}

.shipping-tracking-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.shipping-tracking-row .last-mile-input {
  background: #eefaf3;
  border-color: #cdebd9;
}

.shipping-tracking-row .last-mile-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.16);
}

.shipping-product-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #fff;
}

.shipping-product-row .order-product-preview {
  width: 56px;
  min-height: 56px;
}

.shipping-product-row .thumb-button,
.shipping-product-row .mini-placeholder {
  width: 56px;
  height: 56px;
}

.shipping-product-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.qty-highlight {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #e9f8f0;
  color: var(--green);
  font-weight: 800;
}

.thumb-button {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.thumb-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-button:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.status,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: #f2f2f4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status.pending {
  background: #fff8df;
  color: var(--amber);
}

.status.partial {
  background: #e9f3ff;
  color: var(--blue-dark);
}

.status.first_mile_shipped {
  background: #eef2ff;
  color: #3547a3;
}

.status.last_mile_shipped {
  background: #e9f8f0;
  color: var(--green);
}

.status.shipped,
.status.ok {
  background: #e9f8f0;
  color: var(--green);
}

.status.low {
  background: #fff1ee;
  color: var(--red);
}

.panel-section {
  display: grid;
  gap: 14px;
}

.panel-section + .panel-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}

.segmented {
  display: inline-flex;
  width: fit-content;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f5f5f7;
}

.segmented button {
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.image-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr minmax(320px, 42vw);
}

.drawer-backdrop {
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(2px);
}

.drawer-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.12);
}

.drawer-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.drawer-panel img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #f5f5f7;
}

@media (max-width: 820px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    overflow: visible;
  }

  .splitter {
    display: none;
  }

  .left-pane,
  .right-pane {
    border-radius: 14px;
  }

  .right-pane {
    min-height: 480px;
  }

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

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

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

  .paired-textareas {
    grid-template-columns: 1fr;
  }

  .list-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .list-toolbar-right {
    justify-content: space-between;
    margin-left: 0;
  }

  .list-toolbar input {
    max-width: none;
  }

  .image-drawer {
    grid-template-columns: 1fr;
  }

  .drawer-backdrop {
    display: none;
  }
}
