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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --accent: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

nav {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.logo span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lang-toggle, .unit-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.unit-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-right: 0.25rem;
}

.lang-btn, .unit-btn {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.lang-btn:first-of-type, .unit-btn:first-of-type {
    border-radius: 6px 0 0 6px;
}

.lang-btn:last-of-type, .unit-btn:last-of-type {
    border-radius: 0 6px 6px 0;
}

.lang-btn.active, .unit-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    padding: 5rem 0;
    text-align: center;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.hero h1 span {
    color: var(--accent);
}

.subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    max-width: 700px;
    margin: 0 auto 2rem;
}

.cta-button {
    display: inline-block;
    padding: 1rem 2.5rem;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.section {
    padding: 4rem 0;
}

.section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.section-desc {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 3rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.calc-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.calc-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.calc-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.calc-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.calc-card p {
    font-size: 0.9rem;
    color: var(--text-light);
}

.hidden {
    display: none !important;
}

.calculator-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    margin: 0 auto;
}

.back-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 1.5rem;
    padding: 0;
}

.back-btn:hover {
    text-decoration: underline;
}

.calc-form h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.calc-explanation {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--primary-light);
    border-radius: 8px;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.inline-inputs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-inputs input {
    width: 80px;
}

.hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.calc-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.calc-btn:hover {
    background: var(--primary-dark);
}

.result {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: var(--primary-light);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.result pre {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.8;
}

.hba1c-table, .ketone-scale {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.hba1c-table h4, .ketone-scale h4 {
    margin-bottom: 1rem;
    color: var(--text);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg);
    font-weight: 600;
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.tip-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.tip-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.tip-card h3 {
    color: var(--primary);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.tip-card ul {
    list-style: none;
    padding: 0;
}

.tip-card li {
    padding: 0.35rem 0;
    font-size: 0.9rem;
    color: var(--text);
    padding-left: 1.25rem;
    position: relative;
}

.tip-card li::before {
    content: "•";
    color: var(--accent);
    font-weight: bold;
    position: absolute;
    left: 0;
}

.about-section {
    background: var(--card-bg);
}

.disclaimer, .emergency {
    max-width: 800px;
    margin: 2rem auto;
    padding: 1.5rem;
    border-radius: var(--radius);
}

.disclaimer {
    background: #fef3c7;
    border-left: 4px solid var(--warning);
}

.emergency {
    background: #fee2e2;
    border-left: 4px solid var(--danger);
}

.disclaimer h3, .emergency h3 {
    margin-bottom: 0.75rem;
}

.disclaimer p, .emergency p {
    font-size: 0.95rem;
    line-height: 1.7;
}

footer {
    background: var(--text);
    color: white;
    padding: 2rem 0;
    text-align: center;
    font-size: 0.9rem;
}

footer p {
    opacity: 0.8;
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--card-bg);
        flex-direction: column;
        padding: 1rem 1.5rem;
        box-shadow: var(--shadow);
    }

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

    .mobile-menu-btn {
        display: block;
    }

    .nav-controls {
        gap: 0.5rem;
    }

    .lang-toggle, .unit-toggle {
        font-size: 0.8rem;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .hero {
        padding: 3rem 0;
    }

    .calc-grid {
        grid-template-columns: 1fr;
    }

    .tips-grid {
        grid-template-columns: 1fr;
    }
}
