/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.5;
    padding: 2rem 1rem;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

.setup-container {
    max-width: 600px;
}

/* ── Typography ──────────────────────────────────────────── */
h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #333;
}

h3 {
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #666;
    margin-bottom: 2rem;
}

.hint {
    font-size: 0.85rem;
    color: #888;
    margin-top: 0.25rem;
}

.section-title {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-section {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.35rem;
}

input, select {
    padding: 0.6rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: #fafafa;
    transition: border-color 0.15s;
}

input:focus, select:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
    display: block;
    width: 100%;
    padding: 0.85rem;
    background: #0071e3;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 0.5rem;
}

.btn-primary:hover {
    background: #005bb5;
}

.btn-secondary {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #fff;
    color: #0071e3;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: #f0f0f0;
}

/* ── Legend ───────────────────────────────────────────────── */
.legend {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.legend-color {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.override-info {
    font-size: 0.85rem;
    color: #888;
    font-weight: 400;
}

.override-info a {
    color: #0071e3;
}

/* ── Parent Colors ───────────────────────────────────────── */
.parent-a-bg {
    background-color: #d1e8ff;
    color: #003d7a;
}

.parent-b-bg {
    background-color: #fce4d6;
    color: #7a3300;
}

/* ── Handoff Days (diagonal split) ────────────────────────── */
.handoff-a-to-b {
    background: linear-gradient(135deg, #d1e8ff 45%, #e0e0e0 50%, #fce4d6 55%) !important;
    color: #333;
}

.handoff-b-to-a {
    background: linear-gradient(135deg, #fce4d6 45%, #e0e0e0 50%, #d1e8ff 55%) !important;
    color: #333;
}

.handoff-sample {
    background: linear-gradient(135deg, #d1e8ff 45%, #e0e0e0 50%, #fce4d6 55%);
}

/* ── Calendar Grid ───────────────────────────────────────── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1.25rem;
}

.month {
    background: #fff;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.month table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.month th {
    font-size: 0.7rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    padding: 0.3rem 0;
    text-align: center;
}

.month td {
    text-align: center;
    padding: 0.4rem 0.2rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

.month td.day {
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.15s, transform 0.1s;
}

.month td.day:hover {
    opacity: 0.75;
    transform: scale(1.15);
}

.month td.empty,
.month td.outside {
    color: #ccc;
}

/* ── Ranges Table ────────────────────────────────────────── */
.table-wrapper {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

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

.ranges-table th {
    background: #fafafa;
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid #eee;
}

.ranges-table td {
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    border-bottom: 1px solid #f0f0f0;
}

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

.parent-a-row td:first-child {
    color: #003d7a;
    font-weight: 600;
}

.parent-b-row td:first-child {
    color: #7a3300;
    font-weight: 600;
}

/* ── Restart Day Indicator ───────────────────────────────── */
.restart-day {
    position: relative;
}

.restart-day::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    pointer-events: none;
}

.restart-a::after {
    background: #0057a8;
}

.restart-b::after {
    background: #c44b00;
}

/* ── Context Menu ─────────────────────────────────────────── */
.context-menu {
    display: none;
    position: absolute;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    min-width: 200px;
    padding: 4px 0;
    font-size: 0.875rem;
}

.context-menu-label {
    padding: 5px 12px 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #f0f0f0;
}

.context-menu-item {
    display: block;
    padding: 7px 12px;
    color: #333;
    text-decoration: none;
    cursor: pointer;
}

.context-menu-item:hover {
    background: #f5f5f7;
}

.context-menu-item--active {
    font-weight: 600;
    color: #0071e3;
}

.context-menu-item--active::before {
    content: '✓ ';
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
    body {
        background: #fff;
        padding: 0;
    }

    .no-print {
        display: none !important;
    }

    .month {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .calendar-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }

    .table-wrapper {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .parent-a-bg {
        background-color: #d1e8ff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .parent-b-bg {
        background-color: #fce4d6 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .handoff-a-to-b {
        background: linear-gradient(135deg, #d1e8ff 45%, #e0e0e0 50%, #fce4d6 55%) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .handoff-b-to-a {
        background: linear-gradient(135deg, #fce4d6 45%, #e0e0e0 50%, #d1e8ff 55%) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 500px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }
}
