:root {
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --holiday: #fca5a5;
    --holiday-text: #7f1d1d;
    --vacation: #86efac;
    --vacation-text: #14532d;
    --weekend: #e5e7eb;
    --work: #ffffff;
    --convenio-rest: #fdba74;
    --convenio-rest-text: #7c2d12;
    --convenio-half: #fde047;
    --convenio-half-text: #713f12;
    --border: #d1d5db;
    --radius: 0.5rem;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
}

.container {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1rem;
    height: 100vh;
    padding: 1rem;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}

header {
    text-align: left;
}

h1 {
    margin: 0 0 0.4rem;
    font-size: 1.25rem;
}

.subtitle {
    color: var(--muted);
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    line-height: 1.4;
}

.mode-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.mode-button {
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    border-radius: 9999px;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mode-button:hover {
    background: var(--bg);
}

.mode-button[data-mode="vacation"].active {
    background: var(--vacation);
    color: var(--vacation-text);
    border-color: var(--vacation);
}

.mode-button[data-mode="none"].active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem;
    text-align: left;
}

.card.highlight {
    border-color: var(--accent);
    background: var(--accent-light);
}

.label {
    display: block;
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 0.15rem;
}

.value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
}

.value.positive {
    color: #15803d;
}

.value.negative {
    color: #b91c1c;
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.box {
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 0.2rem;
    border: 1px solid var(--border);
}

.box.weekend { background: var(--weekend); }
.box.holiday { background: var(--holiday); }
.box.convenio-rest { background: var(--convenio-rest); }
.box.convenio-half { background: var(--convenio-half); }
.box.vacation { background: var(--vacation); }
.box.work { background: var(--work); }

.schedule {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
}

.schedule h3 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
}

.schedule ul {
    margin: 0;
    padding-left: 1rem;
    font-size: 0.75rem;
    color: var(--text);
}

.schedule li {
    margin-bottom: 0.35rem;
}

.schedule-hours {
    color: var(--muted);
}

.schedule-total {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
}

.calendar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0.5rem;
    height: 100%;
    overflow: hidden;
}

.month {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.month h2 {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
    text-align: center;
    text-transform: capitalize;
    flex-shrink: 0;
}

.days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.15rem;
    flex: 1;
    min-height: 0;
}

.day-name {
    text-align: center;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.day {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    background: var(--work);
    transition: transform 0.05s ease, box-shadow 0.05s ease;
    min-height: 0;
}

.day:hover:not(.empty):not(.weekend) {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.day.empty {
    background: transparent;
    cursor: default;
}

.day.weekend {
    background: var(--weekend);
    color: var(--muted);
    cursor: default;
}

.day.holiday {
    background: var(--holiday);
    color: var(--holiday-text);
}

.day.vacation {
    background: var(--vacation);
    color: var(--vacation-text);
}

.day.half-vacation {
    border: 2px solid var(--convenio-half);
}

.day.convenio-rest {
    background: var(--convenio-rest);
    color: var(--convenio-rest-text);
}

.day.convenio-half {
    background: var(--convenio-half);
    color: var(--convenio-half-text);
}

.day.today {
    border-color: var(--accent);
    font-weight: 700;
}

@media (max-width: 1024px) {
    html, body {
        overflow: auto;
    }

    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: visible;
        gap: 1rem;
    }

    header, .legend {
        flex: 1 1 200px;
    }

    .summary {
        flex: 2 1 300px;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .calendar {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, minmax(180px, 1fr));
        height: auto;
    }
}

@media (max-width: 640px) {
    .calendar {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
}

/* Login screen */
.hidden {
    display: none !important;
}

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background-color: var(--bg);
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.login-card h1 {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
}

.login-card p {
    color: var(--muted);
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

.google-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: #fff;
    color: #444;
    border: 1px solid #dadce0;
    border-radius: 0.4rem;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.google-button:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.login-error {
    color: #b91c1c;
    margin-top: 1rem;
    font-size: 0.85rem;
}

/* User header */
.user-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.user-picture {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.user-info span {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info span:first-child {
    font-weight: 600;
    color: var(--text);
}

.logout-button {
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--accent-light);
    border-radius: 9999px;
    background: var(--accent-light);
}

.logout-button:hover {
    background: var(--accent);
    color: #fff;
}
