@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-strong: #f0f4ff;
    --text: #0f172a;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --radius: 14px;
    --nav-height: 64px;
}

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

body {
    font-family: 'Manrope', 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 10% 20%, rgba(37,99,235,0.04), transparent 30%), var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(229, 231, 235, 0.8);
}

.nav-content {
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-weight: 700; font-size: 1.9rem; color: var(--text); }
.logo-icon { height: 44px; width: 44px; }
.user-chip {
    background: var(--surface-strong);
    color: var(--primary-dark);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.nav-toggle {
    border: 1px solid var(--border);
    background: var(--surface);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    padding: 8px;
}
.nav-toggle span {
    width: 100%;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-links {
    list-style: none;
    position: absolute;
    left: 0;
    top: var(--nav-height);
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 20px 30px rgba(15,23,42,0.05);
    display: none;
    flex-direction: column;
    padding: 12px 0;
}

.nav-links.open { display: flex; }

.nav-links li { padding: 10px 20px; }
.nav-links a, .link-button {
    color: var(--text);
    font-weight: 600;
}
.link-button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.logout-form { display: inline; }

.mobile-only { display: block; }
.desktop-only { display: none; }

.nav-actions {
    display: none;
    align-items: center;
    gap: 12px;
}

.nav-cta {
    padding: 10px 14px;
}

.muted-link {
    color: var(--muted);
    font-weight: 700;
}
.muted-link:hover { color: var(--text); }

.user-menu {
    position: relative;
}

.user-chip-btn {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-width: 180px;
    padding: 8px 0;
    z-index: 20;
}

.user-dropdown a,
.user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    color: var(--text);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: var(--surface-strong);
}

.user-menu.open .user-dropdown {
    display: block;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
}
.lang-switch a {
    color: var(--muted);
}
.lang-switch a.active-lang {
    color: var(--text);
    text-decoration: underline;
}
.dropdown-lang {
    padding: 8px 14px;
    border-top: 1px solid var(--border);
}

.main-content {
    padding: 24px 0 64px;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 14px;
    font-weight: 600;
}
.alert-success { background: #ecfdf3; color: #0f5132; border-color: #bbf7d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border-color: #fecdd3; }
.alert-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 10px;
}

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

.pill-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 12px 0 6px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 10px 25px rgba(37,99,235,0.25); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-strong); color: var(--text); border-color: var(--border); }
.btn-danger { background: #fee2e2; color: #b91c1c; border-color: #fecdd3; }
.btn-filter { border: 1px solid var(--border); background: var(--surface-strong); color: var(--text); }
.btn-filter.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-sm { padding: 8px 10px; font-size: 0.9rem; }
.full-width { width: 100%; text-align: center; }

.pill-group {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 0;
}
.pill {
    padding: 8px 12px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
}
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.form-container, .auth-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 18px;
}
.form-container h2, .auth-container h2 { margin-bottom: 6px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 700; color: var(--text); }
.form-control {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f8fafc;
    font-size: 1rem;
}
.form-control:focus { outline: 2px solid rgba(37,99,235,0.3); border-color: var(--primary); }
.error { color: var(--danger); font-size: 0.9rem; margin-top: 6px; }
.help-text { color: var(--muted); font-size: 0.9rem; margin-top: 4px; display: block; }
.checkbox { display: flex; align-items: center; gap: 8px; }

.data-table {
    display: none;
    width: 100%;
    border-collapse: collapse;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow);
    margin-top: 10px;
}
.data-table thead { background: var(--surface-strong); }
.data-table th, .data-table td { padding: 12px; text-align: left; }
.data-table tbody tr:nth-child(even) { background: #f8fafc; }
.data-table tbody tr:hover { background: #eef2ff; }

.glucose-value { font-weight: 800; }
.glucose-value.danger, .history-value.danger { color: var(--danger); }
.glucose-value.warning, .history-value.warning { color: var(--warning); }
.glucose-value.normal, .history-value.normal { color: var(--success); }

.history-cards { display: grid; gap: 12px; margin-top: 12px; }
.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
}
.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.history-date { font-weight: 700; }
.history-time { color: var(--muted); font-size: 0.95rem; }
.history-context { color: var(--text); margin-bottom: 4px; }
.history-notes { color: var(--muted); margin-bottom: 8px; }

.stat-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    text-align: center;
}
.stat-box h4 { color: var(--muted); margin-bottom: 6px; }
.stat-box p { font-size: 1.6rem; font-weight: 800; color: var(--text); }

.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.legend {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
}
.legend ul { list-style: none; }
.legend li { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.color-box { width: 18px; height: 18px; border-radius: 6px; }
.color-box.low { background: var(--danger); }
.color-box.normal { background: var(--success); }
.color-box.high { background: var(--warning); }

.landing {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.hero {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 18px;
}

.hero-surface {
    background: linear-gradient(135deg, #f8fbff, #ffffff);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.hero-text h1 {
    font-size: 2.1rem;
    margin-bottom: 10px;
    line-height: 1.2;
}

.hero-description {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 10px;
    color: var(--text);
}

.hero-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    background: linear-gradient(135deg, #f0f4ff, #ffffff);
    box-shadow: var(--shadow);
}
.hero-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.hero-card-title { font-weight: 700; }
.hero-card-date { color: var(--muted); font-size: 0.9rem; }
.hero-chip {
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
}
.hero-chip.success { background: #ecfdf3; color: #0f5132; border: 1px solid #bbf7d0; }
.hero-value {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 8px 0;
}
.hero-value .value { font-size: 2.4rem; font-weight: 800; }
.hero-value .unit { color: var(--muted); }
.hero-points {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    flex-wrap: wrap;
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 8px;
}
.mini-label { color: var(--muted); font-size: 0.9rem; }
.mini-value { font-weight: 700; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.feature h3 { margin-bottom: 6px; }

.cta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.cta .actions { margin: 0; }

.privacy-card {
    background: linear-gradient(135deg, #f0fdf4, #ffffff);
    border-left: 4px solid var(--success);
}

.privacy-card h2 {
    margin-bottom: 16px;
    color: var(--text);
}

.privacy-content p {
    margin-bottom: 14px;
    line-height: 1.7;
    font-size: 1.05rem;
}

.privacy-content p:last-child {
    margin-bottom: 0;
}

.manifesto {
    background: linear-gradient(135deg, #eff6ff, #ffffff);
    border-left: 4px solid var(--primary);
}

.manifesto h2 {
    margin-bottom: 20px;
    text-align: center;
}

.manifesto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.manifesto-item {
    text-align: center;
    padding: 12px;
}

.manifesto-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.manifesto-item h3 {
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.manifesto-item p {
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.95rem;
}

.features-detailed h2 {
    margin-bottom: 18px;
    font-size: 1.8rem;
}

.feature-detailed {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-detailed:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

.feature-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
    width: 60px;
    text-align: center;
}

.feature-content h3 {
    margin-bottom: 8px;
    font-size: 1.15rem;
}

.feature-content p {
    color: var(--muted);
    line-height: 1.7;
    font-size: 1rem;
}

.tech-section {
    background: linear-gradient(135deg, #faf5ff, #ffffff);
    border-left: 4px solid #a855f7;
    text-align: center;
}

.tech-section h2 {
    margin-bottom: 12px;
}

.tech-section > p {
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 16px;
    font-size: 1.05rem;
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 14px;
}

.tech-badge {
    padding: 8px 14px;
    background: linear-gradient(135deg, #a855f7, #9333ea);
    color: white;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.cta-final {
    background: linear-gradient(135deg, #f0f9ff, #ffffff);
    border: 2px solid var(--primary);
    text-align: center;
}

.cta-final h2 {
    margin-bottom: 12px;
    font-size: 1.8rem;
}

.cta-content p {
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 12px;
    font-size: 1.05rem;
}

.cta-note {
    font-size: 0.95rem;
    color: var(--text);
    font-style: italic;
    background: rgba(37, 99, 235, 0.05);
    padding: 12px;
    border-radius: 10px;
    margin-top: 16px;
}

.cta-final .actions {
    justify-content: center;
    margin-top: 20px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1.05rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.page-info { color: var(--muted); }

.no-data {
    text-align: center;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
}

.fab {
    position: fixed;
    bottom: 18px;
    right: 18px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 800;
    box-shadow: 0 16px 35px rgba(37,99,235,0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}
.fab:hover { transform: translateY(-1px); box-shadow: 0 18px 40px rgba(37,99,235,0.4); }

footer {
    background: linear-gradient(90deg, #0f172a, #111827);
    color: #e5e7eb;
    text-align: center;
    padding: 24px 0;
    margin-top: 32px;
}

@media (min-width: 900px) {
    .container { padding: 0 20px; }
    .nav-toggle { display: none; }
    .nav-links {
        position: static;
        display: flex !important;
        flex-direction: row;
        background: transparent;
        border: none;
        box-shadow: none;
        width: auto;
        gap: 14px;
        padding: 0;
    }
    .nav-links li { padding: 0; }
    .nav-links a, .link-button { color: var(--muted); }
    .nav-links a:hover, .link-button:hover { color: var(--text); }
    .nav-links .mobile-only { display: none; }

    .nav-right { gap: 20px; }
    .nav-actions { display: flex; }
    .desktop-only { display: flex; }

    .main-content { padding-top: 32px; }

    .data-table { display: table; }
    .history-cards { display: none; }

    .landing {
        gap: 12px;
    }
}

@media (max-width: 768px) {
    .hero {
        grid-template-columns: 1fr;
    }
    .cta {
        flex-direction: column;
        align-items: flex-start;
    }
    .hero-text h1 {
        font-size: 1.8rem;
    }
    .hero-description {
        font-size: 1rem;
    }
    .manifesto-grid {
        grid-template-columns: 1fr;
    }
    .feature-detailed {
        flex-direction: column;
        text-align: center;
    }
    .feature-icon {
        width: 100%;
    }
    .cta-final {
        text-align: center;
    }
    .cta-final .actions {
        flex-direction: column;
        width: 100%;
    }
    .cta-final .btn {
        width: 100%;
    }
}
