:root {
    color-scheme: light;
    --ink: #1d2528;
    --muted: #667579;
    --line: #d9e0df;
    --bg: #f5f7f4;
    --panel: #ffffff;
    --primary: #176b55;
    --primary-strong: #0f4d3d;
    --accent: #d38b32;
    --danger: #a83f39;
    --warn: #b46a14;
    --soft: #eef3ef;
    --shadow: 0 18px 45px rgba(29, 37, 40, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 282px minmax(0, 1fr);
    min-height: 100vh;
}

.guest-shell {
    display: block;
}

.main-shell {
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: #ffffff;
}

.sidebar-brand {
    display: block;
    padding: 22px 22px 18px;
    line-height: 1.15;
}

.side-nav {
    display: grid;
    gap: 18px;
    padding: 0 14px 24px;
}

.nav-group p {
    margin: 0 0 8px;
    padding: 0 8px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.nav-group a {
    display: block;
    border-radius: 6px;
    padding: 9px 10px;
    color: #4b595c;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
}

.nav-group a:hover,
.nav-group a.is-active {
    background: var(--soft);
    color: var(--primary-strong);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 68px;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    color: var(--primary-strong);
    font-size: 20px;
    font-weight: 800;
    text-decoration: none;
}

.top-search {
    flex: 1 1 260px;
    max-width: 420px;
}

.top-search input {
    min-height: 42px;
    background: #f8faf8;
}

.nav,
.quick-actions {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: nowrap;
    gap: 8px;
    min-width: 0;
    overflow-x: auto;
    padding: 6px 0;
}

.nav a,
.quick-actions a {
    flex: 0 0 auto;
    padding: 9px 10px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.nav a:hover,
.quick-actions a:hover {
    background: #edf2ef;
    color: var(--ink);
}

.quick-actions a:not(.logout-link) {
    background: #e7f0ec;
    color: var(--primary-strong);
}

.page {
    width: min(1260px, calc(100% - 32px));
    margin: 0 auto;
    padding: 36px 0 56px;
}

.login-shell {
    display: grid;
    min-height: calc(100vh - 160px);
    place-items: center;
}

.panel,
.module-card,
.task-item,
.empty-state {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-panel {
    width: min(420px, 100%);
    padding: 30px;
}

.login-heading,
.page-heading {
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(30px, 5vw, 44px);
    line-height: 1.05;
}

h2 {
    margin-bottom: 16px;
    font-size: 20px;
}

label {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd6d4;
    border-radius: 6px;
    padding: 12px 13px;
    color: var(--ink);
    font: inherit;
    background: #fff;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(23, 107, 85, 0.16);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    padding: 0 18px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.button.primary {
    width: 100%;
    background: var(--primary);
    color: #fff;
}

.button.primary:hover {
    background: var(--primary-strong);
}

.button.secondary {
    background: #e7f0ec;
    color: var(--primary-strong);
}

.button.secondary:hover {
    background: #d7e8e0;
}

.link-button {
    margin-top: 10px;
    text-decoration: none;
}

.muted {
    color: var(--muted);
    line-height: 1.5;
}

.alert {
    margin-bottom: 18px;
    border-radius: 6px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert-success {
    background: #e3f3e9;
    color: #155336;
}

.alert-error {
    background: #f8e3df;
    color: var(--danger);
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.module-card {
    display: flex;
    gap: 16px;
    min-height: 130px;
    padding: 22px;
    text-decoration: none;
}

.module-card.active:hover {
    border-color: rgba(23, 107, 85, 0.55);
    transform: translateY(-1px);
}

.all-modules {
    margin-top: 24px;
}

.dashboard-heading {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.module-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.module-header h1,
.dashboard-heading h1 {
    margin-bottom: 10px;
}

.header-actions,
.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.header-actions .button.primary,
.form-actions .button.primary {
    width: auto;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.metric-grid.compact {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
    min-height: 104px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.metric-card span,
.metric-card strong {
    display: block;
}

.metric-card span {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.metric-card strong {
    color: var(--ink);
    font-size: 30px;
}

.metric-card.good {
    border-color: #c8dfd3;
}

.metric-card.new {
    border-color: #d9d3bd;
}

.metric-card.risk {
    border-color: #e3c4bf;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: 18px;
    margin-bottom: 24px;
}

.content-panel,
.table-panel,
.calendar-panel {
    padding: 22px;
}

.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-title h2 {
    margin-bottom: 0;
}

.chart-placeholder {
    display: flex;
    align-items: end;
    gap: 12px;
    min-height: 190px;
    border-radius: 8px;
    padding: 18px;
    background: linear-gradient(#f8faf8 1px, transparent 1px) 0 0 / 100% 38px, #fbfcfb;
}

.chart-placeholder span {
    flex: 1;
    min-height: 24px;
    border-radius: 6px 6px 0 0;
    background: var(--primary);
}

.occupancy-row,
.source-list span {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-weight: 800;
}

.progress {
    height: 12px;
    margin: 10px 0 18px;
    overflow: hidden;
    border-radius: 999px;
    background: #e7ecea;
}

.progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.progress.accent span {
    background: var(--accent);
}

.source-list {
    display: grid;
    gap: 14px;
}

.module-form .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 16px;
}

.module-form label.wide {
    grid-column: 1 / -1;
}

.module-form .checkbox-line {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin-top: 22px;
}

.module-form .checkbox-line input {
    width: auto;
}

.record-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.record-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
}

.detail-grid div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.detail-grid dt {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.detail-grid dd {
    margin: 0;
    color: var(--ink);
    line-height: 1.45;
}

.side-stack {
    display: grid;
    gap: 14px;
}

.small-panel {
    padding: 18px;
}

.small-panel h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

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

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 14px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    white-space: nowrap;
}

.table-actions a {
    color: var(--primary-strong);
    font-weight: 900;
    text-decoration: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    background: #eef1f0;
    color: #526063;
    font-size: 12px;
    font-weight: 900;
}

.badge-good {
    background: #e1f1e8;
    color: #145237;
}

.badge-new {
    background: #fff2d8;
    color: #7a4a0d;
}

.badge-risk {
    background: #f8e0dc;
    color: var(--danger);
}

.legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.legend span {
    border-radius: 999px;
    padding: 8px 10px;
    color: #fff;
    font-size: 12px;
    font-weight: 900;
}

.legend .free,
.calendar-day.free {
    background: #dfeee6;
}

.legend .reserved,
.calendar-day.reserved {
    background: #e8d6b9;
}

.legend .busy,
.calendar-day.busy {
    background: #b9d1c8;
}

.legend .repair,
.calendar-day.repair {
    background: #e4bcb6;
}

.legend .free {
    color: #145237;
}

.legend .reserved {
    color: #75470b;
}

.legend .busy {
    color: #174b3d;
}

.legend .repair {
    color: #842f2a;
}

.calendar-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: 150px repeat(31, minmax(26px, 1fr));
    gap: 4px;
    overflow-x: auto;
}

.booking-occupancy-grid {
    display: grid;
    grid-template-columns: 150px repeat(var(--day-count), minmax(28px, 1fr));
    gap: 4px;
    overflow-x: auto;
}

.calendar-settings {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.calendar-unit-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #fbfcfb;
}

.switch-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    white-space: nowrap;
}

.switch-line input {
    width: auto;
}

.calendar-events-grid {
    margin-top: 18px;
}

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

.booking-event {
    display: grid;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcfb;
}

.booking-event span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.calendar-room,
.calendar-day {
    min-height: 34px;
    border-radius: 5px;
    padding: 8px;
    background: #f5f7f4;
    font-size: 12px;
    font-weight: 800;
}

.calendar-room {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
}

.calendar-room.head,
.calendar-day.head {
    background: var(--primary-strong);
    color: #fff;
}

.module-card.disabled {
    color: var(--muted);
    box-shadow: none;
    opacity: 0.76;
}

.module-icon {
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    background: #e7f0ec;
    color: var(--primary-strong);
    font-size: 22px;
    font-weight: 900;
}

.module-card strong,
.module-card small {
    display: block;
}

.module-card strong {
    margin-bottom: 8px;
    font-size: 19px;
}

.module-card small {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.4;
}

.task-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
}

.stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stats span {
    min-width: 116px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font-size: 14px;
}

.stats strong {
    display: block;
    color: var(--ink);
    font-size: 24px;
}

.task-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.task-form {
    position: sticky;
    top: 92px;
    padding: 22px;
}

.task-list {
    display: grid;
    gap: 14px;
}

.task-item {
    padding: 20px;
}

.task-item.is-completed {
    background: #fbfcfb;
}

.task-main {
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.task-main h2 {
    margin-bottom: 0;
}

.task-main time {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.task-status {
    margin-bottom: 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.is-completed .task-status {
    color: var(--muted);
}

.task-description {
    margin: 14px 0 0;
    color: #465456;
    line-height: 1.5;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.task-meta strong {
    color: var(--ink);
}

.complete-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.complete-form label {
    margin-bottom: 0;
}

.completion {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 16px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.completion a {
    color: var(--primary-strong);
    font-weight: 800;
}

.empty-state {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        max-height: 236px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar-brand {
        padding: 18px 18px 10px;
        font-size: 18px;
    }

    .side-nav {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        padding: 0 14px 14px;
    }

    .nav-group {
        flex: 0 0 170px;
    }

    .nav-group p {
        margin-bottom: 5px;
        font-size: 10px;
    }

    .nav-group a {
        padding: 7px 8px;
        font-size: 13px;
    }

    .topbar,
    .task-heading,
    .module-header,
    .complete-form {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        padding: 14px 16px;
        min-height: auto;
        justify-content: flex-start;
        gap: 14px;
    }

    .top-search {
        flex: 0 0 auto;
        max-width: none;
    }

    .page {
        width: min(100% - 24px, 1180px);
        padding-top: 24px;
    }

    .module-grid,
    .task-layout,
    .metric-grid,
    .dashboard-grid,
    .calendar-settings,
    .record-layout,
    .module-form .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
        width: 100%;
    }

    .quick-actions a {
        white-space: nowrap;
    }

    .task-form {
        position: static;
    }

    .complete-form {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 821px) and (max-width: 1180px) {
    .module-grid,
    .metric-grid,
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
