* {
    box-sizing: border-box;
}

html,body {
    margin: 0;
    min-height: 100%;
    max-width: 100%;
    overflow-x: hidden;
    font-family: 'DM Sans',sans-serif;
    color: #15243f;
    background: #f4f6f8;
}

a {
    text-decoration: none;
    color: inherit;
}

.brand,.darkbrand {
    font-family: 'Playfair Display',serif;
    font-weight: 700;
    font-size: 1.35rem;
}

.brand {
    color: #fff;
}

.darkbrand {
    color: #fff;
}

.brand span,.darkbrand span {
    color: #5aad7f;
}

.btn {
    border: 0;
    border-radius: 9px;
    padding: .72rem 1rem;
    font: 600 .9rem 'DM Sans';
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.primary {
    background: #2d7a4f;
    color: #fff;
}

.ghost {
    background: rgba(255,255,255,.07);
    color: #fff;
    border: 1px solid rgba(255,255,255,.15);
}

.ghost-dark {
    background: #fff;
    color: #24344d;
    border: 1px solid #d8dee7;
}

.danger {
    background: #fff3f3;
    color: #a13b3b;
    border: 1px solid #f0d0d0;
}

.small {
    padding: .5rem .7rem;
    font-size: .75rem;
}

.landing {
    min-height: 100vh;
    background: #0f2044;
    color: #fff;
}

.topnav {
    height: 76px;
    padding: 0 5vw;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.nav-actions,.hero-actions {
    display: flex;
    gap: .65rem;
}

.hero {
    max-width: 1100px;
    margin: auto;
    padding: 11vh 5vw 12vh;
    text-align: center;
}

.eyebrow {
    font-size: .7rem;
    letter-spacing: .16em;
    font-weight: 700;
    color: #5aad7f;
}

.hero h1 {
    font: 700 clamp(2.7rem,6vw,5.3rem)/1.05 'Playfair Display';
    margin: 1.1rem auto;
    max-width: 900px;
}

.hero h1 em {
    color: #5aad7f;
    font-style: italic;
}

.hero p {
    max-width: 680px;
    margin: auto;
    color: rgba(255,255,255,.7);
    font-size: 1.08rem;
    line-height: 1.8;
}

.hero-actions {
    justify-content: center;
    margin: 2rem 0 4rem;
}

.feature-strip {
    display: grid;
    grid-template-columns: repeat(5,1fr);
    gap: .75rem;
}

.feature-strip div {
    padding: 1rem;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 12px;
    color: rgba(255,255,255,.72);
    font-size: .8rem;
}

.feature-strip span {
    display: block;
    margin-top: .4rem;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    background: #0f2044;
}

.auth-card {
    width: min(430px,100%);
    background: #fff;
    border-radius: 18px;
    padding: 2.2rem;
    box-shadow: 0 25px 70px rgba(0,0,0,.2);
}

.auth-card .darkbrand {
    color: #15243f;
    display: block;
    margin-bottom: 2rem;
}

.auth-card h1 {
    font: 700 2rem 'Playfair Display';
    margin: .2rem 0;
}

.muted {
    color: #718096;
}

.auth-card form {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.auth-card label {
    font-size: .82rem;
    font-weight: 600;
}

.auth-card input {
    width: 100%;
    margin-top: .4rem;
    padding: .8rem .85rem;
    border: 1px solid #d8dee7;
    border-radius: 9px;
    font: inherit;
}

.foot {
    text-align: center;
    font-size: .84rem;
    color: #718096;
}

.foot a {
    color: #2d7a4f;
    font-weight: 700;
}

.error {
    background: #fff0f0;
    color: #a33;
    padding: .7rem;
    border-radius: 8px;
    font-size: .82rem;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr;
}

.side {
    background: #0f2044;
    color: #fff;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.side nav {
    display: grid;
    gap: .35rem;
    margin-top: 2.5rem;
}

.side nav a {
    padding: .75rem .8rem;
    border-radius: 8px;
    color: #aebbd0;
}

.side nav a.active,.side nav a:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.sideuser {
    margin-top: auto;
    display: grid;
    gap: .2rem;
    font-size: .84rem;
}

.sideuser span {
    color: #91a2bd;
    font-size: .74rem;
}

.sideuser button {
    margin-top: .7rem;
    border: 0;
    background: none;
    color: #9fb0c8;
    padding: 0;
    cursor: pointer;
    text-align: left;
}

.nav-toggle {
    display: none;
}

.dash {
    padding: 2rem 3vw;
    max-width: 1500px;
    width: 100%;
    margin: auto;
}

.dashhead {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
}

.dashhead h1 {
    font: 700 2.1rem 'Playfair Display';
    margin: .35rem 0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.stats>div,.panel {
    background: #fff;
    border: 1px solid #e3e8ef;
    border-radius: 14px;
    box-shadow: 0 5px 20px rgba(20,35,61,.04);
}

.stats>div {
    padding: 1.2rem;
}

.stats span {
    display: block;
    color: #7c889b;
    font-size: .8rem;
}

.stats b {
    display: block;
    font-size: 1.9rem;
    margin-top: .3rem;
}

.panel {
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.panelhead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel h2 {
    font-size: 1rem;
    margin: 0;
}

.panelhead p {
    margin: .25rem 0 0;
    color: #8792a3;
    font-size: .78rem;
}

.twocol {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.row,.mrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 0;
    border-bottom: 1px solid #edf0f4;
}

.row:last-child,.mrow:last-child {
    border-bottom: 0;
}

.row b,.mrow strong {
    font-size: .88rem;
}

.row span,.mrow span {
    font-size: .76rem;
    color: #8290a2;
}

.mrow i {
    font-style: normal;
    font-size: .7rem;
    color: #657287;
    background: #eef2f7;
    border-radius: 999px;
    padding: .3rem .55rem;
    white-space: nowrap;
}

.empty {
    padding: 1.5rem;
    text-align: center;
    color: #8a95a5;
    font-size: .84rem;
}

.search-input {
    width: min(320px,100%);
    padding: .72rem .85rem;
    border: 1px solid #d8dee7;
    border-radius: 9px;
    font: inherit;
}

.property-card {
    display: grid;
    grid-template-columns: 1.6fr .7fr auto;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 0;
    border-bottom: 1px solid #edf0f4;
}

.property-card:last-child {
    border-bottom: 0;
}

.property-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.property-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: #eef6f1;
    color: #2d7a4f;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    flex: none;
}

.property-main h3 {
    margin: 0 0 .3rem;
    font-size: .98rem;
}

.property-main p {
    margin: .15rem 0;
    color: #7d899a;
    font-size: .78rem;
}

.property-meta {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    color: #718096;
    font-size: .75rem;
}

.property-meta strong {
    color: #15243f;
    font-size: .85rem;
}

.property-actions {
    display: flex;
    gap: .45rem;
    justify-content: flex-end;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(8,19,39,.55);
    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 1000;
}

.modal[hidden] {
    display: none;
}

.modal-card {
    width: min(720px,100%);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 30px 90px rgba(0,0,0,.25);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.2rem;
}

.modal-head h2 {
    margin: .25rem 0 0;
    font: 700 1.55rem 'Playfair Display';
}

.modal-close {
    border: 0;
    background: #f1f3f6;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 1.35rem;
    cursor: pointer;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid label {
    font-size: .78rem;
    font-weight: 600;
    color: #24344d;
}

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

.form-grid input,.form-grid select,.form-grid textarea {
    width: 100%;
    margin-top: .4rem;
    padding: .75rem .8rem;
    border: 1px solid #d8dee7;
    border-radius: 8px;
    font: inherit;
    background: #fff;
}

.form-grid textarea {
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid #edf0f4;
}

.panelhead-actions {
    display: flex;
    gap: .6rem;
}

.dashhead-actions {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
}

.recurring-active-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
}

.recurring-active-row input {
    width: auto;
}

.attach-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.4rem;
    padding-top: 1.1rem;
    border-top: 1px solid #edf0f4;
}

.attach-head h3 {
    margin: 0;
    font-size: .92rem;
}

.attach-upload-btn {
    cursor: pointer;
}

.attach-list {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(110px,1fr));
    gap: .6rem;
    margin-top: .9rem;
}

.attach-item {
    position: relative;
    border: 1px solid #e3e8ef;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attach-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attach-item .attach-file-icon {
    font-size: 1.8rem;
    color: #7d899a;
}

.attach-item .attach-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15,32,68,.75);
    color: #fff;
    font-size: .65rem;
    padding: .25rem .4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attach-item .attach-remove {
    position: absolute;
    top: .25rem;
    right: .25rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 0;
    background: rgba(15,32,68,.8);
    color: #fff;
    font-size: .85rem;
    cursor: pointer;
    line-height: 1;
}

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

    .side {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: .85rem 1rem;
        position: relative;
    }

    .side .darkbrand {
        font-size: 1.05rem;
        margin: 0;
    }

    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border: 0;
        border-radius: 8px;
        background: rgba(255,255,255,.08);
        color: #fff;
        cursor: pointer;
        flex-direction: column;
        gap: 4px;
    }

    .nav-toggle span {
        display: block;
        width: 18px;
        height: 2px;
        background: #fff;
        border-radius: 2px;
    }

    .side nav,
    .side .sideuser {
        display: none;
    }

    .side.nav-open {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .side.nav-open nav {
        display: flex;
        flex-direction: column;
        gap: .2rem;
        flex-basis: 100%;
        width: 100%;
        margin-top: 1rem;
    }

    .side.nav-open nav a {
        padding: .8rem .9rem;
        border-radius: 8px;
    }

    .side.nav-open .sideuser {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-basis: 100%;
        width: 100%;
        margin-top: .75rem;
        padding-top: .9rem;
        border-top: 1px solid rgba(255,255,255,.1);
    }

    .side.nav-open .sideuser span {
        display: none;
    }

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

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

    .dashhead {
        align-items: stretch;
        flex-direction: column;
    }

    .dashhead .btn {
        width: 100%;
        text-align: center;
    }

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

    .property-actions {
        justify-content: flex-start;
    }

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

    .form-grid label.full {
        grid-column: auto;
    }

    .mrow {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: .5rem .75rem;
    }

    .mrow > div {
        flex: 1 1 100%;
        min-width: 0;
    }

    .mrow .property-actions {
        flex: 1 1 100%;
        justify-content: flex-start;
    }

    .panelhead {
        flex-wrap: wrap;
        gap: .75rem;
    }

    .search-input {
        width: 100%;
    }

    .inspection-head-actions {
        flex-direction: column;
        width: 100%;
        gap: .5rem;
    }

    .inspection-item {
        grid-template-columns: 1fr;
    }

    .inspection-item-controls {
        width: 100%;
        justify-content: flex-start;
        margin-top: .5rem;
    }

    .rating-group {
        flex-wrap: wrap;
    }

}

@media(max-width:600px) {
    .hero-actions {
        flex-direction: column;
    }

    .feature-strip {
        grid-template-columns: 1fr 1fr;
    }

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

    .dash {
        padding: 1rem;
    }

    .topnav {
        padding: 0 1rem;
    }

    .panelhead {
        flex-wrap: wrap;
    }

    .modal {
        padding: .5rem;
    }

    .modal-card {
        padding: 1.1rem;
        border-radius: 14px;
    }

    .modal-head h2 {
        font-size: 1.3rem;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
        text-align: center;
    }

    .property-actions {
        flex-wrap: wrap;
    }

    .rating-btn {
        padding: .35rem .5rem;
        font-size: .72rem;
    }

    .inspection-item.expanded .inspection-item-notes {
        grid-template-columns: 1fr;
    }

}

.sitefoot {
    padding: 1.5rem 5vw;
    font-size: .75rem;
    text-align: center;
    color: #a0aec0;
    border-top: 1px solid #e3e8ef;
    background: #f4f6f8;
}

body.dark-page {
    background: #0f2044;
}

body.dark-page .sitefoot {
    color: rgba(255,255,255,.45);
    border-top: 1px solid rgba(255,255,255,.08);
    background: #0f2044;
}

/* --- Inspections --- */

.back-link {
    display: inline-block;
    margin-bottom: 1.2rem;
    font-size: .85rem;
    color: #5a6b85;
}

.inspection-head {
    align-items: center;
}

.inspection-head-actions {
    display: flex;
    gap: .6rem;
}

#inspection-status-banner {
    margin-bottom: 1.2rem;
}

.status-pill {
    display: inline-block;
    padding: .35rem .8rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
}

.status-pill.draft {
    background: #fff4e0;
    color: #9a6300;
}

.status-pill.completed {
    background: #e6f6ec;
    color: #1f7a45;
}

.inspection-section {
    background: #fff;
    border: 1px solid #e3e8ef;
    border-radius: 14px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.inspection-section h3 {
    margin: 0 0 .9rem;
    font-size: 1rem;
}

.inspection-item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: .75rem;
    padding: .8rem 0;
    border-bottom: 1px solid #edf0f4;
}

.inspection-item:last-child {
    border-bottom: 0;
}

.inspection-item-label {
    font-size: .9rem;
    font-weight: 600;
}

.inspection-item-controls {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.rating-group {
    display: flex;
    gap: .35rem;
}

.rating-btn {
    border: 1px solid #d8dee7;
    background: #fff;
    border-radius: 8px;
    padding: .4rem .7rem;
    font-size: .78rem;
    cursor: pointer;
    color: #5a6b85;
}

.rating-btn[data-rating="good"].active {
    background: #e6f6ec;
    border-color: #2d7a4f;
    color: #1f7a45;
}

.rating-btn[data-rating="attention"].active {
    background: #fff4e0;
    border-color: #c88a00;
    color: #9a6300;
}

.rating-btn[data-rating="failed"].active {
    background: #fdeaea;
    border-color: #c0392b;
    color: #a33;
}

.item-icon-btn {
    border: 1px solid #d8dee7;
    background: #fff;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: .95rem;
}

.inspection-item-notes {
    grid-column: 1/-1;
    display: none;
    gap: .6rem;
    margin-top: .5rem;
}

.inspection-item.expanded .inspection-item-notes {
    display: grid;
    grid-template-columns: 2fr 1fr;
}

.inspection-item-notes textarea,
.inspection-item-notes input {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid #d8dee7;
    border-radius: 8px;
    font: inherit;
    font-size: .82rem;
}

/* --- Inspection template editor --- */

.template-card {
    background: #fff;
    border: 1px solid #e3e8ef;
    border-radius: 14px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.template-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
}

.template-toggle {
    display: flex;
    align-items: center;
    gap: .6rem;
    border: 0;
    background: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
    flex: 1;
    min-width: 0;
}

.template-toggle-chevron {
    flex-shrink: 0;
    font-size: .75rem;
    color: #7d899a;
    transition: transform .15s ease;
}

.template-card.expanded .template-toggle-chevron {
    transform: rotate(90deg);
}

.template-card-body {
    display: none;
}

.template-card.expanded .template-card-body {
    display: block;
}

.template-card-head h3 {
    margin: 0;
    font-size: 1.05rem;
}

.template-card-head .muted {
    margin: .2rem 0 0;
    font-size: .8rem;
}

.template-card-actions {
    display: flex;
    gap: .5rem;
}

.template-section-group {
    margin-top: 1.1rem;
    padding-top: .9rem;
    border-top: 1px solid #edf0f4;
}

.template-section-group h4 {
    margin: 0 0 .5rem;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #7d899a;
}

.template-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem 0;
    border-bottom: 1px solid #f2f4f8;
    font-size: .88rem;
}

.template-item-row:last-child {
    border-bottom: 0;
}

.template-item-actions {
    display: flex;
    align-items: center;
    gap: .25rem;
}

.item-move-btn,
.item-edit-btn,
.item-delete-btn {
    border: 1px solid #d8dee7;
    background: #fff;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: .8rem;
    cursor: pointer;
    color: #5a6b85;
}

.item-delete-btn {
    color: #a33;
    border-color: #f0c9c9;
}

.field-hint {
    display: block;
    font-size: .75rem;
    color: #7d899a;
    font-weight: 400;
    margin-top: .3rem;
}

.template-state-badge {
    display: inline-block;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .03em;
    padding: .15rem .5rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #3b4d8c;
    margin-left: .5rem;
    vertical-align: middle;
}

.template-state-badge.universal {
    background: #f1f3f6;
    color: #7d899a;
}

@media print {
    .no-print, .side, .dashhead button, #print-inspection, #complete-inspection, .back-link {
        display: none !important;
    }

    .app {
        display: block !important;
    }

    .dash {
        padding: 0 !important;
        max-width: none !important;
    }

    .inspection-section {
        break-inside: avoid;
        border: 1px solid #ccc;
        box-shadow: none;
    }
}
