/* HMNOVA Super Admin portal. The POS/Owner/Waiter/Manager design tokens, on a
   warmer ground and with an admin-specific set of panels (restaurant cards, a
   licensing form, an audit feed). Nothing here is a new design language — the
   operator's screen should read as the same system as what it administers. */
:root {
  --background: hsl(30 12% 95.5%);
  --foreground: hsl(20 8% 14%);
  --card: #ffffff;
  --surface: hsl(30 15% 97.3%);
  --border: hsl(30 8% 86%);
  --muted: hsl(28 6% 45%);
  --primary: hsl(0 74% 44%);
  --primary-dark: hsl(0 74% 36%);
  --radius: 0.5rem;
  --hero: #4a121e;
  --ok: #10b981;
  --warn: #d97706;
  --bad: hsl(0 74% 44%);
  --info: #2b6cb0;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--background);
  color: var(--foreground);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }

/* ── brand / gate ──────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  background: var(--hero) url('/admin/icons/icon-192.png') center/cover no-repeat;
}
.brand-logo.small { width: 30px; height: 30px; border-radius: 8px; }
.brand-name { font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: .84rem; color: var(--muted); }

.gate-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.gate-card {
  background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) * 2);
  box-shadow: 0 10px 30px rgba(30,12,8,.08); padding: 24px; width: 100%; max-width: 420px;
}
.gate-foot { margin-top: 16px; font-size: .82rem; color: var(--muted); }
.gate-foot code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }

/* ── fields / buttons ──────────────────────────────────────────────── */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .84rem; color: var(--muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 9px 11px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.field input:focus, .field select:focus { outline: 2px solid hsl(0 74% 44% / .25); border-color: var(--primary); }
.field input:disabled { background: var(--surface); color: var(--muted); }
.field.inline { margin: 0; min-width: 190px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 14px; }
.grid2 .wide { grid-column: 1 / -1; }

.btn {
  border: 1px solid var(--border); background: #fff; border-radius: var(--radius);
  padding: 8px 14px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }

/* ── topbar / tabs ─────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 18px; background: var(--hero); color: #fff;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-name { font-weight: 700; }
.topbar-sub { font-size: .8rem; opacity: .8; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.topbar .btn:hover { background: rgba(255,255,255,.2); }

.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; display: inline-block; }
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 3px hsl(160 84% 39% / .2); }
.live-dot.off { background: #ef4444; }

.tabs { display: flex; gap: 4px; padding: 0 14px; background: #fff; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  border: 0; background: transparent; padding: 12px 14px; cursor: pointer;
  color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--foreground); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.badge { background: var(--primary); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .74rem; margin-left: 5px; }

.main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 60px; }
.view-head { margin-bottom: 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px; }
.view-note { color: var(--muted); font-size: .87rem; margin: 0; max-width: 70ch; flex: 1 1 320px; }
.back { margin-bottom: 12px; }

/* ── cards ─────────────────────────────────────────────────────────── */
.cards { display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.5); padding: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0 0 2px; }
.card-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 0; }
.stats dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 700; }
.stats dd.warn { color: var(--warn); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── panels / tables ───────────────────────────────────────────────── */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.5); padding: 16px; margin-bottom: 16px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl code { font-size: .82rem; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; background: var(--surface); border: 1px solid var(--border); }
.pill.ok { background: hsl(160 84% 39% / .12); border-color: hsl(160 84% 39% / .35); color: #06705a; }
.pill.warn { background: hsl(38 92% 50% / .14); border-color: hsl(38 92% 50% / .4); color: #8a5300; }
.pill.bad { background: hsl(0 74% 44% / .1); border-color: hsl(0 74% 44% / .35); color: var(--primary-dark); }
.pill.info { background: hsl(210 70% 45% / .1); border-color: hsl(210 70% 45% / .3); color: #2b6cb0; }
.pill.muted { color: var(--muted); }

.notice { border-radius: var(--radius); padding: 10px 12px; font-size: .87rem; margin: 10px 0; }
.notice-bad { background: hsl(0 74% 44% / .08); border: 1px solid hsl(0 74% 44% / .3); color: var(--primary-dark); }
.notice-info { background: hsl(210 70% 45% / .07); border: 1px solid hsl(210 70% 45% / .25); color: #24537f; }
.login-error, #gate-error { margin-bottom: 10px; }

/* Both disclosure panels share one look. `add-restaurant` is a SEPARATE class
   rather than a second use of `add-branch`, because the two panels carry the
   same field labels and a shared class made "the add-branch form" ambiguous to
   anything selecting by it — which is exactly what the UI probe hit. */
.add-branch, .add-restaurant { margin-top: 12px; }
.add-branch summary, .add-restaurant summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.add-branch form, .add-restaurant form, .panel form { margin-top: 12px; }

.empty, .loading { padding: 26px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--border); border-radius: calc(var(--radius) * 1.5); }

/* ── audit ─────────────────────────────────────────────────────────── */
.row-filter { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.audit { display: grid; gap: 10px; }
.audit-row { display: grid; grid-template-columns: 168px 1fr; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.audit-when { font-size: .82rem; color: var(--muted); }
.audit-action { font-weight: 600; }
.audit-detail { margin: 6px 0 0; padding: 8px; background: var(--surface); border-radius: 6px; font-size: .78rem; white-space: pre-wrap; word-break: break-word; color: var(--muted); }
@media (max-width: 560px) { .audit-row { grid-template-columns: 1fr; } }

/* ── toast ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: .88rem; box-shadow: 0 10px 26px rgba(0,0,0,.25); z-index: 40;
  max-width: min(92vw, 620px);
}
.toast-bad { background: var(--primary-dark); }
