:root {
    --bg: #f3f7f4;
    --card: rgba(255,255,255,0.82);
    --card-strong: #ffffff;
    --text: #17301e;
    --muted: #678071;
    --green: #17a34a;
    --green-dark: #0d7c36;
    --line: rgba(23, 48, 30, 0.08);
    --shadow: 0 16px 40px rgba(23, 48, 30, 0.08);
    --radius: 24px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    background: linear-gradient(180deg, #f6faf7 0%, #eef5ef 100%);
}

body {
    margin: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    color: var(--text);
    background: transparent;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    max-width: 980px;
    margin: 0 auto;
    padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 6px 18px;
}

.app-kicker {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.app-title {
    margin: 0;
    font-size: clamp(1.8rem, 6vw, 2.6rem);
    line-height: 1;
}

.app-badge,
.pill {
    background: rgba(23, 163, 74, 0.12);
    color: var(--green-dark);
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 700;
    font-size: 0.9rem;
}

.page-content {
    display: grid;
    gap: 16px;
}

.card {
    background: var(--card);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.surface-card {
    overflow: hidden;
}

.editor-card {
    position: sticky;
    bottom: 12px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

    .section-head h2 {
        margin: 0 0 4px;
        font-size: 1.15rem;
    }

    .section-head p {
        margin: 0;
        color: var(--muted);
    }

.status-stack {
    display: grid;
    gap: 8px;
}

.message {
    border-radius: 18px;
    padding: 14px 16px;
    font-weight: 600;
}

    .message.success {
        background: rgba(23, 163, 74, 0.12);
        color: var(--green-dark);
    }

    .message.error {
        background: rgba(220, 38, 38, 0.12);
        color: #991b1b;
    }

.desktop-table-wrap {
    display: none;
    overflow: auto;
}

.competitor-table {
    width: 100%;
    border-collapse: collapse;
}

    .competitor-table th,
    .competitor-table td {
        padding: 12px 14px;
        text-align: left;
        border-bottom: 1px solid var(--line);
        white-space: nowrap;
    }

    .competitor-table tbody tr {
        cursor: pointer;
    }

        .competitor-table tbody tr.is-active {
            background: rgba(23, 163, 74, 0.08);
        }

    .competitor-table th:nth-child(1),
    .competitor-table td:nth-child(1) {
        width: 50px;
    }

    .competitor-table th:nth-child(2),
    .competitor-table td:nth-child(2) {
        width: 50px;
    }

    .competitor-table th:nth-child(4),
    .competitor-table td:nth-child(4) {
        width: 50px;
    }


    .competitor-table th:nth-child(1),
    .competitor-table td:nth-child(1),
    .competitor-table th:nth-child(2),
    .competitor-table td:nth-child(2),
    .competitor-table th:nth-child(4),
    .competitor-table td:nth-child(4),
    .competitor-table th:nth-child(5),
    .competitor-table td:nth-child(5),
    .competitor-table th:nth-child(6),
    .competitor-table td:nth-child(6),
    .competitor-table th:nth-child(7),
    .competitor-table td:nth-child(7) {
        text-align: center;
    }


.competitor-cards {
    display: grid;
    gap: 12px;
}

.competitor-card {
    border: 0;
    width: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(248,252,249,0.95));
    border-radius: 22px;
    padding: 16px;
    text-align: left;
    box-shadow: inset 0 0 0 1px rgba(23,48,30,0.06), 0 8px 18px rgba(23,48,30,0.06);
}

    .competitor-card.is-active {
        box-shadow: inset 0 0 0 2px rgba(23,163,74,0.45), 0 10px 24px rgba(23,163,74,0.16);
        transform: translateY(-1px);
    }

.card-topline,
.card-times {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.card-name {
    font-weight: 800;
    font-size: 1.12rem;
    margin: 10px 0;
}

.card-number {
    color: var(--green-dark);
    font-weight: 700;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

    .toggle-row.compact {
        font-size: 0.92rem;
        color: var(--muted);
    }

.editor-form {
    display: grid;
    gap: 16px;
}

.editor-grid {
    display: grid;
    gap: 12px;
    align-items: start;
}

.input-group {
    display: grid;
    gap: 8px;
}

    .input-group > label {
        font-size: 0.95rem;
        font-weight: 700;
    }

    .input-group small {
        color: var(--muted);
        font-weight: 500;
    }

    .input-group input[type="text"],
    .input-group input[type="time"],
    .input-group input:not([type="checkbox"]) {
        width: 100%;
        height: 56px;
        border-radius: 18px;
        border: 1px solid rgba(23,48,30,0.08);
        background: var(--card-strong);
        padding: 0 16px;
        font-size: 1.15rem;
        letter-spacing: 0.06em;
        color: var(--text);
        box-shadow: inset 0 1px 1px rgba(23,48,30,0.03);
    }
        .input-group input[type="text"]:focus,
        .input-group input[type="time"]:focus,
        .input-group input:not([type="checkbox"]):focus {
            outline: none;
            border-color: rgba(23,163,74,0.55);
            box-shadow: 0 0 0 4px rgba(23,163,74,0.12);
        }

    .input-group input[disabled]:not([type="checkbox"]) {
        background: #eef2ef;
        color: #93a19a;
    }

    .input-group input[readonly]:not([type="checkbox"]) {
        background: #eef2ef;
        color: #93a19a;
    }

.saved-field {
    background: rgba(23, 163, 74, 0.14);
    border-radius: 18px;
    padding: 12px;
    box-shadow: inset 0 0 0 1px rgba(23, 163, 74, 0.22);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
    padding: 2px 2px 0;
}

.switch-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.ios-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
    flex: 0 0 auto;
}

    .ios-switch input {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }

    .ios-switch .slider {
        position: absolute;
        inset: 0;
        border-radius: 999px;
        background: #d1d5db;
        transition: background 0.2s ease;
    }

        .ios-switch .slider::before {
            content: "";
            position: absolute;
            width: 26px;
            height: 26px;
            left: 3px;
            top: 3px;
            border-radius: 50%;
            background: #ffffff;
            box-shadow: 0 2px 6px rgba(0,0,0,0.18);
            transition: transform 0.2s ease;
        }

    .ios-switch input:checked + .slider {
        background: var(--green);
    }

        .ios-switch input:checked + .slider::before {
            transform: translateX(20px);
        }

.field-validation {
    color: #b42318;
    font-size: 0.9rem;
    font-weight: 600;
}

.summary-tile {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
    background: rgba(23,163,74,0.08);
    border-radius: 20px;
}

.summary-label {
    color: var(--muted);
    font-size: 0.82rem;
}

.summary-value {
    font-size: 1.05rem;
    font-weight: 800;
    margin-top: 4px;
}

.action-bar,
.send-form {
    display: flex;
    gap: 12px;
}

.action-bar {
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom));
    padding-top: 6px;
}

.btn {
    min-height: 54px;
    border: 0;
    border-radius: 999px;
    padding: 0 20px;
    font-weight: 800;
    font-size: 1rem;
}

.btn-primary {
    flex: 1 1 auto;
    color: white;
    background: linear-gradient(180deg, #22c55e, #159347);
    box-shadow: 0 10px 24px rgba(23,163,74,0.28);
}

.btn-secondary {
    flex: 0 0 20%;
    background: rgba(23,48,30,0.06);
    color: var(--text);
}

.btn-reload {
    flex: 0 0 120px;
    background: rgba(23,48,30,0.06);
    color: var(--text);
}

.btn-ghost {
    width: 100%;
    background: white;
    color: var(--green-dark);
    box-shadow: inset 0 0 0 1px rgba(23,163,74,0.16);
}

.btn-full {
    width: 100%;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 18px;
}

@media (min-width: 768px) {
    .app-shell {
        padding-left: 20px;
        padding-right: 20px;
    }

    .desktop-table-wrap {
        display: block;
    }

    .competitor-cards {
        display: none;
    }

    .editor-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .editor-card {
        position: static;
    }
}
