:root{
  /* GÜNDÜZ (varsayılan) */
  --bg:#f3f5f8; --card:#ffffff; --card2:#f0f3f7; --line:#d9dfe7;
  --txt:#000000; --muted:#000000; --accent:#2f7ff0; --ok:#1fa85a; --warn:#e08a1e; --bad:#d94343;
  --hdr:#ffffffee; --tabs:#ffffff; --hover:#e8edf3; --pill:#e6ebf1;
  --pill-ok-bg:#dff5e8; --pill-ok-txt:#177a43; --pill-bad-bg:#fbe1e1; --pill-bad-txt:#b02a2a;
  --pill-warn-bg:#fdf0d8; --pill-warn-txt:#9a5a08;
  --toast:#ffffff; --toast-ok:#dff5e8; --toast-ok-line:#9fd8b8; --toast-bad:#fbe1e1; --toast-bad-line:#f0a8a8;
  --r:14px; color-scheme:light;
}
/* KARANLIK */
html[data-tema="karanlik"]{
  --bg:#0f1216; --card:#171c22; --card2:#1e242c; --line:#2a323c;
  --txt:#e8edf3; --muted:#e8edf3; --accent:#3d8bfd; --ok:#28c76f; --warn:#ff9f43; --bad:#ea5455;
  --hdr:#0f1216ee; --tabs:#141920; --hover:#1b222b; --pill:#232b34;
  --pill-ok-bg:#123723; --pill-ok-txt:#5ee39b; --pill-bad-bg:#3a1b1e; --pill-bad-txt:#ff8b8b;
  --pill-warn-bg:#3a2d15; --pill-warn-txt:#ffc078;
  --toast:#232b34; --toast-ok:#123723; --toast-ok-line:#1e5c3a; --toast-bad:#3a1b1e; --toast-bad-line:#6b2b2f;
  color-scheme:dark;
}
body{transition:background .2s,color .2s}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  background:var(--bg);color:var(--txt);
  font:15px/1.45 "Poppins",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  padding-bottom:76px;
}
h1,h2,h3{margin:0 0 10px}
h1{font-size:19px}
h2{font-size:16px}
a{color:var(--accent)}

header{
  position:sticky;top:0;z-index:20;background:var(--hdr);backdrop-filter:blur(8px);
  border-bottom:1px solid var(--line);padding:12px 14px;display:flex;align-items:center;gap:10px;
}
header .title{font-weight:700;font-size:17px;flex:1}
header .sub{color:var(--muted);font-size:12px;font-weight:400}

main{padding:14px;max-width:900px;margin:0 auto}
.page{display:none}
.page.active{display:block}

.card{background:var(--card);border:1px solid var(--line);border-radius:var(--r);padding:14px;margin-bottom:12px}
.row{display:flex;gap:10px;align-items:center}
.row.wrap{flex-wrap:wrap}
.spread{justify-content:space-between}
.grow{flex:1}
.muted{color:var(--muted)}
.small{font-size:12px}
.right{text-align:right}
.mt{margin-top:10px}

input,select,textarea,button{font:inherit}
input,select,textarea{
  width:100%;background:var(--card2);color:var(--txt);border:1px solid var(--line);
  border-radius:10px;padding:11px 12px;outline:none;
}
input:focus,select:focus,textarea:focus{border-color:var(--accent)}
label{display:block;font-size:12px;color:var(--muted);margin:0 0 4px}
.field{margin-bottom:10px;flex:1;min-width:130px}

button{
  background:var(--accent);color:#fff;border:0;border-radius:10px;padding:12px 14px;
  font-weight:600;cursor:pointer;
}
button:active{opacity:.85}
button.ghost{background:var(--card2);color:var(--txt);border:1px solid var(--line)}
button.ok{background:var(--ok)}
button.bad{background:var(--bad)}
button.sm{padding:7px 10px;font-size:13px;border-radius:8px}
button.block{width:100%}
button.ikon{padding:0;width:46px;height:46px;flex:0 0 46px;line-height:1;display:flex;align-items:center;justify-content:center;color:#fff}
button.ikon svg{display:block}
button.ikon.acik{background:var(--bad)}
button.ikon.ghost{color:var(--txt)}
button.ikon.acik.ghost{color:#fff;border-color:transparent}
.araclar{gap:8px}
.araclar button.ikon{width:44px;height:44px;flex-basis:44px;border-radius:10px}
select.sm{width:auto;padding:7px 28px 7px 10px;font-size:13px;border-radius:8px}
.mb{margin-bottom:10px}
button:disabled{opacity:.45}

.tabs{
  position:fixed;left:0;right:0;bottom:0;z-index:30;display:flex;
  background:var(--tabs);border-top:1px solid var(--line);
  padding:6px 4px calc(10px + env(safe-area-inset-bottom, 0px));
}
/* Mobil: sayfa gövdesi değil, main kaydırılır -> alt çubuk iOS/Android'de kaydırınca kaybolmaz */
body:not([data-gorunum="masaustu"]){
  height:100vh;height:100dvh;overflow:hidden;display:flex;flex-direction:column;padding-bottom:0;
}
body:not([data-gorunum="masaustu"]) main{
  flex:1;min-height:0;width:100%;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;
  padding-bottom:calc(76px + env(safe-area-inset-bottom, 0px));
}
.tabs button{
  flex:1;background:none;color:var(--muted);font-size:11px;font-weight:600;
  display:flex;flex-direction:column;align-items:center;gap:3px;padding:6px 2px;
}
.tabs button .ico{width:22px;height:22px;display:block}
.tabs button.active{color:var(--accent)}

.list{display:flex;flex-direction:column;gap:8px}
.item{
  background:var(--card2);border:1px solid var(--line);border-radius:12px;padding:10px 12px;
  display:flex;gap:10px;align-items:center;
}
.item .main{flex:1;min-width:0}
.item .name{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.item .meta{font-size:12px;color:var(--muted)}

.pill{display:inline-block;font-size:11px;padding:2px 8px;border-radius:999px;background:var(--pill);color:var(--muted)}
.pill.ok{background:var(--pill-ok-bg);color:var(--pill-ok-txt)}
.pill.bad{background:var(--pill-bad-bg);color:var(--pill-bad-txt)}
.pill.warn{background:var(--pill-warn-bg);color:var(--pill-warn-txt)}

.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px}
.kpi{background:var(--card2);border:1px solid var(--line);border-radius:12px;padding:12px}
.kpi .k{font-size:12px;color:var(--muted)}
.kpi .v{font-size:20px;font-weight:700;margin-top:3px}
.kpi .v.ok{color:var(--ok)} .kpi .v.bad{color:var(--bad)}

table{width:100%;border-collapse:collapse;font-size:13px}
th,td{padding:8px 6px;border-bottom:1px solid var(--line);text-align:left}
th{color:var(--muted);font-weight:600;font-size:12px}
td.num,th.num{text-align:right;white-space:nowrap}

#scanBox{border-radius:12px;overflow:hidden;background:#000;position:relative;display:none}
#scanBox.on{display:block}
#video{width:100%;max-height:23vh;object-fit:cover;display:block}
.scanline{position:absolute;left:8%;right:8%;top:50%;height:2px;background:var(--bad);box-shadow:0 0 12px var(--bad)}

.modal{
  position:fixed;inset:0;z-index:50;background:#000b;display:none;
  align-items:flex-end;justify-content:center;
}
.modal.on{display:flex}
.sheet{
  background:var(--card);width:100%;max-width:640px;border-radius:18px 18px 0 0;
  border:1px solid var(--line);padding:16px;max-height:90vh;overflow:auto;
}
.toast{
  position:fixed;left:50%;bottom:88px;transform:translateX(-50%);z-index:60;
  background:var(--toast);border:1px solid var(--line);color:var(--txt);box-shadow:0 4px 18px #0003;
  padding:10px 16px;border-radius:999px;font-size:13px;opacity:0;transition:.2s;pointer-events:none;
  max-width:90vw;text-align:center;
}
.toast.on{opacity:1}
.toast.ok{background:var(--toast-ok);border-color:var(--toast-ok-line)}
.toast.bad{background:var(--toast-bad);border-color:var(--toast-bad-line)}
.empty{color:var(--muted);text-align:center;padding:22px 10px;font-size:14px}

/* ---- ürün görselleri ---- */
.thumb{
  width:46px;height:46px;flex:0 0 46px;border-radius:10px;object-fit:cover;
  background:var(--card2);border:1px solid var(--line);display:block;
}
.thumb.bos{display:flex;align-items:center;justify-content:center;font-size:20px;opacity:.5}
.thumb.buyuk{width:96px;height:96px;flex:0 0 96px;border-radius:12px;font-size:34px}

.kameraKutu{
  margin-top:10px;background:#000;border-radius:12px;overflow:hidden;
  border:1px solid var(--line);padding:0 0 10px;
}
.kameraKutu video{width:100%;max-height:22vh;object-fit:cover;display:block}
.kameraKutu .row{padding:0 10px}

.alimSatir{border-bottom:1px solid var(--line);padding-bottom:8px;margin-bottom:8px}

/* ---- bağlantı göstergesi ---- */
.nokta{
  width:9px;height:9px;border-radius:50%;background:var(--muted);
  flex:0 0 9px;box-shadow:0 0 6px currentColor;
}
.nokta.ok{background:var(--ok);color:var(--ok)}
.nokta.bad{background:var(--bad);color:var(--bad)}

/* =========================================================
   MASAÜSTÜ GÖRÜNÜMÜ
   Başlıktaki düğme body[data-gorunum] değerini değiştirir.
   Mobil = varsayılan (yukarıdaki stiller), masaüstü = aşağısı.
   ========================================================= */
body[data-gorunum="masaustu"]{
  padding-bottom:0;
  padding-left:var(--yan);
  font-size:14.5px;
  --yan:212px;
}

body[data-gorunum="masaustu"] header{
  position:fixed;top:0;left:0;right:0;height:60px;z-index:40;
  padding:0 18px;
}
body[data-gorunum="masaustu"] header .title{font-size:18px}

/* sol menü */
body[data-gorunum="masaustu"] .tabs{
  top:60px;bottom:0;right:auto;width:var(--yan);
  flex-direction:column;align-items:stretch;justify-content:flex-start;
  border-top:0;border-right:1px solid var(--line);padding:12px 10px;gap:4px;
}
body[data-gorunum="masaustu"] .tabs button{
  flex:0 0 auto;flex-direction:row;justify-content:flex-start;gap:12px;
  padding:11px 14px;border-radius:10px;font-size:14px;
}
body[data-gorunum="masaustu"] .tabs button .ico{width:20px;height:20px}
body[data-gorunum="masaustu"] .tabs button.active{background:var(--card2);color:var(--txt)}
body[data-gorunum="masaustu"] .tabs button:hover{background:var(--hover)}

body[data-gorunum="masaustu"] main{
  max-width:1400px;margin:0;padding:78px 20px 28px;
}

/* sayfa yerleşimleri */
body[data-gorunum="masaustu"] .page.active{
  display:grid;gap:14px;align-items:start;
  grid-template-columns:repeat(auto-fit,minmax(380px,1fr));
}
body[data-gorunum="masaustu"] .page > .card{margin-bottom:0}

/* satış: solda barkod + sepet, sağda son satışlar */
body[data-gorunum="masaustu"] #pg-satis.active{grid-template-columns:1.15fr 1fr}
body[data-gorunum="masaustu"] #pg-satis > .card:nth-child(2){grid-column:2;grid-row:1}

/* ürünler: arama kartı tam genişlik, ürünler kart ızgarası */
body[data-gorunum="masaustu"] #pg-urun.active{grid-template-columns:1fr}
body[data-gorunum="masaustu"] #urunListe{
  display:grid;grid-template-columns:repeat(auto-fill,minmax(400px,1fr));gap:10px;
}

body[data-gorunum="masaustu"] .thumb{width:60px;height:60px;flex-basis:60px}
body[data-gorunum="masaustu"] .item{padding:12px 14px}
body[data-gorunum="masaustu"] .kpi .v{font-size:22px}
body[data-gorunum="masaustu"] table{font-size:13.5px}
body[data-gorunum="masaustu"] th,
body[data-gorunum="masaustu"] td{padding:9px 8px}

/* modal ortada, alt sayfa değil */
body[data-gorunum="masaustu"] .modal{align-items:center}
body[data-gorunum="masaustu"] .sheet{
  border-radius:16px;max-width:720px;max-height:86vh;margin:0 16px;
}
body[data-gorunum="masaustu"] .toast{bottom:26px}

/* dar ekranda masaüstü seçilirse menü daralsın */
@media (max-width:820px){
  body[data-gorunum="masaustu"]{--yan:64px}
  body[data-gorunum="masaustu"] .tabs button{flex-direction:column;gap:3px;font-size:10px;padding:8px 2px}
  body[data-gorunum="masaustu"] main{padding:74px 12px 24px}
  /* dar ekranda tek sütun: son satışlar sepetin yanına değil en alta */
  body[data-gorunum="masaustu"] .page.active,
  body[data-gorunum="masaustu"] #pg-satis.active{grid-template-columns:1fr}
  body[data-gorunum="masaustu"] #pg-satis > .card:nth-child(2){grid-column:auto;grid-row:auto}
}

/* sayfa başlığı kartı */
.sayfaBasligi h1{margin:0 0 2px;font-size:20px}
body[data-gorunum="masaustu"] .page > .card.sayfaBasligi{grid-column:1 / -1}

/* ---- rapor: dönem seçici ve ciro çubukları ---- */
.segment{display:inline-flex;background:var(--card2);border:1px solid var(--line);border-radius:10px;padding:3px;gap:2px}
.segment button{background:none;color:var(--txt);padding:6px 12px;font-size:13px;border-radius:8px;font-weight:600}
.segment button.active{background:var(--accent);color:#fff}
.cubuklar{display:flex;align-items:flex-end;gap:6px;height:130px;padding:6px 2px 0}
.cubuklar .cubuk{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%;min-width:0;gap:4px}
.cubuklar .cubuk .bar{width:100%;max-width:44px;background:var(--accent);border-radius:6px 6px 2px 2px;min-height:2px;opacity:.8;transition:height .25s}
.cubuklar .cubuk.secili .bar{opacity:1;background:var(--ok)}
.cubuklar .cubuk .deger,.cubuklar .cubuk .etiket{font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}

/* ---- giriş ekranı ---- */
.giris{position:fixed;inset:0;z-index:100;background:var(--bg);display:flex;align-items:center;justify-content:center;padding:16px}
.giris[hidden]{display:none}
/* hidden her zaman kazansın (display:flex/grid tanımlı öğeler dahil) */
[hidden]{display:none !important}
.girisKart{width:100%;max-width:380px;margin:0;text-align:center}
.girisKart .field{text-align:left}
.girisKart h1{margin-bottom:2px}
.girisLogo{font-size:44px;line-height:1;margin-bottom:6px}
.girisHata{color:var(--bad);min-height:18px;margin-bottom:8px;text-align:left}
#hdrKullanici{font-weight:500;opacity:.8}

/* ---- tedarikçi: whatsapp ve sipariş ---- */
.wa{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;flex:0 0 44px;border-radius:12px;background:#25d366;color:#fff;text-decoration:none}
.wa.sm{width:36px;height:36px;flex-basis:36px;border-radius:10px}
.wa svg{display:block}
.siparisSatir{cursor:pointer}
.siparisSatir input[type=checkbox]{width:20px;height:20px;flex:0 0 20px;margin:0;accent-color:var(--accent)}
.siparisSatir input.adet{width:68px;flex:0 0 68px;padding:8px 6px;text-align:center}
.tedarikciListe .item{cursor:pointer}
#tedarikciListe .item,#zincirListe .item{cursor:pointer}

/* ---- dönem kontrolü (rapor + gider): Günlük | Haftalık | Aylık | Aralık ---- */
.donem{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.donem .segment{flex-wrap:wrap}
.donem input[type=date],.donem input[type=week],.donem input[type=month]{width:auto;padding:8px 10px}
.donem .dAralik{display:inline-flex;align-items:center;gap:6px}

/* ---- rol bazlı görünürlük: personel kâr/maliyet görmez ---- */
body.personel .adminOnly{display:none !important}
body.cirosuz .ciroOnly{display:none !important}
body:not(.personel) .personelOnly{display:none !important}

/* ---- renkli sekme ikonları: pasifken soluk, aktifken canlı ---- */
.tabs button .ico{opacity:.55;filter:saturate(.6);transition:opacity .15s,filter .15s,transform .15s}
.tabs button.active .ico{opacity:1;filter:none;transform:translateY(-1px)}

.ayrac{border-top:1px solid var(--line)}

/* ---- satış: günlük pano (3 kart yan yana) ---- */
.gunluk{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:12px}
.gunluk .kpi{background:var(--card);padding:10px 10px 9px;min-width:0}
.gunluk .kpi .k{font-size:11px}
.gunluk .kpi .v{font-size:17px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gunluk .kpi .alt{font-size:11px;opacity:.75;margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@media (max-width:360px){.gunluk .kpi .v{font-size:15px}}
.tabs button{font-size:10.5px;padding:6px 0}
#btnTema{font-size:20px;padding:8px 14px}

/* son satışlar: tutar büyük, altında ürün adları */
#sonSatislar .name.tutar{font-size:18px;font-weight:700}
#sonSatislar .meta.urunler{white-space:normal;font-size:12.5px;margin:2px 0}

/* ---- personel inceleme ---- */
#personelListe .item{cursor:pointer}
.avatar{width:42px;height:42px;flex:0 0 42px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:700;color:#fff;font-size:16px}
.saatler{display:flex;align-items:flex-end;gap:2px;height:56px;margin-top:6px}
.saatler .s{flex:1;background:var(--accent);opacity:.75;border-radius:2px 2px 0 0;min-height:2px}
.saatler .s.bos{opacity:.15}
.saatEtiket{display:flex;justify-content:space-between;font-size:10px;opacity:.7}
.ilerleme{height:8px;background:var(--card2);border:1px solid var(--line);border-radius:999px;overflow:hidden}
.ilerleme > div{height:100%;background:var(--ok)}
.karsilastir{display:grid;grid-template-columns:1fr auto;gap:4px 10px;align-items:center;font-size:13px}

/* ---- sağ üst ayarlar düğmesi ---- */
.ayarBtn{background:none;border:0;padding:6px;border-radius:10px;display:flex;align-items:center;justify-content:center}
.ayarBtn:hover{background:var(--card2)}
.ayarBtn.active{background:var(--card2)}
.ayarBtn svg{display:block}

/* ---- sepet satırı: ürün adı orta boy, tutar daha büyük, sola kaydır-sil ---- */
.kaydir{position:relative;overflow:hidden;border-radius:12px}
.kaydir .kaydirArka{position:absolute;inset:0;background:var(--bad);color:#fff;display:flex;align-items:center;justify-content:flex-end;padding-right:18px;font-weight:700;border-radius:12px}
.kaydir .item{position:relative;will-change:transform;user-select:none;-webkit-user-select:none;touch-action:pan-y}
.kaydir.silinecek .kaydirArka{background:#b91c1c}
.sepetSatir .ad{font-size:13px;font-weight:500;line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sepetSatir .fiyat{display:flex;align-items:baseline;gap:8px;margin-top:2px}
.sepetSatir .fiyat .birim{font-size:11.5px;opacity:.75}
.sepetSatir .fiyat .tutar{font-size:17px;font-weight:700}
.sepetSatir .adetKutu{display:flex;align-items:center;gap:4px}
.sepetSatir .adetKutu .adet{min-width:22px;text-align:center;font-weight:700;font-size:15px}
.sepetSatir .adetKutu button{width:34px;height:34px;padding:0;font-size:18px;line-height:1;border-radius:9px}
#sepetListe.dolu::after{content:"← sola kaydırarak sil";display:block;font-size:11px;opacity:.55;text-align:right;padding:2px 4px 0}
