:root {
  --tv-primary: #244AA5;
  --tv-primary-dark: #1b3a85;
  --tv-primary-deep: #102559;
  --tv-primary-soft: #e3eafa;
  --tv-accent: #f0b100;
  --tv-accent-soft: #fdf3d0;
  --tv-bg: #f5f7fa;
  --tv-ink: #0f172a;
  --tv-body: #334155;
  --tv-muted: #64748b;
  --tv-card: #ffffff;
  --tv-border: #e5e9f0;
  --tv-sidebar-w: 248px;
  --bs-body-font-family: "Geist", "Montserrat", "Segoe UI", system-ui, sans-serif;
  --bs-link-color-rgb: 36, 74, 165;
  --bs-link-hover-color-rgb: 27, 58, 133;
}

body { background: var(--tv-bg); color: var(--tv-ink); font-family: var(--bs-body-font-family); font-size: .92rem; -webkit-font-smoothing: antialiased; }
h1, .h1, h2, .h2, h3, .h3 { letter-spacing: -.01em; }

/* ---------------------------------------------------------------- icons */
.tv-icon, svg.lucide { width: 1.1em; height: 1.1em; stroke-width: 2; vertical-align: -.2em; flex-shrink: 0; }
i.tv-icon { display: inline-block; }
.icon-lg { width: 2.2rem !important; height: 2.2rem !important; stroke-width: 1.5; }
.icon-xl { width: 3rem !important; height: 3rem !important; stroke-width: 1.5; }
.btn .tv-icon { margin-top: -.1em; }

/* ---------------------------------------------------------------- layout */
.tv-shell { display: flex; min-height: 100vh; }
.tv-main { flex: 1; min-width: 0; padding: 1.75rem 2rem 3rem; }
.tv-sidebar { background: radial-gradient(120% 60% at 0% 100%, rgba(240,177,0,.10) 0%, transparent 60%), linear-gradient(180deg, var(--tv-primary-deep) 0%, var(--tv-primary) 100%); color: #fff; box-shadow: 1px 0 0 rgba(255,255,255,.06), 4px 0 24px rgba(16,37,89,.12); }
.tv-sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: 1.5rem 1rem 1.25rem; }
@media (min-width: 992px) {
  .tv-sidebar { position: sticky; top: 0; width: var(--tv-sidebar-w); height: 100vh; flex-shrink: 0; }
}
@media (max-width: 991.98px) {
  .tv-sidebar { --bs-offcanvas-width: 270px; }
  .tv-main { padding: 1.25rem 1rem 2.5rem; }
}
.tv-topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; background: var(--tv-primary-deep); box-shadow: 0 2px 12px rgba(16,37,89,.25); }
.tv-icon-btn { color: #fff; border: 1px solid rgba(255,255,255,.2); padding: .3rem .5rem; }
.tv-icon-btn:hover { color: #fff; background: rgba(255,255,255,.1); }

.tv-brand { display: flex; align-items: center; padding: .15rem .75rem 1.25rem; margin-bottom: .35rem; border-bottom: 1px solid rgba(255,255,255,.1); text-decoration: none; }
.tv-brand img { display: block; width: 138px; height: auto; transition: opacity .15s ease; }
.tv-brand:hover img { opacity: .88; }
.tv-topbar .tv-brand { padding: 0; margin: 0; border: 0; }
.tv-topbar .tv-brand img { width: auto; height: 24px; }
.tv-login-logo { display: block; width: 190px; max-width: 100%; height: auto; margin: 0 auto; }

.tv-nav-label { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.45); margin: 1rem .75rem .4rem; }
.tv-nav { display: flex; flex-direction: column; gap: .15rem; }
.tv-nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 10px; color: rgba(255,255,255,.75); text-decoration: none; font-weight: 500; transition: background-color .15s ease, color .15s ease; }
.tv-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.tv-nav a.active { color: var(--tv-primary-deep); background: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--tv-accent), 0 4px 14px rgba(0,0,0,.15); }
.tv-nav a.active .tv-icon { color: var(--tv-primary); }
.tv-region { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: rgba(255,255,255,.6); padding: .5rem .75rem; }
.tv-region .tv-icon { color: var(--tv-accent); }
.tv-logout { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: 10px; color: rgba(255,255,255,.75); text-decoration: none; border: 1px solid rgba(255,255,255,.15); transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.tv-logout:hover { color: #fff; background: rgba(255,255,255,.08); border-color: rgba(240,177,0,.55); }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 800; margin: 0 0 .2rem; }
.page-head p { color: var(--tv-muted); margin: 0; max-width: 640px; }
.page-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 .25rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h1 .badge, .page-title .badge { font-size: .72rem; font-weight: 600; letter-spacing: .01em; }

/* ---------------------------------------------------------------- cards / stats */
.tv-card { background: var(--tv-card); border: 1px solid var(--tv-border); border-radius: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.tv-stat { padding: 1.1rem 1.25rem; height: 100%; }
.tv-stat .label { color: var(--tv-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.tv-stat .value { font-size: 1.75rem; font-weight: 800; line-height: 1.2; color: var(--tv-ink); }
.tv-stat .icon { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; }
.tv-stat .icon .tv-icon { width: 22px; height: 22px; }
.tone-teal { background: var(--tv-primary-soft); color: var(--tv-primary); }
.tone-green { background: #dcfce7; color: #15803d; }
.tone-violet { background: #ede9fe; color: #7c3aed; }
.tone-amber { background: var(--tv-accent-soft); color: #9a7200; }
.tone-red { background: #fee2e2; color: #b91c1c; }
.tone-slate { background: #f1f5f9; color: #475569; }
@media (max-width: 575.98px) {
  .tv-stat { padding: .9rem 1rem; }
  .tv-stat .icon { display: none; }
  .tv-stat .value { font-size: 1.4rem; }
}

.tv-filters .form-label { font-size: .72rem; font-weight: 600; color: var(--tv-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .25rem; }
.form-control, .form-select { border-radius: 10px; border-color: #dbe1ea; font-size: .9rem; }
.form-control:focus, .form-select:focus { border-color: #8aa3e3; box-shadow: 0 0 0 .2rem rgba(36,74,165,.15); }
.form-check-input:checked { background-color: var(--tv-primary); border-color: var(--tv-primary); }
.input-group > .form-control { border-radius: 10px; }
.input-group > .form-control:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .form-control:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.tv-filters .form-select { padding-right: 2rem; background-position: right .65rem center; text-overflow: ellipsis; }
.tv-filters .form-control::placeholder { color: #9aa5b5; }
.tv-filters .filter-checks { display: flex; align-items: center; min-width: 0; height: calc(1.5em + .75rem + 2px); margin: 0; padding: 0 .75rem; border: 1px solid #dbe1ea; border-radius: 10px; background: #fff; cursor: pointer; }
.tv-filters .filter-checks:hover { border-color: #b9c4d6; }
.tv-filters .filter-checks .form-check { display: flex; align-items: center; gap: .5rem; margin: 0; padding-left: 0; white-space: nowrap; min-width: 0; }
.tv-filters .filter-checks .form-check-input { float: none; margin: 0; flex-shrink: 0; cursor: pointer; }
.tv-filters .filter-checks .form-check-label { color: var(--tv-body); font-size: .88rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.tv-filters .btn-tv { height: calc(1.5em + .75rem + 2px); }

.btn { border-radius: 10px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { border-radius: 8px; }
.btn-tv { background: var(--tv-primary); color: #fff; border: 1px solid var(--tv-primary); }
.btn-tv:hover, .btn-tv:focus { background: var(--tv-primary-dark); border-color: var(--tv-primary-dark); color: #fff; }
.btn-outline-secondary { border-color: #dbe1ea; color: var(--tv-body); background: #fff; }
.btn-outline-secondary:hover, .btn-outline-secondary.active { background: #f1f5f9 !important; border-color: #cbd5e1 !important; color: var(--tv-ink) !important; }
.btn-outline-primary { color: var(--tv-primary); border-color: #b9c8ee; background: #fff; }
.btn-outline-primary:hover, .btn-outline-primary:focus { background: var(--tv-primary); border-color: var(--tv-primary); color: #fff; }
.text-bg-primary { background-color: var(--tv-primary) !important; }
.btn-group .btn-outline-secondary.active { background: var(--tv-primary) !important; border-color: var(--tv-primary) !important; color: #fff !important; }
.pagination .page-link { border-radius: 8px !important; margin: 0 .15rem; border-color: var(--tv-border); color: var(--tv-body); }
.pagination .active .page-link { background: var(--tv-primary); border-color: var(--tv-primary); color: #fff; }

/* ---------------------------------------------------------------- property cards */
.prop-card { overflow: hidden; height: 100%; transition: transform .15s ease, box-shadow .15s ease; }
.prop-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(15,23,42,.10); }
.prop-img { position: relative; aspect-ratio: 4 / 3; background: linear-gradient(135deg, #eef2f8 0%, #dfe6f1 100%); overflow: hidden; }
.prop-img img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.prop-card:hover .prop-img img { transform: scale(1.03); }
.prop-img .no-img { position: absolute; inset: 0; display: flex; flex-direction: column; gap: .4rem; align-items: center; justify-content: center; color: #94a3b8; font-size: .75rem; font-weight: 500; }
.prop-img .no-img .tv-icon { width: 2rem; height: 2rem; stroke-width: 1.5; }
.prop-img .badges { position: absolute; z-index: 2; top: .65rem; left: .65rem; display: flex; gap: .35rem; }
.badge { font-weight: 600; border-radius: 7px; padding: .35em .6em; }
.badge-sale { background: var(--tv-primary); color: #fff; }
.badge-rent { background: var(--tv-accent); color: #1a1a1a; }
.badge-stay { background: #ff5a5f; color: #fff; }
.badge-type { background: rgba(255,255,255,.94); color: var(--tv-ink); }
.prop-img .badge { box-shadow: 0 1px 4px rgba(15,23,42,.18); }
.badge .spinner-border-sm { width: .65rem; height: .65rem; border-width: .14em; vertical-align: -.05em; margin-right: .2rem; }

.status-badge { display: inline-flex; align-items: center; gap: .35em; font-weight: 600; text-transform: capitalize; }
.status-badge::before { content: ""; width: .45em; height: .45em; border-radius: 50%; background: currentColor; }
.status-badge:has(.spinner-border)::before { display: none; }
.status-badge.text-bg-success { background: #dcfce7 !important; color: #166534 !important; }
.status-badge.text-bg-warning { background: #fef3c7 !important; color: #92400e !important; }
.status-badge.text-bg-danger { background: #fee2e2 !important; color: #b91c1c !important; }
.status-badge.text-bg-primary { background: var(--tv-primary-soft) !important; color: var(--tv-primary-dark) !important; }
.status-badge.text-bg-info { background: #e0f2fe !important; color: #075985 !important; }
.status-badge.text-bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.tag-light { display: inline-block; background: #f1f5f9; color: var(--tv-muted); border-radius: 6px; padding: .05rem .4rem; font-size: .68rem; font-weight: 600; }
.adapter-tag { display: inline-block; font-family: "Cascadia Code", Consolas, monospace; font-size: .75rem; background: #f1f5f9; color: var(--tv-body); border: 1px solid var(--tv-border); border-radius: 6px; padding: .1rem .45rem; }
.amenity { display: inline-flex; align-items: center; gap: .3rem; border-radius: 99px; padding: .25rem .7rem; font-size: .8rem; font-weight: 500; }
.amenity.yes { background: #dcfce7; color: #166534; }
.amenity.no { background: #f1f5f9; color: #64748b; text-decoration: line-through; }
.prop-price { font-size: 1.25rem; font-weight: 800; color: var(--tv-ink); }
.prop-price small { font-size: .75rem; font-weight: 600; color: var(--tv-muted); }
.prop-title { font-weight: 600; font-size: .95rem; color: var(--tv-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; text-decoration: none; }
.prop-title:hover { color: var(--tv-primary); }
.prop-loc { color: var(--tv-muted); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prop-facts { display: flex; gap: .4rem 1rem; font-size: .83rem; color: var(--tv-body); flex-wrap: wrap; }
.prop-facts span { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.prop-card .prop-facts { flex-wrap: nowrap; overflow: hidden; padding-top: .6rem; border-top: 1px dashed var(--tv-border); min-height: 2.1rem; }
.prop-facts .tv-icon { color: var(--tv-primary); }
.prop-foot { border-top: 1px solid var(--tv-border); font-size: .75rem; color: var(--tv-muted); }
.source-pill { display: inline-block; white-space: nowrap; background: #f1f5f9; color: #334155; border-radius: 99px; padding: .18rem .6rem; font-weight: 600; font-size: .72rem; }
a.source-pill:hover { background: var(--tv-primary-soft); color: var(--tv-primary-dark); }

/* ---------------------------------------------------------------- tables */
.table { --bs-table-hover-bg: #f8fafc; margin: 0; }
.table > :not(caption) > * > * { border-color: #eef2f6; }
.table thead th, .table-light th { background: #f8fafc !important; color: var(--tv-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; white-space: nowrap; }
.tv-card > .table-responsive, .tv-card.table-responsive { border-radius: 16px; }
.tv-card.table-responsive > .table > :not(caption) > * > * { padding: .75rem .75rem; }
.tv-card.table-responsive > .table > :not(caption) > * > :first-child { padding-left: 1.25rem; }
.tv-card.table-responsive > .table > :not(caption) > * > :last-child { padding-right: 1.25rem; }
.table-clickable tbody tr { cursor: pointer; }
.source-name { font-weight: 600; color: var(--tv-ink); text-decoration: none; }
.source-name:hover { color: var(--tv-primary); }
.source-domain { color: var(--tv-muted); text-decoration: none; font-size: .8rem; }
.source-domain:hover { color: var(--tv-primary); text-decoration: underline; }
@media (max-width: 1399.98px) {
  .tv-card.table-responsive > .table > :not(caption) > * > * { padding-left: .55rem; padding-right: .55rem; }
  .notes-cell { max-width: 260px !important; }
}
.notes-cell { max-width: 340px; color: var(--tv-muted); font-size: .8rem; line-height: 1.45; }
.notes-cell > div { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.table-props img { width: 84px; height: 62px; object-fit: cover; border-radius: 8px; background: #e2e8f0; }
.table-props td { vertical-align: middle; }

.table-data-wrap { overflow: auto; max-height: 78vh; border-radius: 16px; }
.table-data { font-size: .84rem; }
.table-data thead th { position: sticky; top: 0; z-index: 3; border-bottom: 1px solid var(--tv-border); }
.table-data td { white-space: normal; }
.table-data img { width: 72px; height: 54px; }
.table-data .col-title { min-width: 300px; max-width: 380px; }
.table-data .col-addr { min-width: 180px; max-width: 240px; }
.table-data .col-feat { min-width: 170px; max-width: 240px; }
.desc-snippet { color: var(--tv-muted); font-size: .78rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: .15rem; }
.data-row { cursor: pointer; }
.row-chevron { color: var(--tv-muted); transition: transform .15s ease; }
.data-row.open { background: #f1f4fc; }
.data-row.open .row-chevron { transform: rotate(90deg); color: var(--tv-primary); }
.expand-row > td { background: #f8fafc; padding: 0 !important; }
.expand-inner { padding: 1.25rem 1.5rem; width: min(1400px, calc(100vw - var(--tv-sidebar-w) - 5rem)); position: sticky; left: 0; }
@media (max-width: 991.98px) { .expand-inner { width: calc(100vw - 2.5rem); } }
.section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--tv-muted); margin-bottom: .35rem; }
.expand-thumbs { display: flex; flex-wrap: wrap; gap: .4rem; }
.expand-thumbs img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; background: #e2e8f0; }

/* ---------------------------------------------------------------- detail */
.gallery-main { aspect-ratio: 16 / 10; background: #0f172a; border-radius: 16px; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-thumbs { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; }
.gallery-thumbs img { width: 96px; height: 72px; object-fit: cover; border-radius: 9px; cursor: pointer; opacity: .6; border: 2px solid transparent; transition: opacity .15s; }
.gallery-thumbs img.active, .gallery-thumbs img:hover { opacity: 1; border-color: var(--tv-primary); }
.back-link { display: inline-flex; align-items: center; gap: .35rem; color: var(--tv-muted); text-decoration: none; font-weight: 500; }
.back-link:hover { color: var(--tv-primary); }

.kv { display: grid; grid-template-columns: minmax(130px, 40%) 1fr; gap: .5rem 1rem; font-size: .88rem; margin: 0; }
.kv dt { color: var(--tv-muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; color: var(--tv-ink); }
.kv-sm { font-size: .82rem; gap: .3rem 1rem; }
.feature-chip { display: inline-block; background: var(--tv-primary-soft); color: var(--tv-primary-dark); border: 1px solid #c3d0f0; border-radius: 99px; padding: .2rem .65rem; margin: 0 .35rem .4rem 0; font-size: .8rem; }
.feature-chip.sm { font-size: .7rem; padding: .05rem .45rem; margin: 0 .25rem .2rem 0; }
pre.raw { background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 1rem; max-height: 520px; overflow: auto; font-size: .78rem; }
.description { white-space: pre-line; line-height: 1.65; color: var(--tv-body); }
.card-title-sm { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--tv-muted); margin-bottom: .9rem; }

/* ---------------------------------------------------------------- jobs */
.log-path { display: flex; gap: .35rem; align-items: flex-start; font-size: .75rem; color: var(--tv-muted); word-break: break-all; margin-bottom: .6rem; }
.fail-list { max-height: 380px; overflow: auto; }
.fail-list td { padding: .6rem .25rem; word-break: break-all; }
.log-box { background: #0f172a; color: #cbd5e1; font-family: "Cascadia Code", Consolas, monospace; font-size: .78rem; border-radius: 12px; padding: 1rem; height: 380px; overflow-y: auto; }
.log-box .error { color: #fca5a5; }
.log-box .warning { color: #fcd34d; }
.progress { height: 8px; border-radius: 99px; background: #eef2f6; }

/* ---------------------------------------------------------------- misc */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: radial-gradient(circle at 20% 20%, #3d66c9 0, var(--tv-primary-dark) 45%, #0a1838 100%); }
.login-card { position: relative; width: 100%; max-width: 420px; border-radius: 20px; overflow: hidden; }
.login-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--tv-primary) 0%, var(--tv-accent) 100%); }
.login-tagline { display: inline-block; margin-top: 1rem; padding: .25rem .75rem; border-radius: 99px; background: var(--tv-primary-soft); color: var(--tv-primary-dark); font-size: .75rem; font-weight: 600; letter-spacing: .02em; }
.tv-input-icon { position: relative; }
.tv-input-icon > .tv-icon { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--tv-muted); z-index: 2; }
.tv-input-icon > .form-control { padding-left: 2.6rem; }
.empty-state { padding: 4rem 1rem; text-align: center; color: var(--tv-muted); }
.empty-state .tv-icon { width: 3rem; height: 3rem; color: #cbd5e1; stroke-width: 1.5; }
.alert { border-radius: 12px; border: none; }
.alert .btn-close { margin-left: auto; position: static; padding: .5rem; }
.alert-dismissible { padding-right: 1rem; }
