/* ============================================================
   Lease Extension Calculator — Modern App Design System
   Scoped under .lex-app  |  Light default + [data-theme=dark]
   ============================================================ */

.lex-app {
    /* ---- Design tokens: light ---- */
    --lex-bg: #f6f8fb;
    --lex-surface: rgba(255, 255, 255, 0.78);
    --lex-surface-solid: #ffffff;
    --lex-border: rgba(226, 232, 240, 0.6);
    --lex-border-strong: #e2e8f0;
    --lex-text: #0f172a;
    --lex-muted: #64748b;
    --lex-faint: #94a3b8;
    --lex-accent: #3b82f6;
    --lex-accent-2: #38bdf8;
    --lex-accent-deep: #2563eb;
    --lex-navy: #1e293b;
    --lex-amber-bg: #fffbeb;
    --lex-amber-border: #fde68a;
    --lex-amber-text: #92400e;
    --lex-shadow: 0 10px 30px -8px rgba(30, 41, 59, 0.12), 0 2px 8px -2px rgba(30, 41, 59, 0.06);
    --lex-shadow-lg: 0 24px 50px -12px rgba(30, 41, 59, 0.18);
    --lex-ring: rgba(59, 130, 246, 0.25);
    --lex-track: #e2e8f0;
    --lex-grid-line: rgba(148, 163, 184, 0.18);

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--lex-text);
    background:
        radial-gradient(1200px 500px at 85% -5%, rgba(59, 130, 246, 0.07), transparent 60%),
        radial-gradient(900px 400px at -10% 15%, rgba(37, 99, 235, 0.06), transparent 55%),
        var(--lex-bg);
    border-radius: 24px;
    padding: 28px;
    margin: 0 0 32px;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
}

.lex-app[data-theme="dark"] {
    --lex-bg: #0b1220;
    --lex-surface: rgba(15, 23, 42, 0.72);
    --lex-surface-solid: #0f172a;
    --lex-border: rgba(51, 65, 85, 0.55);
    --lex-border-strong: #334155;
    --lex-text: #e2e8f0;
    --lex-muted: #94a3b8;
    --lex-faint: #64748b;
    --lex-amber-bg: rgba(120, 53, 15, 0.25);
    --lex-amber-border: rgba(217, 119, 6, 0.45);
    --lex-amber-text: #fcd34d;
    --lex-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.5), 0 2px 8px -2px rgba(0, 0, 0, 0.4);
    --lex-shadow-lg: 0 24px 50px -12px rgba(0, 0, 0, 0.6);
    --lex-track: #334155;
    --lex-grid-line: rgba(100, 116, 139, 0.2);
}

.lex-app *, .lex-app *::before, .lex-app *::after { box-sizing: border-box; }

/* Beat legacy #content heading/link rules from calcstyle.css */
#content .lex-app h1, #content .lex-app h2, #content .lex-app h3,
.lex-app h1, .lex-app h2, .lex-app h3 { color: var(--lex-text); border: 0; padding-bottom: 0; }
#content .lex-app .lex-prose a, .lex-app .lex-prose a { color: var(--lex-accent-deep); }
#content .lex-app[data-theme="dark"] .lex-prose a { color: var(--lex-accent); }
#content .lex-app .lex-cta, #content .lex-app .lex-cta:hover { color: #fff; }

/* ---------------- Header ---------------- */
.lex-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.lex-app .lex-title {
    font-size: clamp(26px, 3.4vw, 38px);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.12;
    margin: 0 0 6px;
    color: var(--lex-text);
    background: linear-gradient(120deg, var(--lex-text) 60%, var(--lex-accent-deep));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.lex-subtitle { color: var(--lex-muted); font-size: 15px; margin: 0 0 14px; max-width: 62ch; }
.lex-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.lex-badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--lex-muted);
    padding: 5px 11px; border-radius: 999px;
    border: 1px solid var(--lex-border);
    background: var(--lex-surface);
    backdrop-filter: blur(6px);
}
.lex-badge svg { width: 13px; height: 13px; stroke: var(--lex-accent); flex: none; }

.lex-theme-toggle {
    flex: none; width: 42px; height: 42px; border-radius: 12px;
    border: 1px solid var(--lex-border); background: var(--lex-surface);
    backdrop-filter: blur(6px); cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center; color: var(--lex-muted);
    box-shadow: var(--lex-shadow); transition: transform .15s ease, color .15s ease;
}
.lex-theme-toggle:hover { transform: translateY(-1px); color: var(--lex-accent); }
.lex-theme-toggle svg { width: 18px; height: 18px; }
.lex-app .icon-sun { display: none; }
.lex-app[data-theme="dark"] .icon-sun { display: block; }
.lex-app[data-theme="dark"] .icon-moon { display: none; }

/* ---------------- Layout grid ---------------- */
.lex-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 22px; align-items: start; }
.lex-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.lex-full { margin-top: 22px; display: flex; flex-direction: column; gap: 22px; }

/* ---------------- Cards ---------------- */
.lex-card {
    background: var(--lex-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--lex-border);
    border-radius: 18px;
    box-shadow: var(--lex-shadow);
    padding: 22px;
}
.lex-card-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; color: var(--lex-text); display: flex; align-items: center; gap: 8px; }
.lex-card-title svg { width: 16px; height: 16px; stroke: var(--lex-accent); }
.lex-card-sub { font-size: 13px; color: var(--lex-muted); margin: 0 0 16px; }

/* ---------------- Segment control ---------------- */
.lex-seg {
    display: flex; gap: 4px; padding: 4px;
    background: color-mix(in srgb, var(--lex-border-strong) 42%, transparent);
    border: 1px solid var(--lex-border);
    border-radius: 12px; margin-bottom: 20px;
}
.lex-seg-btn {
    flex: 1; border: 0; background: transparent; cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 600;
    color: var(--lex-muted); padding: 9px 8px; border-radius: 9px;
    transition: all .18s ease; white-space: nowrap; line-height: 1.2;
}
.lex-seg-btn small { display: block; font-size: 10px; font-weight: 500; color: var(--lex-faint); margin-top: 1px; }
.lex-seg-btn.active {
    background: var(--lex-surface-solid);
    color: var(--lex-text);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}
.lex-seg-btn.active small { color: var(--lex-accent-deep); }
.lex-app[data-theme="dark"] .lex-seg-btn.active small { color: var(--lex-accent); }
.lex-seg-sm { margin: 12px 0; }
.lex-seg-sm .lex-seg-btn { padding: 6px 8px; font-size: 12px; }

/* ---------------- Panes ---------------- */
.lex-pane { display: none; }
.lex-pane.active { display: block; animation: lexFade .25s ease; }
@keyframes lexFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- Fields ---------------- */
.lex-field { margin-bottom: 18px; }
.lex-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; color: var(--lex-text); margin-bottom: 8px; }
.lex-label .lex-hint { font-size: 11px; font-weight: 500; color: var(--lex-faint); }
.lex-pair { display: grid; grid-template-columns: 1fr 140px; gap: 14px; align-items: center; }
.lex-pair-wide { grid-template-columns: 1fr 150px; }
.lex-inline-inputs .lex-input-group.has-suffix .lex-input { padding-right: 30px; padding-left: 9px; }
.lex-inline-inputs .lex-suffix { right: 7px; font-size: 10px; }

.lex-app input[type="range"].lex-range {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 6px; border-radius: 999px;
    background: linear-gradient(to right, var(--lex-accent) 0%, var(--lex-accent-2) var(--fill, 50%), var(--lex-track) var(--fill, 50%));
    outline: none; cursor: pointer; margin: 0; padding: 0; border: 0;
}
.lex-app input[type="range"].lex-range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--lex-surface-solid);
    border: 2px solid var(--lex-accent);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
    transition: transform .12s ease;
}
.lex-app input[type="range"].lex-range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.lex-app input[type="range"].lex-range::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--lex-surface-solid);
    border: 2px solid var(--lex-accent);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}

.lex-app .lex-input {
    width: 100%; font-family: inherit; font-size: 14px; font-weight: 600;
    color: var(--lex-text); background: var(--lex-surface-solid);
    border: 1px solid var(--lex-border-strong); border-radius: 10px;
    padding: 9px 12px; outline: none; margin: 0;
    transition: border-color .15s ease, box-shadow .15s ease;
    -moz-appearance: textfield;
}
.lex-app .lex-input:focus { border-color: var(--lex-accent); box-shadow: 0 0 0 3px var(--lex-ring); }
.lex-app .lex-input::-webkit-outer-spin-button,
.lex-app .lex-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.lex-input-group { position: relative; }
.lex-input-group .lex-input { padding-left: 26px; }
.lex-input-group .lex-prefix {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    font-size: 13px; font-weight: 600; color: var(--lex-faint); pointer-events: none;
}
.lex-input-group .lex-suffix {
    position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
    font-size: 11px; font-weight: 600; color: var(--lex-faint); pointer-events: none;
}
.lex-input-group.has-suffix .lex-input { padding-right: 46px; padding-left: 12px; }

.lex-inline-inputs { display: flex; gap: 10px; }
.lex-inline-inputs > div { flex: 1; }

.lex-slider-value { font-size: 12px; font-weight: 600; color: var(--lex-accent-deep); margin-top: 6px; }
.lex-app[data-theme="dark"] .lex-slider-value { color: var(--lex-accent); }
.lex-slider-value a { color: inherit; text-decoration: underline; }

/* ---------------- Advanced accordion ---------------- */
.lex-advanced {
    border: 1px solid var(--lex-border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--lex-surface-solid) 55%, transparent);
    margin-top: 4px;
    overflow: hidden;
}
.lex-advanced summary {
    list-style: none; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 8px;
    padding: 13px 16px; font-size: 13px; font-weight: 700; color: var(--lex-muted);
    transition: color .15s ease;
}
.lex-advanced summary::-webkit-details-marker { display: none; }
.lex-advanced summary:hover { color: var(--lex-text); }
.lex-advanced summary .chev { margin-left: auto; transition: transform .2s ease; width: 15px; height: 15px; stroke: var(--lex-faint); }
.lex-advanced[open] summary .chev { transform: rotate(180deg); }
.lex-advanced summary .gear { width: 15px; height: 15px; stroke: var(--lex-accent); }
.lex-advanced-body { padding: 4px 16px 16px; border-top: 1px dashed var(--lex-border); }
.lex-advanced-body .lex-field:first-child { margin-top: 14px; }

/* ---------------- Marriage value alert ---------------- */
.lex-alert {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--lex-amber-bg);
    border: 1px solid var(--lex-amber-border);
    color: var(--lex-amber-text);
    border-radius: 14px; padding: 14px 16px; margin: 4px 0 18px;
    font-size: 13px; line-height: 1.5;
    animation: lexFade .3s ease;
}
.lex-alert[hidden] { display: none; }
.lex-alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; stroke: currentColor; }
.lex-alert strong { font-weight: 700; }

/* ---------------- Hero results ---------------- */
.lex-hero-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--lex-faint); margin: 0 0 12px; }
.lex-hero { display: grid; grid-template-columns: 1fr 1.35fr 1fr; gap: 10px; align-items: stretch; }
.lex-hero-item {
    text-align: center; padding: 14px 8px; border-radius: 14px;
    border: 1px solid var(--lex-border);
    background: color-mix(in srgb, var(--lex-surface-solid) 60%, transparent);
}
.lex-hero-item .k { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--lex-faint); margin-bottom: 4px; }
.lex-hero-item .v { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--lex-muted); white-space: nowrap; }
.lex-hero-mid {
    background: linear-gradient(135deg, var(--lex-accent-deep), var(--lex-accent-2));
    border: 0; color: #fff;
    box-shadow: 0 12px 28px -8px rgba(37, 99, 235, 0.45);
}
.lex-hero-mid .k { color: rgba(255, 255, 255, 0.85); }
.lex-hero-mid .v { font-size: 30px; font-weight: 800; color: #fff; }
.lex-hero-note { font-size: 12px; color: var(--lex-faint); margin: 12px 0 0; text-align: center; }

/* ---------------- Breakdown bar ---------------- */
.lex-breakdown-bar {
    display: flex; height: 14px; border-radius: 999px; overflow: hidden;
    background: var(--lex-track); margin: 14px 0 14px;
}
.lex-breakdown-bar span { display: block; height: 100%; transition: width .45s cubic-bezier(.4,0,.2,1); min-width: 0; }
#bdRent { background: #38bdf8; }
#bdRev  { background: #0ea5a5; }
#bdMv   { background: #f59e0b; }
.lex-legend { display: flex; flex-direction: column; gap: 8px; }
.lex-legend-item { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--lex-muted); }
.lex-legend-item .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lex-legend-item .val { margin-left: auto; font-weight: 700; color: var(--lex-text); font-variant-numeric: tabular-nums; }

/* ---------------- Wait vs Act ---------------- */
.lex-wait-row { display: flex; align-items: center; gap: 14px; margin: 14px 0 4px; }
.lex-wait-row .lex-range { flex: 1; }
.lex-wait-row strong { font-size: 13px; min-width: 62px; text-align: right; color: var(--lex-text); }
.lex-compare { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.lex-compare-row { display: grid; grid-template-columns: 74px 1fr 90px; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; color: var(--lex-muted); }
.lex-compare-row .bar-track { height: 12px; border-radius: 999px; background: var(--lex-track); overflow: hidden; }
.lex-compare-row .bar { height: 100%; border-radius: 999px; transition: width .45s cubic-bezier(.4,0,.2,1); }
.lex-compare-row .bar.now { background: linear-gradient(90deg, var(--lex-accent-deep), var(--lex-accent-2)); }
.lex-compare-row .bar.wait { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.lex-compare-row .amt { text-align: right; font-weight: 700; color: var(--lex-text); font-variant-numeric: tabular-nums; }
.lex-wait-extra {
    margin-top: 16px; padding: 12px 16px; border-radius: 12px;
    background: color-mix(in srgb, #ef4444 8%, var(--lex-surface-solid));
    border: 1px solid color-mix(in srgb, #ef4444 25%, transparent);
    font-size: 13px; color: var(--lex-muted); text-align: center;
}
.lex-wait-extra strong { color: #dc2626; font-size: 16px; font-variant-numeric: tabular-nums; }
.lex-app[data-theme="dark"] .lex-wait-extra strong { color: #f87171; }
.lex-wait-extra.is-saving { background: color-mix(in srgb, var(--lex-accent) 8%, var(--lex-surface-solid)); border-color: color-mix(in srgb, var(--lex-accent) 25%, transparent); }
.lex-wait-extra.is-saving strong { color: var(--lex-accent-deep); }

/* ---------------- Charts ---------------- */
.lex-chart-wrap { position: relative; height: 320px; margin-top: 8px; }
.lex-chart-wrap.tall { height: 360px; }

/* ---------------- CTA ---------------- */
.lex-cta {
    display: block; text-align: center; text-decoration: none;
    padding: 15px 22px; border-radius: 13px;
    background: linear-gradient(135deg, #1e3a8a, var(--lex-accent-deep));
    color: #fff !important; font-size: 15px; font-weight: 700; letter-spacing: 0.01em;
    box-shadow: 0 10px 24px -6px rgba(37, 99, 235, 0.5);
    transition: transform .15s ease, box-shadow .15s ease;
}
.lex-cta:hover { transform: translateY(-2px); box-shadow: 0 16px 32px -6px rgba(37, 99, 235, 0.55); color: #fff; text-decoration: none; }

/* ---------------- Author snippet ---------------- */
.lex-author { display: flex; align-items: center; gap: 16px; }
.lex-author img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; border: 2px solid var(--lex-border-strong); flex: none; }
.lex-author p { margin: 0; font-size: 13px; color: var(--lex-muted); }
.lex-author p:first-child { color: var(--lex-text); font-weight: 600; font-size: 14px; }
.lex-author a { color: var(--lex-accent-deep); font-weight: 700; text-decoration: none; }
.lex-app[data-theme="dark"] .lex-author a { color: var(--lex-accent); }
.lex-author a:hover { text-decoration: underline; }

/* ---------------- SEO prose ---------------- */
.lex-prose { max-width: 76ch; }
.lex-prose h2 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; color: var(--lex-text); margin: 26px 0 10px; }
.lex-prose h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--lex-text); margin: 22px 0 8px; }
.lex-prose p, .lex-prose li { font-size: 14.5px; color: var(--lex-muted); line-height: 1.7; }
.lex-prose p { margin: 0 0 12px; }
.lex-prose ul { margin: 0 0 12px; padding-left: 20px; }
.lex-prose a { color: var(--lex-accent-deep); font-weight: 600; }
.lex-app[data-theme="dark"] .lex-prose a { color: var(--lex-accent); }
.lex-prose .lex-disclaimer { font-size: 12.5px; color: var(--lex-faint); font-style: italic; }
.lex-prose-cta { margin: 18px 0; max-width: 340px; }

/* ---------------- Full-width (no sidebar) page variant ---------------- */
#site_content.lex-nosidebar { max-width: 1320px; background: transparent; }
#site_content.lex-nosidebar #content {
    width: 100%;
    max-width: none;
    flex: 1 1 100%;
    border: 0;
    background: transparent;
    padding: 1em 0;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1080px) {
    .lex-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .lex-app { padding: 16px; border-radius: 16px; }
    .lex-card { padding: 16px; }
    .lex-pair, .lex-pair-wide { grid-template-columns: 1fr; gap: 8px; }
    .lex-hero { grid-template-columns: 1fr; }
    .lex-hero-mid .v { font-size: 26px; }
    .lex-hero-item .v { font-size: 18px; }
    .lex-seg-btn { font-size: 12px; padding: 8px 4px; }
    .lex-seg-btn small { display: none; }
    .lex-chart-wrap { height: 260px; }
    .lex-compare-row { grid-template-columns: 60px 1fr 80px; }
    .lex-header { flex-direction: column-reverse; }
}
