:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #2b2f2e;
  --muted: #6b706d;
  --line: #e2ddd2;
  --primary: #3f8f7a;
  --primary-dark: #2f7362;
  --primary-soft: #e4f1ec;
  --gold: #c4a046;
  --gold-soft: #f6efdc;
  --blue: #3f6fa8;
  --blue-soft: #e5ecf5;
  --danger: #b0543e;
  --radius: 16px;
  --nav-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { font-size: 19px; -webkit-text-size-adjust: 100%; }
@media (min-width: 420px) { html { font-size: 20px; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Üst bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--primary-dark); min-width: 0; }
.brand img { display: block; width: 44px; height: auto; flex: none; }
.brand-text { font-weight: 700; font-size: 1rem; line-height: 1.1; }
.brand-text small { font-weight: 400; font-size: .62em; color: #a9b3ae; letter-spacing: .02em; }
.user-chip {
  border: 1.5px solid var(--primary); background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: .9rem;
  max-width: 48vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Ana alan */
.app {
  max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 24px);
}
.app.has-actions { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 110px); }
body.typing .app.has-actions { padding-bottom: 140px; }
.loading { text-align: center; padding: 60px 0; color: var(--muted); }

h1 { font-size: 1.5rem; margin: 6px 0 6px; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 26px 0 10px; }
.lead { font-size: 1.05rem; color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}

/* Butonlar */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 60px; padding: 12px 18px;
  border-radius: 14px; border: 2px solid var(--line); background: #fff;
  font-size: 1.1rem; font-weight: 600; text-decoration: none; color: var(--ink);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-dark); }
.btn-ghost { background: transparent; border-style: dashed; color: var(--muted); }
.btn-danger { color: var(--danger); border-color: #ecd2ca; }
.btn-danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { min-height: 46px; font-size: 1rem; padding: 8px 14px; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* Kullanıcı seçimi */
.user-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.user-btn {
  min-height: 78px; border-radius: 16px; border: 2px solid var(--line); background: #fff;
  font-size: 1.15rem; font-weight: 600; padding: 10px;
}
.user-btn.placeholder { color: var(--muted); font-weight: 500; border-style: dashed; }
.user-btn.current { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

/* Seçim listeleri */
.pick { display: grid; gap: 10px; }
.pick-item {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 66px; padding: 10px 16px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; font-size: 1.12rem;
}
.pick-item .box {
  flex: none; width: 34px; height: 34px; border-radius: 10px; border: 2px solid #c9c4b8;
  display: grid; place-items: center; font-weight: 700; font-size: 1rem; color: #fff;
}
.pick-item.on { border-color: var(--primary); background: var(--primary-soft); }
.pick-item.on .box { background: var(--primary); border-color: var(--primary); }
.pick-item small { display: block; color: var(--muted); font-size: .85rem; }

/* Giriş ekranı */
.datebar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px;
}
.datebar .arrow {
  flex: none; width: 52px; height: 52px; border-radius: 12px; border: none; background: var(--bg);
  font-size: 1.4rem; color: var(--primary-dark);
}
.datebar .arrow:disabled { opacity: .3; }
.datebar label { flex: 1; text-align: center; position: relative; cursor: pointer; }
.datebar .date-main { font-weight: 700; font-size: 1.1rem; display: block; }
.datebar .date-sub { font-size: .85rem; color: var(--muted); display: block; }
.datebar .date-sub.today { color: var(--primary); font-weight: 600; }
.datebar input[type=date] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }

.nb-card { transition: border-color .15s, box-shadow .15s; }
.nb-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.nb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.nb-name { font-size: 1.3rem; font-weight: 700; }
.nb-district { font-size: .85rem; color: var(--muted); }
.nb-step { font-size: .85rem; color: var(--muted); white-space: nowrap; }

.qty-row { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.qty-row + .qty-row { margin-top: 14px; }
.qty-label { flex: 1; font-size: 1.05rem; font-weight: 600; min-width: 0; }
.qty-label .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  flex: none; width: 64px; height: 64px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg);
  font-size: 1.5rem; font-weight: 600; color: var(--primary-dark);
}
.qty-input {
  flex: 1; min-width: 0; width: 100%; height: 64px; border-radius: 12px; border: 2px solid #cfc9bc; background: #fff;
  text-align: center; font-size: 1.7rem; font-weight: 700; padding: 0 4px;
}
.qty-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.qty-input::placeholder { color: #cfcac0; font-weight: 400; }

.actions {
  position: fixed; left: 0; right: 0; z-index: 15;
  bottom: calc(var(--nav-h) + var(--safe-b));
  padding: 10px 16px; background: rgba(246,244,239,.97); border-top: 1px solid var(--line);
}
.actions-inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.actions .btn { min-height: 64px; font-size: 1.15rem; }
.actions .btn-next { flex: 1; }
.actions .btn-save { flex: 1.3; }
body.typing .bottomnav { display: none; }
body.typing .actions { bottom: 0; padding-bottom: calc(10px + var(--safe-b)); }

.hint { font-size: .95rem; color: var(--muted); text-align: center; margin: 8px 0 0; }

/* Alt menü */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line);
}
.bottomnav button {
  flex: 1; border: none; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: .78rem; font-weight: 600; color: var(--muted);
}
.bottomnav .ic { font-size: 1.45rem; line-height: 1; }
.bottomnav button.on { color: var(--primary-dark); }
.bottomnav button.on .ic { background: var(--primary-soft); border-radius: 999px; padding: 3px 16px; }

/* İstatistik kartları */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; }
.stat .v { font-size: 1.75rem; font-weight: 800; line-height: 1.1; }
.stat .l { font-size: .92rem; color: var(--muted); font-weight: 600; }
.stat.total { background: var(--primary); border-color: var(--primary); color: #fff; }
.stat.total .l { color: rgba(255,255,255,.85); }

.saved-banner {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius);
  background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; font-size: 1.15rem; margin-bottom: 14px;
}
.saved-banner .ok { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 1.3rem; flex: none; }

/* Sekmeler */
.seg { display: flex; background: #ebe7de; border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; min-height: 50px; border: none; border-radius: 11px; background: none; font-weight: 600; font-size: 1.02rem; color: var(--muted); }
.seg button.on { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* Yatay çubuklar */
.hbar + .hbar { margin-top: 14px; }
.hbar-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.hbar-top b { font-size: 1.15rem; }
.hbar-track { display: flex; height: 16px; background: #efebe3; border-radius: 8px; overflow: hidden; margin-top: 4px; }
.hbar-track span { display: block; height: 100%; }
.hbar-sub { font-size: .85rem; color: var(--muted); margin-top: 3px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .92rem; margin-bottom: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart svg { display: block; width: 100%; height: auto; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }

/* Geçmiş */
.day-group { margin-bottom: 14px; }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.day-head h3 { margin: 0; font-size: 1.05rem; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.row-item:first-child { border-top: none; }
.row-item .main { flex: 1; min-width: 0; }
.row-item .main b { display: block; }
.row-item .main small { color: var(--muted); }
.row-item .q { font-size: 1.35rem; font-weight: 800; min-width: 48px; text-align: right; }
.icon-btn { width: 48px; height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-size: 1.15rem; }

/* Ayarlar */
.setting-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.setting-row:first-of-type { border-top: none; }
.setting-row .main { flex: 1; min-width: 0; }
.setting-row.off .main { color: var(--muted); text-decoration: line-through; }
details.admin { margin-top: 26px; }
details.admin > summary { cursor: pointer; font-weight: 700; padding: 14px 0; color: var(--muted); }

/* Form alanları */
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-weight: 600; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; min-height: 58px; border-radius: 12px; border: 2px solid #cfc9bc; background: #fff; padding: 8px 14px; font-size: 1.15rem;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }
.check-line { display: flex; align-items: center; gap: 12px; font-size: 1.05rem; min-height: 50px; }
.check-line input { width: 26px; height: 26px; accent-color: var(--primary); }

/* Bildirim ve pencere */
.toast {
  position: fixed; left: 50%; top: 80px; transform: translate(-50%, -20px); z-index: 60;
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 14px; font-weight: 600; font-size: 1.05rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(30,35,33,.45);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
.modal-box {
  background: #fff; width: 100%; max-width: 560px; border-radius: 22px 22px 0 0;
  padding: 22px 18px calc(18px + var(--safe-b)); max-height: 92vh; overflow: auto;
}
@media (min-width: 600px) { .modal { align-items: center; } .modal-box { border-radius: 22px; } }
.modal-box h3 { margin: 0 0 8px; font-size: 1.3rem; }
.modal-box p { margin: 0 0 14px; color: var(--muted); }
.modal-box .btn-row { margin-top: 16px; }

/* Mahalle / ürün listesi */
.list-item.off { background: #faf9f6; }
.list-item.off .list-name { color: var(--muted); }
.list-head { display: flex; align-items: flex-start; gap: 12px; }
.list-head .main { flex: 1; min-width: 0; }
.list-head .dot { flex: none; width: 16px; height: 16px; border-radius: 50%; margin-top: 8px; }
.list-name { font-size: 1.25rem; font-weight: 700; }
.list-use { font-size: .92rem; color: var(--muted); margin-top: 4px; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #ebe7de; color: var(--muted); vertical-align: 3px; }

/* Yabancı / Türk bölümleri */
.grp-block + .grp-block { margin-top: 16px; }
.grp-block.grp-Y, .grp-block.grp-T { border-left: 5px solid var(--blue); padding-left: 12px; }
.grp-block.grp-T { border-left-color: #b5543c; }
.grp-title { font-weight: 800; font-size: 1.05rem; margin-bottom: 8px; color: var(--blue); }
.grp-T .grp-title { color: #b5543c; }
.grp-tag { font-weight: 700; }
.grp-tag.grp-Y { color: var(--blue); }
.grp-tag.grp-T { color: #b5543c; }

/* Tanıtım */
.intro { display: flex; flex-direction: column; min-height: calc(100vh - 110px); }
.intro-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.intro-count { color: var(--muted); font-weight: 600; }
.intro-skip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 10px 16px; font-weight: 600; color: var(--muted); }
.intro-img { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; margin-bottom: 12px; }
.intro-img img { display: block; max-width: 100%; max-height: calc(100vh - 420px); min-height: 220px; object-fit: contain; border-radius: 18px; border: 6px solid #2b2f2e; box-shadow: 0 8px 24px rgba(0,0,0,.12); background: #fff; }
.intro-img.logo img { border: none; box-shadow: none; max-height: 200px; min-height: 0; background: none; }
.intro h1 { text-align: center; font-size: 1.6rem; color: var(--primary-dark); }
.intro-text { text-align: center; font-size: 1.15rem; margin: 0 0 14px; }
.intro-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.intro-dots span { width: 10px; height: 10px; border-radius: 50%; background: #d6d1c5; }
.intro-dots span.on { background: var(--primary); width: 26px; border-radius: 6px; }
.intro .btn { min-height: 64px; font-size: 1.2rem; }

/* Ürün içeriği */
.content-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.content-line { font-size: 1.05rem; padding: 3px 0; }
.content-current { border-color: var(--primary); }
.content-edit-row { display: grid; grid-template-columns: 1fr 1fr 48px; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.content-edit-row input, .content-edit-row select { min-height: 54px; border-radius: 12px; border: 2px solid #cfc9bc; background: #fff; padding: 6px 10px; font-size: 1.05rem; width: 100%; min-width: 0; }
.content-edit-row .line-name { grid-column: 1 / 3; }
.content-edit-row .icon-btn { grid-column: 3; grid-row: 1 / 3; height: 100%; width: 100%; }
.content-edit-row input:focus, .content-edit-row select:focus { outline: none; border-color: var(--primary); }
