:root {
  --ink: #0f172a;
  --muted: #667085;
  --line: #d8dde6;
  --soft: #f5f7fb;
  --panel: #ffffff;
  --accent: #101828;
  --accent-2: #516070;
  --danger: #be123c;
  --ok: #047857;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.07);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(100%, 440px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.login-card h1 { margin: 16px 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
.login-card form { display: grid; gap: 18px; margin-bottom: 18px; }
.login-card small { color: var(--muted); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
.shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.brand-mark, .receipt-logo {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--accent);
  display: inline-block;
}
.brand small { color: var(--muted); display: block; font-size: 14px; }
.brand strong { font-size: 21px; }
.nav {
  display: grid;
  gap: 5px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0 28px;
  scrollbar-width: thin;
}
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: #d8dde6; border-radius: 999px; }
.nav a {
  min-height: 42px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-radius: 8px;
  color: #101828;
  font-size: 16px;
}
.nav a span { width: 22px; text-align: center; color: #273244; }
.nav a.active, .nav a:hover { background: var(--accent); color: #fff; }
.nav a.active span, .nav a:hover span { color: #fff; }
.main { padding: 30px 34px 60px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 52px;
  min-width: 58px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
}
.menu-toggle span {
  display: block;
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: var(--ink);
}
.menu-toggle b {
  font-size: 12px;
  line-height: 1;
}
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  z-index: 40;
}
.topbar h1 { margin: 0; font-size: 30px; }
.muted { margin: 0 0 4px; color: var(--muted); }
.user-chip {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #eef2f6;
  padding: 8px 12px 8px 18px;
  border-radius: 999px;
  white-space: nowrap;
}
.user-chip b {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #dbe3ee;
}
.flash { padding: 14px 16px; border-radius: 8px; margin-bottom: 18px; border: 1px solid; background: #fff; }
.flash.success { border-color: #a7f3d0; color: var(--ok); }
.flash.error { border-color: #fecdd3; color: var(--danger); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 28px;
}
.panel h2 { margin: 0 0 20px; font-size: 22px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.panel-head h2 { margin-bottom: 6px; }
.panel-head p { color: var(--muted); margin: 0; }
.compact { margin-bottom: 8px; }
.settings-tabs { display: grid; gap: 18px; }
.settings-tab-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  box-shadow: var(--shadow);
}
.settings-tab {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.settings-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.settings-tab-panel > .panel { margin-bottom: 0; }
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
}
.tool-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}
.tool-card h3 { margin: 0 0 8px; }
.tool-card p { color: var(--muted); margin: 0 0 18px; line-height: 1.5; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.metric span { color: var(--muted); display: block; margin-bottom: 8px; }
.metric strong { font-size: 30px; }
.metric.warn strong { color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 26px; }
label { display: grid; gap: 9px; font-weight: 700; font-size: 15px; }
label em {
  background: #ffe8eb;
  color: #dc2626;
  font-style: normal;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 6px;
  margin-left: 6px;
}
input, select, textarea {
  width: 100%;
  min-height: 52px;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  padding: 0 16px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
textarea { min-height: 92px; padding-top: 14px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c9d2df; border-color: #8895a7; }
.span-2 { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; padding-top: 28px; }
.check input { width: 18px; min-height: 18px; }
.actions { display: flex; gap: 14px; align-items: center; margin-top: 26px; }
.actions.split { justify-content: flex-end; flex-wrap: wrap; }
.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 48px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.dark { background: #4b5563; color: #fff; border-color: #4b5563; }
.button.ghost { background: #fff; color: var(--accent); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; }
td small { color: var(--muted); }
.link, .row-actions a { color: #1d4ed8; font-weight: 700; }
.row-actions { display: flex; gap: 12px; }
.badge {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e8edf3;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge.danger { background: #ffe4e6; color: var(--danger); }
.empty { color: var(--muted); }
.search-input { margin-bottom: 18px; }
.grn-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(330px, 0.8fr); gap: 28px; align-items: start; }
.preview-panel { position: sticky; top: 26px; }
.receipt-mini {
  width: min(100%, 330px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  text-align: center;
  background: #fff;
}
.receipt-mini h3 { margin: 12px 0; font-size: 17px; }
.receipt-mini p { text-align: left; display: grid; gap: 4px; }
.receipt-mini small { color: var(--muted); }
.receipt-bar, .label-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: #000;
  color: #fff;
  padding: 8px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 12px;
}
.big-number { font-size: 42px; color: #dc2626; font-weight: 800; margin: 6px 0 14px; }
.qr-code {
  display: grid;
  place-items: center;
  width: 170px;
  max-width: 100%;
  margin: 14px auto 6px;
  background: #fff;
}
.qr-code svg {
  display: block;
  width: 100%;
  height: auto;
}
.qr-text {
  text-align: center;
  font-family: "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0;
  margin-bottom: 10px;
}
.print-qr { width: 38mm; }
.label-qr { width: 14mm; margin: 1mm auto 0; }
.package-label .qr-text { font-size: 6px; margin: 0; }
.tracking-page {
  min-height: 100vh;
  background: var(--soft);
  padding: 28px;
}
.tracking-card {
  width: min(100%, 760px);
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 30px;
}
.tracking-card h1 { margin: 14px 0 4px; }
.tracking-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}
.tracking-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.tracking-summary span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.timeline {
  list-style: none;
  display: grid;
  gap: 12px;
  margin: 0 0 24px;
  padding: 0;
}
.timeline li {
  border-left: 4px solid var(--accent);
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
}
.timeline span { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.timeline p { margin: 8px 0 0; color: #344054; }
.lang-switch { display: flex; gap: 6px; }
.lang-switch a, .inline-form button, .text-danger {
  border: 0;
  background: transparent;
  color: #1d4ed8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.link-button {
  border: 0;
  background: transparent;
  color: #1d4ed8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.text-danger { color: var(--danger); }
.inline-form { display: inline; margin-left: 8px; }
.comment { margin-top: 8px; padding: 8px; background: #f8fafc; border-radius: 6px; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input { min-height: 38px; }
.section-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}
.offline-tools {
  border: 1px dashed #98a2b3;
  background: #f8fafc;
  border-radius: 8px;
  padding: 14px;
  margin-top: 18px;
}
.offline-tools p { margin: 0 0 10px; color: var(--muted); }
.offline-conflict {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}
.offline-conflict p { color: var(--danger); margin: 6px 0 10px; }
.scanner-video {
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  background: #000;
}
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
}
.permissions-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.permissions-grid h3 {
  margin: 0 0 12px;
  text-transform: capitalize;
}
.permission-row { margin: 0; }

.print-button { position: fixed; right: 24px; top: 24px; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 0; background: var(--accent); color: #fff; font-weight: 700; }
.print-page, .label-page { background: #fff; display: grid; place-items: start center; padding: 30px; }
.thermal-receipt {
  width: 80mm;
  color: #000;
  background: #fff;
  padding: 5mm;
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
}
.thermal-receipt .large { width: 38px; height: 38px; margin: 0 auto 6px; border-radius: 0; }
.thermal-receipt h1 { font-size: 22px; line-height: 1.05; margin: 0 0 18px; }
.thermal-receipt h2 { font-size: 18px; letter-spacing: 0; margin: 0 0 16px; }
.receipt-lines { text-align: left; }
.receipt-lines p { display: grid; gap: 4px; margin: 13px 0; }
.receipt-lines small { color: #667085; font-size: 12px; }
.receipt-lines strong { font-size: 15px; }
.package-block span { color: #667085; font-size: 13px; }
.package-block strong { display: block; color: #dc2626; font-size: 42px; margin-top: 8px; }
.thermal-receipt footer { color: #667085; font-size: 12px; line-height: 1.5; }
.package-label {
  width: 50mm;
  height: 30mm;
  padding: 2mm;
  background: #fff;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8px;
  overflow: hidden;
}
.package-label p { margin: 4px 0; display: grid; grid-template-columns: 17mm 1fr; gap: 2mm; }
.package-label small { color: #667085; }
.package-label strong { font-size: 9px; }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    height: 100vh;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 40px rgba(15, 23, 42, 0.16);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .grn-layout, .report-grid { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .main { padding: 22px 16px 40px; }
  .topbar {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: center;
    gap: 14px;
  }
  .topbar .user-chip, .topbar .lang-switch {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .topbar h1 { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .stats-grid { grid-template-columns: 1fr; }
}

@media print {
  @page { size: 80mm auto; margin: 0; }
  .print-button { display: none; }
  .print-page { padding: 0; display: block; }
  .thermal-receipt { box-shadow: none; margin: 0; }
  .label-page { padding: 0; display: block; }
  .package-label { margin: 0; }
}
