@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-alt: #fafbfc;
    --border: #e2e5ea;
    --border-light: #eef0f3;
    --text: #1a1d23;
    --text-secondary: #5a6070;
    --text-dim: #8b91a0;
    --accent: #2563eb;
    --accent-soft: #e8edfb;
    --buy: #1d4ed8;
    --rent: #c2410c;
    --modified: #d97706;
    --modified-bg: #fffbeb;
    --breakeven: #64748b;
}

html { font-size: 13px; }

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
}

/* ---- Header ---- */

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
}

header h1 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

header select {
    font-family: inherit;
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.layout {
    display: flex;
    height: calc(100vh - 44px);
}

/* ---- Sidebar ---- */

.sidebar {
    width: 300px;
    min-width: 300px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
}

.main {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* ---- Sections ---- */

.section { border-bottom: 1px solid var(--border-light); }

.section-heading {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}

.section-heading:hover { background: var(--bg); }

.section-heading::before {
    content: "";
    display: inline-block;
    width: 0; height: 0;
    border-left: 4px solid var(--text-dim);
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    margin-right: 6px;
    transition: transform 0.12s;
}

.section.open > .section-heading::before { transform: rotate(90deg); }

.section-body {
    display: none;
    padding: 0 12px 8px;
}

.section.open > .section-body { display: block; }

/* ---- Pinned section ---- */

.pinned-section {
    border-bottom: 2px solid var(--accent-soft);
    background: var(--accent-soft);
}

.pinned-section .section-heading { color: var(--accent); }
.pinned-section .section-heading::before { border-left-color: var(--accent); }

.pinned-section .section-body {
    padding-top: 2px;
}

/* ---- Fields ---- */

.field { margin-bottom: 6px; }

.field-header {
    display: flex;
    align-items: center;
    font-size: 11px;
    margin-bottom: 1px;
    gap: 3px;
    height: 18px;
}

.field-name {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.field-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    font-size: 11px;
    color: var(--text);
    white-space: nowrap;
}

/* Modified dot sits right after the field name */
.modified-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--modified);
    display: none;
    flex-shrink: 0;
}

.field.modified .modified-dot { display: inline-block; }

/* Spacer pushes value + actions to the right */
.field-spacer { flex: 1; }

/* Action buttons: right-aligned after the value */
.field-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.field-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 2px;
    font-size: 12px;
    line-height: 1;
    color: var(--border);
    border-radius: 2px;
    transition: color 0.1s;
}

.field:hover .field-actions button { color: var(--text-dim); }
.field-actions button:hover { color: var(--text) !important; }

/* Material Symbols sizing */
.field-actions .material-symbols-outlined {
    font-size: 16px;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}

.field.modified .btn-reset { color: var(--modified) !important; }
.field.modified .btn-reset .material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.btn-pin.pinned { color: var(--accent) !important; }
.btn-pin.pinned .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}

/* Is-pinned indicator on original field */
.field.is-pinned .field-name { color: var(--accent); }

/* ---- Slider with sensitivity bars ---- */

.slider-wrap {
    position: relative;
    height: 22px;
}

/* Fallback track when no bars loaded */
.slider-wrap::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 8px;
    right: 8px;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    transform: translateY(-50%);
    pointer-events: none;
}

.slider-wrap.has-bars::after { display: none; }

/* Sensitivity bar chart behind slider */
.sensitivity-bars {
    position: absolute;
    top: 2px;
    left: 7px;
    right: 7px;
    height: 18px;
    display: flex;
    gap: 1px;
    pointer-events: none;
    z-index: 1;
    border-radius: 3px;
    overflow: hidden;
}

.sensitivity-bars .sbar {
    flex: 1;
    min-width: 0;
    border-radius: 1px;
}

/* Custom range input */
.slider-wrap input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 22px;
    background: transparent;
    position: relative;
    z-index: 2;
    cursor: pointer;
    margin: 0;
    outline: none;
}

.slider-wrap input[type="range"]::-webkit-slider-runnable-track {
    height: 0;
    background: transparent;
}

.slider-wrap input[type="range"]::-moz-range-track {
    height: 0;
    background: transparent;
    border: none;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 6px;
    height: 20px;
    margin-top: -10px;
    background: var(--surface);
    border: 2px solid var(--text);
    border-radius: 2px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.slider-wrap input[type="range"]::-moz-range-thumb {
    width: 4px;
    height: 18px;
    background: var(--surface);
    border: 2px solid var(--text);
    border-radius: 2px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.field.modified .slider-wrap input[type="range"]::-webkit-slider-thumb {
    border-color: var(--modified);
}
.field.modified .slider-wrap input[type="range"]::-moz-range-thumb {
    border-color: var(--modified);
}

.field select {
    width: 100%;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
}

/* ---- Sidebar actions ---- */

.sidebar-actions {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-light);
}

.sidebar-actions button {
    flex: 1;
    padding: 5px 0;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.sidebar-actions button:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

/* ---- Summary ---- */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}

.stat-card .label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.stat-card .value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 600;
}

.stat-card .value.buy { color: var(--buy); }
.stat-card .value.rent { color: var(--rent); }

/* ---- Charts ---- */

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
}

.chart-card.full-width { grid-column: 1 / -1; }

/* ---- Loading ---- */

.loading {
    display: none;
    position: fixed;
    top: 44px;
    left: 0; right: 0;
    height: 2px;
    background: var(--accent-soft);
    z-index: 100;
}

.loading.active { display: block; }

.loading::after {
    content: "";
    display: block;
    height: 100%;
    width: 25%;
    background: var(--accent);
    animation: loading 0.8s ease-in-out infinite;
}

@keyframes loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(500%); }
}

/* ---- Options row ---- */

.options-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

.options-row label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.options-row input[type="checkbox"] {
    accent-color: var(--accent);
}

/* ---- Scrollbar ---- */

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
