:root {
  /* Sanduku la Maoni brand colors, sampled from the official logo */
  --brand-red: #F70909;
  --brand-red-dark: #B30707;
  --brand-green: #97C21B;
  --brand-green-dark: #7BA015;

  --color-owner: #dc2626;
  --color-manager: #f59e0b;
  --color-viewer: #6b7280;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: var(--brand-red);
  --primary-hover: var(--brand-red-dark);
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: var(--brand-green-dark);
  --sidebar-bg: #3f0202;
  --sidebar-bg-light: #5c0606;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  width: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Sidebar Drawer (slides in from left) */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 98;
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-drawer {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 280px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #2a0101 100%);
  color: #f1d9d9;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 99;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-drawer.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.sidebar-close-btn:hover {
  color: var(--brand-green);
}

.sidebar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}

.sidebar-section {
  padding: 0 12px;
}

.sidebar-section + .sidebar-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #b8a0a0;
  letter-spacing: 0.05em;
  padding: 0 12px;
  margin-bottom: 8px;
  display: none;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #f1d9d9;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
  border: none;
  font-family: var(--font);
  width: 100%;
  text-align: left;
  background: none;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.sidebar-item.active {
  background: var(--primary);
  color: #fff;
}

.sidebar-item-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-item-text {
  flex: 1;
}

.sidebar-user-section {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.sidebar-email {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  word-break: break-all;
}

.sidebar-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  margin-bottom: 10px;
}

.sidebar-role-badge.owner { background: var(--color-owner); }
.sidebar-role-badge.manager { background: var(--color-manager); }
.sidebar-role-badge.viewer { background: var(--color-viewer); }
.sidebar-role-badge.super_admin { background: #1e3a5f; }

.sidebar-business-name {
  font-size: 12px;
  color: #e0b3b3;
  margin-bottom: 12px;
}

.sidebar-business-switcher {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  background: var(--sidebar-bg-light);
  color: #fff;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 600;
  margin-bottom: 12px;
  cursor: pointer;
}

.sidebar-business-switcher:hover {
  border-color: rgba(255,255,255,0.4);
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 8px 0;
}

/* Top Navigation Bar (auto-hides on scroll) */
.top-nav {
  position: sticky;
  top: 0;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  z-index: 50;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Brand accent strip -- red fading into green, same signature gradient as
   the login screen (see .login-box .logo background further down), so the
   app reads as Sanduku la Maoni from the very first screen. Lives as part
   of .top-nav itself so it rides along with the existing hide-on-scroll
   transform below -- no separate JS needed, it disappears with the nav. */
.top-nav::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-red) 0%, var(--brand-red) 35%, var(--brand-green) 75%, transparent 100%);
}

.top-nav.hidden {
  transform: translateY(-100%);
  box-shadow: none;
}

.hamburger-btn {
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: background 0.2s ease;
  border-radius: 8px;
  flex-shrink: 0;
}

/* Top navigation spacer and buttons */
.top-nav-spacer {
  flex: 1;
}

.top-nav-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-btn {
  background: none;
  border: none;
  color: #F70909;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.nav-btn:hover {
  background-color: rgba(247, 9, 9, 0.1);
}

.nav-btn:active {
  background-color: rgba(247, 9, 9, 0.2);
}

@media (max-width: 480px) {
  .top-nav-buttons {
    gap: 4px;
  }

  .nav-btn {
    font-size: 12px;
    padding: 4px 6px;
  }

  /* Three buttons (Back/Home/Language) now share this row with the
     hamburger and the Dashboard/Feedback quick links on narrow phones --
     drop the "Go to dashboard" emoji+word pairing down to just the
     language code so nothing wraps or gets clipped. */
  .nav-lang-btn {
    padding: 4px 5px;
  }
}


.hamburger-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.hamburger-btn span {
  width: 22px;
  height: 2.5px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.top-nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
}

.nav-link {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
  background: rgba(0, 0, 0, 0.05);
  text-decoration: none;
}

.nav-link.active {
  color: var(--primary);
  background: rgba(247, 9, 9, 0.1);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 { margin: 0; font-size: 27px; font-weight: 800; letter-spacing: -0.01em; }
.page-header p { margin: 4px 0 0 0; color: var(--text-muted); font-size: 13px; font-weight: 500; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 { margin: 0 0 14px 0; font-size: 16px; font-weight: 800; }

/* Generic collapsible-card pattern (settings/admin/dashboard/users pages --
   see initCollapsibleCards() in nav.js). Reuses the same chevron+header
   idiom feedback.html hand-wrote first for its Share Link / Categories
   cards, generalized here so other pages don't each hand-roll a listener. */
.collapsible-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
.collapsible-header h2 { margin: 0; }
.collapsible-chevron { font-size: 12px; color: var(--text-muted); transition: transform 0.15s; display: inline-block; }
.collapsible-body { margin-top: 14px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.stat-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.stat-card .value { font-size: 32px; font-weight: 800; margin-top: 6px; }
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s ease;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f0f1f3; }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Forms ---------- */

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: var(--font);
  background: #fff;
  color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 160px; }

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.logo-preview {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
  overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Tables ---------- */

#users-table, #invitations-table, #businesses-table, #pending-approvals-table, #pending-payments-table, #recent-activity {
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
th { text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 700; }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ---------- Badges ---------- */

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
}
.role-badge.owner { background: var(--color-owner); }
.role-badge.manager { background: var(--color-manager); }
.role-badge.viewer { background: var(--color-viewer); }
.role-badge.super_admin { background: #1e3a5f; }

.status-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.expired { background: #fee2e2; color: #991b1b; }
.status-badge.active { background: #dcfce7; color: #166534; }
.status-badge.new { background: #dbeafe; color: #1e40af; }

.category-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #eef0f3;
  color: #475569;
}

/* ---------- Login page ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-red-dark) 0%, var(--brand-red) 55%, var(--brand-green-dark) 130%);
  padding: 20px;
}

.login-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  width: 100%;
  max-width: 420px;
  padding: 36px 34px;
}

.login-box .logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-box .logo-row img { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; }
.login-box .logo { font-size: 20px; font-weight: 800; line-height: 1.15; }
.login-box .logo span { color: var(--brand-green-dark); }
.login-box .subtitle { color: var(--text-muted); font-size: 13px; margin: 10px 0 26px 0; }

.demo-accounts {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.demo-accounts h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 0 0 10px 0; }
.demo-business-group { margin-bottom: 10px; }
.demo-business-group .biz-name { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; }
.demo-account-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  margin: 0 6px 6px 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fafafa;
  font-size: 12px;
  cursor: pointer;
}
.demo-account-chip:hover { background: #eef2ff; border-color: var(--primary); }

.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.error-banner.show { display: block; }

.success-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.success-banner.show { display: block; }

/* ---------- Misc ---------- */

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--text-muted); font-weight: 500; }
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.text-right { text-align: right; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.permission-group { margin-bottom: 14px; }
.permission-group .cat-name { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.permission-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.permission-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.permission-item .dot.granted { background: var(--success); }
.permission-item .dot.denied { background: #d1d5db; }

@media (max-width: 800px) {
  .main { padding: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; }
  .modal { max-width: 92vw; padding: 18px; }
  .sidebar-drawer { width: 100%; }
  .top-nav-links { display: none; }
}
