:root {
    --bg-body: #f5f6f8;
    --bg-card: #ffffff;
    --border-color: #e9ecef;
    --text-primary: #1a1d21;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --accent: #dc3545;
    --radius-card: 14px;
    --radius-pill: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --transition: 0.2s ease;
}

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.min-vh-75 { min-height: 75vh; }

/* ---------- Navbar ---------- */
.navbar {
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    border: none;
}
.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: color var(--transition), background var(--transition);
}
.nav-link:hover {
    color: var(--text-primary);
    background: #f5f6f8;
}
.nav-link.active {
    color: var(--accent) !important;
    background: rgba(220,53,69,0.06);
    font-weight: 600;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

/* Stat cards with color accent */
.card-stat {
    border-left: 3px solid var(--stat-color, var(--border-color));
}
.card-stat .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* ---------- Period pill selector ---------- */
.period-toggle {
    display: inline-flex;
    background: #eef0f2;
    border-radius: var(--radius-pill);
    padding: 3px;
    gap: 2px;
}
.period-toggle a {
    padding: 5px 16px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
}
.period-toggle a:hover {
    color: var(--text-primary);
}
.period-toggle a.active {
    background: #fff;
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-weight: 600;
}

/* ---------- Score ring ---------- */
.score-ring {
    position: relative;
    width: 160px;
    height: 160px;
}

/* ---------- Chart wrappers ---------- */
.chart-wrap {
    position: relative;
    width: 100%;
}
.chart-wrap-sm { height: 200px; }
.chart-wrap-md { height: 340px; }
.chart-wrap-lg { height: 420px; }

/* ---------- Progress bars ---------- */
.progress {
    background: #eef0f2;
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.progress-bar {
    border-radius: var(--radius-pill);
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: 10px;
    font-weight: 500;
    transition: all var(--transition);
}
.btn-outline-success {
    border-radius: var(--radius-pill);
}

/* ---------- Forms ---------- */
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(220,53,69,0.1);
}

/* ---------- Tables ---------- */
.table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom-width: 1px;
}
.table td {
    vertical-align: middle;
}

/* ---------- Section label ---------- */
.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: 10px;
    border: none;
}

/* ---------- Score badge ---------- */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.1rem;
}
.score-good { background: rgba(25,135,84,0.08); color: #198754; }
.score-ok   { background: rgba(230,126,34,0.08); color: #e67e22; }
.score-bad  { background: rgba(220,53,69,0.08); color: #dc3545; }

/* ---------- Login accent ---------- */
.login-card {
    border-top: 4px solid var(--accent);
    border-radius: var(--radius-card);
}

/* ---------- Sync spinner ---------- */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobile nav ---------- */
@media (max-width: 991px) {
    .navbar-collapse {
        padding: 0.5rem 0;
    }
    .navbar-nav {
        gap: 2px !important;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 576px) {
    .table-responsive { font-size: 0.85rem; }
    .card-body { padding: 0.875rem; }
    .chart-wrap-md { height: 240px; }
    .chart-wrap-lg { height: 300px; }
    main.container-fluid { padding-bottom: 1.5rem; }
}

canvas { max-width: 100%; }

/* ---------- Web app manifest hint ---------- */
@media (display-mode: standalone) {
    .navbar { padding-top: env(safe-area-inset-top); }
}
