@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg: #F2F0E7;
    --surface: #FFFFFF;
    --ink: #23281F;
    --ink-soft: #6B6E62;
    --border: #E2DFD2;
    --brass: #B4823C;
    --brass-dark: #8F6529;
    --teal: #2F5D53;
    --teal-dark: #234840;
    --error: #A7382C;
    --error-bg: #FBEEEC;
    --success: #2F5D53;
    --success-bg: #EDF3F1;
    --radius: 3px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--teal-dark);
    color: #E9EEE9;
    padding: 28px 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 36px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--brass);
    color: #241A0B;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.brand-name {
    font-family: 'Fraunces', serif;
    font-size: 17px;
    font-weight: 600;
    color: #FFFFFF;
}

.brand-sub {
    font-size: 12.5px;
    color: #AEC0B8;
}

.sidebar-section h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #91A69C;
    font-weight: 500;
    margin: 0 0 12px;
}

.sidebar .muted {
    color: #8CA098;
    font-size: 13px;
}

.recent-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.recent-list li + li { margin-top: 2px; }

.recent-list a {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: #D8E3DE;
    text-decoration: none;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
}

.recent-list a:hover { background: rgba(255,255,255,0.06); }

.recent-list a.active {
    background: var(--brass);
    color: #241A0B;
    font-weight: 500;
}

/* ---------- Main content ---------- */

.content {
    flex: 1;
    padding: 40px 48px;
    max-width: 880px;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
}

.search-bar input {
    flex: 1;
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 15px;
    color: var(--ink);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(47,93,83,0.13);
}

.search-bar button {
    padding: 13px 22px;
    border: none;
    border-radius: var(--radius);
    background: var(--teal);
    color: #fff;
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
}

.search-bar button:hover { background: var(--teal-dark); }
.search-bar button:focus-visible,
a:focus-visible,
input:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- Notices ---------- */

.notice {
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 24px;
    border-left: 3px solid var(--error);
    background: var(--error-bg);
}

.notice-error strong { color: var(--error); font-size: 14px; }
.notice p { margin: 4px 0 0; font-size: 13.5px; color: #5A4340; }

.notice-success {
    border-left-color: var(--success);
    background: var(--success-bg);
}
.notice-success p { color: var(--success); margin: 0; }

/* ---------- Multi-account UI ---------- */

.account-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--success-bg);
    color: var(--success);
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}

.recent-account {
    display: block;
    font-size: 11px;
    color: var(--ink-soft);
    margin-top: 1px;
}

.account-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 420px;
}

.account-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.account-form input[type="text"] {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}

.account-form input[type="text"]:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
}

.accounts-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.accounts-table th,
.accounts-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

.accounts-table th {
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.accounts-table-actions {
    display: flex;
    gap: 8px;
}

.accounts-table-actions form { margin: 0; }

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
}

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid transparent;
}
.btn-danger:hover { background: var(--error); color: #fff; }

/* ---------- Listing card ---------- */

.listing-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--brass);
    border-radius: var(--radius);
    padding: 32px 34px;
}

.listing-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.listing-ref {
    font-size: 12.5px;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
}

.listing-header h1 {
    font-family: 'Fraunces', serif;
    font-size: 26px;
    font-weight: 600;
    margin: 0 0 6px;
    line-height: 1.25;
}

.listing-location {
    color: var(--ink-soft);
    font-size: 14px;
}

.listing-price {
    font-family: 'Fraunces', serif;
    font-size: 22px;
    font-weight: 600;
    color: var(--teal-dark);
    white-space: nowrap;
}

.listing-specs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}

.spec-label {
    display: block;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    margin-bottom: 3px;
}

.spec-value {
    display: block;
    font-size: 15px;
    font-weight: 500;
}

.listing-description {
    color: #454A3E;
    font-size: 14.5px;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 22px 0 12px;
}

.gallery-header h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.gallery-item {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--bg);
}

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

.empty-state, .empty-state-large {
    color: var(--ink-soft);
    font-size: 14px;
}

.empty-state-large {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
}

/* ---------- Actions ---------- */

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 26px;
}

.pdf-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--ink, #333);
    cursor: pointer;
}

.pdf-option input[type="checkbox"] {
    cursor: pointer;
}

.duplicate-action {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.duplicate-hint {
    font-size: 12.5px;
    color: var(--ink-soft);
    margin: 8px 0 0;
}

.duplicate-action #duplicateResult:empty {
    margin: 0;
}

.duplicate-action #duplicateResult {
    margin-top: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-primary {
    background: var(--teal);
    color: #fff;
}
.btn-primary:hover { background: var(--teal-dark); }

.btn-secondary {
    background: var(--surface);
    border-color: var(--brass);
    color: var(--brass-dark);
}
.btn-secondary:hover { background: #FBF4E8; }

.btn-disabled {
    background: var(--border) !important;
    color: var(--ink-soft) !important;
    pointer-events: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; }
    .content { padding: 24px; }
    .listing-specs { grid-template-columns: repeat(2, 1fr); }
    .gallery { grid-template-columns: repeat(2, 1fr); }
    .listing-header { flex-direction: column; }
}

/* ---------- Account form: <select> to match text inputs ---------- */

.account-form select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--ink);
}

.account-form select:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
}

/* ---------- Agent link field (Manage Agents table) ---------- */

.link-field {
    width: 260px;
    max-width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    font-family: monospace;
    color: var(--ink-soft);
    margin-right: 6px;
    background: var(--bg);
}

/* ---------- Loading overlay (search results) ---------- */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(35, 40, 31, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay[hidden] {
    display: none;
}

.loading-box {
    background: var(--surface);
    border-radius: 8px;
    padding: 28px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.loading-box p {
    margin: 0;
    font-size: 14px;
    color: var(--ink);
    font-weight: 600;
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: pf-spin 0.8s linear infinite;
}

@keyframes pf-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Login page ---------- */

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 36px 32px;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.login-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.login-card input[type="password"] {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}

/* ---------- Agent-facing page (no admin sidebar) ---------- */

.shell-agent {
    display: block;
    max-width: 720px;
    margin: 0 auto;
}

.content-agent {
    padding: 40px 24px;
}

@media (max-width: 760px) {
    .content-agent { padding: 24px 16px; }
}
