:root {
  color-scheme: light;
  --bg: #f6f2ee;
  --surface: #ffffff;
  --ink: #2a211c;
  --muted: #7b6f68;
  --line: #e6ddd6;
  --brand: #7a4e3a;
  --brand-ink: #ffffff;
  --brand-soft: #f1e6df;
  --ok: #2f7d4f;
  --ok-soft: #e3f2e8;
  --warn: #a8641a;
  --warn-soft: #fbefdf;
  --bad: #b3362b;
  --bad-soft: #fbe5e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(42, 33, 28, .06), 0 4px 16px rgba(42, 33, 28, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input { font: inherit; color: inherit; }
img { display: block; }

.page { max-width: 560px; margin: 0 auto; padding: 12px 16px 120px; }

/* Üst çubuk */
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 0 12px; }
.topbar h1 { font-size: 20px; margin: 0; flex: 1; }
.topbar .who { color: var(--muted); font-size: 14px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; font-size: 20px; cursor: pointer;
}

/* Butonlar */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer;
  width: 100%;
}
.btn:active { transform: scale(.99); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.bad { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: 8px 12px; width: auto; font-size: 15px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .btn { flex: 1; }

/* Ana menü */
.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu .tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 18px 14px; min-height: 120px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
}
.menu .tile .emoji { font-size: 30px; }
.menu .tile b { font-size: 17px; display: block; }
.menu .tile small { color: var(--muted); font-size: 13px; }
.menu .tile.wide { grid-column: span 2; min-height: 72px; flex-direction: row; align-items: center; gap: 12px; justify-content: flex-start; }

/* Kart */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.muted { color: var(--muted); }
.small-text { font-size: 14px; }

/* Kamera */
.camera {
  position: relative; background: #111; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 4 / 3; max-height: 42dvh; width: 100%; margin-bottom: 10px;
}
.camera video { width: 100%; height: 100%; object-fit: cover; }
.camera .frame {
  position: absolute; left: 10%; right: 10%; top: 30%; bottom: 30%;
  border: 3px solid rgba(255, 255, 255, .85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25);
  pointer-events: none; transition: border-color .15s;
}
.camera.hit .frame { border-color: #4ade80; }
.camera .cam-msg {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #fff;
  padding: 20px; font-size: 15px;
}
.camera .paused { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; font-weight: 600; }

.cam-controls { display: flex; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.cam-controls .btn { flex: 1; }
.cam-status { font-size: 12px; color: var(--muted); margin-bottom: 10px; min-height: 16px; word-break: break-word; }
.manual { display: flex; gap: 8px; margin-bottom: 12px; }
.manual input { flex: 1; }
input[type=text], input[type=password], input[type=search], input[type=number] {
  width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-size: 17px;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Ürün başlığı */
.product-head { display: flex; gap: 12px; align-items: center; }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--brand-soft); flex: none; }
.thumb.lg { width: 84px; height: 84px; }
.product-head .name { font-weight: 600; line-height: 1.3; }

/* Gruplar (renk) ve varyantlar */
.group { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.group-head .thumb { width: 40px; height: 40px; }
.group-head .gname { font-weight: 600; flex: 1; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 14px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.active { background: var(--brand); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 14px; background: var(--bg); }
.chip b { margin-left: 4px; }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; cursor: pointer; }
.stepper .val { min-width: 34px; text-align: center; font-weight: 700; font-size: 18px; }

/* Seçim ızgarası */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pick {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 10px;
  text-align: left; cursor: pointer; min-height: 64px; display: flex; flex-direction: column; gap: 6px;
}
.pick img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--brand-soft); }
.pick b { font-size: 16px; }
.pick small { color: var(--muted); }
.pick.zero small { color: var(--bad); }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; text-align: left; cursor: pointer; width: 100%;
}

/* Sayım satırı */
.count-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.count-row:last-child { border-bottom: 0; }
.count-row .lbl { flex: 1; }
.count-row input { width: 90px; min-height: 44px; text-align: center; }

/* Alt sabit çubuk */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(246, 242, 238, .96); border-top: 1px solid var(--line); backdrop-filter: blur(6px);
}
.bottom-bar .inner { max-width: 560px; margin: 0 auto; }

/* Alt sayfa (sheet) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
.sheet .sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.sheet .sheet-head h2 { margin: 0; font-size: 18px; flex: 1; }

/* Bildirim */
#toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%) translateY(-120%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; max-width: 92vw;
  transition: transform .2s; font-weight: 600; box-shadow: var(--shadow);
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.ok { background: var(--ok); }
#toast.bad { background: var(--bad); }

/* Hareketler */
.mv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mv .t { color: var(--muted); font-size: 13px; }
.mv .d { font-weight: 700; text-align: right; }
.mv .d.plus { color: var(--ok); }
.mv .d.minus { color: var(--bad); }

.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login .logo { font-size: 26px; font-weight: 800; color: var(--brand); margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.err { color: var(--bad); font-weight: 600; min-height: 22px; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.spacer { height: 10px; }

/* Sipariş hazırlama */
.thumb.sm { width: 36px; height: 36px; border-radius: 8px; }
.order-item.done { opacity: .6; }
.order-line { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.order-line.ok { background: var(--ok-soft); border-radius: 12px; padding: 10px; }
.line-count { font-size: 22px; font-weight: 800; min-width: 48px; text-align: center; }
.order-line.ok .line-count { color: var(--ok); }

.flash { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; color: #fff; animation: pop .15s ease-out; }
.flash.bad { background: #c62828; }
.flash.ok { background: #2e7d32; }
@keyframes pop { from { opacity: .4; transform: scale(1.03); } }
.flash-box { max-width: 480px; width: 100%; text-align: center; }
.flash-title { font-size: 40px; font-weight: 900; letter-spacing: .5px; margin-bottom: 12px; }
.flash-what { font-size: 20px; margin-bottom: 16px; }
.flash-need { background: rgba(255, 255, 255, .15); border-radius: 14px; padding: 12px; text-align: left; font-size: 16px; }
.flash-need .thumb { background: rgba(255, 255, 255, .3); }
.flash-hint { margin-top: 20px; opacity: .8; font-size: 14px; }
