:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #eef3f1;
  --text: #17201c;
  --muted: #68746f;
  --line: #dbe1de;
  --accent: #1f7a5c;
  --accent-strong: #165c45;
  --blue: #255f85;
  --amber: #a66300;
  --danger: #a83b35;
  --shadow: 0 12px 32px rgba(24, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #15201c;
  color: #fff;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  margin-bottom: 28px;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #ffffff;
  color: #15201c;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #b7c5bf;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  display: block;
  padding: 11px 12px;
  border-radius: 8px;
  color: #d6e0dc;
  font-weight: 650;
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  text-decoration: none;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.content {
  padding: 28px 32px 44px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

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

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

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

.panel {
  overflow: hidden;
}

.panel + .panel,
.two-column + .panel {
  margin-top: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td strong,
td small {
  display: block;
}

td small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

tr.is-low {
  background: #fff8ea;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  margin: 18px;
  padding: 22px;
}

.empty-state h2 {
  margin: 0 0 6px;
  font-size: 17px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.flash {
  margin: 0 32px 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #edf5f2;
  color: var(--accent-strong);
  border: 1px solid #c7ded5;
}

.flash-error {
  background: #fff0ee;
  color: var(--danger);
  border-color: #f1c7c2;
}

.definition-list {
  margin: 0;
  padding: 16px 18px 18px;
}

.definition-list div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.definition-list div:last-child {
  border-bottom: 0;
}

.definition-list dt {
  color: var(--muted);
  font-weight: 750;
}

.definition-list dd {
  margin: 0;
  text-align: right;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(430px, 100%);
}

.search-form input,
.form input,
.form select,
.form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.form input,
.form select {
  height: 42px;
}

.form textarea {
  min-height: 88px;
  padding-top: 10px;
  resize: vertical;
}

.button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button:hover {
  filter: brightness(0.98);
}

.button-small {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

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

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

.form-grid-2-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 14px 18px 18px;
}

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

.span-3 {
  grid-column: span 3;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  grid-column: 1 / -1;
  padding-top: 4px;
}

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

.workflow div {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.workflow span {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.workflow strong,
.workflow small {
  display: block;
}

.workflow strong {
  margin-top: 8px;
}

.workflow small {
  margin-top: 2px;
  color: var(--muted);
}

.actions-cell {
  white-space: nowrap;
}

.sync-form {
  padding: 0;
}

.sync-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 18px 0;
}

.sync-status div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.sync-status span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sync-status strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.hint {
  margin: 12px 18px 0;
  color: var(--muted);
}

.hint-error {
  color: var(--danger);
}

tr.is-selected {
  background: #edf5f2;
}

.shipment-form {
  padding: 18px;
}

.shipment-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.shipment-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.shipment-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.shipment-summary strong {
  display: block;
  margin-top: 5px;
}

.order-items {
  padding: 0 18px 18px;
}

.order-items h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.order-items p,
.order-items ul {
  margin: 0;
  color: var(--muted);
}

.label-body {
  background: #d9dddb;
  padding: 24px;
}

.print-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.shipping-label {
  width: 105mm;
  min-height: 148mm;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #222;
  color: #111;
  padding: 10mm;
  box-shadow: var(--shadow);
}

.label-header,
.label-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.label-header {
  align-items: start;
  border-bottom: 2px solid #111;
  padding-bottom: 8mm;
}

.label-header strong,
.label-header span,
.label-block span,
.label-address span,
.label-grid span,
.label-items span {
  display: block;
}

.label-header strong {
  font-size: 22px;
  letter-spacing: 0;
}

.label-channel {
  justify-self: end;
  border: 1px solid #111;
  padding: 4px 8px;
  font-weight: 800;
}

.label-block,
.label-address,
.label-grid,
.label-barcode,
.label-items {
  margin-top: 8mm;
}

.label-block span,
.label-address span,
.label-grid span,
.label-items span {
  color: #555;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.label-block h1 {
  margin: 2mm 0 0;
  font-size: 24px;
  line-height: 1.1;
}

.label-block p,
.label-address p,
.label-items p {
  margin: 2mm 0 0;
}

.label-address strong {
  display: block;
  margin-top: 2mm;
  font-size: 20px;
  line-height: 1.2;
}

.label-grid div {
  border: 1px solid #111;
  padding: 5mm;
}

.label-grid strong {
  display: block;
  margin-top: 2mm;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.label-barcode {
  border: 2px solid #111;
  padding: 4mm;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
}

.label-items ul {
  margin: 2mm 0 0;
  padding-left: 18px;
}

.label-items small {
  color: #555;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf0ef;
}

.login-shell {
  width: min(100%, 420px);
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-brand strong,
.login-brand small {
  display: block;
}

.login-brand small {
  color: var(--muted);
}

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

.form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.login-panel .flash {
  margin: 0 0 16px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px 16px;
  }

  .brand {
    margin-bottom: 12px;
  }

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

  .nav-link {
    white-space: nowrap;
  }

  .metrics-grid,
  .two-column,
  .shipment-summary,
  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  .content {
    padding: 20px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form {
    min-width: 0;
  }

  .flash {
    margin-left: 20px;
    margin-right: 20px;
  }
}

@media print {
  @page {
    size: A6;
    margin: 0;
  }

  body {
    background: #fff;
    padding: 0;
  }

  .print-actions {
    display: none;
  }

  .shipping-label {
    width: 105mm;
    min-height: 148mm;
    margin: 0;
    border: 0;
    box-shadow: none;
  }
}
