/* HouseObj 後台樣式。沒有引入任何 CSS 框架：畫面元素種類不多，
   自己維護一份 token 反而比覆寫框架預設值好讀。 */

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-faint: #94a3b8;
    --accent: #1d4ed8;
    --accent-hover: #1e40af;
    --accent-soft: #eff6ff;
    --ok: #059669;
    --ok-soft: #ecfdf5;
    --warn: #b45309;
    --warn-soft: #fffbeb;
    --bad: #dc2626;
    --bad-soft: #fef2f2;
    --info: #0369a1;
    --info-soft: #f0f9ff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #1e293b;
    --radius: 8px;
    --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 1px 3px rgb(15 23 42 / 4%);
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120;
        --surface: #131c31;
        --surface-2: #0f172a;
        --border: #1e293b;
        --border-strong: #334155;
        --text: #e2e8f0;
        --text-muted: #94a3b8;
        --text-faint: #64748b;
        --accent: #60a5fa;
        --accent-hover: #93c5fd;
        --accent-soft: #172554;
        --ok: #34d399;
        --ok-soft: #052e26;
        --warn: #fbbf24;
        --warn-soft: #3b2b06;
        --bad: #f87171;
        --bad-soft: #3f1414;
        --info: #38bdf8;
        --info-soft: #082f49;
        --sidebar-bg: #060c18;
        --sidebar-active: #16223c;
        --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    }
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "PingFang TC", "Microsoft JhengHei", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1 {
    font-size: 1.5rem;
    font-weight: 650;
    margin: 0 0 .25rem;
    letter-spacing: -.01em;
}

/* Blazor 的 FocusOnNavigate 會在每次換頁後把焦點移到 h1，好讓螢幕閱讀器唸出新頁面標題。
   那是程式設定的焦點、不是使用者操作的控制項，留著預設外框會讓標題看起來像個輸入框。 */
h1:focus,
h1:focus-visible {
    outline: none;
}

h2 {
    font-size: 1rem;
    font-weight: 650;
    margin: 0 0 .75rem;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code, .mono {
    font-family: var(--mono);
    font-size: .85em;
}

/* ---------- 版面骨架 ---------- */

.shell {
    display: grid;
    grid-template-columns: 232px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 0 1.25rem 1.25rem;
}

.brand-mark {
    display: block;
    width: 3rem;
    height: 3rem;
    object-fit: contain;
    flex: none;
}

.brand-name {
    color: #fff;
    font-weight: 700;
    letter-spacing: .01em;
}

.brand-sub {
    font-size: .75rem;
    color: #64748b;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-group {
    padding: 1rem 1.25rem .35rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #475569;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem 1.25rem;
    color: var(--sidebar-text);
    font-size: .875rem;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--sidebar-active);
    color: #fff;
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-icon {
    width: 1.1rem;
    text-align: center;
}

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .65rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.who {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
}

.who-name {
    font-weight: 600;
}

.who-roles {
    display: flex;
    gap: .3rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar-actions form {
    margin: 0;
}

.content {
    padding: 1.5rem;
    max-width: 1600px;
    width: 100%;
}

/* ---------- 卡片與區塊 ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.25rem;
    margin: 1rem 0;
}

.card.narrow {
    max-width: 460px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
}

.card-head h2 {
    margin: 0;
}

/* ---------- 儀表板統計 ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .85rem;
    margin: 1.25rem 0;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .9rem 1rem;
}

.stat-label {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.stat-value.small {
    font-size: 1.1rem;
}

.stat-foot {
    font-size: .75rem;
    color: var(--text-faint);
}

/* ---------- 表單 ---------- */

.form {
    display: flex;
    flex-direction: column;
    gap: .9rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
}

.field > label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.input {
    width: 100%;
    padding: .45rem .6rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .875rem;
}

/* 多行輸入（proxy 清單）：等寬字並允許縱向拉伸，貼一整份清單時才好對齊檢查。 */
textarea.input {
    resize: vertical;
    line-height: 1.5;
}

textarea.input.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .82rem;
}

/* 欄位下方的補充說明。放在 .field 內、字級比標籤再小一階。 */
.field > .hint {
    margin: 0;
    font-size: .78rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.input:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

.input:disabled {
    background: var(--surface-2);
    color: var(--text-faint);
    cursor: not-allowed;
}

.input.small {
    padding: .3rem .45rem;
    font-size: .8rem;
    width: auto;
}

.input.unit {
    width: 4.5rem;
    flex: none;
}

.hint {
    font-size: .74rem;
    color: var(--text-faint);
}

.check {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .85rem;
    cursor: pointer;
}

/* 一列橫排的欄位／選項。窄螢幕自動換行，不會把版面撐爆。 */
.field-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem 1.25rem;
    margin: .6rem 0;
}

.field.compact {
    max-width: 8rem;
}

/* 站台取用方式：每個站台一段，用細分隔線隔開，避免再多包一層卡片。 */
.site-row {
    padding: .9rem 0;
    border-top: 1px solid var(--border);
}

.site-row:first-of-type {
    border-top: none;
    padding-top: .3rem;
}

.site-head {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* proxy 池可能有數百列，限制高度讓下方的站台設定不會被推到看不見的地方。 */
.scroll-y {
    max-height: 22rem;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.warn-text { color: var(--warn); }

.checks {
    justify-content: flex-end;
    gap: .4rem;
}

.range {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.range-sep {
    color: var(--text-faint);
}

.unit-text {
    font-size: .8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.validation-message {
    color: var(--bad);
    font-size: .78rem;
}

.invalid {
    border-color: var(--bad);
}

/* ---------- 搜尋條件面板 ---------- */

.filters {
    padding-bottom: .9rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: .85rem 1rem;
}

.filter-grid .wide {
    grid-column: span 2;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: 1rem;
    padding-top: .9rem;
    border-top: 1px solid var(--border);
}

.inline-form {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

/* ---------- 按鈕 ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .45rem .9rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .85rem;
    font-weight: 550;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover:not(:disabled):not(.disabled) {
    background: var(--surface-2);
    border-color: var(--text-faint);
    text-decoration: none;
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn.primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn.ghost {
    background: transparent;
}

.btn.danger-outline {
    background: transparent;
    border-color: color-mix(in srgb, var(--bad) 55%, var(--border));
    color: var(--bad);
}

.btn.danger-outline:hover:not(:disabled) {
    background: var(--bad-soft);
    border-color: var(--bad);
}

.btn.small {
    padding: .25rem .55rem;
    font-size: .78rem;
}

.btn.block {
    width: 100%;
}

.btn:disabled,
.btn.disabled {
    opacity: .45;
    cursor: not-allowed;
}

.link {
    font-size: .85rem;
    font-weight: 550;
}

.link.back {
    display: inline-block;
    margin-bottom: .35rem;
    font-size: .8rem;
    color: var(--text-muted);
}

/* ---------- 表格 ---------- */

.table-scroll {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.card .table {
    margin: 0;
}

.table th {
    text-align: left;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}

.table td {
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--surface-2);
}

.table.compact th,
.table.compact td {
    padding: .35rem .5rem;
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table .right {
    text-align: right;
}

.table .nowrap {
    white-space: nowrap;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .65rem;
}

.users-table td {
    vertical-align: middle;
}

.row-muted td {
    opacity: .55;
}

.error-row td {
    background: var(--bad-soft);
    font-size: .8rem;
}

/* ---------- 物件列表 ---------- */

.listings .thumb-col {
    width: 76px;
}

.thumb {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--surface-2);
    display: block;
}

.thumb.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    color: var(--text-faint);
    border: 1px dashed var(--border-strong);
}

.title-col {
    min-width: 260px;
    max-width: 420px;
}

.title {
    font-weight: 600;
    color: var(--text);
}

.title:hover {
    color: var(--accent);
}

.sub {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: .15rem;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: baseline;
}

.price {
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.price.big {
    font-size: 1.5rem;
    letter-spacing: -.02em;
}

/* ---------- 標籤與徽章 ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .1rem .45rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    white-space: nowrap;
}

.badge.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.badge.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.badge.role { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.badge.source-f591 { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.badge.source-taiwanhouse { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge.source-yungching { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

.chip {
    display: inline-block;
    padding: .05rem .4rem;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .74rem;
    color: var(--text-muted);
}

/* ---------- 結果列與分頁 ---------- */

.result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin: 1rem 0 .6rem;
    font-size: .85rem;
}

.result-bar label,
.result-bar-controls label {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
    color: var(--text-muted);
    margin-right: .75rem;
}

.result-bar-controls {
    display: flex;
    align-items: center;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0 2rem;
}

.pager-info {
    font-size: .82rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ---------- 明細頁 ---------- */

.detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.detail-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .45rem;
    margin-top: .4rem;
}

.detail-price {
    text-align: right;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 1rem;
    align-items: start;
}

@media (max-width: 1000px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .5rem 1rem;
    margin: 0;
}

.facts.tight {
    grid-template-columns: 1fr;
    gap: .3rem;
}

.facts > div {
    display: flex;
    gap: .5rem;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border);
    padding-bottom: .25rem;
}

.facts dt {
    color: var(--text-muted);
    font-size: .8rem;
    white-space: nowrap;
}

.facts dd {
    margin: 0;
    text-align: right;
    font-size: .85rem;
    word-break: break-word;
}

/* Blazor 預設會把元素之間「只有空白」的節點吃掉，按鈕的間距得自己補。 */
.facts dd .btn + .btn {
    margin-left: .35rem;
}

.description {
    font-size: .875rem;
    line-height: 1.75;
    color: var(--text);
    margin: 0;
    overflow-wrap: anywhere;
}

.description > :first-child {
    margin-top: 0;
}

.description > :last-child {
    margin-bottom: 0;
}

.description h1,
.description h2,
.description h3,
.description h4,
.description h5,
.description h6 {
    font-size: 1rem;
    line-height: 1.5;
    margin: 1rem 0 .35rem;
}

.description p,
.description blockquote,
.description pre,
.description ul,
.description ol,
.description dl,
.description table,
.description figure {
    margin: .5rem 0;
}

.description ul,
.description ol {
    padding-left: 1.5rem;
}

.description blockquote {
    border-left: 3px solid var(--line);
    padding-left: .75rem;
    color: var(--muted);
}

.description table {
    border-collapse: collapse;
    max-width: 100%;
}

.description th,
.description td {
    border: 1px solid var(--line);
    padding: .35rem .5rem;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .5rem;
}

.gallery-item {
    appearance: none;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    cursor: zoom-in;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 7px;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.gallery-item:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    box-shadow: 0 5px 14px rgb(15 23 42 / 14%);
    transform: translateY(-1px);
}

.gallery-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.gallery img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px;
    background: var(--surface-2);
    display: block;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .35rem;
    margin-bottom: .5rem;
}

.tag-cat {
    font-size: .74rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 3rem;
}

.contact {
    border-top: 1px solid var(--border);
    padding-top: .6rem;
    margin-top: .6rem;
}

.contact:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.contact-head {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .35rem;
}

/* ---------- 提示訊息 ---------- */

.alert {
    padding: .6rem .85rem;
    border-radius: var(--radius);
    font-size: .85rem;
    margin: .75rem 0;
    border: 1px solid transparent;
}

.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--info-soft); color: var(--info); }

.muted { color: var(--text-muted); }

/* 已結束 / 不適用的資料列：降低對比但不隱藏，仍然看得到內容。 */
.muted-row > td { color: var(--text-muted); }
.strong { font-weight: 650; }
.danger { color: var(--bad); }
.ok-text { color: var(--ok); }

/* ---------- 危險操作 ---------- */

.purge-scope {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem 2rem;
    margin: 1rem 0;
}

.scope-title {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    margin-bottom: .35rem;
}

.purge-scope ul {
    margin: 0;
    padding-left: 1.1rem;
    font-size: .85rem;
    color: var(--text-muted);
}

.purge-scope li {
    margin-bottom: .2rem;
}

.danger-zone {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .75rem;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--bad);
    border-radius: var(--radius);
    background: var(--bad-soft);
}

.danger-zone .field {
    width: 100%;
    max-width: 320px;
}

.danger-zone .input {
    font-family: var(--mono);
}

.btn.danger-btn {
    background: var(--bad);
    border-color: var(--bad);
    color: #fff;
}

.btn.danger-btn:hover:not(:disabled) {
    filter: brightness(.92);
}

/* ---------- 空狀態 ---------- */

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}

.empty-state.small {
    padding: 2.5rem 1rem;
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: .5rem;
}

.empty-state h1 {
    color: var(--text);
}

.empty-state .btn {
    margin-top: 1rem;
}

/* ---------- 爬取進度 ---------- */

.current-tasks-card {
    padding-bottom: 1.25rem;
}

.task-table > tbody > .task-row > td {
    vertical-align: middle;
}

.task-controls {
    flex-wrap: nowrap;
    gap: .75rem;
}

.task-expander {
    display: inline-grid;
    place-items: center;
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.task-expander:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.task-detail-row > td {
    padding: 0 !important;
    background: var(--surface-2);
}

.task-detail-row:hover > td {
    background: var(--surface-2) !important;
}

.task-details {
    padding: 1rem;
    border-top: 2px solid var(--accent);
}

.task-details-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: .8rem;
}

.task-details h3,
.task-details h4 {
    margin: 0;
}

.task-counters {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.overall-progress {
    display: grid;
    grid-template-columns: minmax(220px, .65fr) minmax(280px, 1.35fr);
    align-items: center;
    gap: 1rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
}

.progress-copy,
.loading-label,
.progress-with-value {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.progress-copy {
    justify-content: space-between;
}

.loading-label {
    color: var(--text-muted);
    font-size: .78rem;
}

.detail-subhead {
    padding-top: 1rem;
    margin: 0 0 .55rem !important;
    font-size: .78rem;
    color: var(--text-muted);
}

.detail-table {
    background: var(--surface);
}

.detail-table > tbody > .egress-batch-row > td {
    padding: 0 !important;
    border-top: 0;
    background: var(--surface-2);
}

.detail-table > tbody > .egress-batch-row:hover > td {
    background: var(--surface-2) !important;
}

.egress-batch {
    margin: 0 .75rem .8rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 7px;
    background: var(--surface);
}

.run.egress-batch {
    padding-top: .75rem;
    margin-top: 0;
}

.progress-with-value {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .65rem;
}

.run {
    border-top: 1px solid var(--border);
    padding-top: .8rem;
    margin-top: .8rem;
}

.run:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.run-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .45rem;
}

.run-head .badge {
    margin-left: .35rem;
}

.progress {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width .4s ease;
}

.run-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    margin-top: .5rem;
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
}

/* ---------- 變更歷程 ---------- */

.timeline {
    display: flex;
    flex-direction: column;
}

.timeline-item {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: .75rem;
    padding: .6rem 0;
    border-top: 1px dashed var(--border);
}

.timeline-item:first-child {
    border-top: none;
}

.timeline-when {
    font-size: .78rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.timeline-body {
    min-width: 0;
}

.timeline-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .4rem;
}

.timeline-fields {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-top: .3rem;
}

.ver {
    font-family: var(--mono);
    font-size: .74rem;
    color: var(--text-faint);
}

/* ---------- 網頁快照與封存 ---------- */

.archive-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.archive-item {
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.archive-item:first-child {
    padding-top: 0;
    border-top: 0;
}

.archive-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .3rem .75rem;
    margin-bottom: .55rem;
}

.archive-meta .badge {
    margin-left: .35rem;
}

.archive-preview {
    position: relative;
    display: block;
    overflow: hidden;
    min-height: 120px;
    max-height: 230px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-2);
}

.archive-preview img {
    display: block;
    width: 100%;
    min-height: 120px;
    max-height: 230px;
    object-fit: cover;
    object-position: top;
}

.archive-preview span {
    position: absolute;
    right: .45rem;
    bottom: .45rem;
    padding: .25rem .45rem;
    border-radius: 5px;
    background: rgb(15 23 42 / 78%);
    color: #fff;
    font-size: .72rem;
}

.archive-preview.missing {
    display: grid;
    place-items: center;
    color: var(--text-muted);
    font-size: .8rem;
}

.archive-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-top: .55rem;
}

/* ---------- 執行中指示 ---------- */

.running {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    flex: none;
}

.spinner.tiny {
    width: 11px;
    height: 11px;
    border-width: 1.5px;
    display: inline-block;
}

/* ---------- 系統設定 ---------- */

.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-top: 1rem;
    padding: 0 .25rem .65rem;
    border-bottom: 1px solid var(--border);
}

.settings-tabs a {
    padding: .35rem 0;
    font-weight: 650;
    font-size: .84rem;
}

.settings-section {
    scroll-margin-top: 4.5rem;
}

.setting-readonly {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
    padding: .65rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
}

.setting-label {
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 600;
}

.settings-savebar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 0 -4px 14px rgb(15 23 42 / 6%);
    backdrop-filter: blur(8px);
}

.settings-savebar > .hint {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .overall-progress {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .settings-savebar {
        align-items: stretch;
        flex-direction: column;
    }

    .settings-savebar .table-actions {
        display: flex;
    }

    .settings-savebar .btn {
        flex: 1;
    }
}

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

@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
}

/* ---------- 登入頁 ---------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem 1rem;
    background: var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgb(15 23 42 / 8%);
    padding: 1.75rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
}

.auth-brand .brand-name {
    color: var(--text);
}

.auth-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.auth-foot {
    font-size: .78rem;
    color: var(--text-faint);
}

/* ---------- 對話框（地圖／街景） ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgb(15 23 42 / 55%);
}

.modal {
    display: flex;
    flex-direction: column;
    width: min(1040px, 100%);
    max-height: 100%;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgb(15 23 42 / 35%);
}

.modal:focus {
    outline: none;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .6rem .75rem .6rem 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-head h2 {
    margin: 0;
    font-size: .95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex: none;
}

.modal-foot {
    margin: 0;
    padding: .45rem 1rem;
    border-top: 1px solid var(--border);
}

/* 地圖 iframe：撐滿剩下的高度，視窗矮的時候由 min() 讓對話框仍留在畫面內。 */
.map-frame {
    display: block;
    width: 100%;
    height: min(62vh, 620px);
    border: 0;
    background: var(--surface-2);
}

/* ---------- 照片瀏覽器 ---------- */

.photo-backdrop {
    padding: clamp(.75rem, 2.5vw, 2rem);
    background: rgb(8 15 30 / 78%);
}

.photo-modal {
    width: min(1280px, 100%);
    height: min(88vh, 900px);
    border-color: rgb(148 163 184 / 45%);
    box-shadow: 0 24px 70px rgb(2 6 23 / 58%);
}

.photo-modal-head {
    position: relative;
    min-height: 48px;
}

.photo-counter {
    position: absolute;
    left: 50%;
    color: var(--text-muted);
    font-size: .82rem;
    font-variant-numeric: tabular-nums;
    transform: translateX(-50%);
}

.photo-counter strong {
    color: var(--text);
}

.photo-stage {
    position: relative;
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
    padding: 1.25rem 4.75rem;
    background:
        radial-gradient(circle at 50% 45%, rgb(51 65 85 / 72%), transparent 65%),
        #0b1120;
}

.photo-full {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    border-radius: 5px;
    box-shadow: 0 12px 35px rgb(0 0 0 / 32%);
}

.photo-nav {
    position: absolute;
    z-index: 1;
    top: 50%;
    display: grid;
    place-items: center;
    width: 48px;
    height: 58px;
    padding: 0 0 .25rem;
    cursor: pointer;
    color: #fff;
    font: 300 2.5rem/1 system-ui, sans-serif;
    background: rgb(15 23 42 / 62%);
    border: 1px solid rgb(255 255 255 / 22%);
    border-radius: 12px;
    box-shadow: 0 6px 18px rgb(0 0 0 / 22%);
    transform: translateY(-50%);
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.photo-nav:hover {
    background: rgb(37 99 235 / 86%);
    border-color: rgb(255 255 255 / 48%);
    transform: translateY(-50%) scale(1.04);
}

.photo-nav:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.photo-prev {
    left: 1rem;
}

.photo-next {
    right: 1rem;
}

.photo-modal-foot {
    text-align: center;
}

@media (max-width: 720px) {
    .modal-backdrop {
        padding: .75rem;
    }

    .modal-head {
        flex-direction: column;
        align-items: stretch;
        gap: .5rem;
    }

    .modal-actions {
        flex-wrap: wrap;
    }

    .photo-modal-head {
        flex-direction: row;
        align-items: center;
    }

    .photo-stage {
        padding: .75rem 3.25rem;
    }

    .photo-nav {
        width: 40px;
        height: 52px;
        border-radius: 10px;
    }

    .photo-prev {
        left: .4rem;
    }

    .photo-next {
        right: .4rem;
    }
}

/* ---------- 響應式 ---------- */

@media (max-width: 860px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        padding-bottom: .5rem;
    }

    .nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0 .75rem;
        gap: .25rem;
    }

    .nav-group {
        display: none;
    }

    .nav-item {
        border-left: none;
        border-radius: 6px;
        padding: .35rem .6rem;
    }

    .nav-item.active {
        border-left: none;
    }

    .content {
        padding: 1rem;
    }

    .filter-grid .wide {
        grid-column: auto;
    }
}

/* ---------- Blazor 內建錯誤列 ---------- */

#blazor-error-ui {
    background: #fef3c7;
    color: #78350f;
    bottom: 0;
    box-shadow: 0 -1px 2px rgb(0 0 0 / 20%);
    display: none;
    left: 0;
    padding: .6rem 1.25rem .6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
    top: .5rem;
}

.blazor-error-boundary {
    background: var(--bad);
    padding: 1rem;
    color: white;
    border-radius: var(--radius);
}

/* ---------- 跨平台重複物件審核 ---------- */

.duplicate-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.duplicate-page-actions {
    display: flex;
    align-items: center;
    gap: .65rem;
    flex-wrap: wrap;
}

.duplicate-page-head p {
    margin: .25rem 0 0;
}

.duplicate-stats {
    margin-bottom: 0;
}

.duplicate-filters {
    padding-top: .75rem;
    padding-bottom: .75rem;
}

.duplicate-filters .field-row {
    margin: 0;
}

.duplicate-filters .btn {
    margin-bottom: 1px;
}

.duplicate-city-filter {
    width: min(300px, 100%);
}

.duplicate-workspace {
    display: grid;
    grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.duplicate-queue {
    position: sticky;
    top: 4.25rem;
    margin-top: 0;
    padding: 0;
    overflow: hidden;
}

.duplicate-queue .card-head {
    padding: .9rem 1rem .7rem;
    margin: 0;
    border-bottom: 1px solid var(--border);
}

.duplicate-queue-list {
    max-height: calc(100vh - 12rem);
    overflow-y: auto;
}

.duplicate-queue-item {
    appearance: none;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: .65rem;
    align-items: start;
    width: 100%;
    padding: .75rem .8rem;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.duplicate-queue-item:hover,
.duplicate-queue-item.selected {
    background: var(--surface-2);
}

.duplicate-queue-item.selected {
    box-shadow: inset 3px 0 var(--accent);
}

.duplicate-queue-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.duplicate-queue-score,
.duplicate-score-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.duplicate-queue-score {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: .85rem;
}

.duplicate-queue-score.ok,
.duplicate-score-ring.ok { background: var(--ok-soft); color: var(--ok); }
.duplicate-queue-score.warn,
.duplicate-score-ring.warn { background: var(--warn-soft); color: var(--warn); }
.duplicate-queue-score.bad,
.duplicate-score-ring.bad { background: var(--bad-soft); color: var(--bad); }
.duplicate-queue-score.info,
.duplicate-score-ring.info { background: var(--info-soft); color: var(--info); }

.duplicate-queue-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: .22rem;
}

.duplicate-queue-body strong,
.duplicate-queue-body .muted {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.duplicate-source-pair {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .25rem;
    color: var(--text-faint);
}

.duplicate-review-panel {
    min-width: 0;
}

.duplicate-review-panel > .card:first-child,
.duplicate-listing-grid .card {
    margin-top: 0;
}

.duplicate-ai-summary {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.duplicate-score-ring {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    font-size: 1.35rem;
}

.duplicate-ai-summary h2 {
    margin-bottom: .25rem;
}

.duplicate-ai-summary p {
    margin: 0 0 .6rem;
    color: var(--text-muted);
}

.duplicate-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.duplicate-listing-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.duplicate-listing-card {
    min-width: 0;
}

.duplicate-listing-card h2 {
    margin-top: .8rem;
    overflow-wrap: anywhere;
}

.duplicate-listing-card .price.big {
    margin-bottom: .75rem;
}

.duplicate-listing-card .facts {
    margin-bottom: .85rem;
}

.duplicate-cover {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 8;
    object-fit: cover;
    border-radius: 7px;
    background: var(--surface-2);
}

.duplicate-cover.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
    border: 1px dashed var(--border-strong);
}

.table-scroll.flat {
    box-shadow: none;
}

.duplicate-compare-table td:nth-child(2),
.duplicate-compare-table td:nth-child(3) {
    min-width: 150px;
    max-width: 260px;
    overflow-wrap: anywhere;
}

.duplicate-compare-table tr.signal-match td:first-child {
    box-shadow: inset 3px 0 var(--ok);
}

.duplicate-compare-table tr.signal-partial td:first-child {
    box-shadow: inset 3px 0 var(--warn);
}

.duplicate-compare-table tr.signal-conflict {
    background: var(--bad-soft);
}

.duplicate-compare-table tr.signal-conflict td:first-child {
    box-shadow: inset 3px 0 var(--bad);
}

.chip.signal-match { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.signal-partial { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.signal-conflict { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

.duplicate-photo-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.duplicate-photo-column {
    min-width: 0;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-2);
}

.duplicate-photo-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .6rem;
}

.duplicate-photo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
}

.duplicate-photo-grid img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 5px;
    background: var(--surface);
}

.duplicate-photo-empty {
    display: grid;
    place-items: center;
    min-height: 150px;
    border: 1px dashed var(--border-strong);
    border-radius: 6px;
    color: var(--text-faint);
}

.duplicate-decision-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .85rem;
}

.btn.duplicate-same {
    color: #fff;
    background: var(--ok);
    border-color: var(--ok);
}

.btn.duplicate-same:hover:not(:disabled) {
    filter: brightness(.94);
}

.duplicate-reset {
    margin-left: auto;
    color: var(--text-muted);
}

@media (max-width: 1100px) {
    .duplicate-workspace {
        grid-template-columns: 1fr;
    }

    .duplicate-queue {
        position: static;
    }

    .duplicate-queue-list {
        max-height: 22rem;
    }
}

@media (max-width: 720px) {
    .duplicate-page-head,
    .duplicate-ai-summary {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .duplicate-listing-grid,
    .duplicate-photo-columns {
        grid-template-columns: 1fr;
    }

    .duplicate-city-filter {
        width: 100%;
    }

    .duplicate-reset {
        margin-left: 0;
    }
}
