:root {
  --bg: #0b0f14;
  --bg-elev: #131924;
  --bg-elev2: #1a2230;
  --border: #232c3a;
  --text: #eef2f7;
  --text-dim: #94a3b8;
  --text-faint: #5b6b82;
  --accent: #22e3a6;
  --accent-dim: #17a67c;
  --accent2: #3b82f6;
  --danger: #f75c5c;
  --warn: #f5a623;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at 20% -10%, #14202b 0%, var(--bg) 45%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.02em; margin: 0 0 8px; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
p { color: var(--text-dim); line-height: 1.5; margin: 0 0 12px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px; }
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }

.card {
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.brand-name { font-weight: 900; font-size: 1.6rem; letter-spacing: -0.03em; }
.tagline { color: var(--text-faint); font-size: 0.85rem; margin-bottom: 22px; }

.auth-card { width: 100%; max-width: 420px; }
label { display: block; font-size: 0.82rem; color: var(--text-dim); margin: 14px 0 6px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 0.95rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-weight: 700; font-size: 0.95rem; font-family: inherit; transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #04150f; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg-elev2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(247,92,92,0.15); color: var(--danger); border: 1px solid rgba(247,92,92,0.3); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error-box { background: rgba(247,92,92,0.12); border: 1px solid rgba(247,92,92,0.35); color: #ff9b9b; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.87rem; margin-top: 14px; }
.success-box { background: rgba(34,227,166,0.1); border: 1px solid rgba(34,227,166,0.3); color: var(--accent); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.87rem; margin-top: 14px; }
.hidden { display: none !important; }

.muted-link { text-align: center; margin-top: 18px; font-size: 0.87rem; color: var(--text-dim); }

/* App shell */
.app-shell { min-height: 100vh; padding-bottom: 84px; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(11,15,20,0.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; }
.topbar .brand-name { font-size: 1.2rem; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent2); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; color: #06122a; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: rgba(19,25,36,0.95); backdrop-filter: blur(10px); border-top: 1px solid var(--border); display: flex; justify-content: space-around; padding: 8px 4px 10px; }
.tab-item { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--text-faint); font-size: 0.68rem; font-weight: 700; cursor: pointer; padding: 4px 10px; border-radius: 10px; }
.tab-item.active { color: var(--accent); }
.tab-item svg { width: 21px; height: 21px; }

.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 230px; background: var(--bg-elev); border-right: 1px solid var(--border); padding: 20px 14px; overflow-y: auto; }
.sidebar .brand { padding: 0 6px; margin-bottom: 26px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-dim); font-weight: 600; font-size: 0.88rem; cursor: pointer; margin-bottom: 3px; }
.side-link.active { background: var(--bg-elev2); color: var(--accent); }
.side-link:hover { color: var(--text); }
.main-with-sidebar { margin-left: 230px; padding: 24px 28px; }
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main-with-sidebar { margin-left: 0; padding: 16px; }
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat-card { padding: 18px; }
.stat-label { color: var(--text-faint); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 900; letter-spacing: -0.03em; }
.stat-sub { font-size: 0.78rem; color: var(--text-dim); margin-top: 4px; }

.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.chip-green { background: rgba(34,227,166,0.14); color: var(--accent); }
.chip-amber { background: rgba(245,166,35,0.14); color: var(--warn); }
.chip-red { background: rgba(247,92,92,0.14); color: var(--danger); }
.chip-blue { background: rgba(59,130,246,0.14); color: var(--accent2); }
.chip-grey { background: var(--bg-elev2); color: var(--text-dim); }

table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
th { text-align: left; color: var(--text-faint); font-weight: 700; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.03em; padding: 10px 8px; border-bottom: 1px solid var(--border); }
td { padding: 12px 8px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.affirmation-card { background: linear-gradient(135deg, rgba(34,227,166,0.14), rgba(59,130,246,0.10)); border: 1px solid rgba(34,227,166,0.25); }
.affirmation-quote { font-size: 1.05rem; font-weight: 700; font-style: italic; color: var(--text); margin-bottom: 6px; }
.affirmation-author { color: var(--accent); font-weight: 700; font-size: 0.82rem; }

.qr-box { display: flex; align-items: center; justify-content: center; background: #fff; border-radius: var(--radius); padding: 20px; }

.list-item { display: flex; align-items: center; justify-content: between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item-main { flex: 1; }
.list-item-title { font-weight: 700; font-size: 0.92rem; }
.list-item-sub { font-size: 0.8rem; color: var(--text-faint); margin-top: 2px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.tab-row { display: flex; gap: 6px; margin-bottom: 18px; overflow-x: auto; padding-bottom: 2px; }
.tab-btn { padding: 9px 16px; border-radius: 999px; background: var(--bg-elev2); color: var(--text-dim); font-weight: 700; font-size: 0.83rem; cursor: pointer; white-space: nowrap; border: 1px solid transparent; }
.tab-btn.active { background: rgba(34,227,166,0.14); color: var(--accent); border-color: rgba(34,227,166,0.3); }

.progress-bar-track { width: 100%; height: 8px; background: var(--bg-elev2); border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto; }

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

.loader { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

canvas { max-width: 100%; }
