:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
h2, h3 { margin: 0 0 12px; font-weight: 650; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.hidden { display: none !important; }

/* ------------------------------------------------------------- layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px;
  flex: 0 0 224px;
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 18px;
}
.brand-dot {
  width: 11px; height: 11px; border-radius: 4px;
  background: linear-gradient(135deg, #f27a1a, #6a3ff0);
  display: inline-block;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; color: #cbd5e1;
  padding: 11px 12px; border-radius: 10px; cursor: pointer;
  font-size: 14px; text-align: left; width: 100%;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: #1e293b; color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px 8px 0; }
.sidebar-foot a { color: #93c5fd; }

.main { flex: 1; min-width: 0; padding: 0 22px 40px; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0 14px; position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--bg) 75%, rgba(244, 246, 251, 0));
}
.topbar-title { font-size: 20px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.sync-state { font-size: 12px; color: var(--muted); text-align: right; }

/* ------------------------------------------------------------- butonlar */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  font-size: 13.5px; font-weight: 550; white-space: nowrap;
  transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 5px 9px; font-size: 12.5px; border-radius: 8px; }
.btn.wide { width: 100%; justify-content: center; padding: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn {
  border: 0; background: transparent; font-size: 17px; cursor: pointer;
  padding: 7px 9px; border-radius: 9px; color: var(--ink);
}
.icon-btn:hover { background: #eef2f7; }
.only-mobile { display: none; }

input, select, textarea {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: #93c5fd; }

/* -------------------------------------------------------------- kartlar */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { margin: 0; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .value { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* ------------------------------------------------------------- filtreler */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 13px; font-size: 13px; cursor: pointer; display: flex; gap: 6px; align-items: center;
}
.chip .count { font-size: 11px; background: #eef2f7; border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.chip.active { border-color: var(--primary); background: #eff6ff; color: var(--primary-dark); font-weight: 600; }
.chip.active .count { background: #dbeafe; color: var(--primary-dark); }

.filter-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.filter-row > * { flex: 0 1 auto; }
.filter-row input[type=search] { flex: 1 1 240px; }
.filter-row select, .filter-row input[type=date] { max-width: 190px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 14px; }
.switch-row input { width: auto; }

.bulkbar {
  position: sticky; top: 66px; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; border-color: #bfdbfe; background: #eff6ff;
}
.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bulk-actions select { max-width: 180px; }

/* -------------------------------------------------------------- siparişler */
.orders-list { display: flex; flex-direction: column; gap: 10px; }

.order-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: start;
  border-left: 4px solid var(--plat, #cbd5e1);
  cursor: pointer; transition: border-color .15s, transform .08s;
}
.order-card:hover { border-color: #cbd5e1; border-left-color: var(--plat); }
.order-card.selected { background: #f8fbff; border-color: #bfdbfe; border-left-color: var(--plat); }
.order-check { padding-top: 3px; }
.order-check input { width: 17px; height: 17px; }
.order-main { min-width: 0; }
.order-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.plat-badge {
  font-size: 11px; font-weight: 700; color: #fff; border-radius: 6px;
  padding: 2px 7px; letter-spacing: .2px;
}
.order-no { font-weight: 700; font-size: 14.5px; }
.status-badge {
  font-size: 11.5px; font-weight: 650; border-radius: 999px; padding: 2px 9px;
  border: 1px solid currentColor;
}
.order-meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.order-meta b { color: var(--ink); font-weight: 600; }
.order-items { margin-top: 8px; font-size: 12.5px; color: #334155; }
.order-items .it { display: flex; gap: 6px; align-items: baseline; }
.order-items .it .qty { font-weight: 700; color: var(--primary); min-width: 26px; }
.order-side { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.order-amount { font-size: 16px; font-weight: 700; white-space: nowrap; }
.order-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); background: #fff;
}

.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin: 18px 0; flex-wrap: wrap; }
.pager .btn { padding: 7px 12px; }

/* -------------------------------------------------------------- tablo */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }

/* -------------------------------------------------------------- grafik */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 190px; padding-top: 8px; }
.chart .bar { flex: 1; min-width: 3px; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 3px 3px 0 0; position: relative; }
.chart .bar:hover { background: #1d4ed8; }
.chart .bar span {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 11px; padding: 3px 6px; border-radius: 5px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s;
}
.chart .bar:hover span { opacity: 1; }

/* -------------------------------------------------------------- mağazalar */
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.store-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; }
.store-card.disabled { opacity: .6; }
.store-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.store-name { font-weight: 700; }
.store-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.sync-ok { color: var(--ok); }
.sync-err { color: var(--danger); }
.err-text { font-size: 11.5px; color: var(--danger); margin-top: 6px; word-break: break-word; }

/* -------------------------------------------------------------- drawer */
.drawer-backdrop, .modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  z-index: 40; backdrop-filter: blur(1px);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw);
  background: #fff; z-index: 50; display: flex; flex-direction: column;
  box-shadow: -12px 0 40px -20px rgba(15, 23, 42, .5);
  animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 2px 0 0; }
.drawer-body { padding: 16px 18px 40px; overflow-y: auto; }
.drawer-body h4 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kv { display: grid; grid-template-columns: 108px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.line-item { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.line-item:last-child { border-bottom: 0; }
.event { font-size: 12.5px; color: var(--muted); padding: 5px 0; border-bottom: 1px solid #f1f5f9; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions-grid .wide { grid-column: 1 / -1; }

/* -------------------------------------------------------------- modal */
.modal {
  position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  background: #fff; border-radius: 16px; display: flex; flex-direction: column;
  box-shadow: 0 30px 60px -20px rgba(15, 23, 42, .5);
}
.modal.label-modal { width: min(860px, calc(100vw - 16px)); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px 18px; overflow-y: auto; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

/* -------------------------------------------------------------- toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 11px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  z-index: 80; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: #b91c1c; }

/* -------------------------------------------------------------- login */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at 20% 20%, #1e293b, #0f172a 60%);
  padding: 20px;
}
.login-card {
  width: min(390px, 100%); background: #fff; border-radius: 18px; padding: 26px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6); display: flex; flex-direction: column; gap: 12px;
}
.login-card .brand { color: var(--ink); padding: 0 0 4px; font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

/* ======================================================== KARGO ETİKETİ
   A6 YATAY (landscape): 148 × 105 mm — lazer yazıcıda A6/A5/A4'e basılır
   ---------------------------------------------------------------------- */
.label-tools { margin-bottom: 6px; }
.label-hint { margin: 0 0 12px; }
.label-preview { background: #eef1f6; border-radius: 12px; padding: 14px; }

/* Ekranda küçültülmüş önizleme; yazdırmada her zaman gerçek mm */
.label-preview .lbl, .label-preview .paper { zoom: .55; }
.label-preview.prev-a6 { display: flex; justify-content: center; }
.label-preview.prev-a5 .lbl { zoom: .5; }
.label-preview.prev-a4 .paper { zoom: .42; }
@media print { .label-preview .lbl, .label-preview .paper { zoom: 1 !important; } }

.sheet { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }

/* ---- ETİKET: 148 × 105 mm (A6 yatay) ---- */
.lbl {
  --ink: #0f172a;
  --muted: #5b6b7f;
  --line: #dfe6ee;
  width: 148mm;
  height: 105mm;
  background: #fff;
  color: var(--ink);
  border: 1px solid #cfd8e3;
  border-radius: 2mm;
  box-shadow: 0 6px 18px -8px rgba(15, 23, 42, .35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: "Inter", "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 9pt;
  line-height: 1.25;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  font-weight: 500;
}
.lbl[data-size="a5"] { width: 210mm; height: 148mm; font-size: 11pt; }
.lbl[data-size="a6-roll"] { width: 150mm; height: 100mm; border-radius: 0; }
.lbl[data-size="a4"] { width: 148mm; height: 105mm; }

/* başlık şeridi */
.lbl-head {
  display: flex; align-items: center; justify-content: space-between; gap: 4mm;
  padding: 2.4mm 4mm;
  background: var(--plat, #0f172a);
  color: #fff;
}
.lbl-brand { display: flex; align-items: baseline; gap: 2.5mm; min-width: 0; }
.lbl-brand b { font-size: 10pt; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl-brand span { font-size: 7pt; opacity: .9; letter-spacing: .8px; text-transform: uppercase; white-space: nowrap; }
.lbl-no { display: flex; align-items: baseline; gap: 2mm; }
.lbl-no span { font-size: 6.8pt; letter-spacing: .9px; text-transform: uppercase; opacity: .9; }
.lbl-no b { font-size: 11pt; letter-spacing: .2px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- gövde: iki sütun (sol alıcı, sağ kargo) ---- */
.lbl-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  min-height: 0;
}
.lbl-to {
  padding: 3.2mm 4mm 2.5mm;
  border-right: 1px dashed var(--line);
  min-width: 0;
}
.lbl-to .cap,
.lbl-side .cap { font-size: 6.8pt; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); }
.lbl-to .who { font-size: 13.5pt; font-weight: 750; line-height: 1.12; margin: .8mm 0 1.6mm; }
.lbl-to .addr { font-size: 9pt; line-height: 1.32; }
.lbl-to .addr .line2 { font-weight: 650; }
.lbl-to .phone {
  display: inline-block; margin-top: 1.6mm; padding: .8mm 2.4mm; border-radius: 999px;
  background: #f1f5f9; font-size: 8.6pt; font-weight: 650; font-variant-numeric: tabular-nums;
}
.lbl-to .phone em { font-style: normal; color: var(--muted); font-weight: 500; font-size: 6.6pt; letter-spacing: .6px; text-transform: uppercase; margin-right: 1mm; }

.lbl-side { padding: 3.2mm 4mm 2.5mm; display: flex; flex-direction: column; gap: 2mm; min-width: 0; }
.lbl-side .firm { font-size: 9.6pt; font-weight: 750; margin-bottom: .6mm; }
.lbl-side .track {
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 10.5pt; font-weight: 700; letter-spacing: .4px; font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.lbl-side .track.empty { color: #94a3b8; font-weight: 600; }
.lbl-side .meta { font-size: 7.6pt; color: var(--muted); }
.lbl-side .meta b { color: var(--ink); font-weight: 650; }
.lbl-side .items { margin-top: auto; border-top: 1px solid #f1f5f9; padding-top: 1.4mm; }
.lbl-side .items .cap { margin-bottom: .8mm; }
.lbl-side .items .row { display: flex; justify-content: space-between; gap: 2mm; font-size: 7.6pt; padding: .35mm 0; }
.lbl-side .items .row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbl-side .items .row b { font-variant-numeric: tabular-nums; }
.lbl-side .items .more { font-size: 7pt; color: var(--muted); }

/* ---- barkod şeridi (tam genişlik) ---- */
.lbl-code {
  padding: 1.8mm 4mm 1.4mm;
  border-top: 1px solid var(--line);
  text-align: center;
}
.lbl-code .bars { width: 100%; height: 15mm; display: block; shape-rendering: crispEdges; }
.lbl-code .human {
  margin-top: .6mm;
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 9pt; letter-spacing: 2px; font-variant-numeric: tabular-nums;
}
.lbl-code .human.plain { letter-spacing: .2px; font-family: inherit; font-weight: 700; font-size: 9.5pt; }

/* ---- alt şerit ---- */
.lbl-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 3mm;
  padding: 1.2mm 4mm;
  background: #f8fafc; border-top: 1px solid var(--line);
  font-size: 6.8pt; color: #475569; letter-spacing: .3px;
}
.lbl-foot .note { font-weight: 700; color: #b45309; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60mm; }

/* ---- A4 sayfası: iki A6 yatay etiket (üst üste) ---- */
.paper {
  width: 210mm; min-height: 297mm; background: #fff; padding: 0;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 6px 18px -8px rgba(15, 23, 42, .35);
}
.paper .lbl { border-radius: 0; box-shadow: none; border: 0; }
.paper .lbl + .lbl { border-top: 1px dashed #cbd5e1; }

/* ---- YAZDIRMA: sadece etiketler, gerçek ölçek ---- */
@media print {
  @page { margin: 0; size: auto; }
  html, body { background: #fff !important; margin: 0 !important; }
  body * { visibility: hidden !important; }
  #labelBackdrop, #labelBackdrop * { visibility: visible !important; }
  #labelBackdrop {
    position: absolute !important; inset: 0 !important; background: #fff !important;
    backdrop-filter: none !important; padding: 0 !important;
  }
  .label-modal {
    position: static !important; transform: none !important; box-shadow: none !important;
    width: auto !important; max-width: none !important; max-height: none !important;
    border-radius: 0 !important; display: block !important; background: #fff !important;
  }
  .modal-head, .label-tools, .label-hint { display: none !important; }
  .modal-body { padding: 0 !important; overflow: visible !important; }
  .label-preview { background: #fff !important; padding: 0 !important; border-radius: 0 !important; }
  .sheet { gap: 0; display: block; }
  .lbl, .paper { box-shadow: none !important; }
  .lbl { border: 0 !important; break-after: page; page-break-after: always; break-inside: avoid; }
  .lbl:last-child { break-after: auto; page-break-after: auto; }
  .paper { break-after: page; page-break-after: always; }
  .paper .lbl { break-after: auto; page-break-after: auto; }
  .paper .lbl + .lbl { border-top: 0 !important; }
}

/* -------------------------------------------------------------- mobil */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; height: 100vh;
    transform: translateX(-100%); transition: transform .2s; width: 232px;
  }
  .sidebar.open { transform: none; }
  .main { padding: 0 12px 40px; }
  .only-mobile { display: inline-flex; }
  .topbar-title { font-size: 17px; }
  .sync-state { display: none; }
  .order-card { grid-template-columns: 28px 1fr; }
  .order-side { grid-column: 2; align-items: flex-start; text-align: left; flex-direction: row; justify-content: space-between; width: 100%; }
  .kpi .value { font-size: 19px; }
  .filter-row select, .filter-row input[type=date] { max-width: none; flex: 1 1 140px; }
  .drawer { width: 100vw; }
  .actions-grid { grid-template-columns: 1fr; }
}
