        @import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Manrope:wght@400;500;600;700&display=swap');

        :root {
            color-scheme: light dark;
            --bg: #f4f1ec;
            --fg: #1f1f1c;
            --muted: #6b6b64;
            --accent: #0f766e;
            --accent-soft: rgba(15, 118, 110, 0.14);
            --panel: #ffffff;
            --border: #d7d2c8;
            --shadow: 0 20px 40px rgba(31, 31, 28, 0.08);
            --warning: #b45309;
            --success: #15803d;
            font-family: "Manrope", "Segoe UI", system-ui, sans-serif;
        }

        @media (prefers-color-scheme: dark) {
            :root {
                --bg: #0f1414;
                --fg: #f5f4f0;
                --muted: #b3b0a8;
                --accent: #5eead4;
                --accent-soft: rgba(94, 234, 212, 0.16);
                --panel: #151a1b;
                --border: #2a2f32;
                --shadow: 0 22px 46px rgba(0, 0, 0, 0.3);
                --warning: #fbbf24;
                --success: #4ade80;
            }
        }

        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            padding: 36px 18px 56px;
            background: var(--bg);
            color: var(--fg);
            position: relative;
            overflow-x: hidden;
        }

        body::before {
            content: "";
            position: fixed;
            inset: -20% -10% auto -10%;
            height: 380px;
            background:
                radial-gradient(circle at 10% 20%, rgba(15, 118, 110, 0.25), transparent 60%),
                radial-gradient(circle at 80% 10%, rgba(180, 83, 9, 0.18), transparent 55%);
            pointer-events: none;
            z-index: -1;
        }

        .container {
            max-width: 1220px;
            margin: 0 auto;
        }

        header {
            display: grid;
            gap: 10px;
            margin-bottom: 26px;
        }

        h1, h2 {
            font-family: "Fraunces", "Georgia", serif;
        }

        h1 {
            margin: 0;
            font-size: clamp(2rem, 3.2vw, 2.7rem);
            letter-spacing: 0.02em;
        }

        h2 {
            margin: 0 0 10px;
            font-size: 1.35rem;
        }

        .subtitle {
            color: var(--muted);
            margin: 0;
        }

        .card {
            background: var(--panel);
            border-radius: 20px;
            box-shadow: var(--shadow);
            padding: 24px;
            overflow-x: auto;
            border: 1px solid rgba(0, 0, 0, 0.03);
            animation: rise 0.6s ease both;
            animation-delay: var(--delay, 0s);
        }

        .card + .card {
            margin-top: 22px;
        }

        @keyframes rise {
            from {
                transform: translateY(18px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        .toolbar {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 14px;
            margin-bottom: 18px;
        }

        .meta {
            color: var(--muted);
            font-size: 0.95rem;
        }

        .badge {
            display: inline-flex;
            align-items: center;
            padding: 4px 12px;
            border-radius: 999px;
            background: var(--accent-soft);
            color: var(--accent);
            font-size: 0.8rem;
            font-weight: 600;
        }

        .scraper-status {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            margin-left: 8px;
            padding: 4px 12px;
            border-radius: 999px;
            font-size: 0.8rem;
            font-weight: 600;
            background: rgba(31, 31, 28, 0.06);
            color: var(--muted);
            cursor: default;
        }

        .scraper-status__icon {
            font-weight: 700;
        }

        .scraper-status--ok {
            background: rgba(21, 128, 61, 0.14);
            color: var(--success);
        }

        .scraper-status--error {
            background: rgba(185, 28, 28, 0.14);
            color: #b91c1c;
        }

        .scraper-status--stale,
        .scraper-status--running {
            background: rgba(180, 83, 9, 0.14);
            color: var(--warning);
        }

        @media (prefers-color-scheme: dark) {
            .scraper-status--error {
                color: #f87171;
            }
        }

        .pill {
            display: inline-flex;
            gap: 6px;
            align-items: center;
            padding: 6px 14px;
            border-radius: 999px;
            background: rgba(31, 31, 28, 0.06);
            color: var(--muted);
            font-size: 0.85rem;
        }

        .search-form {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 16px;
            margin-bottom: 18px;
        }

        .form-field {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .form-field.span-2 {
            grid-column: span 2;
        }

        label {
            font-size: 0.86rem;
            font-weight: 600;
            color: var(--muted);
        }

        input,
        select,
        button {
            font-family: inherit;
        }

        input,
        select {
            padding: 10px 14px;
            border-radius: 12px;
            border: 1px solid var(--border);
            background: transparent;
            color: var(--fg);
        }

        input:focus,
        select:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 4px var(--accent-soft);
        }

        .form-hint {
            font-size: 0.78rem;
            color: var(--muted);
        }

        .switch {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            background: rgba(31, 31, 28, 0.05);
            padding: 10px 12px;
            border-radius: 14px;
        }

        .switch input {
            accent-color: var(--accent);
            transform: scale(1.1);
        }

        .form-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            align-items: center;
        }

        .primary-button,
        .ghost-button {
            padding: 12px 20px;
            border-radius: 14px;
            border: none;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
        }

        .primary-button {
            background: var(--accent);
            color: #fff;
            box-shadow: 0 12px 20px rgba(15, 118, 110, 0.2);
        }

        .primary-button:hover {
            transform: translateY(-1px);
            box-shadow: 0 16px 24px rgba(15, 118, 110, 0.25);
        }

        .ghost-button {
            background: transparent;
            border: 1px solid var(--border);
            color: var(--fg);
        }

        .filter-panel {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 14px;
            margin-bottom: 18px;
            padding: 16px;
            border-radius: 16px;
            background: rgba(31, 31, 28, 0.04);
        }

        .filter-panel .form-field {
            margin: 0;
        }

        .search-box {
            position: relative;
        }

        .pivot-panel {
            margin-bottom: 18px;
            padding: 16px;
            border-radius: 16px;
            background: rgba(31, 31, 28, 0.035);
            border: 1px dashed rgba(31, 31, 28, 0.15);
        }

        .pivot-header {
            display: flex;
            flex-wrap: wrap;
            gap: 14px;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 12px;
        }

        .pivot-header h3 {
            margin: 0 0 4px;
            font-family: "Fraunces", "Georgia", serif;
            font-size: 1.1rem;
        }

        .pivot-controls {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .pivot-controls label {
            display: flex;
            flex-direction: column;
            gap: 4px;
            font-size: 0.78rem;
            color: var(--muted);
        }

        .pivot-controls select {
            min-width: 150px;
        }

        .pivot-table-wrap {
            overflow-x: auto;
        }

        .pivot-table {
            width: 100%;
            border-collapse: collapse;
            min-width: 520px;
        }

        .pivot-table th,
        .pivot-table td {
            padding: 10px 12px;
            border-bottom: 1px solid var(--border);
            text-align: right;
        }

        .pivot-table th:first-child,
        .pivot-table td:first-child {
            text-align: left;
            font-weight: 600;
        }

        .search-box input {
            width: 100%;
            padding: 12px 16px 12px 42px;
            border-radius: 14px;
            border: 1px solid var(--border);
            background: transparent;
            color: var(--fg);
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }

        .search-box svg {
            position: absolute;
            top: 50%;
            left: 14px;
            width: 18px;
            height: 18px;
            transform: translateY(-50%);
            fill: none;
            stroke: var(--muted);
            stroke-width: 2;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            min-width: 720px;
        }

        thead {
            background: rgba(15, 118, 110, 0.08);
        }

        th, td {
            padding: 14px 16px;
            text-align: left;
            border-bottom: 1px solid var(--border);
            vertical-align: top;
        }

        th {
            font-size: 0.8rem;
            font-weight: 700;
            color: var(--muted);
            text-transform: uppercase;
            letter-spacing: 0.08em;
            cursor: pointer;
            user-select: none;
            position: relative;
        }

        th .sort-indicator {
            margin-left: 8px;
            display: inline-flex;
            flex-direction: column;
            font-size: 0.6rem;
            color: var(--border);
        }

        th.active {
            color: var(--accent);
        }

        th.active .sort-indicator {
            color: var(--accent);
        }

        tbody tr:hover {
            background: rgba(15, 118, 110, 0.08);
        }

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

        a:hover {
            text-decoration: underline;
        }

        .no-results {
            padding: 32px;
            text-align: center;
            color: var(--muted);
        }

        .status-note {
            font-size: 0.9rem;
            color: var(--muted);
        }

        .price-cell {
            white-space: nowrap;
        }

        .price-drop {
            display: block;
            font-size: 0.75rem;
            color: var(--success);
            font-weight: 600;
        }

        .price-rise {
            display: block;
            font-size: 0.75rem;
            color: var(--warning);
            font-weight: 600;
        }

        .price-per-m2 {
            display: block;
            font-size: 0.78rem;
            font-weight: 600;
            color: var(--muted);
            margin-top: 3px;
        }

        .price-vs-avg {
            display: block;
            font-size: 0.72rem;
            font-weight: 500;
            color: var(--muted);
            margin-top: 1px;
        }

        .price-vs-avg--below {
            color: var(--success);
        }

        .price-vs-avg--above {
            color: var(--warning);
        }

        .status-pill {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            font-size: 0.75rem;
            font-weight: 600;
            padding: 3px 10px;
            border-radius: 999px;
            white-space: nowrap;
        }

        .status-pill--active {
            background: rgba(21, 128, 61, 0.12);
            color: var(--success);
        }

        .status-pill--inactive {
            background: rgba(180, 83, 9, 0.12);
            color: var(--warning);
        }

        tr.row-inactive > td {
            color: var(--muted);
        }

        tr.row-inactive {
            border-left: 3px solid var(--warning);
            background: rgba(180, 83, 9, 0.03);
        }

        tr.row-inactive:hover {
            background: rgba(180, 83, 9, 0.07);
        }

        .thumb {
            display: block;
            width: 88px;
            height: 62px;
            object-fit: cover;
            border-radius: 8px;
            margin-bottom: 6px;
            background: var(--border);
            flex-shrink: 0;
        }

        .title-cell {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        @media (max-width: 760px) {
            body {
                padding: 20px 12px 40px;
            }

            .card {
                padding: 18px;
            }

            table {
                min-width: 100%;
            }

            th, td {
                padding: 12px;
            }

            .search-form,
            .filter-panel {
                grid-template-columns: 1fr;
            }
        }

        .id-search-form {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            align-items: flex-end;
            margin-bottom: 18px;
        }

        .id-search-form .form-field {
            flex: 1 1 160px;
        }

        .listing-detail {
            display: grid;
            grid-template-columns: auto 1fr;
            gap: 20px;
            align-items: start;
        }

        .listing-detail__img {
            width: 220px;
            height: 165px;
            object-fit: cover;
            border-radius: 8px;
            background: var(--surface-alt);
        }

        .listing-detail__img-placeholder {
            width: 220px;
            height: 165px;
            border-radius: 8px;
            background: var(--surface-alt);
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--muted);
            font-size: 0.85rem;
        }

        .listing-detail__info {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 12px 24px;
        }

        .listing-detail__field {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .listing-detail__field span:first-child {
            font-size: 0.8rem;
            font-weight: 600;
            color: var(--muted);
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }

        .listing-detail__field span:last-child {
            font-size: 1rem;
        }

        .price-history-table {
            margin-top: 16px;
            width: 100%;
        }

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

            .listing-detail__img,
            .listing-detail__img-placeholder {
                width: 100%;
                height: 200px;
            }
        }

        .estimate-result {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 24px;
            margin-top: 20px;
        }

        .estimate-price-block {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .estimate-price-main {
            font-family: "Fraunces", "Georgia", serif;
            font-size: clamp(1.8rem, 3vw, 2.6rem);
            font-weight: 700;
            color: var(--accent);
            line-height: 1.1;
        }

        .estimate-range {
            font-size: 0.88rem;
            color: var(--muted);
        }

        .confidence-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 12px;
            border-radius: 999px;
            font-size: 0.78rem;
            font-weight: 600;
            width: fit-content;
        }

        .confidence-high   { background: rgba(21,128,61,.12); color: var(--success); }
        .confidence-medium { background: rgba(180,83,9,.12);  color: var(--warning); }
        .confidence-low    { background: rgba(180,83,9,.18);  color: var(--warning); }
        .confidence-insufficient { background: rgba(100,100,100,.1); color: var(--muted); }

        .estimate-meta {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .estimate-meta-row {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .estimate-meta-row span:first-child {
            font-size: 0.78rem;
            font-weight: 600;
            color: var(--muted);
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .estimate-meta-row span:last-child {
            font-size: 1rem;
        }

        @media (max-width: 620px) {
            .estimate-result { grid-template-columns: 1fr; }
        }

        .nav {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 16px;
        }

        .nav a {
            display: inline-flex;
            align-items: center;
            padding: 8px 18px;
            border-radius: 999px;
            font-size: 0.9rem;
            font-weight: 600;
            text-decoration: none;
            color: var(--muted);
            background: rgba(31, 31, 28, 0.06);
            transition: background 0.2s ease, color 0.2s ease;
        }

        .nav a:hover {
            color: var(--accent);
            background: var(--accent-soft);
        }

        .nav a.active {
            color: var(--accent);
            background: var(--accent-soft);
        }
