:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #7c3aed;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --info: #0891b2;
    --info-light: #cffafe;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 10px 30px rgba(0,0,0,.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── NAV RIGHT (user + lang + logout) ── */
.nav-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.nav-user {
    color: rgba(255,255,255,.8);
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
}
.lang-switcher select {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 6px;
    padding: .3rem .5rem;
    font-size: .78rem;
    cursor: pointer;
    outline: none;
}
.lang-switcher select option { background: var(--primary-dark); color: #fff; }
.btn-nav-logout {
    color: rgba(255,255,255,.8);
    font-size: 1.1rem;
    text-decoration: none;
    padding: .2rem .4rem;
    border-radius: 6px;
    transition: background .15s;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
}
.btn-nav-logout:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ── PIN INPUT ── */
.pin-row {
    display: flex;
    gap: .65rem;
    justify-content: center;
    margin: .5rem 0 .25rem;
}
.pin-box {
    width: 3rem;
    height: 3.4rem;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}
.pin-box:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.14);
    background: #fff;
}

/* ── AUTH PAGES ── */
.auth-body {
    background: linear-gradient(135deg, #1d4ed8 0%, #7c3aed 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    padding: 2rem 1.75rem;
}
.auth-logo {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: .5rem;
}
.auth-title {
    font-size: 1.4rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 1.25rem;
    color: var(--text);
}
.auth-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: .875rem;
    color: var(--text-muted);
}
.auth-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    margin-left: .25rem;
}
.auth-footer a:hover { text-decoration: underline; }
.auth-lang {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}
.auth-lang select {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: .35rem .7rem;
    font-size: .82rem;
    cursor: pointer;
    background: var(--bg);
    color: var(--text);
    outline: none;
}

/* ── NAV ── */
.navbar {
    background: var(--primary);
    padding: .75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.navbar-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-wrap: wrap;
}
.navbar-brand {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.nav-links {
    display: flex;
    gap: .25rem;
    flex-wrap: wrap;
}
.nav-links a {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    padding: .4rem .75rem;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-links a:hover, .nav-links a.active {
    background: rgba(255,255,255,.2);
    color: #fff;
}

/* ── LAYOUT ── */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

/* ── CARDS ── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ── STAT GRID ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .75rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .55rem .65rem;
    text-align: center;
    border-top: 3px solid transparent;
}
.stat-card.glicemia { border-color: var(--warning); }
.stat-card.pressao  { border-color: var(--danger); }
.stat-card.oxigenio { border-color: var(--info); }
.stat-card.pulsacao { border-color: var(--secondary); }
.stat-card.peso     { border-color: var(--success); }

/* ── INSIGHTS ── */
.insights-card { border-top: 3px solid var(--primary); }
.insights-list { display: flex; flex-direction: column; gap: .45rem; margin-bottom: .75rem; }
.insight-item {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    padding: .55rem .85rem;
    border-radius: 8px;
    font-size: .875rem;
    line-height: 1.5;
    border-left: 3px solid transparent;
}
.insight-item.success { background: var(--success-light); color: #14532d; border-color: var(--success); }
.insight-item.warning { background: var(--warning-light); color: #78350f; border-color: var(--warning); }
.insight-item.danger  { background: var(--danger-light);  color: #7f1d1d; border-color: var(--danger); }
.insight-item.info    { background: var(--info-light);    color: #164e63; border-color: var(--info); }
.insight-disclaimer {
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: .25rem;
    padding-top: .5rem;
    border-top: 1px solid var(--border);
}
.stat-label {
    font-size: .63rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .2rem;
    line-height: 1.2;
}
.stat-value {
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1;
}
.stat-unit {
    font-size: .62rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: .1rem;
}

/* ── MONTH NAV ── */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .75rem 1rem;
}
.month-nav h2 {
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    flex: 1;
}
.btn-nav {
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    border-radius: 8px;
    padding: .45rem .9rem;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
    white-space: nowrap;
}
.btn-nav:hover { background: var(--primary); color: #fff; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
th {
    background: var(--bg);
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .55rem .75rem;
    text-align: left;
    white-space: nowrap;
}
td {
    padding: .55rem .75rem;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}
tr:hover td { background: var(--bg); }
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
}
.badge-jejum    { background: var(--warning-light); color: var(--warning); }
.badge-pos      { background: var(--danger-light); color: var(--danger); }
.badge-antes    { background: var(--success-light); color: var(--success); }
.badge-outro    { background: var(--border); color: var(--text-muted); }

/* ── FORMS ── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: .85rem;
}
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.form-control {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: .6rem .85rem;
    font-size: .95rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
    background: #fff;
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 70px; }

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .65rem 1.25rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: filter .15s, transform .1s;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(1.1); }
.btn-info      { background: var(--info); color: #fff; }
.btn-info:hover { filter: brightness(1.1); }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ── TABS ── */
.tabs {
    display: flex;
    gap: .25rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    background: var(--bg);
    border-radius: 10px;
    padding: .3rem;
}
.tab-btn {
    flex: 1;
    min-width: 100px;
    padding: .55rem .75rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background .15s, color .15s;
    text-align: center;
}
.tab-btn.active {
    background: var(--card);
    color: var(--primary);
    box-shadow: var(--shadow);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── ALERTS ── */
.alert {
    border-radius: 8px;
    padding: .75rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 1rem;
}
.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger  { background: var(--danger-light);  color: var(--danger); }

/* ── CHART ── */
.chart-wrap { position: relative; height: 220px; }

/* ── DELETE ── */
.btn-del {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: .85rem;
    padding: .2rem .4rem;
    border-radius: 4px;
    opacity: .6;
    transition: opacity .15s;
}
.btn-del:hover { opacity: 1; background: var(--danger-light); }

/* ── COLLAPSIBLE ── */
.collapsible-header:hover { background: var(--bg); border-radius: var(--radius); }
.collapse-icon {
    font-size: .75rem;
    color: var(--text-muted);
    transition: color .2s;
    min-width: 12px;
    text-align: center;
}

/* ── EMPTY STATE ── */
.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1rem;
    font-size: .9rem;
}
.empty span { font-size: 2rem; display: block; margin-bottom: .5rem; }

/* ── SECTION HEADER ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: .5rem;
    flex-wrap: wrap;
}
.section-header h3 { font-size: .95rem; font-weight: 700; }

/* ── GAUGE ── */
.gauge-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: .5rem;
}
.gauge {
    text-align: center;
    min-width: 90px;
}
.gauge-value {
    font-size: 1.4rem;
    font-weight: 800;
}
.gauge-label { font-size: .75rem; color: var(--text-muted); }

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .btn { width: 100%; justify-content: center; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .tabs { flex-direction: column; }
    .tab-btn { flex: none; }
}

/* ── DIABETES RADIO OPTIONS ── */
.diabetes-options {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .35rem;
}
.radio-option {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .85rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: .875rem;
    transition: border-color .15s, background .15s;
    user-select: none;
}
.radio-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}
.radio-option input[type=radio] { accent-color: var(--primary); }
