:root {
    --bg: #eef2f5;
    --panel: #ffffff;
    --panel-muted: #f7f9fb;
    --panel-soft: #fbfdff;
    --panel-soft-alt: #f2f7fa;
    --text: #1d2733;
    --muted: #5f6d7a;
    --line: #d7dde5;
    --primary: #114b5f;
    --primary-soft: #e1eef2;
    --danger: #a63446;
    --danger-soft: #fde8eb;
    --success: #197a55;
    --success-soft: #e3f5ee;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: radial-gradient(circle at top, #d8e6ed 0%, var(--bg) 35%, #edf1f5 100%);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

p {
    margin: 0;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 2rem 2.5rem 1rem;
}

.site-header h1,
.panel h2,
.panel h3 {
    margin: 0;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2.5rem 3rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card,
.panel {
    background: var(--panel);
    border: 1px solid rgba(17, 75, 95, 0.08);
    border-radius: 20px;
    box-shadow: 0 20px 45px rgba(15, 37, 48, 0.08);
}

.stat-card {
    padding: 1.2rem 1.25rem;
}

.stats-grid .stat-card:nth-child(1) {
    background: linear-gradient(160deg, #fff8e8 0%, #ffffff 70%);
}

.stats-grid .stat-card:nth-child(2) {
    background: linear-gradient(160deg, #edf8f3 0%, #ffffff 70%);
}

.stats-grid .stat-card:nth-child(3) {
    background: linear-gradient(160deg, #eef7ff 0%, #ffffff 70%);
}

.stats-grid .stat-card:nth-child(4) {
    background: linear-gradient(160deg, #fff0f3 0%, #ffffff 70%);
}

.stat-card p,
.stat-card span {
    margin: 0;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin: 0.5rem 0 0.35rem;
    font-size: 2rem;
}

.panel {
    margin-bottom: 1rem;
}

.panel-section {
    padding: 0;
    overflow: hidden;
    scroll-margin-top: 1rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.panel-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.35rem 1.4rem;
    cursor: pointer;
    list-style: none;
}

.panel-summary::-webkit-details-marker,
.record-summary::-webkit-details-marker {
    display: none;
}

.summary-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.toggle-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 104px;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.toggle-pill::before {
    content: "Extinde";
}

.panel-section[open] .toggle-pill::before {
    content: "Restrange";
}

.panel-body {
    padding: 0 1.4rem 1.4rem;
}

.panel-section[open] {
    border-color: rgba(17, 75, 95, 0.22);
    box-shadow: 0 24px 50px rgba(15, 37, 48, 0.14);
}

.panel-section.is-parent-zone {
    border-color: rgba(17, 75, 95, 0.26);
    box-shadow: 0 0 0 3px rgba(17, 75, 95, 0.08), 0 24px 50px rgba(15, 37, 48, 0.16);
}

.panel-section.is-active-zone {
    border-color: rgba(17, 75, 95, 0.38);
    box-shadow: 0 0 0 4px rgba(17, 75, 95, 0.13), 0 28px 58px rgba(15, 37, 48, 0.2);
    transform: translateY(-2px);
}

.panel-section[open] > .panel-summary {
    border-bottom: 1px solid rgba(17, 75, 95, 0.12);
}

#legacy > .panel-summary {
    background: linear-gradient(135deg, #fff8e8 0%, #ffffff 75%);
}

#legacy[open] > .panel-summary .toggle-pill {
    background: #c98d18;
    border-color: #c98d18;
    color: #fff;
}

#import > .panel-summary {
    background: linear-gradient(135deg, #eef7ff 0%, #ffffff 75%);
}

#import[open] > .panel-summary .toggle-pill {
    background: #2f6fb4;
    border-color: #2f6fb4;
    color: #fff;
}

#rental > .panel-summary {
    background: linear-gradient(135deg, #edf8f3 0%, #ffffff 75%);
}

#rental[open] > .panel-summary .toggle-pill {
    background: #197a55;
    border-color: #197a55;
    color: #fff;
}

#sale > .panel-summary {
    background: linear-gradient(135deg, #fff0f3 0%, #ffffff 75%);
}

#sale[open] > .panel-summary .toggle-pill {
    background: #b64663;
    border-color: #b64663;
    color: #fff;
}

#trash > .panel-summary {
    background: linear-gradient(135deg, #ffe8eb 0%, #ffffff 78%);
}

#trash[open] > .panel-summary .toggle-pill {
    background: #a63446;
    border-color: #a63446;
    color: #fff;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
}

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

.two-column {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stack-block,
.stack-form {
    display: grid;
    gap: 0.8rem;
    padding: 1rem;
    background: var(--panel-muted);
    border-radius: 18px;
    border: 1px solid var(--line);
}

.summary-block {
    background: linear-gradient(180deg, #fff 0%, #f8fbfe 100%);
}

.table-card {
    display: grid;
    gap: 0.8rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    border: 1px solid rgba(17, 75, 95, 0.08);
    border-radius: 18px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.subsection-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.subsection-head h3 {
    margin: 0.2rem 0 0;
}

.summary-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.nested-toggle {
    padding: 0;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.nested-toggle.is-parent-zone {
    box-shadow: 0 0 0 3px rgba(17, 75, 95, 0.06), 0 14px 24px rgba(15, 37, 48, 0.08);
}

.nested-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    cursor: pointer;
    list-style: none;
    background: rgba(255, 255, 255, 0.75);
}

.nested-summary::-webkit-details-marker {
    display: none;
}

.nested-summary-accent {
    background: linear-gradient(135deg, #e4f0f4 0%, #f9fcff 100%);
}

.nested-summary-filter {
    background: linear-gradient(135deg, #f5eefd 0%, #ffffff 80%);
}

.nested-pill {
    min-width: 94px;
    background: #fff;
}

.nested-toggle[open] .nested-pill::before {
    content: "Restrange";
}

.stack-form-inner {
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--line);
    background: transparent;
}

.filter-toggle[open] {
    border-color: rgba(89, 67, 140, 0.22);
    box-shadow: 0 16px 28px rgba(79, 67, 119, 0.12);
}

.filter-toggle.is-active-zone {
    border-color: rgba(89, 67, 140, 0.38);
    box-shadow: 0 0 0 4px rgba(89, 67, 140, 0.12), 0 18px 32px rgba(79, 67, 119, 0.18);
    transform: translateY(-1px);
}

.filter-toggle[open] > .nested-summary {
    background: linear-gradient(135deg, #eadffd 0%, #fdfbff 85%);
}

.filter-toggle.is-active-zone > .nested-summary {
    background: linear-gradient(135deg, #dfd0fb 0%, #f9f5ff 90%);
}

.filter-toggle[open] > .nested-summary .nested-pill {
    background: #5a4d85;
    border-color: #5a4d85;
    color: #fff;
}

.create-toggle[open] {
    border-color: rgba(17, 122, 85, 0.22);
    box-shadow: 0 16px 28px rgba(17, 122, 85, 0.12);
}

.create-toggle.is-active-zone {
    border-color: rgba(17, 122, 85, 0.38);
    box-shadow: 0 0 0 4px rgba(17, 122, 85, 0.12), 0 18px 32px rgba(17, 122, 85, 0.18);
    transform: translateY(-1px);
}

.create-toggle[open] > .nested-summary {
    background: linear-gradient(135deg, #dff3ea 0%, #fbfffd 85%);
}

.create-toggle.is-active-zone > .nested-summary {
    background: linear-gradient(135deg, #d4efdf 0%, #f8fffc 90%);
}

.create-toggle[open] > .nested-summary .nested-pill {
    background: #197a55;
    border-color: #197a55;
    color: #fff;
}

.stack-form label,
.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.stack-form span {
    display: block;
    width: 100%;
    font-size: 0.92rem;
    color: var(--muted);
}

input,
textarea {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font: inherit;
}

.smart-filter {
    position: relative;
    width: 100%;
}

.smart-filter:focus-within {
    border-radius: 14px;
    box-shadow: 0 0 0 4px rgba(17, 75, 95, 0.08);
}

.smart-filter input:disabled {
    background: #edf2f6;
    color: #7a8794;
    cursor: not-allowed;
}

.smart-filter-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 30;
    display: grid;
    gap: 0.2rem;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.45rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 35px rgba(15, 37, 48, 0.16);
}

.smart-filter-menu[hidden] {
    display: none;
}

.smart-filter-option {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.smart-filter-option:hover,
.smart-filter-option.active {
    background: var(--primary-soft);
    color: var(--primary);
}

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

.inline-form input {
    width: auto;
    min-width: 110px;
    flex: 1 1 110px;
}

.inline-form textarea {
    width: 100%;
    flex: 1 1 240px;
    min-height: 84px;
}

.inline-form.wide input {
    min-width: 90px;
}

.labeled-inline-form {
    align-items: stretch;
}

.field-tile {
    display: grid;
    gap: 0.4rem;
    min-width: 140px;
    flex: 1 1 160px;
    padding: 0.7rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--line);
}

.field-tile span {
    width: auto;
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
}

.field-tile input {
    min-width: 0;
    width: 100%;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.checkbox input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.checkbox span {
    width: auto;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

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

.button.ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--line);
}

.button.small {
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
}

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

.button.is-loading,
.button:disabled {
    opacity: 0.72;
    cursor: wait;
}

.alert {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    font-weight: 600;
}

.alert.success {
    background: var(--success-soft);
    color: var(--success);
}

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

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

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

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

.zebra-table th,
.zebra-table td {
    padding: 0.9rem 0.75rem;
    border-top: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.zebra-table th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.zebra-table tbody tr:nth-child(odd) {
    background: var(--panel-soft);
}

.zebra-table tbody tr:nth-child(even) {
    background: var(--panel-soft-alt);
}

.records-list {
    display: grid;
    gap: 0.85rem;
}

.record-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: var(--panel-soft);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.records-list .record-card:nth-child(even) {
    background: var(--panel-soft-alt);
}

.record-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    cursor: pointer;
    list-style: none;
}

.record-card[open] {
    border-color: rgba(17, 75, 95, 0.22);
    box-shadow: 0 20px 35px rgba(15, 37, 48, 0.12);
    transform: translateY(-1px);
}

.record-card.is-active-zone {
    border-color: rgba(17, 75, 95, 0.4);
    box-shadow: 0 0 0 4px rgba(17, 75, 95, 0.12), 0 22px 38px rgba(15, 37, 48, 0.18);
    transform: translateY(-2px);
}

.record-card[open] > .record-summary {
    border-bottom: 1px solid rgba(17, 75, 95, 0.12);
}

.record-card.is-active-zone > .record-summary {
    border-bottom: 1px solid rgba(17, 75, 95, 0.18);
}

#import .record-card[open] > .record-summary {
    background: linear-gradient(135deg, #deecff 0%, #f8fbff 85%);
}

#rental .record-card[open] > .record-summary {
    background: linear-gradient(135deg, #dff3ea 0%, #fbfffd 85%);
}

#sale .record-card[open] > .record-summary {
    background: linear-gradient(135deg, #ffe3ea 0%, #fff9fb 85%);
}

#trash .record-card[open] > .record-summary {
    background: linear-gradient(135deg, #ffd9de 0%, #fff7f8 88%);
}

#trash .record-card.is-active-zone > .record-summary {
    background: linear-gradient(135deg, #ffcfd7 0%, #fff4f6 92%);
}

.record-primary {
    display: grid;
    gap: 0.3rem;
}

.record-meta,
.record-facts,
.import-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.record-meta {
    justify-content: flex-end;
}

.record-body {
    display: grid;
    gap: 1rem;
    padding: 0 1.1rem 1.1rem;
    border-top: 1px solid rgba(17, 75, 95, 0.08);
}

.record-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
    gap: 1rem;
    align-items: start;
}

.record-copy {
    display: grid;
    gap: 0.45rem;
}

.record-copy h3 {
    margin: 0;
}

.record-side {
    display: grid;
    gap: 0.75rem;
    align-content: start;
}

.record-preview {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
}

.photo-summary {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.85rem;
}

.media-grid {
    align-items: stretch;
}

.media-item {
    display: grid;
    gap: 0.45rem;
    width: 132px;
    padding: 0.75rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
}

.media-item form {
    width: 100%;
}

.media-item .button {
    width: 100%;
}

.media-item .muted,
.photo-summary > .muted {
    margin: 0;
}

.photo-summary > .muted {
    width: 100%;
}

.photo-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--panel-muted);
}

.action-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-row-left {
    justify-content: flex-start;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-chip.active {
    background: var(--success-soft);
    color: var(--success);
}

.status-chip.blocked {
    background: var(--danger-soft);
    color: var(--danger);
}

.users-table td:last-child form {
    width: 100%;
}

.action-stack {
    display: grid;
    gap: 0.45rem;
}

.users-table tbody tr.is-active-zone {
    outline: 3px solid rgba(201, 141, 24, 0.28);
    outline-offset: -3px;
    background: #fff4cf !important;
}

.record-stack {
    display: grid;
    gap: 0.55rem;
}

.empty-state {
    padding: 1rem;
    border-radius: 16px;
    background: var(--panel-muted);
    border: 1px dashed var(--line);
    color: var(--muted);
}

.auth-panel {
    max-width: 480px;
    margin: 5rem auto 0;
}

@media (max-width: 1100px) {
    .page-shell {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .panel-summary,
    .panel-body {
        padding-left: 1rem;
        padding-right: 1rem;
    }

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

@media (max-width: 900px) {
    .site-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 1.2rem 1rem 1rem;
    }

    .site-header .button {
        width: 100%;
    }

    .panel-summary,
    .record-summary,
    .subsection-head {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .summary-meta,
    .subsection-head .summary-meta,
    .record-meta {
        width: 100%;
        justify-content: flex-start;
    }

    .toggle-pill {
        min-width: 0;
    }

    .two-column {
        grid-template-columns: 1fr;
    }

    .inline-form input,
    .inline-form textarea,
    .field-tile,
    .inline-form .button,
    .media-item,
    .record-side .button {
        width: 100%;
    }

    .action-row {
        justify-content: stretch;
    }

    .action-row form,
    .action-row .button {
        width: 100%;
    }
}

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

    .stat-card strong {
        font-size: 1.7rem;
    }

    .stack-form,
    .stack-block,
    .record-body {
        padding: 0.9rem;
    }

    .panel-summary {
        padding: 1rem;
    }

    .panel-body {
        padding: 0 1rem 1rem;
    }

    .record-summary {
        padding: 0.9rem;
    }

    .badge {
        font-size: 0.82rem;
    }
}
