:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1f2733;
    --muted: #6b7785;
    --border: #e2e7ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --good: #16a34a;
    --warn: #d97706;
    --bad: #9ca3af;
    --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
    --radius: 10px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef1f6; padding: .1em .35em; border-radius: 4px; font-size: .9em; }

/* Topbar */
.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem; height: 58px;
    position: sticky; top: 0; z-index: 10;
}
.brand a { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.topbar nav { display: flex; gap: 1.2rem; flex: 1; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.user-menu { display: flex; align-items: center; gap: .8rem; }
.user-name { color: var(--text); font-weight: 600; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.8rem 1.5rem 3rem; }
h1 { font-size: 1.6rem; margin: 0 0 .3rem; }
h2 { font-size: 1.2rem; }
.section-title { margin-top: 2rem; }
.muted { color: var(--muted); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.2rem;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.2rem; }
.source-card h2 { margin-top: 0; }
.source-card.disabled { opacity: .65; }
.report-list { list-style: none; padding: 0; margin: .6rem 0 0; }
.report-link { display: block; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 8px; color: var(--text); }
.report-link:hover { border-color: var(--primary); text-decoration: none; background: #f8faff; }
.report-link strong { display: block; }
.report-link span { color: var(--muted); font-size: .88rem; }

/* Forms */
label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .92rem; }
input, select {
    width: 100%; margin-top: .3rem; padding: .55rem .7rem;
    border: 1px solid var(--border); border-radius: 8px; font-size: .95rem;
    background: #fff; color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
label small { font-weight: 400; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 0 1.2rem; }
.upload-form button { margin-top: .4rem; }
.date-row { display: flex; gap: .5rem; align-items: center; margin-top: .3rem; flex-wrap: wrap; }
.date-row input[type="date"],
.date-row input[type="time"] { flex: 1; min-width: 120px; margin-top: 0; }

.mode-toggle { display: flex; gap: .6rem; flex-wrap: wrap; }
.radio-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem;
    border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-weight: 600;
    font-size: .9rem; margin-bottom: 0; background: #fff; }
.radio-pill:has(input:checked) { border-color: var(--primary); background: #eef2fa; color: var(--primary); }
.radio-pill input { width: auto; margin: 0; }

.checkbox-row { display: flex; align-items: flex-start; gap: .5rem; font-weight: 500;
    font-size: .9rem; margin: .2rem 0 1rem; cursor: pointer; }
.checkbox-row input { width: auto; margin: .2rem 0 0; flex-shrink: 0; }

/* Buttons */
.btn {
    display: inline-block; padding: .5rem .9rem; border-radius: 8px;
    border: 1px solid var(--border); background: #fff; color: var(--text);
    font-weight: 600; font-size: .9rem; cursor: pointer; text-align: center;
}
.btn:hover { background: #f3f5f9; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f3c4c4; }
.btn-danger:hover { background: #fdeaea; }
.btn-success { background: var(--good); border-color: var(--good); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-whatsapp { background: #25D366; border-color: #1da851; color: #fff; }
.btn-whatsapp:hover { background: #1da851; border-color: #178a42; }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--muted); cursor: pointer; font-weight: 600; padding: .3rem; }
.btn-link:hover { color: var(--text); }
.inline { display: inline; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .92rem; }
.table thead th { background: #f7f9fc; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.table thead th.sortable:hover { background: #eef2fa; color: var(--text); }
.table thead th.sorted { color: var(--primary); background: #eef2fa; }
.sort-icon { font-style: normal; }
.table tbody tr:hover { background: #f9fbfe; }
.table tfoot td { background: #f7f9fc; border-top: 2px solid var(--border); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }

/* KPIs */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 1rem; margin: 1.2rem 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.kpi-label { display: block; color: var(--muted); font-size: .82rem; }
.kpi-val { display: block; font-size: 1.5rem; font-weight: 700; margin-top: .2rem; }
.kpi-val.accent { color: var(--primary); }

/* Pills & badges */
.pill { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.pill-good { background: #dcfce7; color: #15803d; }
.pill-warn { background: #fef3c7; color: #b45309; }
.pill-bad { background: #f1f3f6; color: #6b7785; }
.badge { display: inline-block; background: var(--primary); color: #fff; padding: .05rem .45rem; border-radius: 6px; font-size: .7rem; font-weight: 700; vertical-align: middle; }
.badge-soon { background: var(--warn); }
.badge-finale { background: #7c3aed; }
.finale-btn { border-color: #c4b5fd; color: #6d28d9; font-weight: 700; }
.finale-btn:hover { background: #f3effe; }
.finale-btn.btn-primary { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.src-tag { font-size: .7rem; background: #eef1f6; color: var(--muted); padding: .15rem .5rem; border-radius: 6px; vertical-align: middle; }

/* Chart */
.chart-card { padding: 1.2rem 1.4rem; margin: 1.2rem 0; }
.chart-title { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .8rem; }

/* Alerts */
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; }
.alert-error { background: #fdeaea; color: #991b1b; border: 1px solid #f3c4c4; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* Page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; }

/* Bars (trend) */
.bar-wrap { position: relative; background: #eef1f6; border-radius: 6px; height: 22px; min-width: 120px; display: inline-flex; align-items: center; }
.bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); border-radius: 6px; opacity: .25; }
.bar-wrap span { position: relative; padding-left: .5rem; font-weight: 600; font-size: .85rem; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { margin-bottom: .2rem; }
.login-card form { text-align: left; margin-top: 1.2rem; }

/* Details / reset password */
.inline-details { display: inline-block; }
.inline-details summary { list-style: none; display: inline-block; }
.inline-details summary::-webkit-details-marker { display: none; }
.reset-form { display: flex; gap: .4rem; margin-top: .5rem; }
.reset-form input { margin-top: 0; }

.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 1.5rem; }
