:root {
    color-scheme: dark;
    --bg: #07101d;
    --surface: #0c1727;
    --surface-raised: #111e30;
    --surface-soft: #15243a;
    --border: #21344d;
    --border-strong: #315070;
    --text: #edf4fb;
    --text-soft: #b5c4d7;
    --muted: #8296ae;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --accent-soft: rgba(56, 189, 248, .12);
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #fb7185;
    --shadow: 0 18px 50px rgba(0, 0, 0, .22);
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --content: 1320px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); line-height: 1.55; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(circle at 80% -10%, rgba(14, 165, 233, .10), transparent 32rem); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #7dd3fc; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(56, 189, 248, .65); outline-offset: 3px; }
img { display: block; max-width: 100%; }
h1, h2, h3 { margin-top: 0; color: var(--text); line-height: 1.14; letter-spacing: -.025em; }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); }
h2 { font-size: clamp(1.35rem, 2vw, 1.8rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }
small { color: var(--muted); }

.skip-link { position: fixed; left: 16px; top: -80px; z-index: 100; padding: 10px 14px; border-radius: 8px; background: var(--text); color: var(--bg); }
.skip-link:focus { top: 16px; }
.muted { color: var(--muted); }
.section { margin-top: 30px; }
.eyebrow, .page-kicker { margin: 0 0 8px; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

/* Public shell */
.site-header { position: sticky; top: 0; z-index: 30; border-bottom: 1px solid rgba(49, 80, 112, .55); background: rgba(7, 16, 29, .88); backdrop-filter: blur(18px); }
.site-header-inner, .site-footer { width: min(calc(100% - 40px), var(--content)); margin: 0 auto; }
.site-header-inner { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.site-brand, .admin-brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.site-brand:hover, .admin-brand:hover { color: var(--text); }
.site-brand strong, .site-brand small, .admin-brand strong, .admin-brand small { display: block; }
.site-brand small, .admin-brand small { margin-top: 1px; font-size: .72rem; letter-spacing: .03em; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid rgba(56, 189, 248, .3); border-radius: 12px; background: linear-gradient(145deg, rgba(56, 189, 248, .2), rgba(14, 165, 233, .05)); color: #d9f4ff; font-weight: 900; letter-spacing: -.05em; }
.site-nav { display: flex; align-items: center; gap: 8px; }
.site-nav a { padding: 9px 13px; border-radius: 10px; color: var(--text-soft); font-size: .9rem; font-weight: 650; }
.site-nav a:hover, .site-nav a.is-active { background: var(--surface-raised); color: var(--text); }
.site-nav .site-nav-admin { margin-left: 6px; border: 1px solid var(--border); }
.public-content { width: min(calc(100% - 40px), var(--content)); min-height: calc(100vh - 190px); margin: 0 auto; padding: 54px 0 76px; }
.site-footer { min-height: 92px; padding: 24px 0 40px; display: flex; justify-content: space-between; gap: 24px; border-top: 1px solid var(--border); color: var(--muted); }
.site-footer strong, .site-footer span { display: block; }
.site-footer strong { color: var(--text-soft); }

/* Admin shell */
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: rgba(8, 18, 32, .96); }
.admin-brand { padding: 0 8px 24px; border-bottom: 1px solid var(--border); }
.app-nav { display: grid; gap: 4px; padding: 20px 0; }
.app-nav-label { margin: 18px 12px 7px; color: #607892; font-size: .66rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.app-nav-label:first-child { margin-top: 0; }
.app-nav-link { position: relative; padding: 10px 12px; border-radius: 10px; color: var(--text-soft); font-size: .9rem; font-weight: 650; }
.app-nav-link:hover { background: var(--surface-raised); color: var(--text); }
.app-nav-link.is-active { background: var(--accent-soft); color: #dff6ff; }
.app-nav-link.is-active::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 4px; background: var(--accent); }
.admin-sidebar-footer { margin-top: auto; padding: 18px 10px 4px; display: grid; gap: 5px; border-top: 1px solid var(--border); font-size: .78rem; }
.admin-sidebar-footer span { color: #607892; }
.admin-workspace { min-width: 0; }
.admin-mobilebar { display: none; }
.admin-content { width: min(100%, calc(var(--content) + 64px)); margin: 0 auto; padding: 42px 32px 72px; }

/* Shared page structure */
.page-header, .section-heading, .rental-page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-header h1, .section-heading h1, .section-heading h2, .rental-page-heading h1 { margin-bottom: 8px; }
.page-header-copy { max-width: 760px; }
.page-actions, .actions, .admin-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.actions { margin-top: 18px; }
.admin-nav { margin: 0 0 20px; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border: 1px solid transparent; border-radius: 10px; background: var(--accent-strong); color: #03121d; font-weight: 800; line-height: 1.2; cursor: pointer; transition: transform .14s ease, background .14s ease, border-color .14s ease; }
.button:hover { transform: translateY(-1px); background: #38bdf8; color: #03121d; }
.button.secondary { border-color: var(--border); background: var(--surface-raised); color: var(--text-soft); }
.button.secondary:hover { border-color: var(--border-strong); background: var(--surface-soft); color: var(--text); }
.button.danger { background: #be123c; color: #fff; }
.button.success { background: #059669; color: #fff; }
.button.ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.button[disabled] { opacity: .45; pointer-events: none; }

.card, .panel { border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg, rgba(17, 30, 48, .92), rgba(10, 23, 39, .95)); box-shadow: 0 1px 0 rgba(255, 255, 255, .02); }
.card { padding: 20px; }
.panel { overflow: hidden; }
.panel-header { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border); }
.panel-header h2, .panel-header h3 { margin: 0; }
.panel-body { padding: 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.metrics, .rental-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 20px 0 30px; }
.metric, .rental-metric { min-height: 108px; padding: 16px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.metric span, .rental-metric span { color: var(--muted); font-size: .7rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.metric strong, .rental-metric strong { margin-top: 8px; font-size: 1.8rem; line-height: 1; }

.pill, .status-pill, .state-pill { display: inline-flex; align-items: center; width: max-content; max-width: 100%; padding: 5px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-soft); color: var(--text-soft); font-size: .68rem; font-weight: 750; line-height: 1.1; white-space: nowrap; }
.status-active, .state-rented, .state-active, .state-verified { border-color: rgba(52, 211, 153, .3); background: rgba(52, 211, 153, .1); color: #8cf0cc; }
.status-vacant, .state-vacant, .state-resolved { border-color: rgba(56, 189, 248, .28); background: rgba(56, 189, 248, .09); color: #9edfff; }
.status-warning, .state-overdue, .state-open, .state-awaiting_sale_offer { border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .1); color: #fddc7b; }
.status-danger, .state-ended, .state-missing { border-color: rgba(251, 113, 133, .2); background: rgba(251, 113, 133, .08); color: #fda4af; }

.notice, .safety-notice, .error-notice { margin: 0 0 20px; padding: 13px 15px; border: 1px solid; border-radius: 12px; }
.notice { border-color: rgba(52, 211, 153, .3); background: rgba(52, 211, 153, .08); color: #b7f7df; }
.safety-notice { border-color: rgba(56, 189, 248, .28); background: rgba(56, 189, 248, .07); color: #ccefff; }
.error-notice { border-color: rgba(251, 113, 133, .28); background: rgba(251, 113, 133, .08); color: #fecdd3; }
.system-note { margin: 18px 0 28px; border: 1px solid var(--border); border-radius: 12px; background: rgba(12, 23, 39, .7); }
.system-note summary { padding: 12px 15px; color: var(--text-soft); font-size: .82rem; font-weight: 750; cursor: pointer; }
.system-note > div { padding: 0 15px 15px; color: var(--muted); font-size: .86rem; }

.table-wrap, .rental-table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 15px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(56, 189, 248, .025); }
.empty, .empty-state { padding: 32px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); text-align: center; }

input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: #081321; color: var(--text); }
input::placeholder, textarea::placeholder { color: #607892; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(56, 189, 248, .12); }
textarea { min-height: 120px; resize: vertical; }
label { color: var(--text-soft); }
.field { display: flex; flex-direction: column; gap: 7px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
form.inline { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 26px; }
form.inline > * { width: auto; min-width: 160px; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; }
.checkbox input { width: auto; margin-top: 4px; }
fieldset { padding: 18px; border: 1px solid var(--border); border-radius: 14px; }
.parcel-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.parcel-option { padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.parcel-option-assigned { border-color: rgba(251, 191, 36, .38); background: rgba(251, 191, 36, .035); }
.parcel-assignment-warning { margin-top: 10px; padding: 9px 10px; display: grid; gap: 2px; border: 1px solid rgba(251, 191, 36, .24); border-radius: 8px; background: rgba(251, 191, 36, .07); color: #fddc7b; font-size: .76rem; }
.parcel-assignment-warning span { color: var(--text-soft); }
.primary-choice { margin-top: 8px; }
.profile-preview pre { max-height: 480px; overflow: auto; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: #081321; white-space: pre-wrap; }
.pagination { display: flex; gap: 6px; }

.confirmation-dialog { width: min(calc(100% - 32px), 540px); padding: 26px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow); }
.confirmation-dialog::backdrop { background: rgba(2, 8, 18, .76); backdrop-filter: blur(4px); }
.confirmation-dialog h2 { margin-bottom: 10px; }
.confirmation-dialog p { color: var(--text-soft); }
.confirmation-dialog ul { margin: 16px 0; padding: 12px 12px 12px 30px; border: 1px solid rgba(251, 191, 36, .28); border-radius: 10px; background: rgba(251, 191, 36, .06); color: #fddc7b; }
.confirmation-dialog-icon { width: 40px; height: 40px; margin-bottom: 18px; display: grid; place-items: center; border-radius: 12px; background: rgba(251, 191, 36, .12); color: var(--warning); font-size: 1.2rem; font-weight: 900; }
.confirmation-dialog-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 9px; }

/* Public listing */
.hero { position: relative; padding: 56px 0 72px; }
.hero::after { content: ""; position: absolute; right: 0; top: 20px; width: min(40vw, 520px); aspect-ratio: 1.3; z-index: -1; border-radius: 50%; background: radial-gradient(circle, rgba(14, 165, 233, .14), transparent 68%); filter: blur(8px); }
.hero-copy { max-width: 760px; }
.hero h1 { max-width: 720px; margin-bottom: 18px; font-size: clamp(2.6rem, 6vw, 5rem); }
.hero p { max-width: 650px; color: var(--text-soft); font-size: clamp(1rem, 2vw, 1.18rem); }
.property-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.property-card { min-height: 230px; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(155deg, var(--surface-raised), var(--surface)); transition: transform .16s ease, border-color .16s ease; }
.property-card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.property-card h2, .property-card h3 { margin: 14px 0 8px; }
.property-card-price { margin-top: 18px; font-size: 1.25rem; font-weight: 850; }
.property-card-meta { color: var(--muted); font-size: .86rem; }
.region-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.region-card { padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: rgba(12, 23, 39, .72); }
.region-card h3 { margin-bottom: 7px; }
.filter-bar { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.property-detail { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 22px; }
.property-summary { padding: clamp(24px, 5vw, 44px); }
.property-aside { padding: 24px; align-self: start; position: sticky; top: 105px; }
.property-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0; }
.property-facts div { padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: rgba(7, 16, 29, .45); }
.property-facts dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.property-facts dd { margin: 4px 0 0; font-weight: 750; }

@media (max-width: 900px) {
    .admin-shell { display: block; }
    .admin-sidebar { position: fixed; left: 0; top: 0; width: min(290px, 86vw); z-index: 60; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
    .nav-open .admin-sidebar { transform: translateX(0); }
    .nav-open::after { content: ""; position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); }
    .admin-mobilebar { position: sticky; top: 0; z-index: 40; min-height: 62px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: rgba(7, 16, 29, .9); backdrop-filter: blur(16px); }
    .mobile-brand { color: var(--text); font-weight: 900; }
    .mobile-brand span { margin-left: 5px; color: var(--muted); font-weight: 650; }
    .nav-toggle { padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-raised); color: var(--text); cursor: pointer; }
    .admin-content { padding: 28px 20px 60px; }
    .property-detail { grid-template-columns: 1fr; }
    .property-aside { position: static; }
}

@media (max-width: 680px) {
    .site-header-inner, .site-footer, .public-content { width: min(calc(100% - 28px), var(--content)); }
    .site-header-inner { min-height: 68px; }
    .site-brand small { display: none; }
    .site-nav { gap: 2px; }
    .site-nav a { padding: 8px 9px; font-size: .82rem; }
    .site-nav .site-nav-admin { display: none; }
    .public-content { padding-top: 34px; }
    .hero { padding: 30px 0 50px; }
    .page-header, .section-heading, .rental-page-heading { flex-direction: column; }
    .metrics, .rental-metrics { grid-template-columns: 1fr 1fr; }
    .filter-bar { grid-template-columns: 1fr; }
    .filter-bar .button { width: 100%; }
    .property-facts { grid-template-columns: 1fr; }
    .site-footer { flex-direction: column; }
    form.inline > * { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
