:root {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e9ebf0;
  --muted: #98a1b2;
  --accent: #4f8cff;
  --accent-ink: #ffffff;
  --ok: #2fbf71;
  --warn: #f2b33d;
  --alert: #ff5a5f;
  --info: #4f8cff;
  --idle: #b98cff;
  --off: #697080;
  --radius: 14px;
  --gutter: 16px;
  color-scheme: dark;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  line-height: 1.45;
  font-size: 15px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

/* ---- üst bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 26px;
  height: 26px;
}
.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.nav a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}
.nav a[aria-current='page'] {
  background: var(--surface-2);
  color: var(--text);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--off);
  flex: none;
}
.dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent);
}
.dot.wait {
  background: var(--warn);
}
.dot.bad {
  background: var(--alert);
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--gutter);
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 17px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}

/* ---- düğmeler ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  touch-action: manipulation;
}
.btn:hover {
  border-color: #3a4150;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.danger {
  color: var(--alert);
}
.btn.ghost {
  background: transparent;
}
.btn.big {
  min-height: 52px;
  font-size: 16px;
  padding: 12px 20px;
}
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 6px;
}
.field label,
.field .label {
  font-size: 13px;
  color: var(--muted);
}
.input,
select.input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.input:focus,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
}
.notice.error {
  border-color: color-mix(in srgb, var(--alert) 60%, var(--border));
  color: #ffc2c4;
}
.notice.warn {
  border-color: color-mix(in srgb, var(--warn) 60%, var(--border));
}

.progress {
  height: 6px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}

/* ---- kamera sayfası ---- */
.camera-layout {
  display: grid;
  gap: var(--gutter);
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .camera-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
  }
}
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.stage video,
.stage img,
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  color: var(--muted);
}
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.stat {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.stat b {
  display: block;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.stat span {
  font-size: 12px;
  color: var(--muted);
}
.stack {
  display: grid;
  gap: 12px;
}
.tips {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}
.dim {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  color: #3b3f47;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  font-size: 14px;
}

/* ---- panel (dashboard) ---- */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: var(--gutter);
}
.summary .stat b {
  font-size: 26px;
}
.cams {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: var(--gutter);
}
.tables {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.table-card {
  --c: var(--off);
  position: relative;
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--c);
}
.table-card[data-status='empty'] {
  --c: #3a404c;
}
.table-card[data-status='arriving'],
.table-card[data-status='seated'] {
  --c: var(--info);
}
.table-card[data-status='no_order_warn'] {
  --c: var(--warn);
}
.table-card[data-status='no_order_alert'] {
  --c: var(--alert);
  background: color-mix(in srgb, var(--alert) 9%, var(--surface));
  animation: pulse 1.6s ease-in-out infinite;
}
.table-card[data-status='ordered'] {
  --c: var(--ok);
}
.table-card[data-status='idle'] {
  --c: var(--idle);
}
.table-card[data-status='leaving'] {
  --c: var(--muted);
}
.table-card[data-status='offline'] {
  --c: var(--off);
  opacity: 0.7;
}
@keyframes pulse {
  50% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--alert) 30%, transparent);
  }
}
@media (prefers-reduced-motion: reduce) {
  .table-card[data-status='no_order_alert'] {
    animation: none;
  }
}
.tc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tc-name {
  font-weight: 700;
  font-size: 17px;
}
.tc-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  white-space: nowrap;
}
.tc-people {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.tc-people b {
  font-size: 38px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tc-rows {
  display: grid;
  gap: 4px;
  font-size: 14px;
}
.tc-rows div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.tc-rows span {
  color: var(--muted);
}
.tc-rows b {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.tc-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.list th,
table.list td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.list th {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface);
}
table.list tr:last-child td {
  border-bottom: 0;
}
.empty-state {
  padding: 32px 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty-state h2 {
  color: var(--text);
  margin-bottom: 8px;
}

/* ---- kurulum ---- */
.setup-layout {
  display: grid;
  gap: var(--gutter);
}
@media (min-width: 1000px) {
  .setup-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
  }
}
.editor {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 72vh;
  background: #050608;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  touch-action: none;
}
.editor canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.zone-list {
  display: grid;
  gap: 6px;
}
.zone-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.zone-item.sel {
  border-color: #ffc43d;
}
.zone-item .input {
  min-height: 36px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
details.card summary {
  cursor: pointer;
  font-weight: 700;
}

/* ---- giriş ---- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
}
.login .card {
  width: min(100%, 360px);
  display: grid;
  gap: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #2b303b;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 14px;
}
[hidden] {
  display: none !important;
}

/* ---- uygulama yükleme sayfası (/yukle) ---- */
.install-card {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
  text-align: left;
}
.install-card h1 {
  font-size: 22px;
}
.install-card p {
  margin: 0;
}
.install-icon {
  border-radius: 18px;
}
.steps {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
}
.share-ico {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
  color: var(--accent);
}
