/* ═══════════════════════════════════════════════════════════════
   Design system — shared between public site and control center.
   Variables adapt to org branding via applyBranding().
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg: #f7f8fa;
    --bg-soft: #ffffff;
    --panel: #ffffff;
    --ink: #111827;
    --muted: #6b7280;
    --line: rgba(0, 0, 0, 0.08);
    --line-strong: rgba(0, 0, 0, 0.16);
    --accent: #1570EF;
    --accent-deep: #1254b5;
    --accent-soft: #dbeafe;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --radius-xl: 12px;
    --radius-lg: 10px;
    --radius-md: 8px;
    --radius-sm: 6px;
    --content: 1240px;
    --brand-font: 'Inter', 'Segoe UI', -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
    margin: 0; color: var(--ink);
    background: var(--bg);
    font-family: var(--brand-font);
    line-height: 1.5;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.shell { width: min(var(--content), calc(100% - 32px)); margin: 0 auto; }

/* ═══════ SHARED COMPONENTS ═══════ */

.button, .ghost-button, .soft-button {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; min-height: 42px; padding: 0 16px;
    border-radius: 8px; border: 1px solid transparent;
    font-weight: 600; cursor: pointer; font-size: 0.92rem;
}
.button { background: var(--accent); color: #fff; }
.button:hover { background: var(--accent-deep); }
.ghost-button { border-color: var(--line-strong); color: var(--ink); background: #fff; }
.soft-button { background: var(--accent-soft); color: var(--accent); }
.text-link { color: var(--accent); font-weight: 600; cursor: pointer; background: none; border: none; padding: 0; font-size: inherit; }

.pill, .badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
}
.pill { color: var(--accent); background: var(--accent-soft); }
.badge { color: #fff; background: rgba(17, 24, 39, 0.85); }

.vis-pill {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px;
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.vis-private     { background: #fee2e2; color: #991b1b; }
.vis-organization{ background: #fef3c7; color: #92400e; }
.vis-network     { background: #dbeafe; color: #1e40af; }
.vis-public      { background: #dcfce7; color: #166534; }
.vis-distributed { background: #f3e8ff; color: #6b21a8; }

.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 6px;
    background: var(--accent-soft); color: var(--accent);
    font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}

.field { display: grid; gap: 8px; }
.field label { font-size: 0.82rem; color: var(--muted); font-weight: 700; }
.field input, .field select, .field textarea {
    width: 100%; min-height: 44px; padding: 10px 12px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: #fff; color: var(--ink);
}
.field textarea { min-height: 140px; resize: vertical; }

.status { color: var(--muted); padding: 1rem 0; }
.status.error { color: #b91c1c; }
.muted { color: var(--muted); }
.form-error { color: #b91c1c; font-size: 0.85rem; margin-top: 0.75rem; }
.form-row { display: flex; gap: 1rem; }
.form-row > * { flex: 1; }

.skel {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 14px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.org-dot {
    display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem;
}
.org-dot::before {
    content: ''; width: 0.5rem; height: 0.5rem; border-radius: 50%;
    background: var(--origin-color, #94a3b8);
}

/* ═══════ PUBLIC SITE HEADER ═══════ */

.site-header {
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
}
.site-header__row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 24px; min-height: 76px;
}
.brand { display: inline-flex; align-items: center; gap: 14px; min-width: 0; cursor: pointer; }
.brand__name {
    font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
}
.brand__sub { color: var(--muted); font-size: 0.84rem; }
.site-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.site-nav a, .site-nav button {
    padding: 10px 14px; border-radius: 8px; color: var(--muted); font-size: 0.92rem;
    background: none; border: none; cursor: pointer;
}
.site-nav a.active, .site-nav a:hover, .site-nav button:hover { color: var(--ink); background: var(--bg); }
.site-nav .cta { background: var(--accent); color: #fff; }

/* ═══════ HERO ═══════ */

.hero { padding: 28px 0 18px; }
.hero__panel {
    position: relative; overflow: hidden; padding: 48px 48px 56px;
    border: none; border-radius: 20px;
    background: linear-gradient(135deg, var(--accent-deep) 0%, var(--accent) 40%, #0ea5e9 70%, #6366f1 100%);
    box-shadow: 0 8px 32px rgba(21, 112, 239, 0.2);
    min-height: 360px;
}
.hero__panel > * { position: relative; z-index: 1; }
.hero h1 {
    max-width: 16ch; font-size: clamp(2.4rem, 5vw, 3.8rem); color: #fff;
    margin: 16px 0 10px; line-height: 1.1; letter-spacing: -0.03em; font-weight: 800;
}
.hero p.lead { max-width: 62ch; color: rgba(255,255,255,0.8); font-size: 1.02rem; }
.hero-grid {
    display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.85fr);
    gap: 28px; align-items: end;
}

/* ═══════ SEARCH CARD / TRUST CARD ═══════ */

.search-card, .trust-card, .section-card, .results-context, .empty-state {
    border: 1px solid var(--line); border-radius: var(--radius-xl);
    background: var(--panel); box-shadow: var(--shadow);
}
.search-card { padding: 18px; display: grid; gap: 14px; }
.search-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.trust-card { padding: 22px; display: grid; gap: 16px; background: var(--bg); }
.trust-card h2 { margin: 0; font-size: 1.05rem; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metric {
    padding: 14px; border-radius: 18px;
    background: rgba(255, 255, 255, 0.72); border: 1px solid rgba(52, 40, 32, 0.08);
}
.metric strong { display: block; font-size: 1.25rem; font-weight: 800; }
.metric span { color: var(--muted); font-size: 0.84rem; }

.hero .search-card { background: rgba(255,255,255,0.95); }
.hero .trust-card { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); }
.hero .trust-card h2, .hero .trust-card .metric strong { color: #fff; }
.hero .trust-card p, .hero .trust-card .metric span { color: rgba(255,255,255,0.7); }
.hero .trust-card .metric { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); }

/* ═══════ PROPERTY CARDS ═══════ */

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.property-card {
    overflow: hidden; border: 1px solid var(--line); border-radius: 10px;
    background: #fff; box-shadow: var(--shadow);
    transition: box-shadow 0.15s, transform 0.15s;
    cursor: pointer; display: block;
}
.property-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-2px); }
.property-card__media {
    position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #e5e7eb;
}
.property-card__media img { width: 100%; height: 100%; object-fit: cover; }
.property-card__placeholder {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; color: var(--muted);
    font-size: 0.82rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
    background: linear-gradient(135deg, #e5e7eb, #d1d5db);
}
.property-card__badge { position: absolute; left: 14px; top: 14px; }
.property-card__body { padding: 18px; display: grid; gap: 10px; }
.price-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.price { font-size: 1.5rem; line-height: 1; font-weight: 800; }
.property-card h3 { margin: 0; font-size: 1.15rem; }
.listing-summary { color: var(--muted); font-size: 0.88rem; }

/* ═══════ SECTION / PAGE HEADING ═══════ */

.section { padding: 18px 0; }
.section-heading, .page-title {
    display: flex; flex-wrap: wrap; justify-content: space-between;
    align-items: end; gap: 16px; margin-bottom: 18px;
}
.section-heading h2, .page-title h1 {
    margin: 16px 0 10px; font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.1; letter-spacing: -0.03em; font-weight: 800;
}
.page-title p, .section-heading p { max-width: 62ch; color: var(--muted); font-size: 1.02rem; }
.inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* ═══════ TOGGLE ═══════ */

.toggle-row { display: flex; gap: 6px; }
.toggle-btn {
    padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
    background: #fff; color: var(--muted); font-weight: 600;
    cursor: pointer; font-size: 0.88rem;
}
.toggle-btn.active { background: var(--accent); color: #fff; border-color: transparent; }

/* ═══════ AREA LINKS ═══════ */

.area-links { display: flex; flex-wrap: wrap; gap: 12px; }
.area-link {
    padding: 10px 16px; border-radius: 8px;
    border: 1px solid var(--line); background: #fff;
    color: var(--ink); font-weight: 600; font-size: 0.92rem; transition: all 0.15s;
}
.area-link:hover { border-color: var(--accent); color: var(--accent); }

/* ═══════ FILTER CHIPS ═══════ */

.filter-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.filter-chip {
    padding: 8px 12px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.76); border: 1px solid var(--line);
    color: var(--muted); font-size: 0.88rem; cursor: pointer;
}
.filter-chip:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
.filter-chip::after { content: ' \00d7'; font-weight: 700; margin-left: 4px; }
.filter-clear {
    font-size: 0.86rem; color: var(--accent); cursor: pointer; font-weight: 600;
    background: none; border: none; padding: 8px 4px;
}

/* ═══════ RESULTS / EMPTY STATE ═══════ */

.results-layout { display: grid; gap: 18px; }
.results-context, .empty-state { padding: 22px; }
.empty-state { display: grid; gap: 14px; justify-items: start; background: #fff; }

/* ═══════ DETAIL PAGE ═══════ */

.detail-grid {
    display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 24px; align-items: start;
}
.gallery {
    overflow: hidden; border-radius: 12px; border: 1px solid var(--line);
    background: #fff; box-shadow: var(--shadow); margin-bottom: 18px;
}
.gallery__hero { aspect-ratio: 16/10; overflow: hidden; }
.gallery__hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-meta {
    padding: 24px; position: sticky; top: 96px;
    border: 1px solid var(--line); border-radius: var(--radius-xl);
    background: var(--panel); box-shadow: var(--shadow);
}
.detail-headline h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin: 16px 0 10px; line-height: 1.1; letter-spacing: -0.03em; font-weight: 800;
}
.spec-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.spec {
    padding: 12px; border-radius: 8px;
    background: var(--bg); border: 1px solid var(--line);
}
.spec strong { display: block; font-size: 1.15rem; }
.detail-block {
    padding: 22px;
    border: 1px solid var(--line); border-radius: var(--radius-xl);
    background: var(--panel); box-shadow: var(--shadow);
}
.detail-block + .detail-block { margin-top: 18px; }
.detail-table {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px;
}
.detail-table div {
    display: flex; justify-content: space-between; gap: 12px;
    padding-bottom: 10px; border-bottom: 1px solid var(--line);
}

/* ═══════ CTA BAND ═══════ */

.cta-band {
    padding: 24px 26px; display: flex; flex-wrap: wrap;
    justify-content: space-between; gap: 18px; align-items: center;
    border: 1px solid var(--line); border-radius: var(--radius-xl);
    background: var(--panel); box-shadow: var(--shadow);
}

/* ═══════ FOOTER ═══════ */

.footer-card {
    padding: 28px; margin-top: 28px;
    border: 1px solid var(--line); border-radius: var(--radius-xl);
    background: var(--panel); box-shadow: var(--shadow);
}
.footer-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 20px; }
.footer-card h4 { margin: 0 0 10px; }
.footer-card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; color: var(--muted); }
.footer-meta { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 18px; color: var(--muted); font-size: 0.85rem; }

/* ═══════ CONTROL CENTER ═══════ */

.login-card {
    max-width: 400px; margin: 0 auto; padding: 28px;
    border: 1px solid var(--line); border-radius: var(--radius-xl);
    background: var(--panel); box-shadow: var(--shadow);
}

.tab-bar {
    display: flex; gap: 0; border-bottom: 2px solid var(--line); margin-bottom: 1rem;
}
.tab {
    padding: 0.6rem 1.2rem; background: none; border: none;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    font-size: 0.9rem; font-weight: 500; color: var(--muted); cursor: pointer;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.sub-tab-bar { display: flex; gap: 0; margin-bottom: 1rem; }
.sub-tab {
    padding: 0.4rem 0.9rem; background: none;
    border: 1px solid var(--line); font-size: 0.8rem;
    font-weight: 500; color: var(--muted); cursor: pointer;
}
.sub-tab:first-child { border-radius: 6px 0 0 6px; }
.sub-tab:last-child { border-radius: 0 6px 6px 0; }
.sub-tab + .sub-tab { border-left: none; }
.sub-tab.active { background: var(--accent); color: white; border-color: var(--accent); }

.btn-primary {
    padding: 0.4rem 1rem; background: var(--accent); color: white;
    border: none; border-radius: 6px; font-size: 0.85rem; cursor: pointer;
}
.btn-secondary {
    padding: 0.4rem 1rem; background: white; color: var(--ink);
    border: 1px solid var(--line); border-radius: 6px; font-size: 0.85rem; cursor: pointer;
}
.btn-link {
    background: none; border: none; color: var(--accent); cursor: pointer;
    font-size: 0.85rem; padding: 0;
}
.btn-sm { padding: 0.2rem 0.6rem; font-size: 0.75rem; }

/* Listings table */
.listings-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.listings-table th {
    text-align: left; padding: 0.6rem 0.75rem; border-bottom: 2px solid var(--line);
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.listings-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.listings-table tr:hover td { background: var(--accent-soft); }
.td-title { font-weight: 500; }

/* Connections */
.connect-form { margin-top: 1.5rem; max-width: 400px; }
.connect-form .form-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.connect-form input {
    flex: 1; padding: 0.45rem 0.6rem;
    border: 1px solid var(--line); border-radius: 6px; font-size: 0.9rem;
}
.connection-block {
    border: 1px solid var(--line); border-radius: 8px;
    padding: 0.75rem 1rem; margin-bottom: 0.75rem;
}
.connection-header { margin-bottom: 0.5rem; }
.connection-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.35rem 0; }
.conn-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); width: 4rem; flex-shrink: 0; }

/* Panel (full-screen edit form) */
.panel {
    position: fixed; inset: 0; background: var(--bg);
    z-index: 100; display: flex; flex-direction: column;
}
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.panel-header h2 { margin: 0; font-size: 1.2rem; }
.btn-close {
    background: none; border: none; font-size: 1.5rem;
    cursor: pointer; color: var(--muted); line-height: 1;
}
.panel-body {
    flex: 1; overflow-y: auto; padding: 2rem 1.5rem;
    max-width: 900px; margin: 0 auto; width: 100%;
}
.panel-body form { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 768px) {
    .panel-body { max-width: 1100px; }
    .panel-body form { grid-template-columns: 1fr 340px; column-gap: 2.5rem; align-items: start; }
    .panel-fields { display: flex; flex-direction: column; }
    .panel-sidebar { display: flex; flex-direction: column; gap: 0.85rem; }
    .panel-body form .panel-footer, .panel-body form .form-error { grid-column: 1 / -1; }
}
.panel-footer {
    display: flex; gap: 0.75rem; padding-top: 1.25rem;
    border-top: 1px solid var(--line); margin-top: 1.25rem;
}
.panel label { display: block; margin-bottom: 0.85rem; font-size: 0.85rem; font-weight: 500; }
.panel input, .panel textarea, .panel select {
    display: block; width: 100%; margin-top: 0.25rem; padding: 0.45rem 0.6rem;
    border: 1px solid var(--line); border-radius: 6px; font-size: 0.9rem;
}

/* Fieldsets */
.visibility-fieldset, .distribution-fieldset {
    border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin: 0.85rem 0;
}
.visibility-fieldset legend, .distribution-fieldset legend {
    font-weight: 600; font-size: 0.85rem; padding: 0 0.4rem;
}
.radio-hint {
    display: flex; align-items: flex-start; gap: 0.5rem;
    padding: 0.5rem 0; border-bottom: 1px solid var(--line);
    cursor: pointer; font-weight: 400;
}
.radio-hint:last-child { border-bottom: none; }
.radio-hint input[type="radio"] { margin-top: 0.25rem; }
.radio-hint span { font-size: 0.82rem; line-height: 1.4; }
.radio-hint strong { font-size: 0.9rem; }
.radio-hint em { font-style: normal; color: var(--accent); font-weight: 600; }
.edge-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.4rem 0; border-bottom: 1px solid var(--line);
}
.edge-row:last-child { border-bottom: none; }
.text-muted { color: var(--muted); font-size: 0.85rem; }

/* ═══════ CONTROL CENTER LAYOUT ═══════ */

.page-head {
    display: flex; flex-wrap: wrap; justify-content: space-between;
    align-items: flex-start; gap: 18px; margin-bottom: 22px;
}
.page-head__title h1 {
    margin: 0; font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.1; letter-spacing: -0.03em; font-weight: 800;
}
.page-head__title p { margin: 10px 0 0; max-width: 68ch; color: var(--muted); }

.controls {
    display: grid;
    grid-template-columns: minmax(300px, 1.4fr) repeat(4, minmax(140px, 0.75fr));
    gap: 12px; align-items: end; padding: 18px;
    border: 1px solid var(--line); border-radius: var(--radius-xl);
    background: var(--panel); box-shadow: var(--shadow);
}

.summary-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: 14px; margin: 18px 0 16px; color: var(--muted);
}
.summary-row strong { color: var(--ink); }

.cc-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

/* ═══════ RESPONSIVE ═══════ */

@media (max-width: 1260px) {
    .cc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .controls { grid-template-columns: minmax(280px, 1.4fr) repeat(2, minmax(140px, 1fr)); }
}
@media (max-width: 1020px) {
    .hero-grid, .detail-grid, .footer-grid { grid-template-columns: 1fr; }
    .search-grid, .cards, .spec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-meta { position: static; }
    .cc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .shell { width: min(100% - 20px, var(--content)); }
    .site-nav { display: none; }
    .hero__panel { border-radius: 24px; padding: 18px; }
    .search-grid, .cards, .spec-grid, .detail-table, .metrics { grid-template-columns: 1fr; }
    .controls, .cc-grid { grid-template-columns: 1fr; }
}
