:root {
    --bg: #f5efe5;
    --panel: #fffaf4;
    --panel-strong: #ffffff;
    --ink: #19242b;
    --muted: #6d7479;
    --line: #e4d8cb;
    --accent: #176b5f;
    --accent-soft: #d9efe8;
    --ok: #1f9d55;
    --warning: #d9a404;
    --critical: #d64545;
    --shadow: 0 16px 36px rgba(40, 33, 24, 0.07);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(23, 107, 95, 0.13), transparent 30%),
        linear-gradient(180deg, #f7f2eb 0%, #f3ece2 100%);
    min-height: 100vh;
}

button,
input,
a {
    font: inherit;
}

.app-shell,
.auth-card {
    width: min(1040px, calc(100% - 28px));
    margin: 18px auto;
}

.inline-feedback {
    width: min(1040px, calc(100% - 28px));
    margin: 14px auto;
}

.topbar,
.calendar-panel,
.auth-card,
.admin-panel {
    background: rgba(255, 253, 249, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(222, 213, 202, 0.85);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.topbar {
    padding: 22px 24px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.eyebrow {
    margin: 0 0 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-family: "Newsreader", serif;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 0.96;
    margin-bottom: 8px;
}

.calendar-header h2,
.auth-card h1,
.detail-header h3 {
    font-family: "Newsreader", serif;
}

.subtitle {
    max-width: 560px;
    color: var(--muted);
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.5;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-card {
    display: grid;
    gap: 3px;
    padding: 11px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    font-size: 13px;
}

.secondary-button,
.nav-link,
.status-button,
.login-form button {
    border: 0;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

.secondary-button,
.nav-link {
    padding: 10px 14px;
    background: var(--panel-strong);
    color: var(--ink);
    border: 1px solid var(--line);
    font-size: 13px;
    font-weight: 600;
}

.secondary-button:hover,
.nav-link:hover,
.status-button:hover,
.login-form button:hover {
    transform: translateY(-1px);
}

.legend-and-actions {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    margin: 14px auto;
    width: min(1040px, calc(100% - 28px));
}

.office-switcher-wrap {
    width: min(1040px, calc(100% - 28px));
    margin: 14px auto 0;
}

.office-switcher {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.office-pill-link {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 253, 249, 0.85);
    color: var(--ink);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
}

.office-pill-link.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.legend,
.status-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.legend span,
.status-button {
    padding: 8px 12px;
    background: rgba(255, 253, 249, 0.85);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.dot.ok,
.office-pill.ok {
    background: rgba(31, 157, 85, 0.15);
    color: var(--ok);
}

.dot.warning,
.office-pill.warning {
    background: rgba(217, 164, 4, 0.18);
    color: #8f6700;
}

.dot.critical,
.office-pill.critical {
    background: rgba(214, 69, 69, 0.16);
    color: var(--critical);
}

.calendar-panel {
    padding: 18px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    width: min(1040px, calc(100% - 28px));
    margin: 0 auto 14px;
}

.admin-grid-wide {
    width: min(1040px, calc(100% - 28px));
}

.admin-panel {
    padding: 18px;
}

.admin-view-note {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
}

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

.admin-module-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 14px 0;
}

.admin-module-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
    background: rgba(255, 253, 249, 0.86);
    font-size: 13px;
    font-weight: 700;
}

.admin-module-link.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.admin-table th,
.admin-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
    font-size: 13px;
}

.admin-table th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.admin-table tr:last-child td {
    border-bottom: 0;
}

.admin-table input,
.admin-table select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 13px;
}

.admin-table select[multiple] {
    min-width: 200px;
}

.table-field-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.table-actions-cell {
    white-space: nowrap;
}

.table-actions-cell button,
.table-actions-cell .ghost-button {
    width: 100%;
}

.table-multi-select {
    min-height: 108px;
}

.admin-inline-link {
    display: inline-flex;
    width: auto;
    align-items: center;
    justify-content: center;
}

.admin-table-users {
    min-width: 980px;
}

.inline-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.muted-inline {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.office-mini-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fcfaf6;
    color: var(--ink);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.office-mini-pill span {
    font-size: 12px;
    line-height: 1;
}

.inline-add-form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.inline-add-form select {
    min-width: 130px;
}

.inline-add-form button {
    width: auto;
    white-space: nowrap;
}

.admin-thin-cell,
.admin-days-col {
    width: 1%;
    white-space: nowrap;
}

.compact-checkbox-list {
    gap: 6px;
}

.compact-pill {
    padding: 6px 8px;
    font-size: 12px;
}

.audit-meta-cell {
    max-width: 320px;
    white-space: pre-wrap;
    word-break: break-word;
}

.empty-cell {
    color: var(--muted);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-chip.is-enabled {
    background: rgba(31, 157, 85, 0.12);
    color: var(--ok);
}

.status-chip.is-disabled {
    background: rgba(214, 69, 69, 0.12);
    color: var(--critical);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.calendar-header h2 {
    font-size: clamp(24px, 3vw, 32px);
    margin-bottom: 0;
}

.weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.weekdays {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.day-card {
    min-height: 92px;
    padding: 11px;
    text-align: left;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 15px;
    display: grid;
    gap: 7px;
    align-content: start;
}

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

.day-card.is-muted {
    opacity: 0.52;
}

.day-card.is-today {
    outline: 2px solid rgba(15, 118, 110, 0.35);
}

.day-card.is-selected {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.day-number {
    font-size: 19px;
    font-weight: 800;
}

.office-pill,
.user-booking {
    display: inline-flex;
    width: fit-content;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.office-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    flex-shrink: 0;
    border: 1px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    cursor: pointer;
}

.office-count-badge.ok {
    background: var(--ok);
    color: #ffffff;
}

.office-count-badge.warning {
    background: var(--warning);
    color: #ffffff;
}

.office-count-badge.critical {
    background: var(--critical);
    color: #ffffff;
}

.user-booking {
    background: var(--accent-soft);
    color: #115e59;
}

.user-booking-text {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.user-booking-text.is-office {
    color: #166534;
}

.user-booking-text.is-not-office {
    color: #991b1b;
}

.helper-copy {
    margin-top: 12px;
    color: var(--muted);
    font-size: 12px;
}

.modal[hidden] {
    display: none;
}

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

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(31, 41, 51, 0.4);
}

.modal-dialog {
    position: relative;
    width: min(980px, calc(100% - 24px));
    margin: 30px auto;
    background: var(--panel-strong);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow);
    max-height: calc(100vh - 60px);
    overflow: auto;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: 0;
    font-size: 28px;
    cursor: pointer;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.detail-header h3 {
    font-size: 28px;
    margin-bottom: 0;
}

.people-list {
    display: grid;
    gap: 8px;
}

.admin-list {
    display: grid;
    gap: 10px;
}

.admin-form-grid,
.membership-form {
    display: grid;
    gap: 10px;
}

.people-list.compact {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.person-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fcfaf6;
}

.admin-row {
    align-items: center;
}

.admin-row-stacked {
    align-items: stretch;
}

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-actions form,
.admin-row form {
    margin: 0;
}

.person-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fcfaf6;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
}

.person-meta {
    color: var(--muted);
    font-size: 12px;
}

.day-person-row:hover {
    background: rgba(23, 107, 95, 0.06);
}

.day-people-table td {
    vertical-align: middle;
}

.day-people-table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
}

.day-people-table th:nth-child(1),
.day-people-table td:nth-child(1) {
    width: 58%;
}

.day-people-table th:nth-child(2),
.day-people-table td:nth-child(2) {
    width: 20%;
}

.day-people-table th:nth-child(3),
.day-people-table td:nth-child(3) {
    width: 22%;
}

.day-people-table td,
.day-people-table th {
    overflow-wrap: anywhere;
}

.report-panel {
    margin-top: 14px;
}

.report-toolbar {
    align-items: end;
}

.report-toolbar select {
    min-width: 220px;
}

.trend-wrap {
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 10px;
}

.trend-svg {
    width: 100%;
    height: auto;
    display: block;
}

.trend-axis {
    stroke: #cbd5e1;
    stroke-width: 1;
}

.trend-grid {
    stroke: #e2e8f0;
    stroke-width: 1;
    stroke-dasharray: 3 4;
}

.trend-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.trend-label {
    fill: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.trend-y-label {
    text-anchor: end;
}

.trend-x-label {
    font-size: 10px;
    font-weight: 600;
}

.report-table-wide {
    min-width: 980px;
}

.report-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.checkbox-wrap {
    display: grid;
    gap: 8px;
}

.checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fcfaf6;
    font-size: 13px;
    font-weight: 700;
}

.checkbox-pill input {
    margin: 0;
}

.field-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 4px;
}

.office-settings-row {
    align-items: flex-end;
}

.office-settings-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.office-settings-grid label {
    display: grid;
    gap: 6px;
}

.office-settings-grid input,
.admin-form-grid input {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 14px;
}

.empty-state-panel {
    text-align: center;
}

.auth-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.auth-card {
    max-width: 460px;
    padding: 26px;
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form input {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 14px;
}

.login-form button {
    padding: 12px 18px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.ghost-button {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    cursor: pointer;
    font-weight: 700;
}

.flash {
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-size: 13px;
}

.flash.info {
    background: rgba(15, 118, 110, 0.1);
}

.flash.success {
    background: rgba(31, 157, 85, 0.12);
}

.flash.warning {
    background: rgba(217, 164, 4, 0.14);
}

.flash.error {
    background: rgba(214, 69, 69, 0.12);
}

@media (max-width: 860px) {
    .topbar,
    .admin-grid,
    .legend-and-actions,
    .calendar-header,
    .detail-header,
    .person-row {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

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

    .office-settings-grid {
        grid-template-columns: 1fr 1fr;
    }

    .table-field-grid {
        grid-template-columns: 1fr;
    }

    .weekdays {
        display: none;
    }

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

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

    .office-settings-grid {
        grid-template-columns: 1fr;
    }

    .modal-dialog {
        padding: 14px;
        margin: 16px auto;
        max-height: calc(100vh - 32px);
    }

    .detail-header h3 {
        font-size: clamp(22px, 6vw, 28px);
    }

    .day-people-table th:nth-child(1),
    .day-people-table td:nth-child(1),
    .day-people-table th:nth-child(2),
    .day-people-table td:nth-child(2),
    .day-people-table th:nth-child(3),
    .day-people-table td:nth-child(3) {
        width: auto;
    }
}
