* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Professional colour palette */
    --primary: #2c5f8d;
    --primary-light: #3b82b6;
    --primary-dark: #1e4363;
    --accent: #0891b2;
    --success: #059669;
    --warning: #dc2626;
    --neutral: #64748b;
    --background: #f8fafc;
    --background-alt: #f1f5f9;
    --panel-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 15px;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 1.25rem 0;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

header .subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Main Layout */
main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.layout-grid {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Map Container */
.map-container {
    flex: 0 0 66.67%;
    position: relative;
    height: 100%;
    background: var(--background-alt);
}

#map {
    width: 100%;
    height: 100%;
}

/* Loading Indicator */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
    display: none;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.loading-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    border: 1px solid var(--border-light);
}

.legend-title {
    font-weight: 600;
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.legend-body {
    display: flex;
    gap: 0.5rem;
    height: 120px;
}

.legend-gradient {
    width: 12px;
    border-radius: 3px;
    flex-shrink: 0;
    background: linear-gradient(to bottom,
        #fde047,
        #a3e635,
        #22c55e,
        #10b981,
        #14b8a6,
        #06b6d4,
        #0ea5e9,
        #2563eb,
        #1e3a8a,
        #0f172a
    );
}

.legend-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1;
}

/* Sidebar */
.sidebar {
    flex: 0 0 33.33%;
    display: flex;
    flex-direction: column;
    background: var(--background);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    gap: 1.25rem;
}

/* Panels */
.panel {
    background: var(--panel-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.panel h2 {
    font-size: 1.125rem;
    color: var(--primary);
    margin-bottom: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.panel h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.875rem;
    font-weight: 600;
}

.panel h4 {
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin: 1rem 0 0.625rem;
    font-weight: 600;
}

/* Property Details */
.placeholder-text {
    color: var(--text-muted);
    text-align: center;
    padding: 2.5rem 1rem;
    font-style: italic;
    font-size: 0.9375rem;
}

.grid-view-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: -0.375rem;
    margin-bottom: 0.875rem;
    line-height: 1.45;
}

.property-info {
    display: grid;
    gap: 0.625rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    background: var(--background-alt);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.info-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.info-value {
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    font-size: 0.9375rem;
}

/* Information Panel */
.info-panel {
    margin-top: auto;
}

.info-toggle {
    width: 100%;
    padding: 1rem;
    background: var(--background-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-toggle:hover {
    background-color: white;
    box-shadow: var(--shadow-sm);
}

.toggle-icon {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
    font-weight: 300;
}

.info-toggle.open .toggle-icon {
    transform: rotate(45deg);
}

.info-content {
    display: none;
    padding-top: 1rem;
}

.info-content.open {
    display: block;
}

.info-content p {
    margin-bottom: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.9375rem;
}

.info-content ul {
    margin: 0.5rem 0 1rem 1.5rem;
    color: var(--text-secondary);
}

.info-content li {
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* Footer */
footer {
    display: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .layout-grid {
        flex-direction: column;
    }

    .map-container {
        flex: 0 0 50vh;
    }

    .sidebar {
        flex: 1;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.25rem;
    }

    header .subtitle {
        font-size: 0.8125rem;
    }

    .map-container {
        flex: 0 0 40vh;
    }

    .sidebar {
        padding: 1rem;
        gap: 1rem;
    }

    .panel {
        padding: 1.25rem;
    }

    .map-legend {
        bottom: 16px;
        right: 16px;
        padding: 0.625rem 0.875rem;
    }
}

/* ── Tax List UI ──────────────────────────────────────────────────────────── */

.tax-group {
    margin-bottom: 0.375rem;
}

.tax-group-header {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    padding: 0.5rem 0 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

.tax-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3125rem 0;
}

.tax-row input[type="checkbox"] {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--primary);
}

.tax-name {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--text-primary);
    min-width: 0;
}

.tax-input-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.tax-pound {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-right: 1px;
}

.tax-input {
    width: 76px;
    padding: 0.25rem 0.375rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8125rem;
    text-align: right;
    background: white;
    color: var(--text-primary);
    -moz-appearance: textfield;
}

.tax-input::-webkit-inner-spin-button,
.tax-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.tax-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(44, 95, 141, 0.12);
}

.tax-input:disabled {
    background: var(--background-alt);
    color: var(--text-muted);
    cursor: not-allowed;
}

.tax-suffix {
    font-size: 0.6875rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 34px;
}

.tax-note {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin: 0 0 0.375rem 1.375rem;
    line-height: 1.4;
    font-style: italic;
}

.tax-total-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: var(--primary);
    border-radius: 8px;
    color: white;
}

.tax-total-label {
    font-size: 0.8125rem;
    font-weight: 500;
    opacity: 0.9;
}

.tax-total-value {
    font-size: 1rem;
    font-weight: 700;
}

/* ── Calculate & Results ──────────────────────────────────────────────────── */

.hidden {
    display: none;
}

.calculate-btn {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.625rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.calculate-btn:hover:not(:disabled) {
    background: var(--primary-dark);
}

.calculate-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.calculate-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: left;
    margin-top: -0.375rem;
    margin-bottom: 0.875rem;
    font-style: italic;
    line-height: 1.4;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.625rem;
    margin-bottom: 1rem;
}

.result-card {
    background: var(--background-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 0.625rem;
    text-align: center;
}

.result-better {
    background: #d1fae5;
    border-color: #6ee7b7;
}

.result-worse {
    background: #fee2e2;
    border-color: #fca5a5;
}

.result-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.result-value {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.result-sub {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-style: italic;
}

.result-better .result-value { color: #065f46; }
.result-worse  .result-value { color: #991b1b; }
.result-better .result-sub   { color: #047857; }
.result-worse  .result-sub   { color: #b91c1c; }

.breakdown-toggle {
    width: 100%;
    padding: 0.5rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease;
    margin-bottom: 0.5rem;
}

.breakdown-toggle:hover {
    background: var(--background-alt);
}

.breakdown-wrap {
    overflow-x: auto;
}

.breakdown {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.breakdown th,
.breakdown td {
    padding: 0.4375rem 0.5rem;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
}

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

.breakdown thead th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.breakdown-total td {
    font-weight: 700;
    border-top: 2px solid var(--border);
    border-bottom: none;
    padding-top: 0.5rem;
}

.one-off-tag {
    display: inline-block;
    font-size: 0.5625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--background-alt);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 3px;
    vertical-align: middle;
    margin-left: 3px;
}

.change-better {
    color: #065f46;
    font-weight: 600;
}

.change-worse {
    color: #991b1b;
    font-weight: 600;
}

/* ── View Mode Toggle ─────────────────────────────────────────────────────── */

.view-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
}

/* Segmented control: pill-shaped container with two option buttons */
.view-toggle-seg {
    display: flex;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.view-toggle-seg-btn {
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 12px;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.view-toggle-seg-btn:last-child {
    border-right: none;
}

.view-toggle-seg-btn:hover:not(.active) {
    background: var(--background-alt);
    color: var(--text-primary);
}

.view-toggle-seg-btn.active {
    background: var(--primary);
    color: #fff;
    cursor: default;
}
