:root {
  --bg: #f6f4f1; --card: #fff; --text: #1f2328; --muted: #5d6670; --line: #e3ded6;
  --brand: #3b2a1e; --accent: #b4572b; --ok: #1a7f37; --ok-bg: #e7f6ec; --err: #c62828; --err-bg: #fdecea;
  --warn: #8a5a00; --warn-bg: #fff4d6; --info-bg: #eef4fb; --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
.muted { color: var(--muted); font-size: .9rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.nowrap { white-space: nowrap; }

/* Üst menü */
.topbar { background: var(--brand); color: #fff; display: flex; flex-wrap: wrap; align-items: center; padding: .6rem 1rem; gap: .5rem; }
.brand { color: #fff; font-weight: 700; text-decoration: none; margin-right: auto; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.nav a, .nav .linklike { color: #f1e7dc; text-decoration: none; padding: .45rem .7rem; border-radius: 6px; font-size: .95rem; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.logout { margin: 0; }
.linklike { background: none; border: 0; cursor: pointer; font: inherit; }
.navtoggle, .navtoggle-btn { display: none; }
@media (max-width: 760px) {
  .navtoggle-btn { display: block; cursor: pointer; padding: .3rem .6rem; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  .navtoggle:checked ~ .nav { display: flex; }
}

.container { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.narrow { max-width: 520px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }

/* Formlar */
label { display: block; font-weight: 600; margin: .9rem 0 .3rem; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: .65rem .75rem; border: 1px solid #c9c2b8; border-radius: 8px; font: inherit; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(180,87,43,.25); border-color: var(--accent); }
.hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.checkbox { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; }
.checkbox input { width: 1.4rem; height: 1.4rem; margin-top: .1rem; flex: none; }

.btn { display: inline-block; border: 0; border-radius: 8px; padding: .7rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--accent); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: #e9e4dc; color: var(--text); }
.btn-danger { background: var(--err); }
.btn-small { padding: .35rem .7rem; font-size: .88rem; }
.btn-block { display: block; width: 100%; text-align: center; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.2rem; align-items: center; }

/* Uyarılar ve rozetler */
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: #0f5323; border-color: #b7e2c4; }
.alert-error { background: var(--err-bg); color: #8e1c1c; border-color: #f3c1bd; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #f0d9a8; }
.alert-info { background: var(--info-bg); color: #1d4a7a; border-color: #c9dbef; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.b-active, .b-sent { background: var(--ok-bg); color: var(--ok); }
.b-redeemed { background: #e8eefc; color: #2847a0; }
.b-expired, .b-pending, .b-sending, .b-retry_pending, .b-not_yet_valid { background: var(--warn-bg); color: var(--warn); }
.b-cancelled, .b-failed { background: var(--err-bg); color: var(--err); }

/* Tablolar */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: #faf8f5; font-weight: 600; white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
dl.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: .4rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; }
@media (max-width: 520px) { dl.kv { grid-template-columns: 1fr; } dl.kv dd { margin-bottom: .5rem; } }

/* Gösterge paneli */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .v { font-size: 1.5rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filters > div { min-width: 140px; }
.filters label { margin: 0 0 .2rem; font-size: .85rem; }
.pill { padding: .4rem .8rem; border-radius: 999px; background: #e9e4dc; color: var(--text); text-decoration: none; font-size: .9rem; }
.pill.on { background: var(--brand); color: #fff; }
.pagination { display: flex; gap: .5rem; margin-top: 1rem; align-items: center; }

/* Personel kupon ekranı (mobil öncelikli) */
body.redeem { background: #f2efe9; font-size: 18px; }
.redeem-head { text-align: center; padding: 1.2rem 1rem .4rem; }
.redeem-head .partners { font-size: .95rem; color: var(--muted); letter-spacing: .3px; }
.redeem-head h1 { font-size: 1.45rem; margin: .3rem 0 0; }
.status-box { border-radius: 14px; padding: 1.2rem; text-align: center; margin-bottom: 1rem; border: 2px solid; }
.status-box .big { font-size: 1.6rem; font-weight: 800; line-height: 1.25; }
.status-box.ok { background: var(--ok-bg); border-color: #86cf9c; color: #0f5323; }
.status-box.bad { background: var(--err-bg); border-color: #ef9a94; color: #8e1c1c; }
.status-box.warn { background: var(--warn-bg); border-color: #e9c46a; color: var(--warn); }
.status-box.done { background: #e8eefc; border-color: #9db3ec; color: #1f3b8a; }
.target { font-size: 1.25rem; font-weight: 700; }
.tiers { list-style: none; padding: 0; margin: .5rem 0 0; }
.tiers li { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px solid var(--line); gap: 1rem; }
.tiers li:last-child { border-bottom: 0; }
input.amount { font-size: 1.6rem; padding: .7rem .8rem; text-align: right; font-weight: 700; }
.calc { margin-top: 1rem; background: #faf8f5; border-radius: 10px; padding: .8rem 1rem; }
.calc div { display: flex; justify-content: space-between; padding: .25rem 0; }
.calc .disc { color: var(--ok); font-weight: 800; font-size: 1.3rem; }
.calc .net { font-weight: 800; font-size: 1.2rem; border-top: 1px dashed var(--line); margin-top: .3rem; padding-top: .5rem; }
.btn-huge { font-size: 1.25rem; padding: 1rem; border-radius: 12px; background: var(--ok); }
.center { text-align: center; }
.m0 { margin: 0; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.mt1 { margin-top: 1rem; }
.mt-s { margin: .6rem 0 0; }
.mt-xs { margin: .2rem 0 0; }
.calc span:last-child { white-space: nowrap; text-align: right; }
.calc span:first-child { padding-right: .75rem; }

/* ---------- Hızlı kupon formu ---------- */
.quick-form { max-width: 560px; }
.quick-form label { margin-top: 1.1rem; }
fieldset.routes { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .6rem; }
fieldset.routes legend { font-weight: 700; margin-bottom: .5rem; padding: 0; }
.route-card { margin: 0; cursor: pointer; display: block; }
.route-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.route-card span { display: block; border: 2px solid #d8d0c4; border-radius: 12px; padding: .85rem 1rem; background: #fff; min-height: 64px; }
.route-card strong { display: block; font-size: 1.1rem; }
.route-card small { color: var(--muted); font-weight: 500; }
.route-card input:checked + span { border-color: var(--accent); background: #fbefe8; box-shadow: 0 0 0 3px rgba(180,87,43,.18); }
.route-card input:checked + span strong::before { content: "✓ "; color: var(--accent); }
.route-card input:focus-visible + span { outline: 3px solid rgba(180,87,43,.4); }
.quick-form input.amount { font-size: 1.5rem; font-weight: 700; }
details.more { margin-top: 1.1rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .7rem 1rem; }
details.more summary { cursor: pointer; color: var(--muted); }
details.more label:first-of-type { margin-top: .6rem; }
.submit-bar { margin-top: 1.4rem; }
.btn-huge { font-size: 1.15rem; padding: 1rem; border-radius: 12px; }
.small-rules { font-size: .85rem; max-width: 560px; }
.result-card { border-radius: 14px; padding: 1rem 1.1rem; margin-bottom: 1.2rem; border: 2px solid; max-width: 560px; }
.result-card.ok { background: var(--ok-bg); border-color: #86cf9c; }
.result-card.warn { background: var(--warn-bg); border-color: #e9c46a; }
.result-title { font-size: 1.3rem; font-weight: 800; margin-bottom: .5rem; }
dl.kv.compact { grid-template-columns: 110px 1fr; gap: .2rem .8rem; margin-bottom: .6rem; }
.cta { display: block; text-align: center; font-size: 1.1rem; padding: .9rem; border-radius: 12px; margin-bottom: 1rem; }

/* ---------- Mobil alt menü ---------- */
.bottombar { display: none; }
@media (max-width: 760px) {
  .container { padding-bottom: 6rem; }
  .bottombar { display: grid; grid-template-columns: 1fr 1.3fr 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: #fff; border-top: 1px solid var(--line); padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom)); gap: .4rem; }
  .bottombar a { display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--muted);
    font-size: .78rem; font-weight: 600; padding: .3rem 0; border-radius: 10px; min-height: 48px; }
  .bottombar a span { font-size: 1.2rem; line-height: 1.1; }
  .bottombar a.on { color: var(--brand); }
  .bottombar a.new { background: var(--accent); color: #fff; }
  /* Kupon formunda alt menü yerine yapışkan "oluştur" butonu */
  .page-create .bottombar { display: none; }
  .page-create .submit-bar { position: sticky; bottom: 0; margin: 1.2rem -1rem 0; padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom));
    background: rgba(246,244,241,.96); border-top: 1px solid var(--line); z-index: 10; }
  .page-create h1 { font-size: 1.3rem; }
  h1 { font-size: 1.3rem; }
  .stat .v { font-size: 1.25rem; }

  /* Tablolar mobilde kart görünümü */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border-bottom: 8px solid var(--bg); padding: .4rem 0; }
  table.cards td { border: 0; padding: .2rem .8rem; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-weight: 500; text-align: left; flex: none; }
  table.cards td.num { text-align: right; }
  table.cards td:empty, table.cards td.empty-m { display: none; }
  table.cards td.title-m { font-size: 1.05rem; font-weight: 700; }
  table.cards td.title-m::before { content: none; }
}
.ok-text { color: var(--ok); font-weight: 600; }
@media (max-width: 760px) { table.cards td::before { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; letter-spacing: 0; } }

/* Oluşturulan kuponun QR kodu */
.qr-box { background: #fff; border-radius: 12px; padding: 1rem; text-align: center; margin: .5rem 0 .6rem; }
.qr-box img { width: 100%; max-width: 260px; height: auto; image-rendering: pixelated; display: block; margin: 0 auto; }
.qr-ref { font-size: 1.05rem; font-weight: 700; margin-top: .4rem; }
/* Hatırlanan işletme satırı */
details.route-picked { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .7rem 1rem; }
details.route-picked summary { cursor: pointer; list-style: none; }
details.route-picked summary::-webkit-details-marker { display: none; }
details.route-picked[open] summary { margin-bottom: .7rem; }
.link { color: var(--accent); text-decoration: underline; margin-left: .3rem; white-space: nowrap; }

/* ---------- İşletmeler, logolar, listeler ---------- */
.logo-xs { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; background: #fff; vertical-align: middle; margin-right: .4rem; }
.logo-sm { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--line); flex: none; }
.logo-md { width: 72px; height: 72px; object-fit: contain; border-radius: 14px; background: #fff; border: 1px solid var(--line); flex: none; }
.logo-ph { display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: var(--brand); background: #efe7dd; }
.logo-current { display: flex; align-items: center; gap: .8rem; margin-bottom: .5rem; }
.brand-biz { display: inline-flex; align-items: center; }
.biz-list { display: grid; gap: .5rem; margin-bottom: 1rem; }
.biz-row { display: flex; align-items: center; gap: .8rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; color: inherit; text-decoration: none; }
a.biz-row:hover { border-color: var(--accent); }
.biz-row.wrap { flex-wrap: wrap; }
.biz-main { flex: 1; min-width: 0; }
.biz-main strong { display: block; }
.biz-main small { color: var(--muted); }
.biz-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.biz-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.biz-head h1 { margin-bottom: .2rem; }
.filters > div.grow { flex: 1; min-width: 200px; }
.login-brand { display: flex; gap: .8rem; align-items: center; margin: .5rem 0 1rem; }
.login-brand img { border-radius: 14px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.target .logo-sm { vertical-align: middle; margin-right: .3rem; }
.stat small { font-size: .78rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
@media (max-width: 760px) { .biz-row.wrap .biz-actions { width: 100%; } }
