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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: #22c55e;
    color: white;
    padding: 0.55rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
}

    header h1 {
        font-size: 1.25rem;
        margin: 0;
        white-space: nowrap;
        flex: 1 1 0;
    }

.header-spacer {
    flex: 1 1 0;
}

nav {
    display: flex;
    gap: 0.5rem;
    flex: 0 0 auto;
    justify-content: center;
    flex-wrap: wrap;
}

    nav button {
        flex: 0 0 auto;
        width: auto;
        padding: 0.45rem 1.15rem;
        border: none;
        background: rgba(255, 255, 255, 0.85);
        color: #374151;
        border-radius: 8px;
        font-weight: 600;
        font-size: 0.85rem;
        white-space: nowrap;
        cursor: pointer;
        border-bottom: 3px solid transparent;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
        transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    }

        nav button:hover {
            background: rgba(255, 255, 255, 0.95);
        }

        /* Per-view accent colors (match the card status colors) */
        nav button[data-view="today"] { border-bottom-color: #22c55e; }
        nav button[data-view="cut"]   { border-bottom-color: #f59e0b; }
        nav button[data-view="quote"] { border-bottom-color: #3b82f6; }
        nav button[data-view="all"]   { border-bottom-color: #16a34a; }
        nav button[data-view="calendar"] { border-bottom-color: #8b5cf6; }
        nav button.active {
            background: white;
            box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
            transform: translateY(1px);
        }

        nav button[data-view="today"].active { color: #15803d; }
        nav button[data-view="cut"].active   { color: #b45309; }
        nav button[data-view="quote"].active { color: #1e40af; }
        nav button[data-view="all"].active   { color: #166534; }
        nav button[data-view="calendar"].active { color: #7c3aed; }

/* Mobile: title on its own line, tabs on their own centered line, smaller so
   they all fit without overflowing off-screen. */
@media (max-width: 767px) {
    .header-spacer { display: none; }
    header h1 { flex: 1 1 100%; }
    nav {
        flex: 1 1 100%;
        justify-content: center;
        gap: 0.35rem;
    }
    nav button {
        padding: 0.35rem 0.55rem;
        font-size: 0.78rem;
    }
}

main {
    flex: 1;
    padding: 1rem;
}

/* Keep list/detail views readable (not edge-to-edge) on wide desktop screens.
   Full width on mobile since the screen is already narrow. */
.view-wrap,
.detail-page {
    max-width: 820px;
    margin: 0 auto;
}

/* Map + cards split layout (list views).
   On desktop the whole view fills the viewport under the sticky header: the map
   stays put (permanent) and only the cards column scrolls. */
.view-wrap.view-wrap-map {
    max-width: 1500px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 110px);
}
.map-toolbar {
    margin-bottom: 0.75rem;
    flex: 0 0 auto;
}
.route-btn {
    padding: 0.5rem 0.9rem;
    border: none;
    border-radius: 8px;
    background: #3b82f6;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}
.route-btn:hover {
    background: #2563eb;
}
.map-split {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    flex: 1 1 auto;
    min-height: 0;
}
.map-panel {
    flex: 0 0 60%;
}
.jobs-map {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: #e5e7eb;
    overflow: hidden;
}
.cards-col {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding-right: 4px;
}
/* Card highlighted when its map pin is hovered/clicked */
.job-card.card-hl {
    background: #cbd2da;
}
.map-msg {
    padding: 1rem;
    color: #555;
    font-size: 0.9rem;
    text-align: center;
}

/* Mobile: stack (map on top, fixed height), normal page scroll */
@media (max-width: 767px) {
    .view-wrap.view-wrap-map {
        height: auto;
        display: block;
    }
    .map-split {
        flex-direction: column;
        height: auto;
    }
    .map-panel {
        flex: none;
        width: 100%;
    }
    .jobs-map {
        height: 300px;
    }
    .cards-col {
        overflow: visible;
    }
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #888;
}

.job-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    border-left: 4px solid #22c55e;
}

    .job-card.status-ootab {
        border-left-color: #f59e0b;
    }

    .job-card.status-tehtud {
        border-left-color: #22c55e;
    }

    .job-card.status-motleb {
        border-left-color: #3b82f6;
    }

    .job-card h3 {
        font-size: 1.1rem;
        margin-bottom: 0.25rem;
    }

    .job-card .meta {
        color: #666;
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .job-card .actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.75rem;
    }

        .job-card .actions a, .job-card .actions button {
            flex: 1;
            padding: 0.5rem;
            border: 1px solid #ddd;
            background: white;
            border-radius: 8px;
            text-decoration: none;
            color: #1a1a1a;
            text-align: center;
            font-size: 0.9rem;
            cursor: pointer;
        }

            .job-card .actions a.maps {
                background: #3b82f6;
                color: white;
                border-color: #3b82f6;
            }

            .job-card .actions a.call {
                background: #22c55e;
                color: white;
                border-color: #22c55e;
            }

footer {
    background: white;
    padding: 0.75rem;
    border-top: 1px solid #eee;
    text-align: center;
}

    footer button {
        background: none;
        border: 1px solid #ddd;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        cursor: pointer;
    }

dialog {
    border: none;
    border-radius: 12px;
    padding: 1.5rem;
    width: 90%;
    max-width: 400px;
}

    dialog h2 {
        margin-bottom: 1rem;
    }

    dialog label {
        display: block;
        margin-bottom: 0.75rem;
    }

    dialog input {
        width: 100%;
        padding: 0.5rem;
        border: 1px solid #ddd;
        border-radius: 6px;
        margin-top: 0.25rem;
    }

.dialog-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

    .dialog-buttons button {
        flex: 1;
        padding: 0.5rem;
        border-radius: 8px;
        border: 1px solid #ddd;
        background: white;
        cursor: pointer;
    }

        .dialog-buttons button[value="save"] {
            background: #22c55e;
            color: white;
            border-color: #22c55e;
        }
/* Lisa nende ridade järel olemasolevasse style.css faili */

fieldset {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

    fieldset legend {
        padding: 0 0.5rem;
        font-weight: 600;
        font-size: 0.9rem;
    }

dialog select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 0.25rem;
    background: white;
}


/* === LISA NEED STYLE.CSS LÕPPU === */

.view-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #1a1a1a;
    font-weight: 600;
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

    .job-header h3 {
        flex: 1;
        font-size: 1.1rem;
    }

.job-date {
    font-size: 0.85rem;
    color: #555;
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
}

    .job-date.no-date {
        background: #fef3c7;
        color: #92400e;
    }

.status-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    background: #f3f4f6;
    color: #444;
}

.status-ootab-bg {
    background: #fef3c7;
    color: #92400e;
}

.status-tehtud-bg {
    background: #d1fae5;
    color: #065f46;
}

.status-motleb-bg {
    background: #dbeafe;
    color: #1e40af;
}

.status-kontakt-bg {
    background: #f3e8ff;
    color: #6b21a8;
}

.notes {
    font-style: italic;
    color: #666;
}

/* Status border colors (replaces old ones) */
.job-card.status-ootab {
    border-left-color: #f59e0b;
}

.job-card.status-tehtud {
    border-left-color: #22c55e;
}

.job-card.status-motleb {
    border-left-color: #3b82f6;
}

.job-card.status-kontakt {
    border-left-color: #a855f7;
}

.job-card.status-default {
    border-left-color: #9ca3af;
}

/* Keep the four nav buttons on a single line, each sized to its own text */
nav {
    flex-wrap: nowrap;
}

    nav button {
        flex: 0 0 auto;
        width: auto;
    }

/* Hint that views can be swiped (visible only on touch screens) */
.swipe-hint {
    flex-basis: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    letter-spacing: 0.03em;
}

@media (hover: hover) and (pointer: fine) {
    .swipe-hint {
        display: none;
    }
}

/* =============================================
   DETAIL PAGE — single client full info view
   ============================================= */

.detail-page {
    padding-bottom: 2rem;
}

.back-btn {
    display: inline-block;
    background: none;
    border: 1px solid #ddd;
    padding: 0.4rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 1rem;
    color: #1a1a1a;
    background: white;
}

    .back-btn:hover {
        background: #f3f4f6;
    }

.detail-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.detail-name-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

    .detail-name-row h2 {
        font-size: 1.3rem;
        flex: 1;
        min-width: 0;
        word-break: break-word;
    }

.detail-section {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

    .detail-section:last-of-type {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

.detail-section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
    margin-bottom: 0.6rem;
    font-weight: 600;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.4rem 0;
    gap: 0.5rem;
    font-size: 0.95rem;
    border-bottom: 1px solid #f9f9f9;
}

    .detail-row:last-child {
        border-bottom: none;
    }

.detail-label {
    color: #888;
    font-weight: 500;
    flex-shrink: 0;
    min-width: 5rem;
}

.detail-value {
    text-align: right;
    color: #1a1a1a;
    word-break: break-word;
    max-width: 65%;
}

.detail-notes {
    background: #f9fafb;
    padding: 0.75rem;
    border-radius: 8px;
    font-style: italic;
    color: #444;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.detail-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

    .detail-actions a, .detail-actions button {
        flex: 1;
        padding: 0.6rem 0.5rem;
        border: 1px solid #ddd;
        background: white;
        border-radius: 8px;
        text-decoration: none;
        color: #1a1a1a;
        text-align: center;
        font-size: 0.9rem;
        cursor: pointer;
        font-weight: 500;
    }

        .detail-actions a.maps {
            background: #3b82f6;
            color: white;
            border-color: #3b82f6;
        }

        .detail-actions a.call {
            background: #22c55e;
            color: white;
            border-color: #22c55e;
        }

        .detail-actions a.ghl-link {
            background: #7c3aed;
            color: white;
            border-color: #7c3aed;
        }

        .detail-actions button.reschedule-btn {
            background: #0ea5e9;
            color: white;
            border-color: #0ea5e9;
        }

        .detail-actions button.status-link-btn {
            background: #0d9488;
            color: white;
            border-color: #0d9488;
        }

.job-time-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.job-time-input {
    padding: 0.3rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
}
.job-time-clear {
    padding: 0.3rem 0.6rem;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #6b7280;
}
.job-time-clear:hover {
    background: #f3f4f6;
}

/* =============================================
   EDITABLE NOTES — textarea + save button
   ============================================= */

.notes-editor {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    background: #fff;
    margin-bottom: 0.5rem;
    transition: border-color 0.15s;
}

    .notes-editor:focus {
        outline: none;
        border-color: #22c55e;
        box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
    }

.save-notes-btn {
    padding: 0.45rem 1rem;
    border: none;
    background: #22c55e;
    color: white;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

    .save-notes-btn:hover {
        background: #16a34a;
    }

    .save-notes-btn:disabled {
        background: #86efac;
        cursor: not-allowed;
    }

.save-status {
    margin-left: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

    .save-status.success {
        color: #16a34a;
    }

    .save-status.error {
        color: #dc2626;
    }

/* =============================================
   GOOGLE DRIVE FOLDER SECTION
   ============================================= */

.no-data {
    color: #888;
    font-size: 0.9rem;
    font-style: italic;
    margin-bottom: 0.5rem;
}

.detail-value a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

    .detail-value a:hover {
        text-decoration: underline;
    }

/* Client name + unique ID subtitle */
.detail-subname {
    display: block;
    font-size: 0.85rem;
    font-weight: 400;
    color: #888;
    margin-top: 0.15rem;
}

/* Folder + upload button row */
.folder-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.upload-btn {
    padding: 0.45rem 1rem;
    border: 1px solid #3b82f6;
    background: white;
    color: #3b82f6;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

    .upload-btn:hover {
        background: #3b82f6;
        color: white;
    }

    .upload-btn:disabled {
        border-color: #93c5fd;
        color: #93c5fd;
        background: #eff6ff;
        cursor: not-allowed;
    }/* =============================================
TIMER SECTION — improved styles
   ============================================= */

.timer-section {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.timer-pending {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    margin-bottom: 0.6rem;
}

.timer-worker-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.timer-worker-label {
    font-size: 0.9rem;
    color: #555;
    font-weight: 500;
    margin-right: 0.25rem;
}

.worker-chip {
    padding: 0.35rem 0.7rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    color: #444;
}

    .worker-chip:hover {
        background: #f3f4f6;
    }

    .worker-chip.active {
        background: #22c55e;
        border-color: #22c55e;
        color: white;
    }

.timer-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* === IDLE buttons (not running) — grey background === */
.timer-btn-idle {
    flex: 1;
    padding: 0.65rem 0.5rem;
    border: 2px solid #d1d5db;
    background: #f9fafb;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    text-align: center;
    color: #374151;
}

    .timer-btn-idle:hover {
        background: #f3f4f6;
        border-color: #9ca3af;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }

    .timer-btn-idle:active {
        transform: scale(0.97);
    }

/* === RUNNING buttons (active) — RED with pulse === */
.timer-btn-running {
    flex: 1;
    padding: 0.65rem 0.5rem;
    border: 2px solid #dc2626;
    background: #fef2f2;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    color: #dc2626;
    animation: timer-pulse 1.5s ease-in-out infinite;
    transition: background 0.15s, border-color 0.15s;
}

    .timer-btn-running:hover {
        background: #fee2e2;
        border-color: #b91c1c;
    }

    .timer-btn-running:active {
        transform: scale(0.97);
    }

@keyframes timer-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.3);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(220, 38, 38, 0);
    }
}

/* Elapsed time display */
.timer-elapsed {
    display: block;
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    color: #dc2626;
    background: #fef2f2;
    padding: 0.5rem;
    border-radius: 10px;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
    border: 1px solid #fecaca;
}

/* =============================================
   CALENDAR VIEW
   ============================================= */
.cal-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: center;
}
.cal-nav-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: #1a1a1a;
}
.cal-nav-btn:hover {
    background: #f3f4f6;
}

/* App password gate */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: #f0fdf4;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 2rem 1.75rem;
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    text-align: center;
}
.login-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #15803d;
}
.login-input {
    padding: 0.75rem 0.9rem;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 1rem;
}
.login-btn {
    padding: 0.75rem;
    border: none;
    border-radius: 10px;
    background: #22c55e;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
}
.login-btn:hover { background: #16a34a; }
.login-btn:disabled { opacity: 0.6; cursor: default; }
.login-err {
    color: #dc2626;
    font-size: 0.85rem;
    min-height: 1em;
}

/* Precipitation radar modal */
.radar-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2vh 2vw;
}
.radar-box {
    background: #fff;
    border-radius: 12px;
    width: min(900px, 96vw);
    height: min(80vh, 720px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.radar-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid #eee;
}
.radar-title {
    font-weight: 700;
    font-size: 1rem;
}
.radar-official {
    color: #2563eb;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: auto;
}
.radar-official:hover {
    text-decoration: underline;
}
.radar-close {
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #6b7280;
}
.radar-close:hover {
    background: #fee2e2;
    color: #b91c1c;
}
.radar-frame {
    flex: 1;
    width: 100%;
    border: 0;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
}
.cal-header {
    background: #f3f4f6;
    padding: 0.5rem 0;
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #666;
}
.cal-day {
    background: white;
    min-height: 80px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    transition: background 0.15s;
    font-size: 0.8rem;
    overflow: hidden;
}
.cal-day-empty {
    background: #f9fafb;
    cursor: default;
}
.cal-day-today {
    background: #f0fdf4;
    border: 2px solid #22c55e;
}
.cal-day-num {
    font-size: 0.8rem;
    font-weight: 600;
    color: #444;
}
.cal-count {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap;
}
.cal-count-active {
    background: #fef3c7;
    color: #92400e;
}
.cal-count-done {
    background: #d1fae5;
    color: #065f46;
}

/* Keep the calendar from stretching edge-to-edge on wide desktops, but only
   use up half the leftover whitespace on each side (midpoint between 1100px and
   the full content width). */
.cal-wrap {
    max-width: calc((100% + 1100px) / 2);
    margin: 0 auto;
}

/* Calendar filter toggles */
.cal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0 0 0.75rem;
}
.cal-filter {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s;
}
.cal-filter.active {
    border-color: #f59e0b;
    background: #fef3c7;
    color: #92400e;
}
.cal-filter-done.active {
    border-color: #16a34a;
    background: #d1fae5;
    color: #065f46;
}
.cal-filter-hp.active {
    border-color: #2563eb;
    background: #dbeafe;
    color: #1e40af;
}
.cal-filter-loading {
    font-size: 0.8rem;
    color: #6b7280;
}
/* Töö Tehtud: one connected pill (Tehtud | Sel nädalal | Kõik) when on */
.cal-tehtud {
    display: inline-flex;
    align-items: stretch;
    border: 1.5px solid #16a34a;
    border-radius: 999px;
    overflow: hidden;
    font-size: 0.82rem;
    font-weight: 600;
    vertical-align: middle;
}
.cal-tehtud button {
    border: none;
    background: #fff;
    color: #166534;
    cursor: pointer;
    padding: 0.35rem 0.8rem;
    white-space: nowrap;
}
.cal-tehtud button + button {
    border-left: 1px solid #bbf7d0;
}
.cal-tehtud-toggle {
    background: #d1fae5;
}
.cal-tehtud-seg.active {
    background: #16a34a;
    color: #fff;
}

/* Collapsible map inside the mobile week view (stacked on top) */
.cal-map-panel {
    margin: 0 0 1rem;
}
.cal-map-panel #cal-map {
    width: 100%;
    height: 320px;
    border-radius: 12px;
    background: #e5e7eb;
    overflow: hidden;
}

/* Compact calendar header — chips left, nav centered, month/year right */
.cal-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.8rem;
    margin-bottom: 0.6rem;
}
.cal-topbar .cal-filters {
    flex: 1 1 0;
    margin: 0;
    justify-content: flex-start;
}
.cal-topbar .cal-nav {
    flex: 0 0 auto;
    margin: 0;
}
.cal-topbar .cal-title {
    flex: 1 1 0;
    margin: 0;
    font-size: 1.1rem;
    text-align: right;
}

/* Map stacked on top — used only at the very start of a month (no past weeks
   to overlay). Smaller so the month's first dates stay visible below. */
.cal-map-stack {
    margin-bottom: 0.6rem;
}
.cal-map-stack #cal-map {
    width: 100%;
    height: 54vh;
    border-radius: 12px;
    background: #e5e7eb;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

/* Desktop month view: the map overlays the past (empty) weeks at the top of the
   grid (top + height set in JS), so it doesn't push the dates down. */
.cal-grid-wrap {
    position: relative;
}
.cal-map-overlay {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 6;
    padding-bottom: 8px;
}
.cal-map-overlay #cal-map {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: #e5e7eb;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

/* Calendar card highlighted when its map pin is hovered/clicked */
.cal-card.card-hl {
    background: #cbd2da;
}

/* Continuous (scrolling) desktop calendar */
.cont-cal-head {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    position: sticky;
    top: 50px;
    z-index: 4;
    background: #e5e7eb;
}
.cont-cal-head .cal-header {
    background: #f3f4f6;
    padding: 0.4rem 0;
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #666;
}
.cont-cal-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #e5e7eb;
}
.cont-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-month-label {
    background: #eef0f3;
    font-weight: 700;
    font-size: 1rem;
    color: #1a1a1a;
    padding: 0.45rem 0.5rem 0.35rem;
    position: sticky;
    top: 84px;
    z-index: 3;
    text-transform: capitalize;
}
.cont-map {
    margin-bottom: 0.6rem;
}
.cont-map #cal-map {
    width: 100%;
    height: 46vh;
    border-radius: 12px;
    background: #e5e7eb;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

/* Weather panel — fixed to the left edge of the page, in the empty margin next
   to the (centered, normal-size) calendar. Shown only when there's room. */
.cal-wx-side {
    display: none;
}
@media (min-width: 1900px) {
    .cal-wx-side {
        display: block;
        position: fixed;
        left: 8px;
        top: 112px;
        width: calc((100vw - 1100px) / 4 - 12px);
        max-width: 240px;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 0.6rem 0.7rem;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
        z-index: 8;
    }
}
.wx-side-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}
.wx-side-sub {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}
.wx-row {
    display: grid;
    grid-template-columns: 46px 24px 34px 1fr auto;
    align-items: center;
    gap: 6px;
    padding: 4px 2px;
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.8rem;
}
.wx-row .t { color: #6b7280; }
.wx-row .em { font-size: 1.05rem; text-align: center; }
.wx-row .tp { font-weight: 600; }
.wx-row .wd { color: #9ca3af; font-size: 0.72rem; }
.wx-row .rn { color: #9ca3af; text-align: right; white-space: nowrap; }
.wx-row .rn.wet { color: #1d4ed8; font-weight: 600; }
.wx-row.is-wet { background: #eff6ff; }

@media (max-width: 767px) {
    .cal-layout { display: block; }
    .cal-wx-side { display: none; }
}

/* Day weather panel (legacy inline; unused) */
.wx-panel {
    margin: 0.4rem 0 1rem;
}
.wx-day-head {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    flex-wrap: wrap;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}
.wx-total.wet {
    color: #1d4ed8;
    font-weight: 600;
}
.wx-hours {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.wx-hour {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 44px;
    font-size: 0.72rem;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 6px 4px;
}
.wx-h {
    color: #6b7280;
}
.wx-emoji {
    font-size: 1.05rem;
}
.wx-temp {
    font-weight: 600;
}
.wx-rain {
    color: #9ca3af;
}
.wx-rain.wet {
    color: #1d4ed8;
    font-weight: 600;
}
.wx-note {
    color: #9ca3af;
    font-size: 0.8rem;
}
.wx-loading {
    color: #6b7280;
    font-size: 0.85rem;
}

/* Mobile week view — one row per day (Mon–Sun) */
.week-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.week-day {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.week-day-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 12px;
    background: #f3f4f6;
    border-bottom: 1px solid #eee;
}
.week-day-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1a1a1a;
}
.week-day-date {
    font-size: 0.85rem;
    color: #6b7280;
}
.week-day-today .week-day-head {
    background: #dcfce7;
}
.week-day-today {
    border-color: #22c55e;
}
.week-day-today .week-day-name {
    color: #065f46;
}
.week-day-jobs {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.week-day-empty {
    color: #c0c0c0;
    font-size: 0.9rem;
    padding: 2px 0;
    text-align: center;
}
/* Compact job cards inside the mobile week view (less vertical space) */
.week-day-jobs .job-card {
    margin: 0;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.week-day-jobs .job-header {
    margin-bottom: 0.25rem;
}
.week-day-jobs .job-card h3,
.week-day-jobs .job-header h3 {
    font-size: 0.9rem;
    margin-bottom: 0;
}
.week-day-jobs .job-date {
    font-size: 0.72rem;
    padding: 0.1rem 0.35rem;
}
.week-day-jobs .job-card .meta {
    font-size: 0.76rem;
    margin-bottom: 0.2rem;
}
.week-day-jobs .job-card .meta.notes {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.week-day-jobs .job-card .actions {
    gap: 0.35rem;
    margin-top: 0.4rem;
}
.week-day-jobs .job-card .actions a,
.week-day-jobs .job-card .actions button {
    padding: 0.35rem;
    font-size: 0.78rem;
}

/* Desktop drag-to-reschedule: rich Notion-style job cards inside day cells */
.cal-day-head {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
}
/* Rainy upcoming day (jobs may need rescheduling). */
.cal-day-rain {
    background: #eff6ff;
    box-shadow: inset 0 3px 0 #60a5fa;
}
.cal-day-rain.cal-day-today {
    background: #eaf6ff;
}
.cal-day-rain-heavy {
    background: #fef2f2;
    box-shadow: inset 0 3px 0 #ef4444;
}
.cal-day-rain .cal-day-head {
    justify-content: space-between;
}
.cal-day-rain-badge {
    font-size: 0.6rem;
    font-weight: 700;
    color: #1d4ed8;
    background: #dbeafe;
    border-radius: 6px;
    padding: 0 4px;
    white-space: nowrap;
    cursor: help;
}
.cal-day-rain-heavy .cal-day-rain-badge {
    color: #b91c1c;
    background: #fee2e2;
}
.cal-cards {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}
.cal-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #f59e0b;
    border-radius: 6px;
    padding: 4px 7px;
    font-size: 0.78rem;
    line-height: 1.2;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 2px;
    user-select: none;
}
.cal-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.cal-card:active {
    cursor: grabbing;
}
.cal-card-active {
    border-left-color: #f59e0b;
}
.cal-card-done {
    border-left-color: #16a34a;
}
.cal-card-hp {
    border-left-color: #2563eb;
}
/* Locked = date agreed with the customer (calendar-only visual). Keeps the
   stage's left-border colour; just tints the background green + a green edge. */
.cal-card-locked {
    background: #dcfce7;
    border-color: #86efac;
    box-shadow: inset 3px 0 0 rgba(22, 163, 74, 0.4), 0 1px 2px rgba(0, 0, 0, 0.06);
}
.cal-dragging {
    opacity: 0.4;
}
.cal-card-top-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
/* Multi-select checkbox: faint until hover, solid when selected. */
.cal-card-select {
    border: none;
    background: transparent;
    padding: 0;
    margin-right: 3px;
    font-size: 0.72rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    flex-shrink: 0;
    transition: opacity 0.12s;
}
.cal-card:hover .cal-card-select { opacity: 0.55; }
.cal-card-select.on { opacity: 1; }
.cal-card-selected {
    background: #eff6ff;
    box-shadow: inset 0 0 0 2px #2563eb, 0 1px 2px rgba(0, 0, 0, 0.06);
}
.cal-card-selected .cal-card-select { opacity: 1; }
/* Right-drag lasso rectangle. */
.cal-marquee {
    position: fixed;
    z-index: 1400;
    border: 1.5px solid #2563eb;
    background: rgba(37, 99, 235, 0.12);
    pointer-events: none;
}
/* Floating selection action bar. */
.cal-select-bar {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 1500;
    background: #1e3a8a;
    color: #fff;
    border-radius: 999px;
    padding: 0.55rem 0.75rem 0.55rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.cal-select-bar button {
    border: none;
    background: #fff;
    color: #1e3a8a;
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
    font-weight: 700;
    cursor: pointer;
}
/* Time button: shows 🕒 (faint) or the set time (solid). Opens a time popover. */
.cal-card-time-btn {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    opacity: 0.4;
    white-space: nowrap;
    transition: opacity 0.12s;
}
.cal-card:hover .cal-card-time-btn {
    opacity: 0.8;
}
.cal-card-time-btn.set {
    opacity: 1;
    color: #2563eb;
}
/* Floating time popover from a calendar card. */
.time-popover {
    position: fixed;
    z-index: 1000;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.time-popover-input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 0.95rem;
    width: 70px;
    text-align: center;
}
.time-popover-input.invalid,
.job-time-input.invalid {
    border-color: #dc2626;
    background: #fef2f2;
}
.time-popover .tp-h,
.time-popover .tp-m {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 4px;
    font-size: 0.95rem;
    cursor: pointer;
}
.time-popover .tp-colon {
    font-weight: 700;
    color: #6b7280;
}
.time-popover .tp-save {
    border: 1px solid #22c55e;
    background: #22c55e;
    color: #fff;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
}
.time-popover .tp-save:hover {
    background: #16a34a;
}
.time-popover-clear {
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    color: #6b7280;
    font-size: 0.8rem;
    line-height: 1;
}
.time-popover-clear:hover {
    background: #fee2e2;
    color: #b91c1c;
}
/* Lock toggle: faint when open, appears on card hover, solid when locked. */
.cal-card-lock {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 0.72rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.3;
    filter: grayscale(1);
    transition: opacity 0.12s, filter 0.12s;
}
.cal-card:hover .cal-card-lock {
    opacity: 0.75;
}
.cal-card-lock.locked {
    opacity: 1;
    filter: none;
}
.cal-card-top {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    align-items: baseline;
}
.cal-card-name {
    font-weight: 700;
    font-size: 0.8rem;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-card-time {
    color: #9ca3af;
    font-size: 0.68rem;
    flex-shrink: 0;
}
.cal-card-addr {
    color: #6b7280;
    font-size: 0.72rem;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.cal-card-addr:hover {
    text-decoration: underline;
}
.cal-card-price {
    font-weight: 600;
    font-size: 0.72rem;
    color: #065f46;
}
.cal-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}
.cal-tag {
    font-size: 0.66rem;
    font-weight: 600;
    padding: 0 7px;
    border-radius: 10px;
    white-space: nowrap;
    line-height: 1.45;
}
.cal-card-link {
    color: #3b82f6;
    text-decoration: none;
    font-size: 0.75rem;
}
.cal-card-link:hover {
    text-decoration: underline;
}
.cal-card-notes {
    color: #6b7280;
    font-size: 0.7rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cal-day.cal-drag-over {
    background: #dbeafe;
    outline: 2px dashed #3b82f6;
    outline-offset: -2px;
}
@media (min-width: 768px) {
    .cal-day {
        min-height: 140px;
        align-items: stretch;
    }
}

/* Reschedule status toast */
.cal-toast {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    text-align: center;
}
.cal-toast-saving {
    background: #1f2937;
}
.cal-toast-saved {
    background: #16a34a;
}
.cal-toast-failed {
    background: #dc2626;
}
.cal-legend {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #666;
    flex-wrap: wrap;
    align-items: center;
}
.cal-load-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid #3b82f6;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.cal-load-btn:hover {
    background: #bfdbfe;
}
.cal-load-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.cal-loaded {
    color: #16a34a;
    font-weight: 600;
}
.cal-error {
    color: #dc2626;
    font-weight: 600;
}
.cal-day-title {
    font-size: 1.1rem;
    margin: 1rem 0 0.5rem;
    color: #1a1a1a;
}
#cal-day-detail {
    margin-top: 1rem;
}
