:root {
  --accent: #dc2626;
  --accent-dark: #b91c1c;
  --ink: #111827;
  --ink-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --surface: #ffffff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #2563eb;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
  padding: 16px 0 8px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-muted); font-size: 13px; }

/* --- Layout shell --- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #111827;
  color: #e5e7eb;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand { font-weight: 700; font-size: 18px; color: #fff; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.sidebar .biz-name { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #9ca3af; margin-bottom: 20px; }
/* Uploaded logos are normalized to a plain (white-background) JPEG — see
   Branding.php — so on this dark sidebar they get a small white card
   behind them rather than looking like a stray white rectangle. Capped
   at a modest max-width/max-height so even a very wide or very tall
   upload reads as a small mark next to the business name, never as a
   dominant banner. */
.sidebar .sidebar-logo {
  display: block;
  max-width: 130px;
  max-height: 48px;
  width: auto;
  height: auto;
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 10px;
  object-fit: contain;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; color: #d1d5db; font-size: 14px; font-weight: 500;
  margin-bottom: 2px;
}
.sidebar nav a:hover { background: #1f2937; text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.content { padding: 24px 28px; max-width: 1200px; }

/* --- Cards / surfaces --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-row { display: flex; gap: 16px; flex-wrap: wrap; }
.card-row > .card { flex: 1; min-width: 200px; }
.stat-label { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; }

/* --- Page header --- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 160px; }
.help-text { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; line-height: 1.2;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--ink); }
.btn-secondary:hover { background: #f3f4f6; text-decoration: none; }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fef2f2; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { font-size: 12px; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; letter-spacing: 0.02em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* --- Badges --- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-amber { background: #fef3c7; color: #92400e; }

/* --- Alerts / flash --- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* --- Auth / installer pages --- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 4px; }
.auth-box { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.install-box { width: 100%; max-width: 640px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.steps .step { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.steps .step.done { background: var(--accent); }

/* --- Utility --- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--ink-muted); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt-0 { margin-top: 0; }
.text-right { text-align: right; }

/* --- Public (no-login) document view --- */
.public-doc { max-width: 900px; margin: 24px auto; padding: 0 16px; }

/* --- Responsive --- */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 12px 14px; }
  .sidebar nav { display: flex; overflow-x: auto; gap: 4px; }
  .sidebar nav a { white-space: nowrap; margin-bottom: 0; }
  .sidebar .biz-name { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .card-row { flex-direction: column; }
  .card-row > .card { min-width: 0; width: 100%; flex: none; box-sizing: border-box; }
  .public-doc { margin: 12px auto; }
  .public-doc .page-header { flex-direction: column; gap: 12px; }
  .public-doc .page-header > div:last-child { text-align: left; }
}
