:root {
        --primary: #319795;
        --primary-hover: #2c7a7b;
        --secondary: #3182ce;
        --accent: #d69e2e;
        --danger: #e53e3e;
        --bg-light: #f7fafc;
        --card-light: #ffffff;
        --text-light: #2d3748;
        --border-light: #e2e8f0;

        --bg-dark: #1a202c;
        --card-dark: #2d3748;
        --text-dark: #e2e8f0;
        --border-dark: #4a5568;
    }

    [data-theme="light"] {
        --bg: var(--bg-light);
        --card: var(--card-light);
        --text: var(--text-light);
        --border: var(--border-light);
    }

    [data-theme="dark"] {
        --bg: var(--bg-dark);
        --card: var(--card-dark);
        --text: var(--text-dark);
        --border: var(--border-dark);
    }

    body {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        background-color: var(--bg);
        color: var(--text);
        margin: 0;
        padding: 0;
        transition: background 0.3s, color 0.3s;
    }

    .container {
        max-width: 700px;
        margin: 0 auto;
        padding: 16px;
    }

    header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        min-width: 0;
        margin-bottom: 16px;
        background: var(--card);
        padding: 12px 16px;
        border-radius: 12px;
        border: 1px solid var(--border);
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    h1 {
        font-size: 18px;
        margin: 0;
        font-weight: 700;
    }

    .app-heading {
        flex: 1 1 auto;
        min-width: 0;
    }

    .app-heading h1 {
        overflow-wrap: anywhere;
    }

    .app-meta {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 4px;
    }

    .app-age {
        color: #718096;
        font-size: 12px;
        line-height: 1.3;
    }

    .app-caregiver {
        padding: 2px 7px;
        border-radius: 999px;
        background: var(--bg);
        color: var(--text);
        font-size: 11px;
        line-height: 1.3;
    }

    .header-btns {
        display: flex;
        gap: 8px;
        flex: 0 0 auto;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    button {
        background: var(--primary);
        color: white;
        border: none;
        padding: 8px 12px;
        border-radius: 8px;
        font-size: 14px;
        cursor: pointer;
        font-weight: 500;
        transition: background 0.2s;
    }

    button:hover {
        background: var(--primary-hover);
    }

    button.secondary {
        background: #718096;
    }
    button.secondary:hover {
        background: #4a5568;
    }

    /* --- Globalne banery aktywnych stoperów (Na górze) --- */
    .active-timer-banner {
        background: linear-gradient(135deg, #319795, #3182ce);
        color: white;
        padding: 12px 16px;
        border-radius: 12px;
        margin-bottom: 12px;
        display: none;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        font-weight: 600;
        animation: pulseBanner 2s infinite;
    }
    .active-timer-banner.sleep-banner {
        background: linear-gradient(135deg, #2b6cb0, #4c51bf);
    }

    @keyframes pulseBanner {
        0% { transform: scale(1); }
        50% { transform: scale(1.01); }
        100% { transform: scale(1); }
    }

    /* Zakładki nawigacyjne */
    .tabs {
        display: flex;
        gap: 4px;
        margin-bottom: 16px;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .tab-btn {
        background: var(--card);
        color: var(--text);
        border: 1px solid var(--border);
        flex: 1;
        padding: 10px 8px;
        text-align: center;
        border-radius: 8px;
        font-size: 13px;
        cursor: pointer;
        white-space: nowrap;
    }

    .tab-btn.active {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
        font-weight: 600;
    }

    .tab-content {
        display: none;
    }
    .tab-content.active {
        display: block;
    }

    /* Karty / Sekcje */
    .card {
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 16px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    .grid-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 12px;
    }

    .grid-buttons.three-cols {
        grid-template-columns: repeat(3, 1fr);
    }

    .action-card-btn {
        background: var(--bg);
        color: var(--text);
        border: 1px solid var(--border);
        padding: 14px 10px;
        border-radius: 10px;
        text-align: center;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        transition: all 0.2s;
    }

    .action-card-btn:hover {
        border-color: var(--primary);
        background: rgba(49, 151, 149, 0.05);
    }

    .action-card-btn span.icon {
        font-size: 22px;
    }

    /* Sekcje zwijalne grup */
    .group-section {
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 12px;
        overflow: hidden;
        background: var(--card);
    }

    .group-header {
        background: var(--bg);
        padding: 12px 16px;
        font-weight: 600;
        font-size: 14px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        user-select: none;
        border-bottom: 1px solid var(--border);
    }

    .group-body {
        padding: 12px;
        max-height: 400px;
        overflow-y: auto;
        transition: max-height 0.3s ease;
    }

    .group-body.collapsed {
        display: none;
    }

    .entry-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
        border-bottom: 1px solid var(--border);
        font-size: 13px;
    }

    .entry-heading {
        min-width: 0;
        flex: 1 1 40%;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    .entry-item:last-child {
        border-bottom: none;
    }

    .entry-time {
        color: #718096;
        font-size: 12px;
    }

    .action-btns {
        display: flex;
        min-width: 0;
        flex: 1 1 60%;
        gap: 6px;
        align-items: center;
        justify-content: flex-end;
    }

    .entry-time {
        min-width: 0;
        overflow-wrap: anywhere;
        line-height: 1.4;
    }

    .icon-btn {
        background: none;
        border: none;
        color: var(--text);
        cursor: pointer;
        font-size: 14px;
        padding: 4px;
    }

    /* Statusy / Badges */
    .badge-status {
        display: inline-block;
        padding: 2px 6px;
        border-radius: 4px;
        font-size: 11px;
        font-weight: 600;
    }
    .badge-ok { background: #c6f6d5; color: #22543d; }
    .badge-warn { background: #fed7d7; color: #742a2a; }
    .badge-caregiver { background: #e2e8f0; color: #4a5568; font-size: 10px; padding: 1px 5px; border-radius: 4px; margin-left: 4px; }

    /* Style okien modalnych */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    .modal-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        display: none;
        align-items: center;
        justify-content: center;
        z-index: 1000;
        padding: 16px;
    }

    .modal-card {
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 16px;
        width: 100%;
        max-width: 400px;
        padding: 20px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.2);
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-title {
        font-size: 16px;
        font-weight: 700;
        margin-bottom: 14px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-group label {
        display: block;
        font-size: 12px;
        font-weight: 600;
        margin-bottom: 4px;
        color: var(--text);
    }

    .form-control {
        width: 100%;
        padding: 10px;
        border: 1px solid var(--border);
        background: var(--bg);
        color: var(--text);
        border-radius: 8px;
        font-size: 14px;
        box-sizing: border-box;
    }

    /* Ekran logowania i konfiguracji */
    .auth-screen {
        position: fixed;
        inset: 0;
        background: var(--bg);
        display: none;
        align-items: center;
        justify-content: center;
        z-index: 2000;
        padding: 16px;
    }

    .auth-box {
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 16px;
        width: 100%;
        max-width: 380px;
        padding: 24px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        text-align: center;
    }

    /* Toast notifications */
    .toast {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        box-sizing: border-box;
        width: max-content;
        max-width: calc(100vw - 32px);
        background: #2d3748;
        color: white;
        padding: 10px 20px;
        border-radius: 12px;
        font-size: 13px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        z-index: 5000;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 12px;
    }
    .toast button {
        background: #e53e3e;
        padding: 4px 8px;
        font-size: 11px;
    }
    .empty-group { color: #718096; font-size: 13px; padding: 8px; }

    .status-summary-row {
        margin-bottom: 4px;
    }

    .status-summary-row:last-child { margin-bottom: 0; }

    .status-summary-row.is-muted { color: #718096; }

    .poop-warning-icon {
        color: var(--danger);
        font-size: 1.2em;
        font-weight: 800;
    }

    @media (max-width: 520px) {
        header {
            align-items: flex-start;
            padding: 10px;
        }

        .header-btns {
            max-width: 170px;
            gap: 4px;
        }

        .header-btns button {
            padding: 6px 8px !important;
        }

        .toast {
            bottom: calc(16px + env(safe-area-inset-bottom));
            padding: 10px 14px;
        }

        .entry-item {
            flex-direction: column;
            align-items: stretch;
            gap: 5px;
            padding: 10px 8px;
            font-size: 14px;
        }

        .entry-heading {
            flex: 0 0 auto;
            font-size: 14px;
            line-height: 1.45;
        }

        .action-btns {
            flex: 0 0 auto;
            width: 100%;
            justify-content: space-between;
            gap: 5px;
        }

        .entry-time {
            flex: 1 1 auto;
            font-size: 13px;
            line-height: 1.45;
            text-align: left;
        }

        .entry-item .icon-btn {
            display: inline-grid;
            flex: 0 0 32px;
            width: 32px;
            height: 32px;
            min-height: 32px;
            padding: 4px;
            place-items: center;
            font-size: 16px;
        }

        .badge-caregiver {
            font-size: 11px;
        }
    }

    body[data-style="dark"] { --bg: #0f1419; --card: #1a2230; --text: #f1f5f9; --border: #334155; }
