@import url(/fonts.css);

:root {
  --ink: #1D2340;
  --ink-2: #4A5170;
  --muted: #6A7190;
  --paper: #E6E9F2;
  --card: #FFFFFF;
  --line: #D5DAE7;
  --accent: #E0336A;
  --accent-ink: #B81F51;
  --accent-soft: #FCE4EC;
  --ok: #0E9265;
  --ok-soft: #DDF3EA;
  --bad: #C8283A;
  --bad-soft: #FBE3E6;
  --warn: #B86E00;
  --warn-soft: #FDF0D8;
  --wa: #1DA851;
  --radius-lg: 18px;
  --radius: 12px;
  --nav-h: 64px;
  --font: 'Bricolage', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Üst çubuk ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: #fff;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
}
.topbar-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; color: #fff; text-decoration: none; flex-shrink: 0; }
.logo img { width: 28px; height: 28px; }
.event-picker { flex: 1; min-width: 0; position: relative; }
.event-picker select {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,.1); color: #fff; border: 0;
  border-radius: 10px; padding: 9px 34px 9px 12px; font-weight: 600; font-size: 15px;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.event-picker select option { color: var(--ink); }
.event-picker::after {
  content: ''; position: absolute; right: 13px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.user-btn {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px;
}

/* ---------- Gezinme ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { display: flex; max-width: 760px; margin: 0 auto; }
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--nav-h); text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--accent); }

body.single-nav .nav { display: none; }
body.single-nav main.view { padding-bottom: 32px; }
main.view {
  max-width: 760px; margin: 0 auto;
  padding: 20px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
}

@media (min-width: 900px) {
  .nav { position: sticky; top: 58px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); padding: 0; }
  .nav a { flex: 0 0 auto; flex-direction: row; gap: 8px; height: 50px; padding: 0 16px; font-size: 15px; }
  .nav a svg { width: 20px; height: 20px; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }
  main.view { padding-bottom: 48px; }
}

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.view-head h1 { font-size: 28px; font-weight: 800; }
.view-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Kartlar, alanlar ---------- */
.card { background: var(--card); border-radius: var(--radius-lg); padding: 18px; }
.card + .card { margin-top: 14px; }
.card h2 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span, .field > label { font-weight: 600; font-size: 15px; }
.field small { color: var(--muted); font-size: 13px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff;
  font-size: 17px;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(29,35,64,.12); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .row.stack-sm { grid-template-columns: 1fr; } }

/* Bilet türü seçimi */
.types { display: grid; gap: 10px; }
.type-opt { position: relative; }
.type-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.type-opt .box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff;
}
.type-opt .name { font-weight: 700; font-size: 17px; }
.type-opt .meta { color: var(--muted); font-size: 13px; }
.type-opt .price { font-weight: 800; font-size: 20px; white-space: nowrap; }
.type-opt input:checked + .box { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.type-opt input:focus-visible + .box { outline: 3px solid var(--accent); outline-offset: 2px; }
.type-opt input:disabled + .box { opacity: .45; }

/* Segmented kontrol */
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 46px; padding: 6px 10px; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: #fff; font-weight: 600; font-size: 15px;
}
.seg input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.stepper { justify-self: start; display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff; }
.stepper button { width: 50px; height: 48px; border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--ink); }
.stepper button:disabled { opacity: .3; }
.stepper output { min-width: 40px; text-align: center; font-weight: 800; font-size: 20px; }

.total-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 6px 0 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--paper);
}
.total-bar strong { font-size: 24px; font-weight: 800; }

/* ---------- Düğmeler ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: var(--radius); border: 1.5px solid transparent;
  font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--ink); color: #fff;
}
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.btn.primary { background: var(--accent); }
.btn.primary:hover { background: var(--accent-ink); }
.btn.wa { background: var(--wa); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.danger { background: #fff; color: var(--bad); border-color: #F0B9C0; }
.btn.ghost { background: transparent; color: var(--ink); min-height: 40px; padding: 0 10px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row > .btn { flex: 1 1 180px; }

/* ---------- Durum etiketleri ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pill.valid { background: var(--ok-soft); color: var(--ok); }
.pill.used { background: #E4E7F1; color: var(--ink-2); }
.pill.cancelled { background: var(--bad-soft); color: var(--bad); }
.pill.off { background: var(--warn-soft); color: var(--warn); }

/* ---------- Listeler ---------- */
.search-bar { display: grid; gap: 10px; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips button {
  flex-shrink: 0; border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 14px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.list { background: var(--card); border-radius: var(--radius-lg); overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: #F6F7FB; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* ---------- Satış sonrası ---------- */
.done-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.done-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; flex-shrink: 0; }
.done-icon svg { width: 28px; height: 28px; color: #fff; }
.done-head h1 { font-size: 24px; font-weight: 800; }
.done-head p { margin: 2px 0 0; color: var(--muted); }
.qr-strip { display: flex; gap: 12px; overflow-x: auto; padding: 4px 0 10px; margin-bottom: 8px; }
.qr-mini { flex: 0 0 auto; width: 150px; text-align: center; font-size: 13px; color: var(--muted); }
.qr-mini img { width: 150px; height: 150px; display: block; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.qr-strip.single .qr-mini, .qr-strip.single .qr-mini img { width: 210px; }
.qr-strip.single .qr-mini img { height: 210px; }
.qr-strip.single { justify-content: center; }

/* ---------- Detay paneli (dialog) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px;
  border-radius: 22px 22px 0 0; background: var(--card); color: var(--ink);
  max-height: 90vh; overflow: auto;
}
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 22px; } }
dialog.sheet::backdrop { background: rgba(20, 24, 45, .55); }
.sheet-body { padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 22px; font-weight: 800; }
.close-x { border: 0; background: var(--paper); width: 36px; height: 36px; border-radius: 50%; font-size: 20px; cursor: pointer; flex-shrink: 0; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0 0 18px; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- Kapı ---------- */
.door-counter { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.door-counter strong { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.door-counter span { color: var(--muted); font-size: 16px; }
.door-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; background: #D7DBE7; border-radius: 14px; margin-bottom: 14px; }
.door-tabs button { border: 0; background: none; padding: 10px; border-radius: 10px; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.door-tabs button[aria-pressed="true"] { background: #fff; color: var(--ink); }
.camera {
  position: relative; background: #12162B; border-radius: var(--radius-lg); overflow: hidden;
  aspect-ratio: 1; max-width: 520px; margin: 0 auto;
}
.camera #reader { width: 100%; height: 100%; }
.camera #reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.camera .cam-msg {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 24px; color: #E1E4F0; gap: 14px; align-content: center;
}
.camera .cam-msg strong { color: #fff; font-size: 18px; }

.scan-result {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; justify-content: center;
  padding: 32px 24px; color: #fff; text-align: center; cursor: pointer;
  animation: pop .18s ease-out;
}
.scan-result.ok { background: var(--ok); }
.scan-result.bad { background: var(--bad); }
.scan-result.warn { background: #A65F00; }
.scan-result .big-icon { width: 96px; height: 96px; margin: 0 auto 18px; }
.scan-result h2 { font-size: clamp(30px, 8vw, 44px); font-weight: 800; margin-bottom: 14px; }
.scan-result .who { font-size: clamp(24px, 7vw, 34px); font-weight: 700; margin-bottom: 6px; word-break: break-word; }
.scan-result .what { font-size: 18px; opacity: .92; }
.scan-result .hint { margin-top: 36px; font-size: 15px; opacity: .8; }
@keyframes pop { from { transform: scale(.97); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .scan-result { animation: none; } }

/* ---------- Rapor ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border-radius: var(--radius-lg); padding: 16px; }
.stat b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 14px; }
.meter { height: 10px; border-radius: 999px; background: var(--paper); overflow: hidden; margin: 10px 0 4px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.meter.ink i { background: var(--ink); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 0 8px 8px 0; }
.tbl td { padding: 10px 8px 10px 0; border-top: 1px solid var(--line); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Etkinlik düzenleme ---------- */
.type-row { display: grid; grid-template-columns: 1fr 110px 96px auto; gap: 8px; align-items: end; margin-bottom: 10px; }
.type-row .input { min-height: 46px; font-size: 16px; padding: 10px 12px; }
.type-row label > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
@media (max-width: 560px) {
  .type-row { grid-template-columns: 1fr 1fr; padding: 12px; background: var(--paper); border-radius: var(--radius); }
  .type-row .name-col { grid-column: 1 / -1; }
}
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---------- Giriş ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--ink); }
.login-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 22px; padding: 28px 24px; }
.login-card .logo { color: var(--ink); margin-bottom: 22px; font-size: 22px; }
.login-card h1 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 10px; font-weight: 600; margin-bottom: 14px; }

/* ---------- Bildirimler ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 80; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: 480px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); pointer-events: auto; }
.toast.error { background: var(--bad); }
.toast.success { background: var(--ok); }

.notice { padding: 12px 14px; border-radius: var(--radius); background: var(--warn-soft); color: #6E4300; margin-bottom: 14px; line-height: 1.45; }
.muted { color: var(--muted); }
.mt { margin-top: 16px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
