:root {
  --bg: #0a1215;
  --bg2: #0e181c;
  --surface: #132126;
  --surface2: #1a2c32;
  --border: #22383f;
  --text: #e6f1f2;
  --muted: #8aa3a8;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --accent-ink: #042f2b;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --ok: #4ade80;
  --info: #60a5fa;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.danger { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.hidden { display: none !important; }

/* ---------- üst bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(10, 18, 21, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.topbar .brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: var(--accent-ink);
}
.brand-mark { background: #fff; }
.wordmark { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; font-family: Georgia, "Times New Roman", serif; }
.wordmark b { font-size: 20px; letter-spacing: .06em; font-weight: 700; }
.wordmark small { font-size: 10.5px; letter-spacing: .22em; color: var(--accent); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark img { width: 88%; height: auto; display: block; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--text);
}
.iconbtn:hover { background: var(--surface); }

main { max-width: 900px; margin: 0 auto; padding: 14px 14px calc(96px + var(--safe-bottom)); }

/* ---------- genel bileşenler ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px;
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.section-title { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 2px 8px; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-weight: 600;
  white-space: nowrap;
}
.btn:hover { border-color: #2f4c55; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #5eead4; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  background: var(--bg2); border: 1px solid var(--border); outline: none;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.search {
  position: relative; display: flex; align-items: center;
}
.search svg.i { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 44px; min-height: 52px; font-size: 16px; border-radius: 14px; background: var(--surface); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface2); color: var(--muted); white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.st-alinacak { background: rgba(96,165,250,.14); color: #93c5fd; }
.st-teslim_alindi { background: rgba(167,139,250,.15); color: #c4b5fd; }
.st-yikamada { background: rgba(56,189,248,.14); color: #7dd3fc; }
.st-hazir { background: var(--warn-soft); color: var(--warn); }
.st-teslim_edildi { background: rgba(74,222,128,.13); color: var(--ok); }
.st-iptal { background: var(--danger-soft); color: var(--danger); }

/* ---------- ana panel ---------- */
.today {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px;
}
.today .card { padding: 10px 12px; }
.today .k { font-size: 12px; color: var(--muted); }
.today .v { font-size: 18px; font-weight: 700; margin-top: 2px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 14px; min-height: 104px; border-radius: var(--radius); cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: transform .08s ease, border-color .15s;
}
.tile:hover { border-color: #2f4c55; }
.tile:active { transform: scale(.98); }
.tile .ic {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.tile .lbl { font-weight: 650; font-size: 15px; line-height: 1.25; }
.tile .count {
  position: absolute; top: 12px; right: 12px; min-width: 30px; height: 30px; padding: 0 9px; border-radius: 999px;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; background: var(--surface2); color: var(--text);
}
.tile .count.hot { background: var(--accent); color: var(--accent-ink); }
.tile.primary { background: linear-gradient(135deg, #0f766e, #115e59); border-color: #14b8a6; }
.tile.primary .ic { background: rgba(255,255,255,.14); color: #fff; }

/* ---------- listeler ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer;
}
.item:hover { border-color: #2f4c55; }
.item .title { font-weight: 650; font-size: 16px; }
.item .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.item .actions { display: flex; gap: 6px; margin-top: 10px; }
.item .actions .btn { flex: 1; }
.item .actions .iconbtn { background: var(--surface2); border-radius: 10px; width: 44px; height: 44px; }
.item .amount { font-weight: 700; text-align: right; }
.no { color: var(--accent); font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty svg.i { width: 42px; height: 42px; opacity: .5; margin-bottom: 8px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; min-height: 40px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface2); color: var(--accent); }

/* ---------- müşteri kartı ---------- */
.cust-head { text-align: center; padding: 18px 14px 14px; }
.cust-head .code { color: var(--muted); font-weight: 600; font-size: 13px; }
.cust-head .name { font-size: 22px; font-weight: 750; color: var(--accent); margin: 2px 0 6px; }
.kv { display: grid; grid-template-columns: 82px 1fr; gap: 6px 10px; font-size: 15px; }
.kv .k { color: var(--muted); }
.debt-box { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--bg2); margin-top: 12px; }
.debt-box.has { background: var(--danger-soft); }
.debt-box .v { font-size: 20px; font-weight: 750; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.quick button {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 12px;
  background: var(--surface2); border: 1px solid var(--border); cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text);
}
.quick button svg.i { width: 22px; height: 22px; color: var(--accent); }
.quick button.wa svg.i { color: #25d366; }

/* ---------- sipariş düzenleme ---------- */
.order-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.trk { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 8px 1px 9px; font: inherit; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; vertical-align: 1px; }
.trk svg.i { width: 13px; height: 13px; }
.order-head .name { font-size: 19px; font-weight: 750; }
.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 12px; }
.flow button {
  border: 1px solid var(--border); background: var(--bg2); border-radius: 10px; padding: 8px 2px; cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--muted); line-height: 1.2; min-height: 48px;
}
.flow button.done { color: var(--accent); border-color: transparent; background: var(--accent-soft); }
.flow button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.summary {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 6px; text-align: center;
}
.summary .k { font-size: 11px; color: var(--muted); letter-spacing: .04em; font-weight: 600; }
.summary .v { font-size: 16px; font-weight: 700; margin-top: 2px; }
.summary .bal .v { color: var(--danger); }
.summary .bal.zero .v { color: var(--ok); }

.toolbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.toolbar .btn { flex-direction: column; gap: 2px; min-height: 58px; padding: 6px 4px; font-size: 12.5px; white-space: normal; line-height: 1.15; }
.toolbar .btn svg.i { width: 18px; height: 18px; }

.lines { margin-top: 12px; }
.lines-head, .line { display: grid; grid-template-columns: 1fr 58px 52px 52px 76px; gap: 6px; align-items: center; }
.lines-head { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .04em; padding: 0 12px 6px; }
.lines-head span:not(:first-child), .line span:not(:first-child) { text-align: right; }
.line {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 6px; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.line:hover { border-color: var(--accent); }
.line .nm { font-weight: 650; font-size: 14px; line-height: 1.2; }
.line .nm small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.line .tt { font-weight: 700; }
.adj { display: flex; justify-content: space-between; padding: 8px 12px; font-size: 14px; color: var(--muted); }

.fab {
  position: fixed; right: 18px; bottom: calc(18px + var(--safe-bottom)); z-index: 30;
  height: 58px; min-width: 58px; padding: 0 22px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 750; font-size: 16px;
  display: flex; align-items: center; gap: 8px; box-shadow: 0 10px 28px rgba(20, 184, 166, .35);
}
.fab svg.i { width: 22px; height: 22px; stroke-width: 2.6; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
@media (min-width: 640px) { .overlay { align-items: center; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + var(--safe-bottom)); animation: up .2s ease;
}
@media (min-width: 640px) { .sheet { border-radius: 20px; } }
.sheet h2 { margin: 0 0 12px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.sheet h2 .spacer { flex: 1; }
.sheet .foot { display: flex; gap: 8px; margin-top: 16px; }
.sheet .foot .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }

.prod-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (min-width: 480px) { .prod-grid { grid-template-columns: repeat(3, 1fr); } }
.prod {
  text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.prod:hover, .prod.on { border-color: var(--accent); }
.prod.on { background: var(--accent-soft); }
.prod b { display: block; font-size: 14px; }
.prod span { font-size: 12px; color: var(--muted); }

.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: 6px; }
.stepper .input { text-align: center; font-size: 20px; font-weight: 700; }
.calc { font-size: 14px; color: var(--muted); text-align: center; padding: 10px; border-radius: 12px; background: var(--surface); }
.calc b { color: var(--text); font-size: 18px; }

/* ---------- toast ---------- */
#toasts { position: fixed; left: 0; right: 0; top: 12px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 92vw; padding: 12px 16px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border);
  box-shadow: var(--shadow); font-weight: 600; animation: up .2s ease;
}
.toast.ok { border-color: var(--accent); }
.toast.err { border-color: var(--danger); color: #fecaca; }

/* ---------- giriş ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 24px; }
.login-logo { display: block; width: 78%; max-width: 260px; height: auto; margin: 4px auto 10px; }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 22px; }

/* ---------- tablolar (rapor/admin) ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 6px; border-bottom: 1px solid var(--border); }
table.t td { padding: 9px 6px; border-bottom: 1px solid var(--border); }
table.t td.r, table.t th.r { text-align: right; white-space: nowrap; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface); }
.scroll-x { overflow-x: auto; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 750; margin-top: 2px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- fiş yazdırma ---------- */
#print { display: none; }
@media print {
  @page { size: 80mm auto; margin: 4mm; }
  body { background: #fff; color: #000; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; font: 12px/1.35 "Courier New", monospace; color: #000; width: 72mm; }
  #print .plogo { display: block; width: 46mm; margin: 0 auto 4px; }
  #print h3 { text-align: center; margin: 0 0 2px; font-size: 15px; }
  #print .c { text-align: center; }
  #print hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
  #print table { width: 100%; border-collapse: collapse; }
  #print td { padding: 1px 0; vertical-align: top; }
  #print td.r { text-align: right; }
  #print .big { font-size: 16px; font-weight: bold; }
}
