        .processing-overlay {
            position: fixed;
            inset: 0;
            z-index: 99999;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 24px;
            background: rgba(244, 246, 248, 0.88);
            backdrop-filter: blur(3px);
        }

        .processing-overlay.is-visible {
            display: flex;
        }

        .processing-box {
            width: min(360px, 100%);
            padding: 28px;
            border: 1px solid #dfe5ea;
            border-radius: 16px;
            background: #ffffff;
            box-shadow: 0 14px 45px rgba(23, 33, 43, 0.18);
            text-align: center;
        }

        .processing-spinner {
            width: 48px;
            height: 48px;
            margin: 0 auto 17px;
            border: 5px solid #dbe7f5;
            border-top-color: #ff6a00;
            border-radius: 50%;
            animation: processing-spin 0.8s linear infinite;
        }

        .processing-title {
            margin: 0;
            color: #17212b;
            font-size: 20px;
            font-weight: 800;
        }

        .processing-help {
            margin: 8px 0 0;
            color: #66727f;
            font-size: 14px;
            line-height: 1.45;
        }

        .processing-form button[disabled] {
            cursor: wait;
            opacity: 0.7;
        }

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

        @media (prefers-reduced-motion: reduce) {
            .processing-spinner {
                animation-duration: 1.8s;
            }
        }

        :root {
            --background: #f4f6f8;
            --panel: #ffffff;
            --text: #17212b;
            --muted: #66727f;
            --border: #dfe5ea;
            --accent: #ff6a00;
            --accent-dark: #c84f00;
            --shadow: 0 4px 18px rgba(23, 33, 43, 0.07);
            --radius: 14px;
        }

        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            background: var(--background);
            color: var(--text);
            font-family:
                -apple-system,
                BlinkMacSystemFont,
                "Segoe UI",
                Arial,
                sans-serif;
        }

        .page-header {
            background: linear-gradient(
                135deg,
                var(--accent-dark),
                var(--accent)
            );
            color: white;
            padding: 42px 20px 70px;
        }

        .header-inner,
        .page-content {
            width: min(1180px, calc(100% - 32px));
            margin: 0 auto;
        }

        .page-header h1 {
            margin: 0 0 8px;
            font-size: clamp(28px, 5vw, 44px);
            line-height: 1.1;
        }

        .page-header p {
            margin: 0;
            opacity: 0.88;
            font-size: 17px;
        }

        .search-panel {
            background: var(--panel);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 20px;
            margin-top: -34px;
        }

        .market-switch {
            margin-top: 14px;
            text-align: right;
        }

        .market-switch a {
            color: var(--accent);
            font-weight: 700;
            text-decoration: none;
        }

        .market-switch a:hover {
            text-decoration: underline;
        }

        .search-form {
            display: flex;
            gap: 12px;
            align-items: end;
        }

        .field {
            flex: 1;
        }

        label {
            display: block;
            margin-bottom: 7px;
            color: var(--muted);
            font-size: 14px;
            font-weight: 700;
        }

        input {
            width: 100%;
            height: 48px;
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 0 14px;
            color: var(--text);
            font-size: 17px;
        }

        input:focus {
            outline: 3px solid rgba(21, 101, 192, 0.15);
            border-color: var(--accent);
        }

        button {
            height: 48px;
            border: 0;
            border-radius: 10px;
            padding: 0 24px;
            background: var(--accent);
            color: white;
            cursor: pointer;
            font-size: 16px;
            font-weight: 700;
        }

        button:hover {
            background: var(--accent-dark);
        }

        .message {
            margin-top: 16px;
            border-radius: 10px;
            padding: 13px 15px;
        }

        .error {
            background: #fff1f1;
            color: #a62424;
            border: 1px solid #f0cccc;
        }

        .intro {
            margin: 28px 0;
            color: var(--muted);
        }

        .market-section {
            margin: 34px 0 48px;
        }

        .section-heading {
            display: flex;
            align-items: flex-end;
            justify-content: space-between;
            gap: 20px;
            margin-bottom: 17px;
        }

        .section-heading h2 {
            margin: 0 0 5px;
            font-size: 28px;
        }

        .section-heading p,
        .table-heading p {
            margin: 0;
            color: var(--muted);
            font-size: 14px;
        }

        .card-grid {
            display: grid;
            grid-template-columns:
                repeat(auto-fit, minmax(190px, 1fr));
            gap: 16px;
        }

        .stat-card,
        .table-panel,
        .empty-state {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
        }

        .stat-card {
            min-height: 154px;
            padding: 21px;
        }

        .stat-label {
            color: var(--muted);
            font-size: 14px;
            font-weight: 700;
        }

        .stat-value {
            margin-top: 13px;
            font-size: clamp(27px, 4vw, 36px);
            font-weight: 800;
            letter-spacing: -0.03em;
        }

        .stat-description {
            margin-top: 9px;
            color: var(--muted);
            font-size: 13px;
            line-height: 1.4;
        }

        .table-panel {
            margin-top: 18px;
            overflow: hidden;
        }

        .table-heading {
            padding: 20px;
            border-bottom: 1px solid var(--border);
        }

        .table-heading h3 {
            margin: 0 0 5px;
        }

        .table-scroll {
            overflow-x: auto;
        }

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

        th,
        td {
            padding: 14px 16px;
            border-bottom: 1px solid var(--border);
            text-align: right;
            white-space: nowrap;
        }

        th:first-child,
        td:first-child {
            text-align: left;
        }

        th {
            background: #f9fafb;
            color: var(--muted);
            font-size: 12px;
            letter-spacing: 0.03em;
            text-transform: uppercase;
        }

        tbody tr:last-child td {
            border-bottom: 0;
        }

        tbody tr:hover {
            background: #fafcfe;
        }

        .empty-state {
            padding: 26px;
            color: var(--muted);
        }

        .empty-state.small {
            border: 0;
            box-shadow: none;
            border-radius: 0;
        }

        .page-footer {
            padding: 30px 20px 50px;
            color: var(--muted);
            text-align: center;
            font-size: 13px;
        }


        .index-controls {
            display: grid;
            grid-template-columns: repeat(2, minmax(160px, 220px)) auto;
            gap: 14px;
            align-items: end;
            margin-bottom: 18px;
            padding: 18px;
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
        }

        .index-controls select {
            width: 100%;
            height: 46px;
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 0 12px;
            background: white;
            color: var(--text);
            font-size: 15px;
        }

        .price-index-cards {
            margin-bottom: 18px;
        }

        .visual-grid,
        .agent-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 18px;
            margin-top: 18px;
        }

        .visual-panel {
            min-width: 0;
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 14px;
        }

        .chart-box,
        .map-box {
            width: 100%;
            height: 390px;
        }

        .distance-panel {
            margin-top: 18px;
        }

        .distance-chart {
            width: 100%;
            height: 360px;
        }

        .agent-chart {
            width: 100%;
            height: 420px;
        }

        .map-placeholder {
            min-height: 390px;
            display: grid;
            place-items: center;
            color: var(--muted);
            text-align: center;
            padding: 40px;
        }

        .comparable-table small {
            color: var(--muted);
        }

        .action-panel {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 20px;
            padding: 24px;
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
        }
        .action-panel h2 { margin: 0 0 7px; }
        .action-panel p { margin: 0; color: var(--muted); }
        .action-button {
            flex: 0 0 auto;
            display: inline-flex;
            min-height: 48px;
            align-items: center;
            justify-content: center;
            border-radius: 10px;
            padding: 0 20px;
            background: var(--accent);
            color: white;
            font-weight: 700;
            text-decoration: none;
        }
        .action-button:hover { background: var(--accent-dark); }

        #incode {
            text-transform: uppercase;
        }

        @media (max-width: 640px) {
            .search-form {
                display: block;
            }

            .index-controls,
            .visual-grid,
            .agent-grid {
                grid-template-columns: 1fr;
            }

            .chart-box,
            .map-box,
            .distance-chart,
            .agent-chart {
                height: 330px;
            }

            .action-panel { display: block; }
            .action-button { width: 100%; margin-top: 18px; }

            button {
                width: 100%;
                margin-top: 12px;
            }

            .page-header {
                padding-top: 30px;
            }

            .stat-card {
                min-height: auto;
            }
        }

:root {
    --background: #f3f6f9;
    --panel: #ffffff;
    --text: #17212b;
    --muted: #65727e;
    --border: #dfe6ec;
    --accent: #ff6a00;
    --accent-dark: #c84f00;
    --success: #137333;
    --shadow: 0 8px 24px rgba(23, 33, 43, 0.08);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;
}

a {
    color: var(--accent);
}

.portal-container {
    width: min(1380px, calc(100% - 32px));
    margin: 0 auto;
}

.portal-header {
    background: linear-gradient(
        135deg,
        var(--accent-dark),
        var(--accent)
    );
    color: white;
    position: relative;
}

.portal-header-inner {
    position: relative;
    width: 100%;
    max-width: none;
    min-height: 70px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    justify-content: center;
}

.portal-brand {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    display: flex;
    align-items: center;
    text-decoration: none;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.portal-brand span {
    opacity: 0.75;
    font-weight: 500;
}

.portal-navigation {
    margin: 0 auto;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.portal-navigation a {
    padding: 10px 12px;
    border-radius: 8px;
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
}

.portal-navigation a:hover {
    background: rgba(255, 255, 255, 0.14);
}

.menu-toggle {
    display: none;
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    padding: 8px 12px;
    background: transparent;
    color: white;
    font-weight: 700;
}

.portal-userbar {
    border-bottom: 1px solid var(--border);
    background: white;
    padding: 9px 0;
    color: var(--muted);
    font-size: 13px;
}

.portal-main {
    min-height: calc(100vh - 160px);
    padding: 34px 0 60px;
}

.portal-footer {
    border-top: 1px solid var(--border);
    background: white;
    padding: 24px 0;
    color: var(--muted);
    font-size: 13px;
}

.page-heading {
    margin-bottom: 24px;
}

.page-heading h1 {
    margin: 0 0 7px;
    font-size: clamp(28px, 5vw, 42px);
}

.page-heading p {
    margin: 0;
    color: var(--muted);
}

.card-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
}

.portal-card {
    display: block;
    min-height: 190px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 24px;
    color: var(--text);
    text-decoration: none;
}

.portal-card:hover {
    border-color: #b7c9d9;
    transform: translateY(-1px);
}

.portal-card-icon {
    font-size: 34px;
}

.portal-card h2 {
    margin: 18px 0 8px;
    font-size: 21px;
}

.portal-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.portal-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0 13px;
    background: white;
    color: var(--text);
    font-size: 16px;
}

button,
.button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 9px;
    padding: 0 18px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    text-decoration: none;
    font-size: 15px;
    font-weight: 800;
}

button:hover,
.button:hover {
    background: var(--accent-dark);
}

.message {
    margin-bottom: 18px;
    border-radius: 9px;
    padding: 13px 15px;
}

.message-error {
    border: 1px solid #efc7c7;
    background: #fff1f1;
    color: #9b2424;
}

.message-success {
    border: 1px solid #bcdcc4;
    background: #edf8f0;
    color: var(--success);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(
        135deg,
        #c84f00,
        #ff6a00
    );
}

.login-card {
    width: min(440px, 100%);
    border-radius: 18px;
    background: white;
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.22);
    padding: 34px;
}

.login-card h1 {
    margin: 0 0 8px;
}

.login-card .subtitle {
    margin: 0 0 28px;
    color: var(--muted);
}

.login-card .field {
    margin-bottom: 18px;
}

.login-card button {
    width: 100%;
}

.login-meta {
    margin-top: 22px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

@media (max-width: 820px) {
    .menu-toggle {
        display: inline-flex;
    }

    .portal-header-inner {
        flex-wrap: wrap;
        padding: 12px 0;
    }

    .portal-navigation {
        display: none;
        width: 100%;
        margin: 0;
        padding-bottom: 8px;
        flex-direction: column;
        align-items: stretch;
    }

    .portal-navigation.is-open {
        display: flex;
    }

    .portal-navigation a {
        text-align: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}


/* Statistics pages inside the authenticated portal */
.stats-page-heading {
    margin-bottom: 22px;
}

.stats-content {
    width: 100%;
}

.portal-main .search-panel {
    margin-top: 0;
}

.portal-main .page-content,
.portal-main .header-inner {
    width: 100%;
}

.portal-main .market-section:first-of-type {
    margin-top: 28px;
}

@media (max-width: 820px) {
    .portal-main {
        padding-top: 24px;
    }
}
@media (max-width: 900px) {
    .portal-header-inner {
        justify-content: space-between;
        padding: 0 16px;
    }

    .portal-brand {
        position: static;
        transform: none;
    }
}
/* Clockwork orange brand refresh */
.portal-brand-logo {
    background: #fff;
    border-radius: 10px;
    padding: 5px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.portal-brand-logo img { max-height: 48px; width: auto !important; }
