:root {
  color-scheme: light;
  --bg: #f6f4f0;
  --panel: #ffffff;
  --panel-2: #faf8f5;
  --text: #1d1b18;
  --muted: #6b665e;
  --border: #e4e0d8;
  --accent: #b4361f;
  --accent-hover: #9a2d18;
  --accent-ink: #ffffff;
  --accent-soft: #fbeae5;
  --ok: #1e7a3c;
  --ok-soft: #e4f3e8;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  /* grafik */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #ebe8e2;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141312;
    --panel: #1d1c1a;
    --panel-2: #232220;
    --text: #f3f1ec;
    --muted: #a8a399;
    --border: #34322e;
    --accent: #e8664a;
    --accent-hover: #f07a60;
    --accent-ink: #1a0d09;
    --accent-soft: #3a211a;
    --ok: #4cc27a;
    --ok-soft: #17301f;
    --danger: #f07167;
    --danger-soft: #3a1c1a;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #2c2a27;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141312;
  --panel: #1d1c1a;
  --panel-2: #232220;
  --text: #f3f1ec;
  --muted: #a8a399;
  --border: #34322e;
  --accent: #e8664a;
  --accent-hover: #f07a60;
  --accent-ink: #1a0d09;
  --accent-soft: #3a211a;
  --ok: #4cc27a;
  --ok-soft: #17301f;
  --danger: #f07167;
  --danger-soft: #3a1c1a;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #2c2a27;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- Butonlar & formlar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600;
  transition: background .12s, border-color .12s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 18px; font-size: 16px; }

label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=date], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text); font-weight: 400;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 60px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Tablolar ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-2); }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
tr.cancelled td.keep { text-decoration: none; }
tfoot td { font-weight: 700; border-bottom: none; }

/* ---------- Giriş ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .logo { font-size: 40px; text-align: center; }
.login-card h1 { text-align: center; margin: 6px 0 20px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---------- Kabuk ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.user-box { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 14px; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- Satış ekranı ---------- */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 16px; height: calc(100vh - 62px - 32px); }
.pos-left { display: flex; flex-direction: column; min-height: 0; }
.cat-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; flex-shrink: 0; }
.cat-tabs button {
  border: 1px solid var(--border); background: var(--panel); padding: 9px 16px; border-radius: 999px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.cat-tabs button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.search { margin-bottom: 10px; flex-shrink: 0; }
.products {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
  overflow-y: auto; align-content: start; padding-bottom: 8px;
}
.product {
  border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius);
  padding: 14px 12px; min-height: 92px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  box-shadow: var(--shadow); transition: border-color .1s, transform .05s;
  user-select: none;
}
.product:hover { border-color: var(--accent); }
.product:active { transform: scale(.98); }
.product .p-name { font-weight: 650; }
.product .p-price { color: var(--accent); font-weight: 700; }
.product .p-cat { font-size: 12px; color: var(--muted); }

.cart { display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.cart-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order-types { display: flex; gap: 4px; background: var(--panel-2); padding: 3px; border-radius: 10px; border: 1px solid var(--border); }
.order-types button { border: none; background: transparent; padding: 5px 10px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.order-types button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.cart-items { flex: 1; overflow-y: auto; padding: 6px 0; }
.cart-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 16px; border-bottom: 1px dashed var(--border); }
.cart-line .c-name { font-weight: 600; }
.cart-line .c-unit { font-size: 12px; color: var(--muted); }
.cart-line .c-total { font-weight: 700; text-align: right; }
.qty { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.qty button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); cursor: pointer; font-weight: 700; font-size: 16px; line-height: 1; }
.qty button:hover { background: var(--panel-2); }
.qty span { min-width: 26px; text-align: center; font-weight: 700; }
.cart-foot { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--panel-2); }
.totals div { display: flex; justify-content: space-between; font-size: 14px; }
.totals .grand { font-size: 24px; font-weight: 800; margin-top: 4px; }
.cart-tools { display: flex; gap: 6px; }
.cart-tools .btn { flex: 1; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-grid .btn { padding: 14px 8px; font-size: 15px; }
.pay-grid .btn.cash { background: var(--ok); border-color: var(--ok); color: #fff; }
.pay-grid .btn.card { background: var(--series-1); border-color: var(--series-1); color: #fff; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--panel); border-radius: 16px; width: 100%; max-width: 460px; max-height: calc(100vh - 32px);
  overflow-y: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); border: 1px solid var(--border);
}
.modal.wide { max-width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 8px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.big-total { font-size: 32px; font-weight: 800; text-align: center; padding: 8px; }
.quick-cash { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.change-box { text-align: center; padding: 12px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: 20px; }
.change-box.neg { background: var(--danger-soft); color: var(--danger); }
.split-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; }

/* ---------- Raporlar ---------- */
.range-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.range-bar .seg { display: flex; gap: 4px; flex-wrap: wrap; }
.range-bar input[type=date] { width: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-size: 26px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card + .card { margin-top: 0; }
.report-section { margin-bottom: 16px; }

.split-bar { display: flex; gap: 2px; height: 18px; border-radius: 4px; overflow: hidden; background: var(--grid); margin: 6px 0 14px; }
.split-bar span { display: block; height: 100%; }
.legend-list { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; font-size: 14px; }
.legend-item .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend-item .pct { color: var(--muted); min-width: 48px; text-align: right; }

.colchart { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 200px; border-bottom: 1px solid var(--border); padding-top: 8px;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px); background-size: 100% 25%; }
.colchart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; position: relative; min-width: 6px; }
.colchart .bar { width: 100%; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 0; transition: opacity .1s; }
.colchart:hover .bar { opacity: .55; }
.colchart .col:hover .bar { opacity: 1; }
.col-labels { display: flex; gap: 2px; margin-top: 4px; }
.col-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); min-width: 6px; overflow: hidden; white-space: nowrap; }
.tooltip {
  position: fixed; z-index: 60; pointer-events: none; background: var(--text); color: var(--bg);
  padding: 7px 10px; border-radius: 8px; font-size: 13px; line-height: 1.35; box-shadow: var(--shadow); white-space: nowrap;
}
details.table-toggle { margin-top: 10px; }
details.table-toggle summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }

/* ---------- Fiş ---------- */
.receipt {
  width: 72mm; max-width: 100%; margin: 0 auto; background: #fff; color: #000;
  font: 12px/1.35 "Courier New", ui-monospace, monospace; padding: 10px 8px;
}
.receipt .c { text-align: center; }
.receipt .b { font-weight: 700; }
.receipt .big { font-size: 16px; font-weight: 700; }
.receipt .huge { font-size: 26px; font-weight: 800; }
.receipt hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
.receipt .row { display: flex; justify-content: space-between; gap: 6px; }
.receipt .row > span:first-child { flex: 1; overflow-wrap: anywhere; }
.receipt .stamp { border: 2px solid #000; text-align: center; font-weight: 800; padding: 4px; margin: 6px 0; font-size: 16px; }
.receipt-preview { background: var(--panel-2); padding: 12px; border-radius: 12px; border: 1px solid var(--border); }

#print-area { display: none; }
@media print {
  @page { margin: 0; }
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area .receipt { width: 72mm; padding: 2mm; }
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Mobil ---------- */
@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; height: auto; }
  .products { max-height: none; overflow: visible; }
  .cart { max-height: none; }
  .cart-items { max-height: 320px; }
  .grid-2 { grid-template-columns: 1fr; }
  .user-box .uname { display: none; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; padding: 8px 16px; }
  .nav { order: 3; flex-basis: 100%; }
  .brand .bname { display: none; }
  .user-box { margin-left: auto; }
  main { padding: 12px 16px; }
  .products { grid-template-columns: repeat(2, 1fr); }
  .quick-cash { grid-template-columns: repeat(2, 1fr); }
  .kpi .k-value { font-size: 22px; }
}

/* ---------- Gün sonu & bildirimler ---------- */
.badge.warn { background: #fff4e0; color: #9a5b00; border-color: transparent; }
:root[data-theme="dark"] .badge.warn { background: #3a2c12; color: #f0b44c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.warn { background: #3a2c12; color: #f0b44c; } }
.bell { position: relative; font-size: 16px; }
.bell-count {
  position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-item { display: flex; flex-direction: column; gap: 6px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.photo-item img { width: 100%; height: 150px; object-fit: cover; border-radius: 6px; display: block; background: var(--border); }
.photo-item select { padding: 5px 8px; font-size: 13px; }
.card.alert { border-color: var(--danger); background: var(--danger-soft); margin-bottom: 16px; }
.open-day { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; flex-wrap: wrap; }
.status-list { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.steps { padding-left: 20px; font-size: 14px; line-height: 1.6; }
code { background: var(--panel-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
table.detail td { padding: 6px 4px; }
table.detail h3 { margin: 0; }
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.notif:hover { background: var(--panel-2); }
.notif.unread { border-left: 4px solid var(--accent); }
.notif-title { font-weight: 700; }
.notif-body { white-space: pre-line; font-size: 14px; margin-top: 4px; }
.notif-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
