:root {
    --bg: #f4f0e8;
    --paper: #fffaf0;
    --ink: #202124;
    --muted: #6d665b;
    --line: #e3d8c8;
    --brand: #1f6f5b;
    --brand-dark: #155141;
    --accent: #d97941;
    --danger: #bb3e3e;
    --warn: #c58a1f;
    --ok: #2d7d46;
    --blue: #2f6f9f;
    --shadow: 0 18px 45px rgba(73, 55, 32, .12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    background:
        radial-gradient(circle at 8% 5%, rgba(217, 121, 65, .18), transparent 28rem),
        radial-gradient(circle at 92% 8%, rgba(31, 111, 91, .16), transparent 24rem),
        linear-gradient(135deg, #f7f1e5 0%, #efe7d8 100%);
    min-height: 100vh;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

.sidebar {
    background: #193c33;
    color: #f8f3e7;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 18px;
    letter-spacing: .04em;
}

.brand small {
    display: block;
    color: rgba(248, 243, 231, .7);
    font-size: 12px;
    font-weight: 400;
    margin-top: 4px;
}

.nav-section {
    color: rgba(248, 243, 231, .55);
    font-size: 12px;
    margin: 18px 10px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #f8f3e7;
    padding: 10px 12px;
    border-radius: 13px;
    margin-bottom: 4px;
    font-size: 14px;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 250, 240, .14);
    text-decoration: none;
}

.main {
    min-width: 0;
    padding: 20px 22px 78px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
}

.top-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

.card {
    background: rgba(255, 250, 240, .92);
    border: 1px solid rgba(227, 216, 200, .9);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.grid {
    display: grid;
    gap: 14px;
}

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

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

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

.metric {
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, .86), rgba(255, 247, 230, .76));
    border: 1px solid rgba(227, 216, 200, .9);
}

.metric b {
    display: block;
    font-size: 28px;
    margin-bottom: 5px;
}

.metric span {
    color: var(--muted);
    font-size: 13px;
}

.btn,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 13px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    font-size: 14px;
}

.btn:hover,
button:hover,
input[type="submit"]:hover {
    background: var(--brand-dark);
    color: #fff;
    text-decoration: none;
}

.btn.secondary {
    background: #fffaf0;
    color: var(--brand);
    border-color: var(--line);
}

.btn.secondary:hover {
    background: #f5ead7;
}

.btn.danger {
    background: var(--danger);
}

.btn.warn {
    background: var(--warn);
}

.btn.small {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
}

form.inline {
    display: inline;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    color: var(--muted);
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 11px;
    background: #fffdf8;
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
}

textarea {
    min-height: 88px;
    resize: vertical;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 240, .7);
}

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

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    color: var(--muted);
    font-weight: 700;
    background: rgba(246, 237, 222, .9);
}

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

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
}

.status-vacant,
.badge.ok {
    background: var(--ok);
}

.status-rented,
.badge.blue {
    background: var(--blue);
}

.status-repair,
.badge.warn {
    background: var(--warn);
}

.status-reserved,
.badge.accent {
    background: var(--accent);
}

.badge.danger {
    background: var(--danger);
}

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

.notice {
    border-radius: 16px;
    padding: 12px 14px;
    background: rgba(31, 111, 91, .1);
    border: 1px solid rgba(31, 111, 91, .25);
    margin-bottom: 14px;
}

.alert {
    border-radius: 16px;
    padding: 12px 14px;
    background: rgba(187, 62, 62, .1);
    border: 1px solid rgba(187, 62, 62, .25);
    margin-bottom: 14px;
}

.floor-block {
    margin-bottom: 18px;
}

.floor-title {
    font-weight: 800;
    margin-bottom: 8px;
    color: #4b4033;
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 10px;
}

.room-tile {
    border-radius: 18px;
    padding: 13px;
    min-height: 86px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.room-tile:after {
    content: "";
    position: absolute;
    width: 74px;
    height: 74px;
    right: -18px;
    bottom: -22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
}

.room-no {
    font-size: 22px;
    font-weight: 900;
}

.room-meta {
    font-size: 12px;
    margin-top: 6px;
    opacity: .88;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.login-card {
    width: min(460px, 100%);
    background: rgba(255, 250, 240, .94);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-card h1 {
    margin: 0 0 8px;
}

.login-card .sub {
    color: var(--muted);
    margin-bottom: 20px;
}

.bottom-nav {
    display: none;
}

.print-only {
    display: none;
}

.chart-bar {
    height: 12px;
    border-radius: 999px;
    background: rgba(31, 111, 91, .16);
    overflow: hidden;
}

.chart-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--brand), var(--accent));
}

.photo-thumb {
    width: 58px;
    height: 58px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--line);
}

.signature-pad {
    width: 100%;
    height: 160px;
    border: 1px dashed var(--brand);
    border-radius: 14px;
    background: #fffdf8;
    touch-action: none;
}

.contract-body {
    white-space: pre-wrap;
    line-height: 1.9;
    font-size: 16px;
}

.signature-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    margin-top: 40px;
}

.signature-image,
.signature-empty {
    width: 100%;
    height: 130px;
    border-bottom: 1px solid #333;
    object-fit: contain;
    background: #fff;
}

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

    .sidebar {
        display: none;
    }

    .main {
        padding: 14px 12px 84px;
    }

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

    .topbar h1 {
        font-size: 22px;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .form-grid,
    .signature-row {
        grid-template-columns: 1fr;
    }

    .card {
        border-radius: 18px;
        padding: 14px;
    }

    table {
        min-width: 680px;
    }

    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 2px;
        padding: 7px 7px 9px;
        background: rgba(25, 60, 51, .96);
        z-index: 20;
    }

    .bottom-nav a {
        color: #f8f3e7;
        text-align: center;
        font-size: 12px;
        border-radius: 12px;
        padding: 7px 4px;
    }

    .bottom-nav a.active {
        background: rgba(255, 250, 240, .14);
    }
}

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .top-actions,
    .bottom-nav,
    .no-print,
    .btn,
    button {
        display: none !important;
    }

    .app-shell,
    .main {
        display: block;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 0;
        padding: 0;
    }

    .print-only {
        display: block;
    }
}
