:root {
    --blue-50: 
#eef8ff;
    --blue-100: 
#d9f0ff;
    --blue-300: 
#86cdf7;
    --blue-500: 
#2495d3;
    --blue-700: 
#12689c;
    --navy: 
#163247;
    --text: 
#294455;
    --muted: 
#728795;
    --border: 
#dceaf2;
    --background: 
#f5fbff;
    --white: 
#ffffff;
    --success: 
#16885d;
    --warning: 
#b9710c;
    --danger: 
#c84444;
    --shadow: 0 10px 30px 
rgba(37, 113, 158, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--background);
    font-family: Arial, Helvetica, sans-serif;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    padding: 24px 16px;
    color: 
white;
    background: linear-gradient(180deg, 
#1c80b9, 
#17668f);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 8px 34px;
    color: 
white;
    font-size: 22px;
    font-weight: 700;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: var(--blue-700);
    background: 
white;
    border-radius: 11px;
    font-size: 14px;
}

.navigation {
    display: grid;
    gap: 5px;
}

.navigation a {
    padding: 12px 14px;
    color: 
rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    text-decoration: none;
}

.navigation a:hover {
    color: 
white;
    background: 
rgba(255, 255, 255, 0.16);
}

.main-content {
    padding: 28px;
}

.topbar,
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--blue-500);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1, h2 {
    color: var(--navy);
}

h1 {
    margin: 0;
    font-size: clamp(25px, 3vw, 34px);
}

.user-button {
    padding: 10px 14px;
    color: var(--navy);
    background: 
white;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.stat-card,
.content-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.stat-card {
    display: grid;
    gap: 10px;
    padding: 22px;
}

.stat-card span {
    color: var(--muted);
    font-size: 14px;
}

.stat-card strong {
    color: var(--blue-700);
    font-size: 32px;
}

.stat-card-warning strong {
    color: var(--warning);
}

.stat-card-danger strong {
    color: var(--danger);
}

.content-card {
    padding: 24px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}

.button-primary {
    color: 
white;
    background: var(--blue-500);
}

.button-primary:hover {
    background: var(--blue-700);
}

.button-secondary {
    color: var(--blue-700);
    background: var(--blue-50);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group {
    display: grid;
    gap: 7px;
}

.form-group-full {
    grid-column: 1 / -1;
}

label {
    color: var(--navy);
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    color: var(--text);
    background: 
white;
    border: 1px solid var(--border);
    border-radius: 9px;
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid var(--blue-100);
    border-color: var(--blue-500);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.alert {
    padding: 14px 16px;
    margin-bottom: 20px;
    border-radius: 10px;
}

.alert-success {
    color: 
#0c6140;
    background: 
#e5f8ef;
}

.alert-error {
    color: 
#962d2d;
    background: 
#ffeded;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 13px;
}

.badge {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success {
    color: 
#126443;
    background: 
#ddf7eb;
}

.empty-state {
    padding: 34px 12px;
    text-align: center;
}

@media (max-width: 1050px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        padding: 14px;
    }

    .brand {
        margin-bottom: 15px;
    }

    .navigation {
        display: flex;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .navigation a {
        white-space: nowrap;
    }

    .main-content {
        padding: 18px;
    }

    .topbar,
    .page-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group-full {
        grid-column: auto;
    }

    .form-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }
}

.auth-body,
.error-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at top left, 
#dff4ff, 
transparent 45%),
        var(--background);
}

.login-page {
    width: 100%;
    max-width: 460px;
}

.login-card,
.error-card {
    padding: clamp(26px, 6vw, 42px);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.login-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
    color: var(--navy);
    font-size: 22px;
    font-weight: 700;
    text-decoration: none;
}

.login-description {
    margin-bottom: 26px;
    color: var(--muted);
    line-height: 1.6;
}

.login-form {
    margin-top: 20px;
}

.button-full {
    width: 100%;
}

.auth-alert {
    position: fixed;
    z-index: 10;
    top: 20px;
    width: min(460px, calc(100% - 40px));
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    color: var(--navy);
    font-size: 14px;
    font-weight: 700;
}

.logout-button {
    padding: 8px 10px;
    color: var(--blue-700);
    background: var(--blue-50);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.logout-button:hover {
    background: var(--blue-100);
}

.error-card {
    width: min(100%, 500px);
    text-align: center;
}

@media (max-width: 560px) {
    .user-menu {
        align-items: flex-start;
        flex-direction: column;
    }
}

.page-description {
    margin: 7px 0 0;
    color: var(--muted);
}

.back-link {
    color: var(--blue-700);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.detail-list,
.unit-summary {
    display: grid;
    gap: 0;
    margin: 0;
}

.detail-list div,
.unit-summary div {
    display: grid;
    grid-template-columns: minmax(130px, 40%) 1fr;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.detail-list div:last-child,
.unit-summary div:last-child {
    border-bottom: 0;
}

.detail-list dt,
.unit-summary dt {
    color: var(--muted);
    font-size: 14px;
}

.detail-list dd,
.unit-summary dd {
    margin: 0;
    color: var(--navy);
    font-weight: 700;
}

.property-description {
    margin: 0;
    line-height: 1.7;
}

.muted-text {
    color: var(--muted);
}

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
}

.section-header p {
    margin: 7px 0 0;
}

.units-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.unit-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: 
#fcfeff;
}

.unit-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
}

.unit-card h3 {
    margin: 10px 0 0;
    color: var(--navy);
    font-size: 19px;
}

.unit-card-actions {
    display: flex;
    gap: 15px;
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.unit-card-actions a {
    color: var(--blue-700);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.badge-info {
    color: 
#165f91;
    background: 
#e1f3ff;
}

.badge-neutral {
    color: 
#526c7b;
    background: 
#edf3f6;
}

.danger-zone {
    margin-top: 20px;
    border-color: 
#ffd1d1;
}

.danger-zone h2 {
    color: var(--danger);
}

.button-danger {
    color: 
white;
    background: var(--danger);
}

.button-danger:hover {
    background: 
#a93232;
}

@media (max-width: 850px) {
    .detail-grid,
    .units-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .section-header,
    .button-group {
        align-items: stretch;
        flex-direction: column;
    }

    .detail-list div,
    .unit-summary div {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 18px;
}

.room-card {
    display: grid;
    gap: 16px;
    padding: 20px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.room-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.room-card-header h3,
.room-card-header p {
    margin: 0;
}

.room-card-header p,
.room-description {
    margin-top: 4px;
    color: var(--muted);
}

.equipment-list {
    display: grid;
    gap: 10px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.equipment-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    background: 
#f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.equipment-list li > div {
    display: grid;
    gap: 3px;
}

.equipment-list small {
    color: var(--muted);
}

.equipment-list .is-archived {
    opacity: 0.55;
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr 1fr 80px;
    gap: 10px;
    padding-top: 6px;
}

.inline-form select,
.inline-form .button {
    grid-column: span 1;
}

.button-link-danger {
    padding: 0;
    color: 
#b91c1c;
    background: 
transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
}

.button-link-danger:hover {
    color: 
#7f1d1d;
    text-decoration: underline;
}

@media (max-width: 700px) {
    .inline-form {
        grid-template-columns: 1fr;
    }

    .equipment-list li {
        align-items: flex-start;
        flex-direction: column;
    }
}

.unit-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.unit-photo-card {
    overflow: hidden;
    border: 1px solid 
#e5e7eb;
    border-radius: 0.75rem;
    background: 
#ffffff;
}

.unit-photo-link {
    display: block;
    background: 
#f3f4f6;
}

.unit-photo-link img {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.unit-photo-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem;
}

.button-link {
    padding: 0;
    border: 0;
    color: 
#2563eb;
    background: 
transparent;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.button-link:hover {
    color: 
#1d4ed8;
}

.unit-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.unit-list-card {
    overflow: hidden;
    border: 1px solid 
#e5e7eb;
    border-radius: 0.75rem;
    background: 
#fff;
    box-shadow: 0 1px 2px 
rgba(0, 0, 0, 0.04);
}

.unit-list-card-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 190px;
    overflow: hidden;
    color: 
#6b7280;
    background: 
#f3f4f6;
}

.unit-list-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.unit-list-card-image:hover img {
    transform: scale(1.03);
}

.unit-list-card-placeholder {
    font-size: 0.9rem;
}

.unit-list-card-content {
    padding: 1rem;
}

.unit-list-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.unit-list-card-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.unit-list-card-header h2 a {
    color: inherit;
    text-decoration: none;
}

.unit-list-card-header h2 a:hover {
    text-decoration: underline;
}

.unit-list-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
}

.unit-list-meta div {
    min-width: 0;
}

.unit-list-meta dt {
    color: 
#6b7280;
    font-size: 0.75rem;
}

.unit-list-meta dd {
    margin: 0.15rem 0 0;
    font-weight: 600;
    font-size: 0.9rem;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid 
#e5e7eb;
    border-radius: 0.75rem;
    background: 
#fff;
}

.filter-form .form-group {
    min-width: min(100%, 320px);
    margin: 0;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: 
#fff;
}

.data-table th,
.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid 
#e5e7eb;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: 
#4b5563;
    background: 
#f9fafb;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.data-table tbody tr:hover {
    background: 
#f9fafb;
}

.table-actions {
    text-align: right;
    white-space: nowrap;
}

.button-small {
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
}

.form-section {
    margin-top: 1rem;
    padding-top: 1.25rem;
    border-top: 1px solid 
#e5e7eb;
}

.form-section h2 {
    margin: 0;
    font-size: 1.1rem;
}

.form-section p {
    margin: 0.35rem 0 0;
}

.page-actions-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.status-danger {
    color: 
#991b1b;
    background: 
#fee2e2;
}

.danger-zone {
    margin-top: 1.5rem;
    border-color: 
#fecaca;
}

.button-warning {
    color: 
#92400e;
    background: 
#fef3c7;
    border: 1px solid 
#fcd34d;
}

.button-danger {
    color: 
#fff;
    background: 
#dc2626;
    border: 1px solid 
#dc2626;
}

.button-danger:hover {
    background: 
#b91c1c;
    border-color: 
#b91c1c;
}

.detail-card-full {
    grid-column: 1 / -1;
}

.upload-form,
.note-form {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid 
#e5e7eb;
    border-radius: 0.75rem;
    background: 
#f9fafb;
}

.inline-form {
    display: inline;
}

.notes-list {
    display: grid;
    gap: 0.75rem;
}

.tenant-note {
    padding: 1rem;
    border: 1px solid 
#e5e7eb;
    border-radius: 0.75rem;
    background: 
#fff;
}

.tenant-note-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.tenant-note-content {
    line-height: 1.55;
}

.button-link-danger {
    padding: 0;
    color: 
#dc2626;
    border: 0;
    background: 
transparent;
    cursor: pointer;
    text-decoration: underline;
}

.button-link-danger:hover {
    color: 
#991b1b;
}

.template-variables-panel {
    margin-top: 2rem;
    padding: 1.25rem;
    border: 1px solid 
#d7dce3;
    border-radius: 8px;
    background: 
#f8fafc;
}

.template-variables-panel h2 {
    margin-top: 0;
}

.template-variables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem 1.5rem;
}

.template-variables-panel h3 {
    margin: 0 0 .5rem;
    font-size: 1rem;
}

.template-variables-panel ul {
    margin: 0;
    padding-left: 1.15rem;
}

.template-variables-panel li {
    margin-bottom: .35rem;
}

.template-variables-panel code {
    color: 
#9f1239;
    font-size: .9em;
}

.text-warning {
    color: 
#9a6700;
    font-size: 0.875rem;
}

.text-success {
    color: 
#18794e;
    font-size: 0.875rem;
}