:root {
    --public-line: rgba(35, 56, 74, 0.12);
    --ink: #102033;
    --muted: #62748a;
    --line: #d9e2ec;
    --panel: #ffffff;
    --bg: #edf3f8;
    --brand: #0f6c5b;
    --brand-deep: #0a4d41;
    --shadow: 0 24px 60px rgba(16, 32, 51, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: SF Pro Display, SF Pro Icons, Helvetica Neue, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(169, 133, 67, 0.12), transparent 28%),
        radial-gradient(circle at bottom right, rgba(109, 125, 95, 0.08), transparent 30%),
        linear-gradient(180deg, #fbf8f2 0%, #f5f3ee 100%);
    min-height: 100vh;
}

body.modal-open {
    overflow: hidden;
}

a { color: inherit; text-decoration: none; }

.admin-layout {
    display: flex;
    min-height: 100vh;
    background: #f0f2f5;
}

.sidebar {
    min-height: 100vh;
    background: #1a2e4a;
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    color: #fff;
}

.admin-nav__eyebrow {
    text-transform: uppercase;
    letter-spacing: .14em;
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,.82);
}

.admin-nav__title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 6px;
}

.admin-nav__meta {
    color: rgba(255,255,255,.72);
    font-size: 13px;
    margin-top: 6px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    padding: 0.7rem 0 1rem;
}

.sidebar-link {
    color: rgba(255,255,255,.86);
    padding: .7rem 1rem;
    border-radius: .6rem;
    margin: 0.1rem .5rem;
    font-size: .94rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.sidebar-link__external {
    flex-shrink: 0;
    font-size: .86rem;
    color: rgba(255,255,255,.72);
}

.sidebar-footer {
    margin-top: auto;
    padding: 0.85rem 0 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
}

.sidebar-section {
    margin: .65rem .85rem .35rem;
    padding: .7rem .6rem 0;
    border-top: 1px solid rgba(255,255,255,.12);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .13em;
    color: rgba(255,255,255,.5);
    font-weight: 700;
}

.main-content {
    flex: 1;
    min-height: 100vh;
    min-width: 0;
}

.page-header {
    background: #fff;
    border-bottom: 1px solid #e3e6ea;
    padding: .95rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.page-header__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1b2b3d;
}

.page-header__user {
    color: #5f6f80;
    font-size: .92rem;
}

.content-area {
    padding: 1.5rem;
}

.page-hero,
.auth-card,
.admin-card,
.metric-card {
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--public-line);
    border-radius: 1.4rem;
    box-shadow: 0 18px 45px rgba(35, 56, 74, 0.07);
}

.page-hero,
.auth-card,
.admin-card {
    padding: 1.5rem;
}

.page-kicker {
    display: inline-flex;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    font-weight: 700;
    color: #a98543;
}

.page-hero h2,
.auth-card h1 {
    font-size: 2rem;
    letter-spacing: -0.04em;
    margin: 0.5rem 0 1rem;
}

.page-hero p,
.text-muted {
    color: var(--muted);
    line-height: 1.6;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.metric-card {
    padding: 1.35rem 1rem;
    text-align: center;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1f4f86;
    line-height: 1;
}

.metric-label {
    color: #6b7785;
    font-size: .82rem;
    margin-top: .45rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .85fr);
    gap: 1.5rem;
}

.admin-stack {
    display: grid;
    gap: 1.5rem;
}

.admin-card__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-card__header h2,
.admin-card__header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.admin-card__meta {
    color: #7b8794;
    font-size: .8rem;
}

.mass-group-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.mass-card {
    border: 1px solid #e3e6ea;
    border-radius: 1rem;
    padding: 1rem;
    background: #fbfcfe;
}

.mass-card__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: .9rem;
}

.mass-card__header h3 {
    margin: 0 0 .2rem;
    font-size: 1rem;
}

.weekend-start-hero {
    margin-bottom: 1.25rem;
}

.weekend-start-card {
    margin-bottom: 1.5rem;
}

.weekend-start-form {
    display: grid;
    gap: 1.2rem;
}

.weekend-start-grid,
.weekend-special-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.weekend-special-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.weekend-readings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.field-block {
    display: grid;
    gap: .45rem;
}

.field-label {
    font-size: .82rem;
    font-weight: 700;
    color: #31465d;
}

.field-input {
    width: 100%;
    min-height: 46px;
    border-radius: .9rem;
    border: 1px solid #d6dee8;
    background: #fbfcfd;
    color: #13263a;
    padding: .78rem .95rem;
    font-size: .94rem;
}

button.field-input {
    text-align: left;
    cursor: pointer;
}

button.field-input[disabled] {
    cursor: default;
    color: #7f8da0;
}

.field-input:focus {
    outline: 0;
    border-color: #6986a8;
    box-shadow: 0 0 0 4px rgba(105, 134, 168, 0.12);
}

.weekend-toggle-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.weekend-lookup-row {
    display: flex;
    align-items: center;
    gap: .9rem;
    flex-wrap: wrap;
}

.lookup-status {
    color: #64758a;
    font-size: .9rem;
}

.toggle-card {
    display: flex;
    gap: .85rem;
    align-items: flex-start;
    padding: 1rem 1.05rem;
    border: 1px solid #dce3ec;
    border-radius: 1rem;
    background: #f8fafc;
}

.toggle-card input {
    margin-top: .2rem;
}

.toggle-card strong {
    display: block;
    font-size: .94rem;
    color: #182a3f;
}

.toggle-card small {
    display: block;
    margin-top: .3rem;
    color: #66788d;
    line-height: 1.5;
}

.weekend-action-row {
    display: flex;
    gap: .85rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 46px;
    padding: 0 1.15rem;
    border-radius: 999px;
    font-size: .92rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.btn-primary {
    background: #284a70;
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: #284a70;
    border-color: #cfd7e2;
}

.weekend-mini-list {
    display: grid;
    gap: .75rem;
}

.weekend-mini-item,
.weekend-note-box {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1rem;
    border-radius: .95rem;
    background: #f8fafc;
    border: 1px solid #e3e8ef;
}

.weekend-note-box {
    display: grid;
    gap: .45rem;
}

.weekend-calendar-card {
    margin-top: 1.5rem;
}

.liturgical-list {
    display: grid;
    gap: .75rem;
}

.liturgical-list__item {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    padding: .9rem 1rem;
    border: 1px solid #e3e8ef;
    border-radius: .95rem;
    background: #f8fafc;
}

.liturgical-list__date {
    font-size: .85rem;
    font-weight: 700;
    color: #3e556d;
}

.liturgical-list__content {
    display: grid;
    gap: .2rem;
}

.liturgical-list__content strong {
    font-size: .98rem;
    color: #13263a;
}

.liturgical-list__content span {
    color: #6a7c90;
    font-size: .76rem;
    letter-spacing: .08em;
}

.liturgical-list__empty {
    padding: 1rem;
    border: 1px dashed #d3dae5;
    border-radius: .95rem;
    color: #6b7c90;
    background: #fafbfd;
}

.reading-modal[hidden] {
    display: none;
}

.reading-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.reading-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 24, 39, 0.62);
}

.reading-modal__panel {
    position: relative;
    width: min(860px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    margin: 1rem auto;
    background: #fff;
    border-radius: 1.2rem;
    box-shadow: 0 30px 80px rgba(16, 32, 51, 0.24);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.reading-modal__header,
.reading-modal__footer {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid #e4e9f0;
}

.reading-modal__footer {
    border-bottom: 0;
    border-top: 1px solid #e4e9f0;
    display: flex;
    justify-content: flex-end;
}

.reading-modal__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.reading-modal__header h3 {
    margin: .35rem 0 .2rem;
    font-size: 1.4rem;
}

.reading-modal__citation {
    color: #64758a;
    font-size: .95rem;
}

.reading-modal__close {
    border: 1px solid #d6dee8;
    background: #f8fafc;
    color: #415364;
    border-radius: 999px;
    padding: .55rem .9rem;
    font-size: .86rem;
    font-weight: 700;
    cursor: pointer;
}

.reading-modal__body {
    padding: 1.2rem;
    overflow-y: auto;
    line-height: 1.7;
    color: #1f3145;
}

.reading-modal__body p {
    margin: 0 0 1rem;
}

@media (max-width: 1100px) {
    .weekend-start-grid,
    .weekend-special-grid,
    .weekend-readings-grid,
    .weekend-toggle-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 780px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .page-hero h2,
    .auth-card h1 {
        font-size: 1.6rem;
    }

    .weekend-action-row .btn {
        width: 100%;
    }

    .weekend-lookup-row .btn {
        width: 100%;
    }

    .liturgical-list__item {
        grid-template-columns: 1fr;
        gap: .35rem;
    }
}

.mass-card__count,
.skill-pill,
.role-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
}

.mass-card__count {
    min-width: 2rem;
    height: 2rem;
    background: #e7eef8;
    color: #1f4f86;
    font-weight: 700;
}

.roster-list {
    display: grid;
    gap: .65rem;
}

.roster-item {
    display: flex;
    justify-content: space-between;
    gap: .8rem;
    align-items: flex-start;
    padding: .8rem .9rem;
    border: 1px solid #e3e6ea;
    border-radius: .9rem;
    background: #fff;
}

.skill-pill {
    min-width: 2rem;
    height: 2rem;
    background: #eff8f5;
    color: var(--brand-deep);
    font-weight: 700;
}

.role-pills {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.role-pill {
    gap: .45rem;
    padding: .55rem .8rem;
    background: #eef3f8;
    color: #294560;
    font-size: .9rem;
}

.role-pill strong {
    color: #1f4f86;
}

.role-pill--inactive {
    background: #f1f1f1;
    color: #666;
}

.build-list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--muted);
    line-height: 1.7;
}

.table-wrap {
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    text-align: left;
    padding: .85rem .75rem;
    border-bottom: 1px solid #e3e6ea;
    vertical-align: top;
}

.song-table th:nth-child(2),
.song-table th:nth-child(3),
.song-table th:nth-child(4),
.song-table td:nth-child(2),
.song-table td:nth-child(3),
.song-table td:nth-child(4) {
    white-space: nowrap;
}

.record-details-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 .9rem;
    border-radius: 999px;
    border: 1px solid #cfd7e2;
    background: #fff;
    color: #284a70;
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
}

.record-details-panel[hidden] {
    display: none;
}

.record-details-panel {
    min-width: 620px;
    margin-top: .7rem;
}

.record-detail-lines {
    display: grid;
    gap: 0;
}

.record-detail-line {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
    column-gap: 1.15rem;
    color: #1f3145;
    font-size: .98rem;
    line-height: 1.45;
    padding: .8rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.record-detail-line:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.record-detail-label {
    font-weight: 700;
    color: #102033;
}

.record-detail-value {
    color: #1f3145;
    min-width: 0;
    word-break: break-word;
}

.inactive-row {
    background: #faf7f7;
    color: #666;
}

.inactive-row td {
    opacity: .9;
}

.empty-note {
    padding: .9rem 1rem;
    border-radius: .9rem;
    background: #f7fafc;
    color: var(--muted);
    border: 1px dashed #d3dde8;
}

.setup-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.setup-message {
    margin-top: 1rem;
    padding: 1rem 1.1rem;
    border-radius: 1rem;
    font-weight: 600;
}

.setup-message--success {
    background: #e5f6ef;
    color: #0c5a48;
}

.setup-message--error {
    background: #fdeaea;
    color: #982d2d;
}

.setup-actions {
    margin-top: 1.2rem;
}

.auth-form-grid {
    display: grid;
    gap: 1rem;
}

.auth-form-field {
    display: grid;
    gap: .35rem;
}

.auth-input {
    width: 100%;
    min-height: 42px;
    padding: .75rem .9rem;
    border: 1px solid #cfd7e2;
    border-radius: .85rem;
    background: #fff;
    color: #102033;
    font: inherit;
}

.staffing-toolbar {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}

.page-staffing .content-area {
    padding: 1rem;
}

.page-staffing .page-header {
    padding: .7rem 1rem;
}

.page-staffing .sidebar {
    width: 200px;
}

.planner-topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.planner-topbar h2 {
    margin: .35rem 0 0;
    font-size: 1.8rem;
    letter-spacing: -0.04em;
}

.planner-scroll {
    overflow-x: auto;
    padding-bottom: .5rem;
}

.planner-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(355px, 1fr));
    gap: 1rem;
    align-items: start;
    min-width: 1085px;
}

.planner-mass-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: .85rem;
    box-shadow: 0 8px 24px rgba(35, 56, 74, 0.06);
    padding: 1rem;
}

.planner-mass-head {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    align-items: flex-start;
    margin-bottom: .8rem;
}

.planner-mass-head h3 {
    margin: 0 0 .25rem;
    font-size: 1.45rem;
    letter-spacing: -0.03em;
}

.planner-rehearsal {
    color: #6c7a8c;
    font-size: .78rem;
}

.planner-mini-btn {
    border: 0;
    border-radius: .35rem;
    background: #f1f3f5;
    color: #667587;
    padding: .25rem .5rem;
    font-size: .65rem;
    line-height: 1.1;
    cursor: pointer;
}

.planner-slot-list,
.planner-vocal-list {
    display: grid;
    gap: .36rem;
}

.planner-vocal-list {
    margin-top: .45rem;
}

.planner-slot-row {
    display: grid;
    grid-template-columns: 76px 62px minmax(0, 1fr) auto;
    gap: .42rem;
    align-items: center;
    padding: .1rem 0;
}

.planner-slot-label strong {
    font-size: .82rem;
}

.planner-slot-role {
    color: #8a97a8;
    font-size: .62rem;
    white-space: nowrap;
}

.planner-slot-control {
    min-width: 0;
}

.planner-person-select {
    width: 100%;
    padding: .32rem .42rem;
    border: 1px solid #cdd5df;
    border-radius: .32rem;
    background: #fff;
    font-size: .72rem;
    min-width: 0;
}

.planner-slot-actions {
    display: flex;
    gap: .25rem;
    align-items: center;
    justify-content: flex-start;
}

.planner-slot-row--vocal {
    cursor: grab;
}

.planner-slot-row--vocal.is-dragging {
    opacity: .45;
}

.planner-slot-row--vocal:hover {
    background: #fafcfe;
    border-radius: .4rem;
}

.planner-drag-handle {
    cursor: grab;
}

.planner-slot-row--vocal .planner-slot-control,
.planner-slot-row[data-slot-type="fixed"] .planner-slot-control {
    max-width: 100%;
}

.btn,
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .85rem 1.25rem;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #274058 0%, #355772 100%);
    color: #fff;
    font-weight: 700;
}

@media (max-width: 1350px) {
    .stats-grid,
    .mass-group-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .admin-layout {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
    }

    .stats-grid,
    .mass-group-grid {
        grid-template-columns: 1fr;
    }

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

    .page-staffing .sidebar {
        width: 100%;
    }
}
