:root {
    --brand-primary: #334155;
    --brand-primary-soft: rgba(51, 65, 85, 0.08);
    --brand-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --text: #0f172a;
    --text-muted: #64748b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--brand-font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.site-header {
    background: var(--brand-primary);
    color: white;
    padding: 2.5rem 0;
}

.header-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}

.brand-block {
    min-width: 0;
    flex: 1 1 280px;
}

.site-header .brand {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

.site-header .tagline {
    margin: 0.4rem 0 0;
    opacity: 0.85;
    font-size: 1rem;
}

.header-right {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}

.signin-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.4rem 0;
    white-space: nowrap;
}
.signin-link:hover { color: white; }

.tenant-meta {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 0.75rem;
    row-gap: 0.25rem;
    margin: 0;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    align-self: flex-start;
}

.tenant-meta dt {
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.7rem;
}

.tenant-meta dd {
    margin: 0;
    font-weight: 600;
    word-break: break-all;
}

main {
    padding: 3rem 0;
}

.listings-section h2 {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    color: var(--text);
}

.status {
    color: var(--text-muted);
    padding: 1rem 0;
}

.status.error {
    color: #b91c1c;
}

.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.listing-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.listing-card:hover {
    border-color: var(--brand-primary);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}

.listing-card .card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.listing-card .tag {
    display: inline-block;
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.origin-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--origin-color, #475569);
    background: color-mix(in srgb, var(--origin-color, #475569) 12%, transparent);
    margin-left: auto;
}

.origin-badge::before {
    content: '';
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--origin-color, #475569);
}

.listing-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.listing-card .desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 0.85rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.listing-card .price {
    font-weight: 700;
    color: var(--brand-primary);
    font-size: 1.05rem;
}

.site-footer {
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    background: white;
}

.site-footer p {
    margin: 0.25rem 0;
}

.site-footer .meta {
    font-size: 0.75rem;
    color: #94a3b8;
}

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

.login-wrap {
    max-width: 360px;
    margin: 6rem auto;
    padding: 2rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
}
.login-wrap h1 { margin: 0 0 1.5rem; font-size: 1.5rem; }
.login-wrap label { display: block; margin-bottom: 1rem; font-size: 0.9rem; font-weight: 500; }
.login-wrap input { display: block; width: 100%; margin-top: 0.3rem; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; }
.login-wrap button[type="submit"] { width: 100%; padding: 0.6rem; background: #1e40af; color: white; border: none; border-radius: 6px; font-size: 1rem; cursor: pointer; }
.form-error { color: #b91c1c; font-size: 0.85rem; margin-top: 0.75rem; }

.control-header {
    background: #0f172a;
    color: white;
    padding: 1rem 0;
}
.control-header h1 { margin: 0; font-size: 1.3rem; }
.control-header-inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.control-top-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
    flex-wrap: wrap;
}
.control-top-bar select {
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 0.9rem;
}
.user-info { font-size: 0.8rem; opacity: 0.7; }

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    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(--text-muted);
    cursor: pointer;
}
.tab.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}
.btn-primary {
    padding: 0.4rem 1rem;
    background: #1e40af;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}
.btn-secondary {
    padding: 0.4rem 1rem;
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}
.btn-link {
    background: none;
    border: none;
    color: #60a5fa;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
}

/* 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(--border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.listings-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.listings-table tr:hover td { background: var(--bg); }
.td-title { font-weight: 500; }

.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);
}

.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; }

/* Panel */
.panel {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.panel[hidden] { display: none; }
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    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(--text-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 {
        grid-column: 1 / -1;
    }
    .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(--border);
    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(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}
.form-row { display: flex; gap: 1rem; }
.form-row label { flex: 1; }

/* Visibility fieldset */
.visibility-fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin: 0.85rem 0;
}
.visibility-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(--border);
    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(--brand-primary); font-weight: 600; }

/* Distribution */
.distribution-fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin: 0.85rem 0;
}
.distribution-fieldset legend { font-weight: 600; font-size: 0.85rem; padding: 0 0.4rem; }
.edge-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}
.edge-row:last-child { border-bottom: none; }
.btn-sm { padding: 0.2rem 0.6rem; font-size: 0.75rem; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }
