:root {
    --green: #345c9b;
    --green-2: #2a4c82;
    --gold: #ffc93d;
    --teal: #3c6c74;
    --bg: #f4f6f8;
    --ink: #1c2430;
    --card: #ffffff;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", "Avenir Next", sans-serif;
}

.town-bar {
    background: var(--gold);
    color: var(--ink);
    text-align: center;
    font-size: 0.92rem;
    font-weight: 650;
    padding: 0.45rem 1rem;
}

.site-header {
    background: #fff;
    color: var(--ink);
    border-bottom: 1px solid #e4e8ee;
}

.site-header .navbar-brand,
.site-header .nav-link,
.site-header .navbar-text {
    color: var(--ink);
}

.site-header .nav-link.active,
.site-header .nav-link:hover,
.site-header .nav-link:focus {
    color: var(--green);
}

.site-header .nav-link.active {
    text-decoration: underline;
    text-underline-offset: 0.28rem;
}

.site-header .navbar {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.site-header .navbar-nav {
    flex-wrap: nowrap;
}

@media (max-width: 1199.98px) {
    .site-header .navbar-nav {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.35rem 0 0.6rem;
    }

    .site-header .dropdown-menu {
        position: static;
        background: transparent;
        box-shadow: none;
        border: 0;
        padding: 0 0 0.15rem 0.85rem;
        min-width: 0;
    }

    .site-header .dropdown-item,
    .site-header .dropdown-item:hover,
    .site-header .dropdown-item:focus,
    .site-header .dropdown-item.active,
    .site-header .dropdown-item:active {
        color: var(--ink);
        background: transparent;
    }
}

.site-header .nav-link,
.site-header .dropdown-toggle {
    white-space: nowrap;
    font-size: 0.95rem;
    padding: 0.4rem 0.5rem;
}

.site-header button.nav-link {
    background: transparent;
    border: 0;
}

.site-header .dropdown-menu {
    border: 0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(28, 36, 32, 0.16);
    min-width: 11rem;
}

.site-header .dropdown-item {
    padding: 0.55rem 0.9rem;
}

.site-header .dropdown-item.active,
.site-header .dropdown-item:active {
    background: var(--green);
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.brand-lockup img {
    height: 54px;
    width: auto;
    object-fit: contain;
}

.brand-lockup small {
    display: block;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gold);
    font-size: 0.68rem;
}

.page {
    padding: 1.5rem 0 3rem;
}

.card {
    border: 0;
    box-shadow: 0 1px 2px rgba(28, 36, 32, 0.06);
}

.stat {
    background: var(--card);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    height: 100%;
}

.stat .label {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #5c6b63;
}

.stat .value {
    font-size: 1.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.btn-town {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.btn-town:hover,
.btn-town:focus {
    background: var(--green-2);
    border-color: var(--green-2);
    color: #fff;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background:
        linear-gradient(var(--gold), var(--gold)) top / 100% 42px no-repeat,
        var(--bg);
}

.login-card {
    width: min(440px, 100%);
    background: #fff;
    border-radius: 16px;
    padding: 2rem 1.75rem;
    box-shadow: 0 12px 40px rgba(27, 67, 50, 0.12);
}

.login-card img.logo {
    width: min(320px, 100%);
    height: auto;
    display: block;
    margin: 0 auto 0.35rem;
}

.person-select {
    max-width: 22rem;
}

.section-label {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #5c6b63;
    margin: 0.8rem 0 0.25rem;
}

.day-switch {
    display: none;
}

.schedule-board {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.person-row {
    display: grid;
    grid-template-columns: 9.5rem repeat(7, minmax(7.2rem, 1fr));
    gap: 0.35rem;
    align-items: start;
    background: #fff;
    border-radius: 12px;
    padding: 0.45rem;
}

.person-row .who {
    position: sticky;
    left: 0;
    background: #fff;
    font-weight: 650;
    padding-top: 0.35rem;
}

.cell-day {
    display: none;
    font-size: 0.75rem;
    color: #5c6b63;
    margin-bottom: 0.2rem;
}

.cell.is-today {
    background: #fff8e8;
    border-radius: 8px;
}

.group-row td {
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.78rem;
    color: #5c6b63;
    background: transparent;
    border: 0;
}

.day-card {
    background: #fff;
    border-radius: 12px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
}

.day-card header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;
}

.tag {
    display: inline-block;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    background: #e7eee9;
    margin-right: 0.25rem;
}

.tag.pending { background: #fde8e8; color: #842029; }
.tag.approved { background: #d8f3dc; color: #1b4332; }
.tag.denied { background: #ececec; color: #555; text-decoration: line-through; }

.badge-status {
    font-weight: 600;
}

.status-draft { background: #e9ecef; color: #333; }
.status-submitted { background: #fff3cd; color: #664d03; }
.status-returned { background: #f8d7da; color: #842029; }
.status-approved { background: #d8f3dc; color: #1b4332; }
.status-pending { background: #fff3cd; color: #664d03; }
.status-denied { background: #f8d7da; color: #842029; }

.admin-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.55rem;
}

.admin-links a {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-height: 4.4rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid #d5dde6;
    border-radius: 0.7rem;
    background: #fff;
    text-decoration: none;
    color: var(--ink);
    box-shadow: 0 6px 14px rgba(28, 36, 48, 0.04);
}

.admin-links a:hover {
    border-color: var(--green);
    background: #f7f9fc;
}

.admin-links strong {
    color: var(--green);
    font-size: 0.98rem;
}

.admin-links span {
    font-size: 0.78rem;
    color: #5c6770;
    line-height: 1.25;
}

.hours {
    font-variant-numeric: tabular-nums;
}

.form-control,
.form-select,
.form-control-sm,
.form-select-sm {
    font-size: 16px;
}

.navbar-toggler {
    min-height: 44px;
}

.navbar-toggler {
    min-width: 44px;
}

@media (max-width: 767.98px) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .page {
        padding-top: 1rem;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }

    .person-select {
        max-width: 100%;
    }

    .brand-lockup img {
        height: 42px;
    }

    .site-header .nav-link,
    .site-header .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .login-card {
        padding: 1.4rem 1rem;
    }

    .week-nav {
        width: 100%;
    }

    .week-nav .btn {
        flex: 1;
    }

    .day-switch {
        display: flex;
        gap: 0.35rem;
        overflow-x: auto;
        position: sticky;
        top: 0;
        z-index: 5;
        background: var(--bg);
        padding: 0.35rem 0 0.6rem;
    }

    .day-switch button {
        flex: 1 1 0;
        min-width: 0;
        min-height: 48px;
        padding: 0.2rem 0;
        border: 0;
        border-radius: 10px;
        background: #fff;
        color: var(--ink);
        line-height: 1.1;
    }

    .day-switch button span {
        display: block;
        font-size: 0.72rem;
        color: #5c6b63;
    }

    .day-switch button.active {
        background: var(--green);
        color: #fff;
    }

    .day-switch button.active span {
        color: #f3e6c4;
    }

    .person-row {
        grid-template-columns: 1fr;
    }

    .person-row .cell {
        display: none;
    }

    .person-row .cell.show-day {
        display: block;
    }

    .cell-day {
        display: block;
    }

    .action-bar {
        position: sticky;
        bottom: 0;
        z-index: 5;
        background: var(--bg);
        margin-top: 0.4rem;
        padding: 0.45rem 0 calc(0.45rem + env(safe-area-inset-bottom));
        box-shadow: 0 -8px 12px var(--bg);
    }

    .action-bar .btn {
        flex: 1 1 45%;
    }

    .day-card header {
        flex-wrap: wrap;
    }

    .stack-table thead {
        display: none;
    }

    .stack-table,
    .stack-table tbody,
    .stack-table tr,
    .stack-table td {
        display: block;
        width: 100%;
    }

    .stack-table tr {
        background: #fff;
        border-radius: 12px;
        margin-bottom: 0.7rem;
        padding: 0.35rem 0.85rem;
    }

    .stack-table td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        border: 0;
        padding: 0.4rem 0;
    }

    .stack-table td::before {
        content: attr(data-label);
        color: #5c6b63;
        font-size: 0.72rem;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

    .stack-table .group-row {
        background: transparent;
        padding: 0.2rem 0;
        margin-bottom: 0.2rem;
    }

    .stack-table .group-row td {
        display: block;
        padding: 0.35rem 0 0;
    }

    .stack-table .group-row td::before {
        content: none;
    }

    .table-responsive {
        overflow: visible;
    }
}

.schedule-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.week-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.week-nav .nav-short { display: none; }

.view-switch {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    background: #fff;
    border: 2px solid var(--green);
    border-radius: 0.7rem;
    overflow: hidden;
    position: sticky;
    top: 0.4rem;
    z-index: 20;
    box-shadow: 0 6px 18px rgba(28, 36, 48, 0.08);
}

.view-switch .view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.85rem;
    padding: 0.45rem 0.5rem;
    color: var(--green);
    background: #fff;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.92rem;
    border-right: 1px solid #c5d2e4;
}

.view-switch .view-btn:last-child { border-right: 0; }

.view-switch .view-btn.active {
    background: var(--green);
    color: #fff;
}

.shift-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.shift-chip {
    border: 0;
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    font-weight: 700;
    cursor: grab;
    min-height: 2.5rem;
}

.shift-chip.armed {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

.shift-chip.kind-regular { background: #e7eef8; color: #345c9b; }
.shift-chip.kind-custom { background: #e5f2f3; color: #3c6c74; }
.shift-chip.kind-training { background: #fff4d4; color: #8a6200; }
.shift-chip.kind-off { background: #eef1f4; color: #5c6770; }
.shift-chip.kind-vacation { background: #e5f6ec; color: #1f7a4d; }
.shift-chip.kind-sick { background: #fdecec; color: #9b2c2c; }
.shift-chip.kind-holiday { background: #f3eafa; color: #6b3fa0; }

.drop-cell {
    min-height: 2.75rem;
    border: 1px solid #d5dde6;
    border-radius: 0.55rem;
    padding: 0.4rem 0.55rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.05rem;
}

.drop-cell.over {
    outline: 2px solid var(--green);
    background: #eef3fa;
}

.drop-cell .chip {
    font-size: 0.9rem;
    font-weight: 750;
    line-height: 1.2;
}

.drop-cell .default-tag,
.mini.quiet {
    font-size: 0.7rem;
    color: #6b7280;
}

.drop-cell.kind-regular,
.drop-cell.kind-regular .chip,
.mini.kind-regular { color: #345c9b; }
.drop-cell.kind-custom,
.drop-cell.kind-custom .chip,
.mini.kind-custom { color: #3c6c74; }
.drop-cell.kind-training,
.drop-cell.kind-training .chip,
.mini.kind-training { color: #8a6200; }
.drop-cell.kind-off,
.drop-cell.kind-off .chip { color: #5c6770; background: #f4f6f8; }
.drop-cell.kind-vacation,
.drop-cell.kind-vacation .chip,
.mini.kind-vacation { color: #1f7a4d; }
.drop-cell.kind-sick,
.drop-cell.kind-sick .chip,
.mini.kind-sick { color: #9b2c2c; }
.drop-cell.kind-holiday,
.drop-cell.kind-holiday .chip,
.mini.kind-holiday { color: #6b3fa0; }

.drop-cell.kind-regular { background: #f3f7fc; }
.drop-cell.kind-custom { background: #eef7f8; }
.drop-cell.kind-training { background: #fff8e8; }
.drop-cell.kind-vacation { background: #eef9f2; }
.drop-cell.kind-sick { background: #fdf1f1; }
.drop-cell.kind-holiday { background: #f7f1fc; }

.staff-board {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.board-group {
    margin: 0.55rem 0 0;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--teal);
    font-weight: 800;
}

.person-card {
    background: #fff;
    border: 1px solid #d9e0e8;
    border-radius: 0.85rem;
    box-shadow: 0 8px 18px rgba(28, 36, 48, 0.05);
    overflow: hidden;
}

.person-name {
    margin: 0;
    padding: 0.7rem 0.85rem;
    background: linear-gradient(180deg, #f7fafc 0%, #eef3f7 100%);
    border-bottom: 1px solid #d9e0e8;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: 0.01em;
}

.person-days {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.55rem 0.7rem 0.7rem;
}

.day-slot {
    display: grid;
    grid-template-columns: 4.6rem 1fr;
    gap: 0.45rem;
    align-items: center;
}

.day-slot.is-today .day-label {
    color: var(--green);
}

.day-slot.is-today .drop-cell {
    box-shadow: inset 0 0 0 2px var(--green);
}

.day-label {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--ink);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.day-label span {
    font-weight: 650;
    color: #6b7280;
    text-transform: none;
}

.week-heads { display: none; }

.day-card {
    display: grid;
    grid-template-columns: minmax(8rem, 12rem) 1fr;
    align-items: stretch;
}

.day-card .person-name {
    border-bottom: 0;
    border-right: 1px solid #d9e0e8;
    display: flex;
    align-items: center;
}

.day-card .drop-cell {
    margin: 0.55rem;
    min-height: 3.2rem;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
}

.month-head {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--teal);
}

.month-cell {
    background: #fff;
    border: 1px solid #e2e6ea;
    border-radius: 0.45rem;
    min-height: 5.5rem;
    padding: 0.4rem 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    color: inherit;
    text-decoration: none;
}

.month-cell:hover {
    border-color: var(--green);
    background: #f7f9fc;
}

.month-cell.out { opacity: 0.4; }

.month-cell .date-num {
    font-size: 1.05rem;
    font-weight: 750;
    line-height: 1;
    color: var(--ink);
}

.month-cell .date-dow {
    display: none;
    font-size: 0.72rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.month-cell .month-summary {
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--green);
}

.month-cell .month-summary.quiet,
.month-cell .mini.quiet {
    color: #6b7280;
    font-weight: 500;
}

.month-cell .mini {
    display: block;
    font-size: 0.72rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

dialog#hours-dialog {
    border: 0;
    border-radius: 12px;
    padding: 1.25rem;
    max-width: 24rem;
}

dialog#hours-dialog::backdrop { background: rgba(28, 36, 48, 0.45); }

@media (max-width: 768px) {
    .week-nav {
        width: 100%;
    }

    .week-nav .btn {
        flex: 1 1 0;
        min-width: 0;
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }

    .week-nav .nav-full { display: none; }
    .week-nav .nav-short { display: inline; }

    .day-card {
        grid-template-columns: 1fr;
    }

    .day-card .person-name {
        border-right: 0;
        border-bottom: 1px solid #d9e0e8;
    }

    .month-grid {
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
    }
    .month-head, .month-cell.out { display: none; }
    .month-cell {
        min-height: 0;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.35rem 0.55rem;
        padding: 0.65rem 0.8rem;
    }
    .month-cell .date-num { font-size: 1.15rem; }
    .month-cell .date-dow { display: inline; }
    .month-cell .month-summary { margin-left: auto; }
    .month-cell .mini { flex: 1 1 100%; }
}

@media (min-width: 992px) {
    .week-heads {
        display: grid;
        grid-template-columns: 10rem repeat(7, minmax(0, 1fr));
        gap: 0.35rem;
        align-items: end;
        padding: 0 0.15rem;
        margin-bottom: 0.15rem;
    }

    .week-heads .head {
        display: flex;
        flex-direction: column;
        font-weight: 800;
        font-size: 0.82rem;
        color: var(--ink);
        text-decoration: none;
        text-align: center;
    }

    .week-heads .head.is-today,
    .month-cell.is-today {
        box-shadow: inset 0 0 0 2px var(--green);
        border-radius: 0.4rem;
        padding: 0.15rem;
    }

    .staff-board:not(.day-board) .person-card {
        display: grid;
        grid-template-columns: 10rem 1fr;
        align-items: stretch;
    }

    .staff-board:not(.day-board) .person-name {
        border-bottom: 0;
        border-right: 1px solid #d9e0e8;
        display: flex;
        align-items: center;
    }

    .staff-board:not(.day-board) .person-days {
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 0.35rem;
        padding: 0.55rem;
    }

    .staff-board:not(.day-board) .day-slot {
        display: block;
    }

    .staff-board:not(.day-board) .day-label {
        display: none;
    }
}

@media print {
    .site-header, .no-print { display: none !important; }
    body { background: #fff; }
}
