:root {
  color-scheme: light dark;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #6b7280;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-contrast: #ffffff;
  --pill-bg: #e5e7eb;
  --pill-text: #111827;
  --header-bg: #0f172a;
  --header-text: #ffffff;
  --focus: #93c5fd;
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #1f2a44;
  --primary: #3b82f6;
  --primary-contrast: #0b1220;
  --pill-bg: #1f2937;
  --pill-text: #e5e7eb;
  --header-bg: #0b1220;
  --header-text: #e5e7eb;
  --focus: #60a5fa;
}

* { box-sizing: border-box; }
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}
header {
  padding: 12px 16px;
  background: var(--header-bg);
  color: var(--header-text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
header.topbar { position: sticky; top: 0; z-index: 5; }
main { padding: 16px; }
a { color: var(--primary); text-decoration: none; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.muted { color: var(--muted); }
input, button, select, textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
input:focus, button:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
button { cursor: pointer; }
.primary-btn {
  background: var(--primary);
  color: var(--primary-contrast);
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  display: inline-block;
  text-align: center;
}
.pill {
  background: var(--pill-bg);
  color: var(--pill-text);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.stack-form input,
.stack-form select { width: 100%; }
.stack-form button { width: auto; margin-top: 6px; }
.form-card { max-width: 520px; margin: 0 auto; }
.page-center { display: flex; flex-direction: column; align-items: center; }
.page-center > * { width: 100%; max-width: 520px; }
.phone-row { display: flex; gap: 8px; align-items: center; }
.theme-toggle {
  background: transparent;
  border: none;
  color: var(--header-text);
  padding: 6px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
}
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle span { font-size: 12px; }
.theme-toggle:hover { background: rgba(255,255,255,0.12); }
.topbar-link { color: var(--header-text); }
.topbar-actions { display: inline-flex; align-items: center; gap: 10px; }
.app-shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 60px); }
.app-shell.no-nav { grid-template-columns: 1fr; }
.sidebar {
  padding: 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow: auto;
}
.nav-section { font-size: 12px; color: var(--muted); text-transform: uppercase; margin: 12px 0 6px; }
.nav-link { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nav-link:hover { background: var(--pill-bg); }
.main-content { padding: 16px; }
.bottom-nav {
  display: none;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.nav-tab {
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 64px;
  font-size: 11px;
  flex: 0 0 auto;
}
.nav-tab svg { width: 20px; height: 20px; }
.nav-tab:hover { background: var(--pill-bg); }
.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.profile-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--header-text);
  padding: 6px 10px;
  border-radius: 8px;
  margin-left: 8px;
}
.profile-link svg { width: 18px; height: 18px; }
.profile-link:hover { background: rgba(255,255,255,0.12); }
.brand-badge img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
}

@media (max-width: 640px) {
  header { flex-wrap: wrap; }
  main { padding: 12px; }
  .card { padding: 10px; }
  .primary-btn { width: auto; }
  .phone-row { flex-direction: column; align-items: stretch; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { padding-bottom: 72px; }
  .bottom-nav { display: flex; }
}
