:root {
  --bg: #0c0c0d;
  --panel: #17171a;
  --panel-border: #2a2a2e;
  --text: #eaeaea;
  --text-muted: #9a9a9f;
  --accent: #e0263a;
  --accent-dark: #a91c2c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }

.accent { color: var(--accent); }

/* ---------- Public marketing pages ---------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 5%;
  border-bottom: 1px solid var(--panel-border);
}
.site-header .brand { font-size: 1.3rem; font-weight: 700; }
.site-header nav a { margin-left: 24px; color: var(--text-muted); }
.site-header nav a:hover { color: var(--text); }
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 10px 22px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}
.btn:hover { background: var(--accent-dark); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
}

.hero { text-align: center; padding: 80px 5% 40px; }
.hero h1 { font-size: 2.6rem; margin-bottom: 16px; line-height: 1.2; }
.hero p { color: var(--text-muted); max-width: 560px; margin: 0 auto 28px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 40px auto;
  padding: 0 5%;
}
.feature-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.site-footer {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 5%;
  border-top: 1px solid var(--panel-border);
  margin-top: 60px;
}

/* ---------- Auth forms ---------- */
.auth-wrap {
  max-width: 380px;
  margin: 80px auto;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}
.auth-wrap h1 { font-size: 1.4rem; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--text-muted); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  background: #0c0c0d;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 1px solid var(--accent); }
.error-box { background: #2a1418; border: 1px solid var(--accent-dark); color: #ff8a93; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.help-text { color: var(--text-muted); font-size: 0.85rem; margin-top: 16px; text-align: center; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}
.sidebar-brand { font-weight: 700; font-size: 1.15rem; margin-bottom: 24px; padding: 0 10px; }
.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-size: 0.9rem;
}
.nav-link:hover { background: #1f1f23; color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; }
.sidebar-logout { margin-top: auto; padding: 0 10px; }
.link-button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 8px 0; font-size: 0.85rem; }
.link-button:hover { color: var(--accent); }

.app-content { flex: 1; padding: 28px 36px; max-width: 1100px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header h1 { font-size: 1.5rem; margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 18px; }
.stat-card .label { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 6px; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; }

.progress-bar { background: #0c0c0d; border-radius: 6px; height: 8px; overflow: hidden; margin-top: 8px; }
.progress-bar > div { background: var(--accent); height: 100%; }

.card-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.item-card.done { opacity: 0.55; }
.item-card .title { font-weight: 600; }
.item-card .meta { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }
.item-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; }
.icon-btn:hover { color: var(--accent); }

.inline-form { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.inline-form input, .inline-form select { padding: 9px 12px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px; color: var(--text); }
.inline-form input[type="text"] { flex: 1; min-width: 180px; }

.empty-state { color: var(--text-muted); padding: 40px 0; text-align: center; }

.habit-grid { border-collapse: collapse; width: 100%; }
.habit-grid th, .habit-grid td { padding: 6px 8px; text-align: center; font-size: 0.8rem; border-bottom: 1px solid var(--panel-border); }
.habit-grid th:first-child, .habit-grid td:first-child { text-align: left; }
.habit-check { width: 18px; height: 18px; cursor: pointer; }

/* ---------- Admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); overflow: hidden; }
.admin-table th, .admin-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--panel-border); font-size: 0.9rem; }
.admin-table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; }
.badge.active { background: #123b23; color: #4ade80; }
.badge.inactive { background: #3b1212; color: #f87171; }

/* ---------- Charts ---------- */
.chart-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.chart-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 20px; }
.chart-row .chart-card { margin-bottom: 0; }

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.stat-card, .item-card, .chart-card {
  animation: fadeInUp 0.35s ease both;
}
.stat-grid > *:nth-child(1) { animation-delay: 0.02s; }
.stat-grid > *:nth-child(2) { animation-delay: 0.06s; }
.stat-grid > *:nth-child(3) { animation-delay: 0.10s; }
.stat-grid > *:nth-child(4) { animation-delay: 0.14s; }
.stat-grid > *:nth-child(5) { animation-delay: 0.18s; }
.card-list > *:nth-child(n) { animation-delay: calc(0.03s * var(--i, 0)); }

.progress-bar > div { transition: width 0.8s ease; }

.btn, .stat-card, .item-card, .feature-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(224, 38, 58, 0.35); }
.btn:active { transform: translateY(0); }
.stat-card:hover, .item-card:hover, .feature-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.nav-link { transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease; }
.nav-link:hover { padding-left: 16px; }

/* ---------- Themes (color/style-inspired, not copyrighted characters) ---------- */
/* "Web" theme: red/blue, Spiderman-inspired palette. Decorative diagonal pattern only, no imagery. */
body.theme-web {
  --bg: #060b1f;
  --panel: #0c1638;
  --panel-border: #1f3070;
  --accent: #e0263a;
  --accent-dark: #a91c2c;
}
body.theme-web::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    repeating-linear-gradient(45deg, rgba(224,38,58,0.04) 0 2px, transparent 2px 40px),
    repeating-linear-gradient(-45deg, rgba(58,90,224,0.05) 0 2px, transparent 2px 40px);
}

/* "Knight" theme: black/yellow, Batman-inspired palette. Sharper corners, radial glow accent. */
body.theme-knight {
  --bg: #000000;
  --panel: #111111;
  --panel-border: #2b2b2b;
  --accent: #f1c40f;
  --accent-dark: #c49a08;
  --radius: 3px;
}
body.theme-knight .btn { color: #111; }
body.theme-knight::before {
  content: "";
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 900px;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(circle, rgba(241,196,15,0.06) 0%, transparent 60%);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .sidebar-brand { margin-bottom: 0; margin-right: auto; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar-logout { margin-top: 0; padding: 0; }
  .app-content { padding: 20px 16px; }
  .hero h1 { font-size: 2rem; }
  .site-header nav a { margin-left: 12px; }
}
