:root {
  --red: #ea002a;
  --red-dark: #b90021;
  --black: #0c0c0d;
  --ink: #202124;
  --muted: #6c6c70;
  --line: #e2e2e4;
  --soft: #f5f5f6;
  --stone: #d7d3c7;
  --warm-grey: #a59d95;
  --white: #fff;
  --success: #177245;
  --danger: #b42318;
  --shadow: 0 20px 50px rgba(0,0,0,.08);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--soft); font-size: 16px; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
input, select, textarea {
  width: 100%; border: 1px solid #cfcfd2; border-radius: 10px; background: white; color: var(--ink);
  padding: .78rem .9rem; min-height: 46px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(234,0,42,.12); }
label { font-weight: 650; font-size: .92rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 3.4vw, 3.4rem); line-height: 1.05; letter-spacing: -.045em; margin-bottom: .65rem; }
h2 { font-size: clamp(1.35rem, 2vw, 1.9rem); line-height: 1.15; letter-spacing: -.025em; margin-bottom: .4rem; }
h3 { font-size: 1.05rem; margin-bottom: .55rem; }
.muted { color: var(--muted); }
.eyebrow { color: var(--red); font-weight: 800; font-size: .75rem; letter-spacing: .115em; text-transform: uppercase; margin-bottom: .6rem; }
.stack { display: grid; gap: .75rem; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 46px; padding: .72rem 1.1rem;
  border: 1px solid transparent; border-radius: 10px; font-weight: 750; text-decoration: none; transition: .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--red); color: white; box-shadow: 0 8px 18px rgba(234,0,42,.18); }
.button-primary:hover { background: var(--red-dark); }
.button-secondary { background: var(--black); color: white; }
.button-quiet { background: white; color: var(--ink); border-color: var(--line); }
.button-small { min-height: 38px; padding: .48rem .78rem; font-size: .85rem; }
.text-link { color: var(--red); font-weight: 700; text-decoration: none; text-align: center; }

.brand { display: inline-flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; background: var(--black); color: white; border-left: 8px solid var(--red); border-radius: 4px; font-size: .82rem; font-weight: 900; letter-spacing: -.04em; }
.brand-mark-large { width: 64px; height: 64px; border-left-width: 12px; font-size: 1.1rem; }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: .98rem; }
.brand-copy small { color: var(--muted); font-size: .74rem; margin-top: .22rem; }

.topbar { min-height: 72px; padding: .8rem clamp(1rem, 3vw, 3.5rem); background: white; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.topbar-actions form { margin: 0; }
.nav-link { text-decoration: none; color: var(--muted); font-size: .9rem; font-weight: 700; padding: .5rem .65rem; border-radius: 8px; }
.nav-link:hover, .nav-link.is-active { color: var(--black); background: var(--soft); }
.user-chip { background: var(--soft); border-radius: 999px; padding: .5rem .8rem; font-size: .86rem; font-weight: 700; }

.page-shell { width: min(1460px, calc(100% - 2rem)); margin: 0 auto; padding: 2.4rem 0 4rem; }
.page-heading, .property-heading { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 1.8rem; }
.property-meta { color: var(--muted); margin: 0; }
.property-select { min-width: min(340px, 100%); display: grid; gap: .35rem; color: var(--muted); }
.panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.035); padding: 1.4rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; margin-bottom: 1rem; }
.panel-heading h2, .panel-heading p { margin-bottom: 0; }
.alert { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1.25rem; font-weight: 650; }
.alert-success { color: #0f5d37; background: #e9f7ef; border: 1px solid #b9e4ca; }
.alert-error { color: #8a1c13; background: #fff0ed; border: 1px solid #f4c2bb; }

.login-page { background: white; }
.login-shell { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; }
.login-brand-panel { background: var(--black); color: white; display: grid; align-items: end; padding: clamp(2rem, 6vw, 6rem); position: relative; overflow: hidden; }
.login-brand-panel::after { content: ''; position: absolute; width: 36vw; aspect-ratio: 1; border: 8vw solid var(--red); border-radius: 50%; right: -20vw; top: -18vw; opacity: .9; }
.login-brand-panel::before { content: ''; position: absolute; width: 1px; height: 70%; background: rgba(255,255,255,.18); right: 18%; bottom: 0; transform: rotate(28deg); }
.login-brand-inner { max-width: 650px; position: relative; z-index: 1; }
.login-brand-inner .eyebrow { margin-top: 2rem; }
.login-brand-inner h1 { font-size: clamp(2.6rem, 5vw, 5.2rem); max-width: 780px; }
.login-brand-inner > p:last-child { color: #c9c9cc; max-width: 580px; font-size: 1.12rem; }
.login-form-panel { display: grid; place-items: center; padding: 2rem; }
.login-card { width: min(440px, 100%); display: grid; gap: 1.4rem; }
.login-card h2 { font-size: 2rem; }
.otp-input { font-size: 1.8rem; text-align: center; letter-spacing: .55rem; font-weight: 800; }
.dev-code { padding: .7rem .9rem; background: #fff6d8; color: #5b4610; border: 1px solid #eed991; border-radius: 10px; font-size: .9rem; }
.security-note { color: var(--muted); font-size: .83rem; text-align: center; border-top: 1px solid var(--line); padding-top: 1rem; margin: 0; }
.turnstile-wrap { min-height: 142px; display: flex; align-items: center; justify-content: center; padding: .35rem 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; min-height: 190px; display: flex; flex-direction: column; }
.kpi-card.is-muted { opacity: .65; }
.kpi-card-top { display: flex; align-items: start; justify-content: space-between; gap: .6rem; color: var(--muted); font-size: .87rem; font-weight: 700; }
.source-badge { display: inline-flex; white-space: nowrap; padding: .25rem .48rem; border-radius: 6px; font-size: .68rem; font-weight: 850; letter-spacing: .02em; }
.source-centris { background: #eeeeef; color: #262629; }
.source-realtor_ca { background: #ffe8ed; color: #a7001e; }
.kpi-value { font-size: clamp(2.35rem, 5vw, 4.3rem); letter-spacing: -.06em; line-height: 1; margin: 1.25rem 0 .8rem; color: var(--black); }
.kpi-comparison { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .8rem; }
.change-pill { padding: .2rem .42rem; border-radius: 5px; font-weight: 800; }
.change-pill.up { color: var(--success); background: #e8f6ee; }
.change-pill.down { color: var(--danger); background: #fff0ed; }
.kpi-total { color: var(--muted); font-size: .78rem; margin: auto 0 0; padding-top: .75rem; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, .85fr); gap: 1rem; margin-bottom: 1rem; }
.chart-panel { min-height: 480px; }
.chart-wrap { position: relative; height: 340px; }
.tab-list { display: inline-flex; padding: .25rem; border-radius: 10px; background: var(--soft); }
.tab-button { border: 0; border-radius: 8px; padding: .55rem .78rem; background: transparent; color: var(--muted); font-size: .85rem; font-weight: 750; }
.tab-button.is-active { background: white; color: var(--black); box-shadow: 0 2px 7px rgba(0,0,0,.08); }
.chart-note { margin: .85rem 0 0; color: var(--muted); font-size: .76rem; }
.partial-key { display: inline-block; width: 8px; height: 8px; background: var(--warm-grey); border-radius: 50%; vertical-align: middle; margin-right: .35rem; }
.insight-panel { background: var(--black); color: white; border-color: var(--black); }
.insight-panel .eyebrow { color: #ff4969; }
.insight-panel .muted, .insight-panel .note-meta { color: #bdbdc2; }
.insight-panel blockquote { font-size: 1.28rem; line-height: 1.55; margin: 1.4rem 0; border-left: 4px solid var(--red); padding-left: 1rem; }
.note-meta { font-size: .8rem; }
.admin-inline { margin-top: 2rem; border-top: 1px solid #343438; padding-top: 1rem; }
.admin-inline summary { cursor: pointer; font-weight: 750; margin-bottom: 1rem; }
.admin-inline textarea { resize: vertical; }
.client-resources { display: grid; gap: 1.35rem; margin-top: 1.6rem; padding-top: 1.4rem; border-top: 1px solid #343438; }
.client-resource-section { display: grid; gap: .75rem; }
.client-resource-heading { display: grid; gap: .18rem; }
.client-resource-heading h3 { color: white; font-size: .98rem; line-height: 1.3; margin: 0; }
.client-resource-heading span { color: #9f9fa6; font-size: .7rem; }
.client-document-list, .client-video-list { display: grid; gap: .55rem; }
.client-document { display: flex; align-items: center; gap: .7rem; padding: .7rem; border: 1px solid #343438; border-radius: 10px; background: #171719; color: white; text-decoration: none; transition: .18s ease; }
.client-document:hover { border-color: #66666d; background: #202023; transform: translateY(-1px); }
.client-document > span:last-child { min-width: 0; display: grid; }
.client-document strong { overflow: hidden; text-overflow: ellipsis; font-size: .82rem; line-height: 1.35; }
.client-document small { color: #a9a9af; font-size: .68rem; margin-top: .15rem; }
.pdf-badge { flex: 0 0 auto; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--red); color: white; font-size: .67rem; font-weight: 900; letter-spacing: .04em; }
.client-video { display: grid; border: 1px solid #343438; border-radius: 11px; overflow: hidden; background: #171719; color: white; text-decoration: none; transition: .18s ease; }
.client-video:hover { border-color: #66666d; transform: translateY(-1px); }
.video-preview { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #242427; }
.video-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.play-button { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; transform: translate(-50%,-50%); display: grid; place-items: center; padding-left: 3px; border-radius: 50%; background: rgba(234,0,42,.94); color: white; font-size: 1rem; box-shadow: 0 8px 22px rgba(0,0,0,.35); }
.video-copy { display: grid; padding: .72rem .8rem .78rem; }
.video-copy strong { font-size: .82rem; line-height: 1.35; }
.video-copy small { color: #a9a9af; font-size: .68rem; margin-top: .16rem; }
.detail-panel { margin-bottom: 1rem; }
.listing-row-wrap { display: grid; }
.listing-row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .9rem 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; }
.listing-row > div { display: grid; }
.listing-row strong { color: var(--ink); }
.global-video-panel { display: grid; grid-template-columns: minmax(230px,.65fr) minmax(420px,1.35fr); align-items: center; gap: clamp(1.25rem,3vw,3rem); margin-bottom: 1rem; }
.global-video-copy h2 { margin-bottom: .6rem; }
.global-video-copy p:last-child { margin-bottom: 0; }
.youtube-frame { position: relative; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; background: #111; }
.youtube-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.summary-strip { display: grid; grid-template-columns: repeat(4,1fr); background: var(--black); color: white; border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.summary-strip > div { padding: 1.15rem 1.3rem; display: grid; border-right: 1px solid #303034; }
.summary-strip > div:last-child { border: 0; }
.summary-strip strong { font-size: 1.8rem; }
.summary-strip span { color: #bfc0c4; font-size: .78rem; }
.section-nav { display: flex; gap: .4rem; padding: .45rem; background: white; border: 1px solid var(--line); border-radius: 12px; position: sticky; top: 82px; z-index: 10; margin-bottom: 1rem; overflow-x: auto; }
.section-nav a { padding: .6rem .9rem; border-radius: 8px; color: var(--muted); font-size: .86rem; font-weight: 750; text-decoration: none; white-space: nowrap; }
.section-nav a:hover { color: var(--black); background: var(--soft); }
.admin-section { scroll-margin-top: 150px; background: white; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; padding: 1.4rem; }
.section-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1.2rem; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-help { max-width: 480px; text-align: right; font-size: .85rem; }
.admin-two-columns { display: grid; grid-template-columns: 1.15fr .85fr; gap: 1rem; margin-bottom: 1rem; }
.upload-card { border: 1px solid var(--line); border-radius: 13px; padding: 1rem; display: grid; gap: .8rem; }
.import-errors { margin-top: .5rem; max-width: 32rem; color: var(--muted); font-size: .78rem; }
.import-errors summary { cursor: pointer; font-weight: 700; color: var(--red); }
.import-errors ul { margin: .45rem 0 0; padding-left: 1.1rem; }
.import-errors li + li { margin-top: .3rem; }
.import-errors p { margin: .4rem 0 0; }
.drop-zone { min-height: 175px; display: grid; place-items: center; align-content: center; gap: .35rem; text-align: center; padding: 1.2rem; border: 1.5px dashed #b7b7bb; border-radius: 10px; background: #fafafa; cursor: pointer; }
.drop-zone:hover { border-color: var(--red); background: #fff8f9; }
.drop-zone span { color: var(--muted); font-size: .82rem; font-weight: 500; }
.drop-zone .upload-icon { color: var(--red); font-size: 2rem; font-weight: 400; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.selected-files { color: var(--muted); font-size: .82rem; }
.compact-panel { box-shadow: none; }
.compact-panel h3 { margin-bottom: .8rem; }
.check-list { display: grid; gap: .65rem; list-style: none; padding: 0; margin: 0; color: var(--muted); }
.check-list li::before { content: '✓'; color: var(--success); font-weight: 900; margin-right: .55rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: .78rem .85rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .81rem; vertical-align: middle; }
th { background: #f8f8f9; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .055em; }
tbody tr:last-child td { border-bottom: 0; }
.empty-cell { text-align: center; padding: 2rem; color: var(--muted); }
.status { display: inline-flex; padding: .25rem .5rem; border-radius: 6px; font-size: .68rem; font-weight: 800; text-transform: capitalize; }
.status-completed, .status-completed_with_errors { background: #e8f6ee; color: #12613a; }
.status-failed { background: #fff0ed; color: #981e15; }
.status-draft, .status-processing { background: #eeeeef; color: #55555b; }
.property-admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .8rem; }
.property-admin-card { border: 1px solid var(--line); border-radius: 13px; padding: 1rem; display: grid; grid-template-columns: 1fr auto; gap: .8rem; }
.property-admin-main h3 { margin: .6rem 0 .15rem; }
.property-admin-main > p { color: var(--muted); font-size: .82rem; }
.property-admin-stats { display: flex; flex-wrap: wrap; gap: .7rem; color: var(--muted); font-size: .76rem; }
.property-admin-actions { display: flex; gap: .4rem; align-items: start; }
.property-resources-admin { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: .75rem; }
.property-resources-admin > summary { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .85rem; font-weight: 800; }
.property-resources-admin > summary span { display: inline-grid; place-items: center; min-width: 23px; height: 23px; padding: 0 .35rem; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: .7rem; }
.resource-admin-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; margin-top: .8rem; }
.resource-admin-form { align-content: start; border: 1px solid var(--line); border-radius: 11px; padding: .9rem; background: #fafafa; }
.resource-admin-form h4 { margin: 0; font-size: .9rem; }
.resource-admin-form label { display: grid; gap: .3rem; font-size: .78rem; }
.resource-admin-form input, .resource-admin-form select { min-height: 40px; padding: .58rem .68rem; font-size: .8rem; }
.optional-label { color: var(--muted); font-size: .68rem; font-weight: 500; }
.form-help { color: var(--muted); font-size: .72rem; margin: 0; }
.resource-notice { margin: .8rem 0 0; padding: .75rem .85rem; border-radius: 9px; background: #f5f8f6; color: #35604a; font-size: .72rem; line-height: 1.5; }
.resource-admin-list { display: grid; margin-top: .8rem; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.resource-admin-item { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .7rem .8rem; background: white; border-bottom: 1px solid var(--line); }
.resource-admin-item:last-child { border-bottom: 0; }
.resource-admin-item > div { min-width: 0; display: grid; }
.resource-admin-item strong { overflow: hidden; text-overflow: ellipsis; font-size: .78rem; }
.resource-admin-item span { color: var(--muted); font-size: .68rem; }
.resource-admin-item form { flex: 0 0 auto; }
.inline-form { grid-column: 1 / -1; display: flex; gap: .45rem; align-items: center; border-top: 1px solid var(--line); padding-top: .75rem; }
.inline-form select { min-width: 180px; }
.inline-form .button { white-space: nowrap; }
.panel-table { height: fit-content; }
.common-content-grid { margin-bottom: 0; }
.global-video-admin-state { align-content: start; display: grid; justify-items: start; gap: .7rem; }
.global-video-admin-state h3, .global-video-admin-state p { margin: 0; }

.centered-state { min-height: calc(100vh - 150px); display: grid; place-items: center; }
.empty-state { text-align: center; max-width: 580px; background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(2rem,5vw,4rem); box-shadow: var(--shadow); }
.empty-state .brand-mark { margin: 0 auto 1.5rem; }
.empty-state p { color: var(--muted); }
.error-code { display: inline-block; color: var(--red); font-weight: 900; font-size: 1.1rem; margin-bottom: .7rem; }
.footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.2rem clamp(1rem,3vw,3.5rem); border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; background: white; }

@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 38vh; align-items: center; }
  .login-brand-panel::after { width: 60vw; right: -30vw; top: -30vw; }
  .login-brand-inner h1 { font-size: clamp(2.3rem, 9vw, 4rem); }
  .login-form-panel { min-height: 62vh; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card:last-child { grid-column: 1 / -1; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .global-video-panel { grid-template-columns: 1fr; }
  .admin-two-columns, .property-admin-grid { grid-template-columns: 1fr; }
  .resource-admin-grid { grid-template-columns: 1fr; }
  .user-chip, .brand-copy small { display: none; }
}

@media (max-width: 680px) {
  .topbar { min-height: 64px; padding: .65rem .8rem; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-copy strong { font-size: .88rem; }
  .topbar-actions .nav-link { display: none; }
  .page-shell { width: min(100% - 1rem, 1460px); padding-top: 1.35rem; }
  .page-heading, .property-heading { align-items: stretch; flex-direction: column; gap: 1rem; }
  .property-select { min-width: 100%; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card:last-child { grid-column: auto; }
  .kpi-card { min-height: 165px; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .chart-wrap { height: 285px; }
  .tab-list { align-self: start; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-strip > div:nth-child(2) { border-right: 0; }
  .summary-strip > div:nth-child(-n+2) { border-bottom: 1px solid #303034; }
  .property-admin-card { grid-template-columns: 1fr; }
  .property-admin-actions { grid-row: 2; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .section-help { text-align: left; }
  .listing-row { align-items: start; flex-direction: column; }
  .footer { flex-direction: column; }
}

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