/* Saha ekranı — dükkân zemininde, eldivenle, güneş altında kullanılacak.
   Büyük dokunma hedefleri, yüksek kontrast, tek vurgu rengi (iş güvenliği turuncusu). */
:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #ebe8e1;
  --ink: #16181d;
  --ink-2: #4a4d55;
  --ink-3: #80838b;
  --line: #d9d5cc;
  --panel: #16181d;
  --panel-2: #252930;
  --accent: #e8590c;
  --accent-ink: #ffffff;
  --ok: #2b8a3e;
  --warn: #b35c00;
  --err: #c92a2a;
  --radius: 14px;
  --tap: 56px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --surface: #1b1e24; --surface-2: #252930; --ink: #f1efe9; --ink-2: #b9bcc4; --ink-3: #868a93;
    --line: #2f343c; --panel: #08090b; --panel-2: #22262d; --accent: #ff7a2f; --accent-ink: #16181d; --ok: #51cf66; --warn: #ffa94d; --err: #ff6b6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --surface: #1b1e24; --surface-2: #252930; --ink: #f1efe9; --ink-2: #b9bcc4; --ink-3: #868a93;
  --line: #2f343c; --panel: #08090b; --panel-2: #22262d; --accent: #ff7a2f; --accent-ink: #16181d; --ok: #51cf66; --warn: #ffa94d; --err: #ff6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); letter-spacing: .04em; }

/* Üst bar */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--panel); color: #f1efe9; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; }
.brand-mark { width: 14px; height: 14px; background: var(--accent); border-radius: 3px; transform: rotate(45deg); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.who { font-size: 14px; color: #b9bcc4; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid #3a3e46; background: transparent;
  color: #f1efe9; font-size: 14px; font-weight: 600;
}
.demo-banner { background: var(--warn); color: #fff; font-size: 14px; padding: 8px 16px; text-align: center; }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 120px; }
.view-title { font-size: 24px; margin: 8px 0 16px; letter-spacing: -.01em; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 24px 0 8px; font-weight: 600; }
.hint { color: var(--ink-2); margin: 8px 0 0; }
.hint.small { font-size: 14px; }
.msg { min-height: 1.4em; margin: 10px 0 0; color: var(--err); font-weight: 500; }
.msg.ok { color: var(--ok); }

/* PIN */
#view-login { text-align: center; padding-top: 4vh; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 8px 0 4px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-3); }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); }
.pin-dots i.off { display: none; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 16px auto 0; }
.keypad button {
  height: 72px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  font-size: 28px; font-weight: 600; font-family: var(--mono);
}
.keypad button:active { background: var(--surface-2); }
.keypad .key-ok { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-family: var(--font); font-size: 20px; }

/* Sekmeler */
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: var(--radius); padding: 4px; margin-bottom: 16px; }
.tab { min-height: 48px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; color: var(--ink-2); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* Tarama butonu */
.btn-scan {
  width: 100%; min-height: 128px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: 18px; background: var(--accent); color: var(--accent-ink); font-size: 22px; font-weight: 700;
}
.btn-scan svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.btn-scan:active { transform: scale(.99); filter: brightness(.95); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); margin: 24px 0 16px; font-size: 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.search label { display: block; font-weight: 600; margin-bottom: 8px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; }

input, textarea, select {
  width: 100%; min-height: var(--tap); padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); font-size: 18px;
}
textarea { min-height: 72px; resize: vertical; font-size: 16px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--ink); }
input[aria-invalid="true"] { border-color: var(--err); }

.btn {
  min-height: var(--tap); padding: 0 20px; border-radius: 12px; border: 1.5px solid var(--ink); background: var(--ink);
  color: var(--bg); font-weight: 700; font-size: 17px; white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); flex: 1; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.light { background: #fff; color: #16181d; border-color: #fff; }
.btn.ghost-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; }

/* Sonuç listesi */
.results { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.results button {
  width: 100%; text-align: left; padding: 14px 16px; border-radius: var(--radius); border: 1.5px solid var(--line);
  background: var(--surface); display: grid; gap: 2px;
}
.results button:active { border-color: var(--ink); }
.results .r-name { font-weight: 600; }
.results .r-vin { font-family: var(--mono); color: var(--ink-2); font-size: 14px; }

/* Araç kartı */
.vcard { background: var(--panel); color: #f1efe9; border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.vcard .v-name { font-size: 20px; font-weight: 700; line-height: 1.25; }
.vcard .v-vin { font-family: var(--mono); font-size: 15px; color: #b9bcc4; margin-top: 4px; word-break: break-all; }
.vcard .v-vin b { color: #fff; font-weight: 600; }
.vcard .v-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.vcard .v-stat { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.vcard .v-stat span { display: block; font-size: 12px; color: #868a93; text-transform: uppercase; letter-spacing: .06em; }
.vcard .v-stat strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.vcard .v-stat.warn strong { color: #ffa94d; }

/* Kontrol listesi */
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ck {
  display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 4px 10px; padding: 8px 12px; min-height: var(--tap);
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.ck.on { border-color: var(--accent); }
.ck input[type="checkbox"] { width: 28px; height: 28px; min-height: 0; margin: 0 8px; accent-color: var(--accent); }
.ck .ck-name { font-weight: 600; font-size: 17px; }
.ck .ck-cat { font-size: 13px; color: var(--ink-3); }
.ck .money { grid-column: 2; }
.money { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); padding-left: 14px; }
.money span { color: var(--ink-3); font-weight: 600; }
.money input { border: 0; min-height: 48px; padding-left: 6px; font-variant-numeric: tabular-nums; }
.money.big input { min-height: var(--tap); font-size: 24px; font-weight: 600; }
.money:focus-within { border-color: var(--ink); }

.other { margin-top: 16px; }
.other > label { display: block; font-weight: 600; margin-bottom: 6px; }
.other-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button { min-height: var(--tap); border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.more { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 8px; }
.more summary { min-height: 48px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 label, label.block { display: block; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.grid2 input, label.block input, label.block textarea, label.block .money { margin-top: 6px; }
label.block { margin-top: 14px; }

/* Kaydet çubuğu */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line);
}
.savebar > * { max-width: 560px; }
@media (min-width: 600px) { .savebar { justify-content: center; } .savebar .btn.primary { max-width: 400px; } }
.save-sum { font-weight: 500; opacity: .85; font-variant-numeric: tabular-nums; }

/* Sonuç */
#view-done { text-align: center; padding-top: 6vh; }
.done-icon { width: 80px; height: 80px; margin: 0 auto; border-radius: 50%; background: var(--ok); color: #fff; font-size: 44px; line-height: 80px; font-weight: 700; }
.done-list { list-style: none; padding: 0; margin: 8px 0 28px; text-align: left; display: grid; gap: 8px; }
.done-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 12px; }
.done-list li span:last-child { color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.done-list li.total { border-color: var(--ink); font-weight: 700; }

/* Tarayıcı */
.scanner { position: fixed; inset: 0; z-index: 20; background: #000; display: flex; flex-direction: column; }
#reader { position: absolute; inset: 0; }
#reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
#reader img, #reader__dashboard, #reader__header_message { display: none !important; }
.scanner-frame {
  position: absolute; left: 6%; right: 6%; top: 38%; height: 18%; border: 3px solid var(--accent); border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.45);
}
.scanner-msg { position: absolute; left: 16px; right: 16px; top: calc(20% - 1em); text-align: center; color: #fff; font-weight: 600; margin: 0; text-shadow: 0 1px 3px #000; }
.scanner-msg.err { color: #ffa94d; }
.scanner-actions { position: absolute; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.scanner-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 30; margin: 0 auto; max-width: 520px;
  background: var(--ink); color: var(--bg); padding: 14px 16px; border-radius: 12px; font-weight: 600; text-align: center;
}

@media (prefers-reduced-motion: no-preference) {
  .view { animation: in .18s ease-out; }
  @keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
