:root {
  --bg: #eef2f5;
  --panel: #ffffff;
  --panel-2: #f5f7f9;
  --text: #162025;
  --muted: #66737d;
  --line: #d8e0e6;
  --brand: #0d9488;
  --brand-dark: #0f766e;
  --accent: #c2410c;
  --danger: #b42318;
  --ok: #167b46;
  --warn: #b25e09;
  --ink: #121a1f;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(13, 148, 136, 0.10), transparent 28%),
    linear-gradient(180deg, #f8fafb 0%, var(--bg) 36%, #e8edf1 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(16, 24, 30, 0.36), rgba(16, 24, 30, 0.54)),
    url("https://images.unsplash.com/photo-1607082350899-7e105aa886ae?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 30px;
}

.tracking-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(16, 24, 30, 0.30), rgba(16, 24, 30, 0.52)),
    url("https://images.unsplash.com/photo-1586528116311-ad8dd3c8310d?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.tracking-panel {
  width: min(560px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.tracking-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tracking-brand p {
  margin: 4px 0 0;
}

.tracking-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.status-card {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #f8fafb;
}

.status-card.error {
  background: #fff1f0;
  border-color: #fecaca;
}

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

.status-card small,
.status-summary small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 850;
  margin-bottom: 4px;
}

.status-card-head strong,
.status-summary > strong {
  display: block;
  font-size: 22px;
}

.status-summary {
  margin-top: 12px;
}

.status-summary p {
  margin: 8px 0 0;
  color: var(--text);
  display: grid;
  gap: 2px;
}

.status-summary p span {
  color: var(--muted);
  font-size: 13px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--brand);
  color: white;
  font-weight: 800;
  flex: 0 0 auto;
  box-shadow: 0 10px 28px rgba(13, 148, 136, 0.28);
}

.logo-img {
  object-fit: contain;
  background: white;
  padding: 4px;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.15;
}

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

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: #394348;
  font-size: 13px;
  font-weight: 650;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--text);
  padding: 10px 12px;
  min-height: 42px;
}

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

input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--brand);
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: 10px;
  background: #e8eef1;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.btn:hover {
  filter: brightness(0.99);
  transform: translateY(-1px);
}

.btn.primary {
  background: linear-gradient(135deg, var(--brand), #0f766e);
  color: white;
  box-shadow: 0 10px 22px rgba(13, 148, 136, 0.20);
}

.btn.dark {
  background: var(--ink);
  color: white;
}

.btn.danger {
  background: #fee4e2;
  color: var(--danger);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn.icon {
  width: 38px;
  padding: 0;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #10181d 0%, #152228 58%, #0f171c 100%);
  color: white;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.side-brand small, .user-chip small {
  display: block;
  color: rgba(255,255,255,0.64);
}

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

.nav button {
  text-align: left;
  background: transparent;
  color: rgba(255,255,255,0.78);
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 700;
}

.nav button.active, .nav button:hover {
  background: rgba(255,255,255,0.12);
  color: white;
  box-shadow: inset 3px 0 0 var(--brand);
}

.user-chip {
  margin-top: auto;
  padding: 14px;
  background: rgba(255,255,255,0.09);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px;
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(216, 224, 230, 0.82);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(12px);
}

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

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

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

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.05);
}

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

.metric-value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 850;
}

.section {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

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

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

.labels-toolbar select {
  width: auto;
  min-width: 220px;
}

.check-line {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}

.check-line input,
td input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

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

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

th {
  font-size: 12px;
  text-transform: uppercase;
  color: #536167;
  background: #f3f7f9;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #f8fafb;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f6;
  border: 1px solid rgba(17, 24, 39, 0.06);
}

.status-select {
  width: auto;
  min-height: 30px;
  padding: 4px 28px 4px 10px;
  font-size: 12px;
  font-weight: 850;
  border-radius: 999px;
  cursor: pointer;
}

.status.Delivered, .status.Paid, .status.Confirmed {
  background: #dcfce7;
  color: var(--ok);
}

.status.Pending, .status.Packed, .status.Partially {
  background: #fef3c7;
  color: var(--warn);
}

.status.Cancelled, .status.Returned, .status.Refunded, .status.Unpaid {
  background: #fee4e2;
  color: var(--danger);
}

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

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

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

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}

.modal {
  width: min(980px, 100%);
  max-height: min(86vh, 860px);
  overflow: auto;
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal.small {
  width: min(560px, 100%);
}

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

.cart-line {
  display: grid;
  grid-template-columns: 1fr 84px 90px 38px;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.cart-line:last-child {
  border-bottom: 0;
}

.totals {
  display: grid;
  gap: 8px;
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.totals .grand {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-size: 20px;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 60;
}

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

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.barcode {
  font-family: "Courier New", monospace;
  font-weight: 900;
  background: repeating-linear-gradient(90deg, #111 0 2px, #fff 2px 4px, #111 4px 5px, #fff 5px 8px);
  height: 42px;
  color: transparent;
  border: 1px solid var(--line);
}

.settings-brand {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 20px;
  padding: 18px;
  background: linear-gradient(135deg, #f6faf9, #f8f6f2);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.logo-preview {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: white;
  border: 1px dashed #b9c5cc;
  overflow: hidden;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.logo-preview span {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--brand);
  color: white;
  font-weight: 900;
  font-size: 22px;
}

.logo-copy h2 {
  margin-bottom: 6px;
}

.logo-copy p {
  margin: 0 0 12px;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.dark-mode {
  --bg: #10171b;
  --panel: #172126;
  --panel-2: #1f2b31;
  --text: #eef5f4;
  --muted: #a9b7bb;
  --line: #314247;
  --ink: #0b1114;
}

.dark-mode input,
.dark-mode select,
.dark-mode textarea,
.dark-mode .table-wrap,
.dark-mode th {
  background: #121b1e;
  color: var(--text);
}

.dark-mode body,
.dark-mode .main {
  background: var(--bg);
}

.dark-mode .topbar,
.dark-mode .settings-brand {
  background: rgba(23, 33, 38, 0.86);
}

.dark-mode tbody tr:hover {
  background: #1b282d;
}

@media (max-width: 1080px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split {
    grid-template-columns: 1fr;
  }
  .form-grid, .form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .main {
    padding: 16px;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .cards, .form-grid, .form-grid.two {
    grid-template-columns: 1fr;
  }
  .settings-brand {
    grid-template-columns: 1fr;
  }
  .logo-preview {
    width: 96px;
    height: 96px;
  }
  .cart-line {
    grid-template-columns: 1fr;
  }
  .tracking-search {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: white;
  }
  .no-print {
    display: none !important;
  }
}
