:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #eef2f7;
    color: #1d252c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(148, 163, 184, 0.14), transparent 28%),
        #eef2f7;
}

a {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
}

.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
    padding: 0 24px;
    border-bottom: 1px solid #d7dde2;
    background: #ffffff;
}

.top-bar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
}

.brand {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    font-weight: 700;
    text-decoration: none;
    color: #2d3748;
}

.brand-title {
    color: #1e293b;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.2;
}

.brand-subtitle {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
}

.primary-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #5a6b7c;
    font-size: 14px;
}

.primary-nav a {
    text-decoration: none;
}

.primary-nav a:hover {
    color: #2d3748;
}

.nav-user {
    color: #2d3748;
    font-weight: 600;
}

.main-content {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.25;
}

.page-header p {
    margin: 0;
    color: #5a6b7c;
}

.login-page {
    display: flex;
    justify-content: center;
}

.login-panel {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid #d7dde2;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(45, 55, 72, 0.12);
}

.login-subtitle {
    margin-top: 8px;
    color: #5a6b7c;
}

.login-error {
    margin: 16px 0;
    padding: 10px 12px;
    border: 1px solid #f0b7c3;
    border-radius: 8px;
    background: #fff4f6;
    color: #a42318;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #5a6b7c;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c8d1d8;
    border-radius: 8px;
    background: #ffffff;
    font-size: 14px;
}

.login-button {
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: #2d6b79;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.login-button:hover {
    background: #25576a;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 24px;
    margin-bottom: 16px;
}

.legend-card {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border: 1px solid #dbe3ea;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
    font-size: 0.78rem;
    font-weight: 700;
    color: #475569;
}

.legend-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.legend-chip {
    width: 14px;
    height: 14px;
    border-radius: 5px;
    border: 1px solid transparent;
}

.legend-empty {
    background: #f8fafc;
    border-color: #dbe3ea;
}

.legend-caution {
    background: #facc15;
    border-color: #eab308;
}

.legend-full {
    background: #ef4444;
    border-color: #dc2626;
}

.calendar-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.button-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid #c8d1d8;
    border-radius: 10px;
    background: #ffffff;
    color: #2d3748;
    font-weight: 600;
    text-decoration: none;
}

.button-link:hover {
    background: #eef3f5;
}

.panel {
    padding: 20px;
    border: 1px solid #d7dde2;
    border-radius: 22px;
    background: #ffffff;
    box-shadow: 0 16px 44px rgba(15, 23, 42, 0.07);
}

.panel h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

.panel ul {
    margin: 0;
    padding-left: 20px;
}

.panel li + li {
    margin-top: 6px;
}

.calendar-panel {
    overflow: hidden;
    padding: 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.month-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 92px;
    padding: 20px 22px;
    background: #1e293b;
    color: #ffffff;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

.month-title {
    margin: 0;
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    font-size: clamp(1.3rem, 2vw, 1.6rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.month-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.month-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

.month-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
}

.month-btn-icon {
    width: 40px;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
}

.month-btn-today {
    padding-inline: 16px;
}

.calendar-weekdays {
    border-bottom: 1px solid #dbe3ea;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 800;
    text-align: center;
}

.weekday-label {
    padding: 12px 6px;
}

.weekday-sunday {
    color: #ef4444;
}

.weekday-saturday {
    color: #2563eb;
}

.calendar-days {
    border-left: 1px solid #e2e8f0;
    border-top: 1px solid #e2e8f0;
}

.calendar-day {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 170px;
    padding: 12px 10px 10px;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.calendar-day:hover {
    position: relative;
    z-index: 1;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
    transform: translateY(-1px);
}

.calendar-day-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.calendar-day-date {
    display: inline-flex;
}

.day-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.95rem;
}

.day-chips {
    display: grid;
    gap: 5px;
    align-content: start;
}

.slot-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 7px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.68rem;
    line-height: 1.2;
}

.slot-chip-label {
    font-weight: 800;
}

.slot-chip-value {
    font-weight: 700;
    white-space: nowrap;
}

.slot-chip--empty {
    background: #f8fafc;
    border-color: #dbe3ea;
    color: #94a3b8;
}

.slot-chip--open {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

.slot-chip--caution {
    background: #facc15;
    border-color: #eab308;
    color: #1f2937;
}

.slot-chip--full {
    background: #ef4444;
    border-color: #dc2626;
    color: #ffffff;
}

.slot-chip-noassign {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

.outside-month {
    background: #f7f9fc;
    color: #94a3b8;
}

.outside-month .day-number {
    opacity: 0.72;
}

.outside-month .day-chips {
    opacity: 0.56;
}

.past-day {
    background: #f7f9fc;
    filter: saturate(0.82) brightness(0.985);
}

.past-day .day-chips {
    opacity: 0.66;
}

.today .day-number {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.day-panel {
    padding: 0;
    overflow: hidden;
}

.day-panel-invalid {
    padding: 24px;
}

.detail-panel {
    padding: 0;
    overflow: hidden;
}

.detail-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    padding: 16px 20px;
    background: #1e293b;
    color: #ffffff;
}

.detail-back-link {
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
}

.detail-back-link:hover {
    color: #cbd5e1;
}

.detail-title {
    margin: 0;
    flex: 1;
    font-size: 1.1rem;
    font-weight: 800;
    text-align: center;
}

.detail-save-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 24px;
    border: 0;
    border-radius: 14px;
    background: #2563eb;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.2);
}

.detail-save-button:hover {
    background: #1d4ed8;
}

.detail-save-button:disabled,
.login-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.detail-banner-wrap {
    padding: 20px 24px 0;
}

.detail-body {
    padding: 24px;
}

.detail-slot-section + .detail-slot-section {
    margin-top: 48px;
}

.detail-slot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.detail-slot-heading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail-slot-heading h3 {
    margin: 0;
    color: #64748b;
    font-size: 0.95rem;
    font-weight: 800;
}

.detail-slot-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    background: #334155;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 900;
}

.detail-slot-total {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    border: 2px solid transparent;
    font-size: 0.92rem;
    font-weight: 800;
}

.detail-slot-fields {
    display: grid;
    grid-template-columns: 140px minmax(180px, 1fr) minmax(140px, 180px);
    gap: 14px;
}

.detail-content-field {
    grid-column: 1 / -1;
}

.day-sections {
    display: grid;
    gap: 16px;
    padding: 24px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.day-section {
    padding: 18px;
    border: 1px solid #dbe3ea;
    border-radius: 18px;
    background: linear-gradient(180deg, #fbfdff 0%, #f7fafc 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.day-section h3 {
    margin: 2px 0 0;
    font-size: 1rem;
    color: #1e293b;
}

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

.day-slot-code {
    margin: 0;
    color: #2d6b79;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.section-content {
    min-height: 60px;
}

.empty-state {
    margin: 0;
    color: #a0aeb6;
}

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

.form-field:last-child {
    margin-bottom: 0;
}

.form-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: #5a6b7c;
}

.form-field input[type="number"],
.form-field textarea,
.text-input,
.text-area {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c8d1d8;
    border-radius: 8px;
    background: #ffffff;
    font-size: 14px;
    font-family: inherit;
}

.form-field textarea,
.text-area {
    min-height: 84px;
    resize: vertical;
}

.day-caption {
    margin: 0;
    color: #5a6b7c;
    max-width: 420px;
    text-align: right;
}

.detail-count-input {
    text-align: center;
    font-weight: 800;
}

.detail-note-input {
    min-height: 88px;
}

.detail-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 24px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.detail-cancel-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 24px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
    color: #475569;
    font-size: 1rem;
    font-weight: 800;
    text-decoration: none;
}

.detail-cancel-button:hover {
    background: #f1f5f9;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0;
    padding: 0 24px 24px;
}

.status-banner {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 600;
}

.success-banner {
    border: 1px solid #b7d9bf;
    background: #eef9f0;
    color: #255c2f;
}

.error-banner {
    border: 1px solid #f0b7c3;
    background: #fff4f6;
    color: #a42318;
}

.status-panel {
    margin-top: 20px;
}

.error-panel p {
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .top-bar {
        gap: 8px;
        padding: 12px 16px;
    }

    .top-bar-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .primary-nav {
        width: 100%;
        justify-content: flex-end;
    }

    .main-content {
        padding: 24px 16px;
    }

    .calendar-header {
        justify-content: stretch;
    }

    .legend-card {
        width: 100%;
    }

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

    .month-controls {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .detail-topbar,
    .detail-slot-header,
    .detail-slot-fields,
    .detail-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .detail-title {
        text-align: left;
    }

    .detail-save-button,
    .detail-cancel-button {
        width: 100%;
    }

    .detail-body,
    .detail-banner-wrap,
    .detail-footer {
        padding: 18px;
    }

    .detail-slot-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .calendar-day {
        min-height: 136px;
        padding: 8px;
    }

    .slot-chip {
        padding: 5px 6px;
        font-size: 0.66rem;
    }
}
