/* Modera admin panel. Neutral palette + one teal accent. Theme: data-theme="light|dark" on
   <html> from the asl_theme cookie; without it (auto) the OS preference decides. */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e4e4e7;
  --text: #18181b;
  --muted: #5f5f69;
  --hover: #f0f0f2;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-text: #0f5f59;
  --accent-soft: #d5f5ef;
  --on-accent: #ffffff;
  --warn-soft: #fdf0d5; --warn-text: #8a4b07;
  --ok-bg: #ecfdf5; --ok-text: #065f46;
  --err-bg: #fef2f2; --err-text: #991b1b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0b0d; --surface: #17171a; --border: #2a2a2e; --text: #f4f4f5; --muted: #a1a1aa;
  --hover: #222226; --accent: #2dd4bf; --accent-hover: #5eead4; --accent-text: #5eead4;
  --accent-soft: #123f3b; --on-accent: #08201d; --warn-soft: #3a2a0c; --warn-text: #fbbf6a;
  --ok-bg: #052e26; --ok-text: #6ee7b7; --err-bg: #2a0f0f; --err-text: #fca5a5; --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0d; --surface: #17171a; --border: #2a2a2e; --text: #f4f4f5; --muted: #a1a1aa;
    --hover: #222226; --accent: #2dd4bf; --accent-hover: #5eead4; --accent-text: #5eead4;
    --accent-soft: #123f3b; --on-accent: #08201d; --warn-soft: #3a2a0c; --warn-text: #fbbf6a;
    --ok-bg: #052e26; --ok-text: #6ee7b7; --err-bg: #2a0f0f; --err-text: #fca5a5; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; font-weight: 600; margin: 0 0 .25rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.grow { flex: 1; min-width: 0; }

.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-logo { width: 34px; height: auto; display: block; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.75rem;
}
.card.narrow { max-width: 480px; }
.chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: var(--accent-soft); color: var(--accent-text);
}
.chip.warn { background: var(--warn-soft); color: var(--warn-text); }

/* auth pages */
.auth-wrap {
  min-height: 100vh; max-width: 420px; margin: 0 auto; padding: 48px 16px;
  display: flex; flex-direction: column; gap: 1.5rem; justify-content: center;
}
.auth-wrap > .brand { align-self: center; font-size: 1.1rem; }
.option { margin: 1.25rem 0 0; }
.divider { margin: 1.5rem 0; border-top: 1px solid var(--border); }
.lang-switch { display: flex; gap: .75rem; justify-content: center; font-size: .8rem; }
.lang-switch a { color: var(--muted); }
.lang-switch a[aria-current] { color: var(--text); font-weight: 600; }

/* forms & buttons */
.stack { display: flex; flex-direction: column; gap: .9rem; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .875rem; font-weight: 500; }
input[type=email], input[type=password], input[type=text] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem;
}
input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; border-radius: 8px; padding: .6rem 1rem; min-height: 40px;
  border: 1px solid transparent; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--hover); color: var(--text); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--hover); }
.alert { padding: .65rem .85rem; border-radius: 8px; font-size: .9rem; }
.alert.ok { background: var(--ok-bg); color: var(--ok-text); }
.alert.err { background: var(--err-bg); color: var(--err-text); }

/* app shell */
.shell { display: flex; min-height: 100vh; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.sidebar {
  width: 264px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 14px; }
.switcher { position: relative; }
.switcher summary, .switcher.static {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; list-style: none;
}
.switcher.static { cursor: default; }
.switcher summary::-webkit-details-marker { display: none; }
.switcher-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: .8rem;
}
.switcher-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.switcher-text strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher-text small { font-size: .75rem; color: var(--muted); }
.switcher-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 16px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px;
  border-radius: 8px; font-size: .875rem; font-weight: 500; color: var(--muted);
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-item svg { flex: none; }
.userbox {
  margin-top: auto; border-top: 1px solid var(--border); padding: 12px 6px 0;
  display: flex; align-items: center; gap: 10px;
}
.userbox strong { display: block; font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox form { margin: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 999px; flex: none; display: grid; place-items: center;
  background: var(--hover); font-size: .8rem; font-weight: 600;
}
.scrim { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pagehead {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 18px 32px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.pagehead h1 { margin: 0; font-size: 1.375rem; }
.crumb { font-size: .75rem; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a {
  min-width: 40px; height: 38px; display: grid; place-items: center;
  font-size: .75rem; font-weight: 600; color: var(--muted);
}
.seg a.on { background: var(--accent-soft); color: var(--accent-text); }
.page { padding: 28px 32px; max-width: 1200px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.only-mobile { display: none; }

/* page content */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 4px;
}
.tile-icon { color: var(--accent-text); margin-bottom: 4px; }
.tile-label { font-size: .8125rem; color: var(--muted); }
.tile-value { font-size: 1.75rem; font-weight: 700; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.empty-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); margin-bottom: 8px;
}
.empty p:last-child { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.restaurant-card { display: flex; flex-direction: column; gap: 14px; padding: 1.25rem; }
.restaurant-card .btn { align-self: flex-start; }
.restaurant-head { display: flex; align-items: center; gap: 10px; }
.restaurant-head h2 { flex: 1; margin: 0; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.metrics dt { font-size: .75rem; color: var(--muted); }
.metrics dd { margin: 0; font-size: 1.25rem; font-weight: 700; }

@media (max-width: 900px) {
  .only-mobile { display: inline-flex; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: 288px; max-width: 86vw;
    transform: translateX(-100%); transition: transform .2s ease; overflow-y: auto;
  }
  .nav-toggle:checked ~ .sidebar { transform: none; box-shadow: 8px 0 32px rgba(0,0,0,.18); }
  .nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(9,9,11,.45); }
  .pagehead { padding: 12px 16px; }
  .page { padding: 20px 16px; }
}
@media (max-width: 520px) {
  .card { padding: 1.25rem; }
  .pagehead h1 { font-size: 1.125rem; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* lists, tables, forms (phase 3) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 7px; font-size: .875rem; font-weight: 600; color: var(--muted); }
.tabs a:hover { color: var(--text); }
.tabs a.on { background: var(--accent-soft); color: var(--accent-text); }
.tabs .count { font-size: .7rem; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); }
.search { display: flex; gap: 8px; flex: 1 1 280px; max-width: 420px; }
.search input { flex: 1; min-width: 0; }
input[type=search], input[type=time], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .75rem; min-height: 40px;
}
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; font-size: .75rem; font-weight: 600; color: var(--muted); padding: 12px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 20px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover { background: var(--hover); }
.strong { font-weight: 600; color: var(--text); }
.nowrap { white-space: nowrap; }
.empty-row { padding: 24px 20px; margin: 0; }
.chip.muted-chip { background: var(--hover); color: var(--muted); }
.back-link { font-size: .875rem; font-weight: 600; align-self: flex-start; }
.person { display: flex; align-items: center; gap: 14px; }
.person-name { margin: 0; font-size: 1.125rem; }
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 20px 0 0; }
.facts dt { font-size: .75rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.form-narrow { max-width: 460px; }
.days { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.days legend { font-size: .875rem; font-weight: 500; margin-bottom: 8px; padding: 0; }
.day { flex-direction: row; }
.day input { position: absolute; opacity: 0; }
.day span {
  display: inline-grid; place-items: center; min-width: 52px; min-height: 40px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px; font-weight: 600; font-size: .8125rem; color: var(--muted); cursor: pointer;
}
.day input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.danger-zone { border-color: color-mix(in srgb, var(--err-text) 30%, var(--border)); }
.btn.danger { background: var(--err-text); color: var(--surface); align-self: flex-start; }
.btn.danger:hover { filter: brightness(1.08); color: var(--surface); }
.card > h2 { margin-bottom: .5rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input[type=text] { flex: 1 1 220px; min-width: 0; }
.actions { white-space: nowrap; text-align: right; }
.actions > * { vertical-align: middle; }
.small-btn { min-height: 34px; padding: .3rem .75rem; font-size: .8125rem; }
.popover { display: inline-block; position: relative; margin-left: 6px; text-align: left; }
.popover summary { list-style: none; }
.popover summary::-webkit-details-marker { display: none; }
.popover-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 300px; white-space: normal;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 12px;
}
.popover-body p { margin-bottom: 10px; }
.config-list { display: flex; flex-direction: column; gap: 0; }
.config-list > h2 { margin-bottom: .75rem; }
.config-item { border-top: 1px solid var(--border); }
.config-item summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 14px 0; cursor: pointer; list-style: none;
}
.config-item summary::-webkit-details-marker { display: none; }
.config-name { flex: 1 1 200px; font-weight: 600; }
.config-values { flex: 2 1 320px; color: var(--text); }
.config-item[open] summary .small-btn { background: var(--hover); }
.config-item form.stack { padding: 4px 0 18px; }
.remove-form { padding: 0 0 18px; }
.add-item summary { color: var(--accent-text); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
input[type=number] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .75rem; min-height: 40px;
}
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot th { border-top: 1px solid var(--border); color: var(--text); font-size: .875rem; padding: 12px 20px; }
.chip.danger-chip { background: var(--err-bg); color: var(--err-text); }
input[type=date] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; min-height: 40px;
}
.inline-form label { flex-direction: row; align-items: center; gap: 8px; }
.hint { font-weight: 400; }
.preset-list { list-style: none; margin: 0 0 16px; padding: 0; }
.preset-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.preset-list li:last-child { border-bottom: 1px solid var(--border); }
.preset-list form { margin: 0; }
.preset-add input.amount { flex: 0 1 160px; }
form.inline { display: inline-block; margin: 0 0 0 6px; }
.card-title { padding: 16px 20px 4px; margin: 0; }
.alert p { margin: 0; }
.alert p + p { margin-top: 6px; }
.impersonation-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 32px;
  background: #b91c1c; color: #ffffff; font-size: .875rem; font-weight: 500;
}
.impersonation-banner form { margin: 0; }
.btn.banner-btn { min-height: 34px; padding: .3rem .9rem; background: transparent; color: #ffffff; border-color: rgba(255,255,255,.65); }
.btn.banner-btn:hover { background: rgba(255,255,255,.12); color: #ffffff; }
@media (max-width: 900px) { .impersonation-banner { padding: 10px 16px; } }

/* Public demo panel (DEMO_MODE): reset notice + one-click sign-in on the login card. */
.demo-banner {
  padding: .6rem 1.25rem; background: var(--accent-soft); color: var(--accent-text);
  font-size: .875rem; font-weight: 600; border-bottom: 1px solid var(--border);
}
.demo-option .btn { margin-top: .75rem; display: inline-flex; }
