:root {
  --accent: #c4a06a;
  --accent-dark: #9d7f4e;
  --bg: #0f172a;
  --bg-elev: #1e293b;
  --bg-elev-2: #243244;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { filter: brightness(1.1); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.85rem; }
.muted { color: var(--text-muted); font-size: 0.9rem; }
.center { text-align: center; }

/* ── Top bar ──────────────────────────────────────── */
.topbar {
  background: linear-gradient(180deg, #121c33 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(140%) blur(8px);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
}
.brand {
  color: var(--text); font-weight: 700; letter-spacing: -0.01em; font-size: 1.05rem;
}
.brand-mark { color: var(--accent); margin-right: 4px; }
.topbar-nav { display: flex; align-items: center; gap: 16px; }
.who { color: var(--text-muted); font-size: 0.9rem; }
.who strong { color: var(--text); font-weight: 600; }
.logout-form { display: inline; }
.nav-link {
  color: var(--text-muted); font-size: 0.9rem;
  padding: 4px 6px;
}
.nav-link:hover { color: var(--accent); }
.logo-preview {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 8px;
}
.logo-preview img { max-height: 64px; width: auto; display: block; }
.btn-link {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-family: inherit; font-size: 0.9rem; padding: 4px 6px;
}
.btn-link:hover { color: var(--accent); }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { filter: brightness(1.1); }

/* ── Container ─────────────────────────────────── */
.container {
  max-width: 1100px; margin: 0 auto; padding: 32px 24px 96px;
}

/* ── Auth (login) ───────────────────────────────── */
body.is-auth {
  display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% 0%, #1e293b 0%, var(--bg) 60%);
}
body.is-auth .container { width: 100%; max-width: 420px; padding: 48px 24px; }
.auth-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.auth-card .muted { margin: 0 0 24px; }
.auth-card .field { display: block; margin-bottom: 14px; }
.auth-card .field > span {
  display: block; margin-bottom: 6px;
  font-size: 0.85rem; color: var(--text-muted); font-weight: 500;
}
.auth-card .field input {
  width: 100%; padding: 10px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.95rem;
}
.auth-card .field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 160, 106, 0.15);
}
.auth-card button { width: 100%; margin-top: 8px; }
.auth-card .foot-link { margin: 20px 0 0; text-align: center; }
.auth-card .foot-link a { color: var(--text-muted); font-size: 0.85rem; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px;
  font-weight: 600; font-size: 0.9rem;
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: transform 0.1s ease, filter 0.15s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent); color: #0f172a;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  background: transparent; color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-elev); }
.btn-danger {
  background: var(--danger); color: #fff;
}
.btn-danger:hover { filter: brightness(1.08); }

/* ── Page header ───────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header h1 { margin: 0 0 4px; font-size: 1.6rem; letter-spacing: -0.01em; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Messages ─────────────────────────────── */
.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.msg {
  padding: 12px 14px; border-radius: 8px; margin-bottom: 8px;
  font-size: 0.9rem;
}
.msg-success { background: rgba(34, 197, 94, 0.12); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.msg-error { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.msg-info, .msg-debug { background: var(--bg-elev); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Table ───────────────────────────────── */
.table-wrap {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
table {
  width: 100%; border-collapse: collapse;
}
table th, table td {
  text-align: left; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table thead th {
  background: var(--bg-elev-2); font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600;
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: var(--bg-elev-2); }

.card-table .name { font-weight: 600; }
.card-table .actions { text-align: right; white-space: nowrap; }
.card-table .actions a, .card-table .actions button,
.card-table .actions form { margin-left: 12px; font-size: 0.9rem; }
.card-table .actions form { display: inline; margin-left: 12px; }
.card-table .actions form button { margin-left: 0; }
.card-table .actions .danger { color: var(--danger); }
.card-table .actions .copy-link,
.card-table .actions .share-link,
.card-table .actions .btn-link {
  background: none; border: none; color: var(--accent);
  cursor: pointer; padding: 0; font-family: inherit; font-size: 0.9rem;
}
.card-table .actions .copy-link:hover,
.card-table .actions .share-link:hover,
.card-table .actions .btn-link:hover { filter: brightness(1.1); }

.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
}
.pill-ok { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.pill-off { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

.empty {
  background: var(--bg-elev); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 48px 24px;
  text-align: center;
}
.empty h2 { margin: 0 0 8px; font-size: 1.2rem; }
.empty p { margin: 0 0 20px; color: var(--text-muted); }

/* ── Card form ────────────────────────────── */
.card-form {
  display: flex; flex-direction: column; gap: 16px;
}
.form-section {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px;
}
.form-section h2 {
  margin: 0 0 16px;
  font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--accent);
  font-weight: 700;
}
.form-section h3.subhead {
  margin: 20px 0 6px; font-size: 0.85rem; font-weight: 600;
  color: var(--text);
}
.color-field.locked {
  opacity: 0.55;
  pointer-events: none;
  cursor: not-allowed;
}
.color-field.locked input[type="color"] {
  filter: saturate(0.7);
}
.inline-checkbox {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--text); cursor: pointer;
}
.inline-checkbox input { width: auto; }

.qr-preview { text-align: center; }
.qr-preview img {
  display: block; margin: 12px auto;
  max-width: 220px; padding: 16px;
  background: #fff; border-radius: 12px; border: 1px solid var(--border);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  shape-rendering: crispEdges;
}
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-bottom: 20px;
}
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 600px) {
  .stats-grid, .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .stats-grid, .stats-grid-4 { grid-template-columns: 1fr; }
}

/* ── Menu tiles ────────────────────────────── */
.menu-tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 32px;
}
.tile {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  text-decoration: none; color: var(--text);
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile-primary {
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 70%, #000 30%) 100%);
  color: #0f172a; border-color: transparent;
}
.tile-primary .tile-icon { background: rgba(15, 23, 42, 0.15); color: #0f172a; }
.tile-primary h3, .tile-primary p { color: #0f172a; }
.tile-primary p { opacity: 0.8; }
.tile-icon {
  flex-shrink: 0;
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--bg); color: var(--accent);
  display: grid; place-items: center;
  font-size: 1.3rem; font-weight: 700;
}
.tile-body h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.tile-body p { margin: 2px 0 0; font-size: 0.82rem; color: var(--text-muted); }

/* ── Section headings ──────────────────── */
.section-heading {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px; gap: 16px; flex-wrap: wrap;
}
.section-heading h2 { margin: 0; font-size: 1.2rem; letter-spacing: -0.01em; }

.overview { margin-bottom: 32px; }
.overview h2 { margin: 0 0 14px; font-size: 1.1rem; }
.top-cards, .rest-cards { margin-bottom: 28px; }

.rest-details > summary {
  cursor: pointer; color: var(--accent);
  padding: 8px 12px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.9rem; font-weight: 500;
  user-select: none; list-style: none;
}
.rest-details > summary::-webkit-details-marker { display: none; }
.rest-details[open] > summary { border-radius: 8px 8px 0 0; }

.row-link { display: block; text-decoration: none; color: inherit; }
.row-link:hover .name { color: var(--accent); }

/* ── Search bar ──────────────────────────── */
.search-bar { margin-bottom: 12px; }
.search-bar input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.95rem; font-family: inherit;
}
.search-bar input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 160, 106, 0.15);
}
.search-bar input::placeholder { color: var(--text-muted); }

.all-cards { margin-top: 32px; margin-bottom: 32px; }
.stat {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; text-align: center;
}
.stat-value {
  font-size: 1.5rem; font-weight: 700; color: var(--accent);
  letter-spacing: -0.01em;
}
.stat-label {
  font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
  margin-top: 4px;
}
.analytics canvas { margin: 16px 0; }
.ref-list {
  list-style: none; padding: 0; margin: 4px 0 0;
}
.ref-list li {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.ref-list li:last-child { border-bottom: none; }
.form-section > p.muted { margin: -8px 0 16px; }
.grid-2 {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
@media (max-width: 680px) {
  .grid-2 { grid-template-columns: 1fr; }
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 0.85rem; color: var(--text-muted); font-weight: 500;
}
.field small {
  font-size: 0.8rem; color: var(--text-muted);
}
.field.inline-check {
  flex-direction: row; align-items: center; gap: 10px;
  padding: 10px 0;
}
.field.inline-check label { margin: 0; color: var(--text); font-size: 0.95rem; }

.field input[type="text"],
.field input[type="email"],
.field input[type="url"],
.field input[type="tel"],
.field input[type="password"],
.field input[type="number"],
.field input[type="color"],
.field textarea,
.field select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input[type="color"] { height: 42px; padding: 4px; cursor: pointer; }
.field input[type="file"] {
  padding: 8px; background: var(--bg);
  border: 1px dashed var(--border); border-radius: 8px;
  color: var(--text-muted); font-size: 0.85rem;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 160, 106, 0.15);
}
.field .errorlist {
  list-style: none; padding: 0; margin: 0;
  color: #fca5a5; font-size: 0.85rem;
}

.service-table input[type="text"],
.service-table input[type="number"] {
  width: 100%; padding: 7px 9px; font-size: 0.88rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
}
.service-table th, .service-table td { padding: 8px 10px; }

.form-actions {
  display: flex; gap: 12px; padding: 8px 0;
  position: sticky; bottom: 16px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding-top: 16px;
}

/* ── Confirm delete ───────────────────────── */
.confirm {
  max-width: 480px; margin: 40px auto;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px;
  text-align: center;
}
.confirm h1 { margin: 0 0 12px; font-size: 1.4rem; }
.confirm p { margin: 0 0 10px; }
.confirm-actions {
  display: flex; gap: 10px; justify-content: center;
  margin-top: 20px;
}
