:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #eef1f6;
  --muted: #8b93a3;
  --accent: #ff5a30;
  --pending: #3b82f6;
  --preparing: #f59e0b;
  --ready: #22c55e;
  --late: #ef4444;
  --note: #facc15;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.error { color: #fca5a5; min-height: 1.4em; margin: 6px 0; text-align: center; }

.screen { min-height: 100vh; min-height: 100dvh; }

/* ---- Marka ---- */
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-size: 24px; }
.brand p { margin: 2px 0 0; color: var(--muted); }
.logo {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 22px; letter-spacing: -1px;
}
/* Marka: ada'kolay logosu (görsel) + POS */
.brandmark { display: flex; align-items: center; gap: 2px; margin: 0; }
.brandmark img { height: 36px; display: block; }
.brandmark .pos { font-weight: 900; font-size: 30px; line-height: 1; margin-top: -8px; color: var(--text); }
.product { font-weight: 300; color: var(--muted); font-size: 22px; margin-left: 10px; }
.brand.small .brandmark img { height: 24px; }
.brand.small .brandmark .pos { font-size: 20px; margin-top: -5px; }
.brand.small .logo { width: 38px; height: 38px; font-size: 16px; border-radius: 10px; }
.brand.small b { font-size: 18px; margin-right: 8px; }

/* ---- Giriş ---- */
#login { display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(720px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px; }
.login-card h2 { font-size: 18px; font-weight: 600; margin: 26px 0 14px; color: var(--muted); }
.users { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.user {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 10px; min-height: 120px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); transition: transform .08s, border-color .15s;
}
.user:active { transform: scale(.97); }
.user:hover { border-color: var(--accent); }
.avatar { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: #334155; font-weight: 700; font-size: 19px; }
.user small { color: var(--muted); }
.link { color: var(--accent); padding: 8px 0; margin-top: 18px; }
#pinStep h2 { text-align: center; color: var(--text); font-size: 22px; margin-top: 10px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 4px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots i.on { background: var(--accent); border-color: var(--accent); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 360px; margin: 8px auto 0; }
.pinpad button {
  height: 72px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); font-size: 28px; font-weight: 600;
}
.pinpad button:active { background: #2b3140; }
.pinpad .fn { font-size: 18px; color: var(--muted); }

/* ---- Üst çubuk ---- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: rgba(15, 17, 21, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.live { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--late); vertical-align: middle; }
.live.on { background: var(--ready); box-shadow: 0 0 0 4px rgba(34, 197, 94, .18); }
.stations { display: flex; gap: 8px; overflow-x: auto; flex: 1 1 240px; scrollbar-width: none; }
.stations::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; padding: 10px 16px; min-height: 44px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 600;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.counts { display: flex; gap: 8px; }
.count { padding: 6px 12px; border-radius: 10px; background: var(--panel-2); font-size: 14px; color: var(--muted); white-space: nowrap; }
.count b { font-size: 18px; margin-right: 4px; }
.count.pending b { color: var(--pending); }
.count.preparing b { color: var(--preparing); }
.count.ready b { color: var(--ready); }
.tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.clock { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; margin-right: 6px; }
.icon {
  display: grid; place-items: center; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px; background: var(--panel-2);
  border: 1px solid var(--line); font-size: 18px;
}
.icon:active { background: #2b3140; }
#userInitials { font-size: 14px; font-weight: 700; }

.banner { margin: 10px 16px 0; padding: 12px 16px; border-radius: 12px; background: #1e3a5f; color: #dbeafe; }
.banner.warn { background: #5b1d1d; color: #fee2e2; }

/* ---- Fişler ---- */
.tickets {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; padding: 16px; align-items: start;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.ticket {
  display: flex; flex-direction: column; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden;

}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.ticket.fresh { box-shadow: 0 0 0 3px var(--pending); animation: pop .35s ease-out; }
.ticket.late { border-color: var(--late); }
.ticket.late .elapsed { color: #fff; background: var(--late); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .55; } }
.ticket-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ticket.s-Pending .ticket-head { background: linear-gradient(180deg, rgba(59, 130, 246, .2), transparent); }
.ticket.s-Preparing .ticket-head { background: linear-gradient(180deg, rgba(245, 158, 11, .22), transparent); }
.ticket.s-Ready .ticket-head { background: linear-gradient(180deg, rgba(34, 197, 94, .22), transparent); }
.table { font-size: 22px; font-weight: 800; line-height: 1.1; }
.meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.elapsed { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; padding: 4px 10px; border-radius: 9px; background: var(--panel-2); white-space: nowrap; }
.lines { list-style: none; margin: 0; padding: 6px 0; }
.line { display: flex; gap: 12px; padding: 10px 14px; cursor: pointer; user-select: none; }
.line:active { background: var(--panel-2); }
.qty { min-width: 46px; font-size: 26px; font-weight: 800; color: var(--accent); text-align: right; line-height: 1.1; }
.line .name { font-size: 20px; font-weight: 700; line-height: 1.2; }
.line .sub { color: var(--muted); font-size: 15px; }
/* Porsiyon ve özellikler: büyük, renkli etiketler (uzaktan okunur) */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 8px; font-size: 16px; font-weight: 700; line-height: 1.3; }
.tag.portion { background: rgba(249, 115, 22, .18); color: #fdba74; border: 1px solid rgba(249, 115, 22, .55); text-transform: uppercase; letter-spacing: .02em; }
.tag.option { background: rgba(56, 189, 248, .14); color: #bae6fd; border: 1px solid rgba(56, 189, 248, .4); }
.line .note { display: inline-block; margin-top: 6px; padding: 4px 10px; border-radius: 8px; background: rgba(250, 204, 21, .16); color: var(--note); font-size: 16px; font-weight: 700; border: 1px solid rgba(250, 204, 21, .45); }
.line.void .tag { opacity: .55; text-decoration: line-through; }
.station-tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; vertical-align: middle;
  background: rgba(148, 163, 184, .16); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, .35); }
.station-tag.none { background: rgba(245, 158, 11, .16); color: #fbbf24; border-color: rgba(245, 158, 11, .5); }
.ticket-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.progress { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.progress.all { color: var(--ready); }
.chip.locked { cursor: default; }
.line.done .name, .line.done .qty { color: var(--ready); }
.line.done .name::after { content: " ✓"; }
.line.void { background: rgba(239, 68, 68, .08); }
.line.void .name, .line.void .qty { color: #fca5a5; text-decoration: line-through; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 6px; background: var(--late); color: #fff; margin-left: 6px; text-decoration: none; }
.actions { display: flex; gap: 8px; padding: 10px 12px 12px; margin-top: auto; }
.btn { flex: 1; min-height: 52px; border-radius: 12px; font-weight: 700; font-size: 17px; background: var(--panel-2); border: 1px solid var(--line); }
.btn:active { transform: scale(.98); }
.btn.start { background: var(--preparing); color: #1a1205; border-color: transparent; }
.btn.ready { background: var(--ready); color: #052e14; border-color: transparent; }
.btn.serve { background: #e2e8f0; color: #0f172a; border-color: transparent; }
.btn.small { flex: 0 0 auto; padding: 0 14px; font-size: 15px; }
.btn:disabled { opacity: .5; }

.empty { display: grid; place-items: center; text-align: center; color: var(--muted); padding: 12vh 16px; }
.empty-icon { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 40px; background: var(--panel); color: var(--ready); margin: 0 auto 16px; }
.empty h2 { color: var(--text); }

/* ---- Son servis edilenler ---- */
.drawer { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); display: flex; justify-content: flex-end; }
.drawer-panel { width: min(420px, 100%); height: 100%; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.drawer-panel header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.recent-list { overflow-y: auto; padding: 10px 16px 24px; }
.recent { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.recent div { flex: 1; min-width: 0; }
.recent b { display: block; }
.recent span { color: var(--muted); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: #f1f5f9; color: #0f172a; padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  max-width: calc(100% - 32px);
}
.toast.err { background: #fecaca; color: #450a0a; }

/* ---- Orta ekranlar: istasyonlar kendi satırında (kesilmesin) ---- */
@media (max-width: 1180px) {
  .stations { order: 3; flex-basis: 100%; }
}

/* ---- Küçük ekranlar ---- */
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 8px 12px; }
  .stations { order: 3; flex-basis: 100%; }
  .counts { order: 4; flex-basis: 100%; }
  .count { flex: 1; text-align: center; }
  .clock { display: none; }
  .tickets { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .login-card { padding: 20px; }
  .users { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
@media (min-width: 1800px) {
  .tickets { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
