:root {
    --primary: #1b66c9;
    --bg: #f6f8fb;
    --card: #fff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --success: #16a34a;
    --danger: #dc2626;
}

* {
    box-sizing: border-box;
    font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
    -webkit-tap-highlight-color: transparent
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%
}
/* ── Top bar ── */
.topbar {
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15)
}

.brand {
    font-weight: 800;
    font-size: 16px;
    white-space: nowrap
}

.nav {
    display: flex;
    gap: 2px;
    flex-wrap: wrap
}

    .nav a {
        color: #fff;
        text-decoration: none;
        padding: 8px 12px;
        border-radius: 6px;
        opacity: .85;
        font-size: 14px;
        white-space: nowrap;
        transition: opacity .15s,background .15s
    }

        .nav a:hover, .nav a.active {
            opacity: 1;
            background: rgba(255,255,255,.18)
        }

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px
}

    .menu-toggle:active {
        background: rgba(255,255,255,.15)
    }

@media(max-width:600px) {
    .topbar {
        padding: 8px 12px
    }

    .brand {
        font-size: 15px
    }

    .menu-toggle {
        display: block
    }

    .nav {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0;
        margin-top: 6px
    }

        .nav.open {
            display: flex
        }

        .nav a {
            padding: 14px 12px;
            border-radius: 0;
            border-top: 1px solid rgba(255,255,255,.12);
            font-size: 15px;
            opacity: 1
        }

            .nav a:active {
                background: rgba(255,255,255,.2)
            }
}
/* ── Layout ── */
.container {
    max-width: 1100px;
    margin: 16px auto;
    padding: 0 16px
}

@media(max-width:600px) {
    .container {
        margin: 8px auto;
        padding: 0 8px
    }
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(16,24,40,.06)
}

@media(max-width:600px) {
    .card {
        padding: 12px 10px;
        border-radius: 8px
    }
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px
}

@media(max-width:900px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 12px
    }
}
/* ── Typography ── */
.h1 {
    font-size: 22px;
    margin: 0 0 10px 0;
    line-height: 1.3
}

@media(max-width:600px) {
    .h1 {
        font-size: 17px;
        margin: 0 0 8px 0
    }
}

.label {
    font-size: 12px;
    color: var(--muted);
    margin: 10px 0 6px;
    font-weight: 600
}
/* ── Inputs ── */
.input, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    min-height: 44px;
    color: var(--text);
    transition: border-color .15s
}

    .input:focus, select:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(27,102,201,.12)
    }

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px
}

@media(max-width:600px) {
    .row {
        grid-template-columns: 1fr;
        gap: 8px
    }
}
/* ── Buttons ── */
.btn {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    min-height: 44px;
    white-space: nowrap;
    transition: opacity .15s,transform .1s;
    user-select: none
}

    .btn:active {
        transform: scale(.97)
    }

    .btn.secondary {
        background: #fff;
        color: var(--primary);
        border-color: var(--primary)
    }

        .btn.secondary:active {
            background: #f0f4ff
        }

    .btn.danger {
        background: var(--danger);
        color: #fff;
        border-color: var(--danger)
    }

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center
}

@media(max-width:600px) {
    .btn-group {
        gap: 6px
    }

        .btn-group .btn {
            padding: 9px 10px;
            font-size: 13px;
            flex: none
        }
}
/* ── Hint ── */
.hint {
    background: #fff3cd;
    border: 1px solid #ffe69c;
    color: #664d03;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.5
}

@media(max-width:600px) {
    .hint {
        font-size: 12px;
        padding: 8px 10px;
        border-radius: 8px
    }
}
/* ── KPI tiles ── */
.kpis {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 10px
}

@media(max-width:900px) {
    .kpis {
        grid-template-columns: repeat(2,1fr)
    }
}

@media(max-width:400px) {
    .kpis {
        grid-template-columns: 1fr;
        gap: 8px
    }
}

.tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    transition: box-shadow .15s
}

    .tile .t {
        color: var(--muted);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .3px;
        font-weight: 600
    }

    .tile .v {
        font-weight: 900;
        font-size: 18px;
        margin-top: 4px;
        word-break: break-all;
        line-height: 1.2
    }

@media(max-width:600px) {
    .tile {
        padding: 10px
    }

        .tile .v {
            font-size: 15px
        }
}
/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px
}

@media(max-width:600px) {
    .table-wrap {
        margin: 0 -10px;
        padding: 0 10px
    }
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px
}

    .table th, .table td {
        border-bottom: 1px solid var(--border);
        padding: 10px 8px;
        text-align: left;
        font-size: 13px;
        white-space: nowrap
    }

    .table th {
        color: var(--muted);
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .3px;
        position: sticky;
        top: 0;
        background: var(--card)
    }

    .table tbody tr:last-child td {
        border-bottom: none
    }

    .table tbody tr:hover {
        background: #f8fafc
    }

@media(max-width:600px) {
    .table th, .table td {
        padding: 8px 6px;
        font-size: 12px
    }

    .table th {
        font-size: 10px
    }
}
/* ── Misc ── */
.footer {
    max-width: 1100px;
    margin: 16px auto;
    padding: 10px 16px;
    color: var(--muted);
    font-size: 11px;
    text-align: center
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eaf2ff;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800
}
/* ── Plan table inputs (compact in table cells) ── */
.table .input, .table select {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 6px
}

@media(max-width:600px) {
    .table .input, .table select {
        min-height: 34px;
        padding: 5px 6px;
        font-size: 12px
    }
}
/* ── Loading state ── */
.loading {
    opacity: .5;
    pointer-events: none
}
/* ── Smooth scroll for iOS ── */
@supports(-webkit-touch-callout:none) {
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch
    }
}
