:root {
  --burgundy: #800020;
  --burgundy-light: #a3324a;
  --navy: #0f172a;
  --bg: #f1f5f9;
  --border: #e2e8f0;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --success: #16a34a;
  --warning: #b45309;
  --danger: #991b1b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--navy);
  height: 100%;
  overscroll-behavior-y: contain;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 70px; /* room for bottom nav */
  padding-top: env(safe-area-inset-top);
}

.hidden { display: none !important; }

/* ---- Loading ---- */
.loading-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--burgundy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Offline banner ---- */
.offline-banner {
  background: var(--warning);
  color: #fff;
  text-align: center;
  font-size: 13px;
  padding: 8px 16px;
  position: sticky; top: 0; z-index: 50;
}

/* ---- Top bar ---- */
.top-bar {
  background: var(--navy);
  color: #fff;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top));
  font-weight: 800;
  font-size: 18px;
  position: sticky; top: 0; z-index: 40;
}

/* ---- Bottom nav ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.nav-item {
  flex: 1;
  background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 0 8px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: inherit;
}
.nav-item.active { color: var(--burgundy); font-weight: 700; }
.nav-icon { font-size: 20px; }

/* ---- Cards ---- */
.card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 16px;
  margin: 8px 16px 0;
}
.card h3 { margin: 0 0 8px; font-size: 15px; font-weight: 700; }

.greeting {
  padding: 20px 20px 4px;
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
}

/* ---- Stat tiles ---- */
.stat-row { display: flex; gap: 0; }
.stat-tile {
  flex: 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 8px 16px 0;
  padding: 16px;
  display: flex; align-items: center; gap: 12px;
}
.stat-row .stat-tile:first-child { margin-right: 4px; }
.stat-row .stat-tile:last-child { margin-left: 4px; }
.stat-value { font-size: 20px; font-weight: 800; color: var(--navy); }
.stat-label { font-size: 12px; color: var(--text-muted); }

/* ---- Action buttons ---- */
.action-row { display: flex; gap: 8px; padding: 8px 16px 0; }
.action-btn {
  flex: 1;
  background: #fff;
  border: 1.5px solid var(--burgundy);
  border-radius: 8px;
  padding: 14px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--burgundy);
  font-size: 11px;
  font-family: inherit;
}
.action-btn .icon { font-size: 22px; }

/* ---- Quick tile grid ---- */
.quick-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px;
}
.quick-tile {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 10px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--navy);
  text-align: left;
  font-family: inherit;
}
.quick-tile .icon { font-size: 20px; color: var(--burgundy); }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  background: var(--burgundy);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  width: 100%;
}
.btn:disabled { opacity: 0.6; }
.btn.secondary { background: #fff; border: 1.5px solid var(--burgundy); color: var(--burgundy); }

/* ---- Forms ---- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--navy); }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}

/* ---- Login screen ---- */
.login-screen {
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px;
  background: var(--navy);
}
.login-logo { text-align: center; color: #fff; font-size: 26px; font-weight: 800; margin-bottom: 32px; }
.login-card { background: #fff; border-radius: 16px; padding: 24px; }
.login-error {
  background: #fef2f2; color: var(--danger);
  border-radius: 8px; padding: 10px 12px;
  font-size: 13px; margin-bottom: 14px;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
}
.badge-success { background: #f0fdf4; color: var(--success); }
.badge-warning { background: #fffbeb; color: var(--warning); }
.badge-danger { background: #fef2f2; color: var(--danger); }
.badge-default { background: #f1f5f9; color: var(--text-muted); }
