/* ==========================================================================
   VALUNOX.COM - Financial & Valuation Portal Core Stylesheet
   Palette: Institutional Slate & Emerald Green (WCAG AAA Compliant)
   Architecture: Zero-Storage, Zero-Inline, Tabular Numerical Grid
   ========================================================================== */

:root {
    --bgColor: #f8fafc;
    --cardBg: #ffffff;
    --txtColor: #0f172a;
    --txtMuted: #475569;
    --borderColor: #cbd5e1;
    --linkColor: #047857;
    --linkHover: #065f46;
    --focusBorder: #059669;
    --focusRing: rgba(5, 150, 105, 0.18);
    --trEvenBgColor: #f1f5f9;
    --submitBg: #047857;
    --submitHover: #065f46;
    --mathGreen: #059669;
    --alertRed: #dc2626;
    --alertOrange: #d97706;
}

[data-theme="darkMode"] {
    --bgColor: #0b1120;
    --cardBg: #131d31;
    --txtColor: #f8fafc;
    --txtMuted: #94a3b8;
    --borderColor: #26354f;
    --linkColor: #10b981;
    --linkHover: #34d399;
    --focusBorder: #10b981;
    --focusRing: rgba(16, 185, 129, 0.22);
    --trEvenBgColor: #182339;
    --submitBg: #10b981;
    --submitHover: #059669;
    --mathGreen: #34d399;
    --alertRed: #ef4444;
    --alertOrange: #fbbf24;
}

* {margin: 0; padding: 0; box-sizing: border-box; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif}
body {font-size: 16px; background: var(--bgColor); color: var(--txtColor); line-height: 1.5; -webkit-font-smoothing: antialiased}
a {text-decoration: none; color: var(--linkColor); transition: color 0.15s ease}
a:hover {text-decoration: none; color: var(--linkHover)}

input, textarea, select {background: var(--cardBg); color: var(--txtColor); border: 1px solid var(--borderColor); border-radius: 6px; padding: 8px 12px; font-size: inherit; transition: all 0.2s ease} 
input:focus, textarea:focus, select:focus {outline: none; border-color: var(--focusBorder); box-shadow: 0 0 0 3px var(--focusRing); background: var(--cardBg)}

h1, h2, h3, h4, h5, h6 {margin: 20px 0; color: var(--txtColor); font-weight: 700}
p {line-height: 1.6; color: var(--txtMuted); word-wrap: break-word; overflow-wrap: break-word}
strong {color: var(--txtColor)}

pre, code {word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace}
.cb {clear: both} .cl {clear: left} .cr {clear: right} .fl {float: left} .fr {float: right} .fn {float: none}
.center {text-align: center} .hidden {display: none !important} .bold {font-weight: bold} .italic {font-style: italic} .border {border: solid 1px var(--borderColor); border-radius: 6px} .mt15 {margin-top: 15px}

/* Page Frame Layout */
.wrapper {width: 100%; max-width: 1200px; margin: auto; padding: 0 16px}
.setting, .header, .body, .footer {width: 100%; display: flow-root}
.setting {margin-top: 10px}
.header {margin: 20px 0 30px 0}
.footer {margin: 30px 0; text-align: center; color: var(--txtMuted)}

/* Header & Setting Grid (PRESERVED: DO NOT BREAK LEFT ALIGNMENT OF SEARCH RADIO) */
.settingL, .settingR, .headerL, .headerR {width: 50%; float: left; padding: 5px 10px}
.settingR {text-align: right}
.bodyL {width: 75%; float: left; padding: 10px 20px 10px 0}
.bodyR {width: 25%; float: left; padding: 10px 0 10px 20px; border-left: 1px solid var(--borderColor)}

/* Setting Bar Elements */
.altThemeBtn {background: var(--cardBg); border: 1px solid var(--borderColor); font-size: 14px; color: var(--txtColor); cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: all 0.2s ease} 
.altThemeBtn:hover {border-color: var(--focusBorder); background: var(--trEvenBgColor)}
.altThemeBtn.active {border-color: var(--linkColor); color: var(--linkColor); font-weight: 600; background: var(--trEvenBgColor)}
.fontSizeBox {padding: 4px 8px; min-width: 120px; font-size: 14px}

/* Logo & Search Engine */
.logo, .slogan, .logo:hover, .slogan:hover {color: var(--txtColor); text-decoration: none}
.logo {font-size: 26px; font-weight: 800; color: var(--linkColor); letter-spacing: -0.5px}
.slogan {font-size: 14px; color: var(--txtMuted)}
.searchContainer {position: relative; width: 100%}
.searchWrapper {display: flex; align-items: stretch; width: 100%}
.searchDropdown {position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--cardBg); border: 1px solid var(--borderColor); border-radius: 6px; box-shadow: 0 8px 16px rgba(0,0,0,0.12); z-index: 1000; max-height: 340px; overflow-y: auto; display: none; text-align: left}
.searchDropdown.active {display: block}
.searchItem {padding: 10px 14px; border-bottom: 1px solid var(--borderColor); display: block; text-decoration: none; color: var(--txtColor); transition: background 0.15s ease}
.searchItem:last-child {border-bottom: none}
.searchItem:hover, .searchItem.selected {background: var(--trEvenBgColor); text-decoration: none}
.searchItemCat {display: inline-block; font-size: 11px; font-weight: bold; background: var(--trEvenBgColor); color: var(--linkColor); padding: 2px 6px; border-radius: 3px; margin-right: 6px; text-transform: uppercase}
.searchItemName {font-weight: 600; font-size: 14px; color: var(--txtColor)}
.searchItemDesc {font-size: 12px; color: var(--txtMuted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis}
#sInput {flex: 3; height: 2.4em; padding: 0 12px; border: 1px solid var(--borderColor); border-radius: 6px 0 0 6px}
#sInput:focus {border-right: 1px solid var(--focusBorder)}
#sButton {flex: 1; height: 2.4em; font-size: inherit; background: var(--submitBg); color: #fff; font-weight: bold; border: none; border-radius: 0 6px 6px 0; cursor: pointer; transition: background 0.2s ease}
#sButton:hover {background: var(--submitHover)}

/* Institutional Financial Cards Framework (1 Tool + 5 Text Cards) */
.blockTool, .blockText, .blockList {width: 100%; margin-bottom: 20px; background: var(--cardBg); border: 1px solid var(--borderColor); border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); transition: box-shadow 0.2s ease}
.blockTool:empty {display: none}
.blockTool:hover, .blockList:hover {box-shadow: 0 4px 8px rgba(0,0,0,0.06)}
.blockText {background: transparent; border: none; padding: 0; box-shadow: none}
.blockTool p, .blockTool textarea, .blockTool input, .blockText p {margin: 10px 0}
.inputBox, .inputArea {width: 100%; min-height: 42px; border: 1px solid var(--borderColor); border-radius: 6px; padding: 10px; font-size: inherit; font-family: inherit}
.inputArea {min-height: 180px; resize: vertical}

/* Buttons & Feedback States */
.submitBtn, .btn {background: var(--submitBg); color: #FFF; border: none; border-radius: 6px; font-size: 15px; font-weight: 600; padding: 10px 24px; cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center}
.submitBtn:hover, .btn:hover {background: var(--submitHover); transform: translateY(-1px)}
.submitBtn:active, .btn:active {transform: translateY(0)}
.submitBtn:disabled, .btn:disabled {background: var(--borderColor); color: var(--txtMuted); cursor: not-allowed; transform: none}
.success {color: var(--mathGreen); font-weight: 600}
.error {color: var(--alertRed); font-weight: 600}
.inputError {border-color: var(--alertRed) !important; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important}

/* Typography, Lists & Mockup Display */
.guideList li {margin: 8px 0 8px 20px; color: var(--txtMuted)}
.specList li {margin: 8px 0 8px 40px; color: var(--txtMuted)}
.cImg img {max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 16px auto; box-shadow: 0 4px 6px rgba(0,0,0,0.05)}
.cImg figcaption {text-align: center; font-style: italic}
.sticker {margin: 16px 0 6px 0; line-height: 1.3}

/* Navigation Links & Social */
.linkList li {list-style: none; margin: 6px 0}
.linkList a {display: inline-block; padding: 6px 12px; background: var(--bgColor); border: 1px solid var(--borderColor); border-radius: 6px; width: 100%; transition: all 0.2s ease; color: var(--txtColor)}
.linkList a:hover {background: var(--trEvenBgColor); border-color: var(--focusBorder); text-decoration: none; padding-left: 16px; color: var(--linkColor)}
#F, #X, #P {padding: 6px 14px; background: #1877f2; color: #FFF; font-weight: bold; border: none; border-radius: 4px; cursor: pointer; transition: all 0.2s ease} #X {background: #1d9bf0} #P {background: #e60023}
#F:hover, #X:hover, #P:hover {transform: translateY(-1px); opacity: 0.9}

/* Hub Catalog Layout (.floor & .room) */
.floor {width: 100%; padding: 20px; margin: 0 0 16px 0; border: 1px solid var(--borderColor); border-radius: 8px; background: var(--cardBg); box-shadow: 0 1px 3px rgba(0,0,0,0.02); transition: all 0.2s ease}
.floor:hover {box-shadow: 0 4px 6px rgba(0,0,0,0.05); border-color: var(--focusBorder)}
.blockTool h2, .floor h2 {display: flex; align-items: center; gap: 8px; margin-top: 0}
.hubIcon {display: inline-flex; align-items: center; justify-content: center; color: var(--linkColor); flex-shrink: 0; width: 20px; height: 20px}
.room {width: 50%; float: left; padding: 6px}
.room h3 {margin: 4px 0 6px 0; font-size: 1.05rem}
.room p {margin: 0 0 6px 0; font-size: 0.95rem; line-height: 1.45}
.floor h3 {margin: 0 0 6px 0; font-size: 1.15rem}
.floor p {margin: 0; line-height: 1.5}

/* Advertisement Slots (Preserving Golden Ratio 3:3 Middle Ads) */
.adsTop, .adsMiddle, .adsRight, .adsBottom {display: none; width: 100%; text-align: center; margin: 0 auto; overflow: hidden}
.adsTop:not(:empty) {display: flex; align-items: center; justify-content: center; min-height: 90px; max-height: 100px; max-width: 970px; margin-bottom: 20px}
.adsMiddle:not(:empty) {display: flex; align-items: center; justify-content: center; min-height: 250px; margin: 20px 0; padding: 20px; background: var(--cardBg); border: 1px solid var(--borderColor); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05)}
.adsRight:not(:empty) {display: flex; align-items: center; justify-content: center; min-height: 250px; margin-top: 20px; padding: 20px; background: var(--cardBg); border: 1px solid var(--borderColor); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); max-width: 100%}
.adsBottom:not(:empty) {display: flex; align-items: center; justify-content: center; min-height: 90px; margin-top: 20px}
[data-theme="darkMode"] .adsTop, [data-theme="darkMode"] .adsMiddle, [data-theme="darkMode"] .adsRight, [data-theme="darkMode"] .adsBottom {filter: opacity(0.85); transition: filter 0.2s ease}
[data-theme="darkMode"] .adsTop:hover, [data-theme="darkMode"] .adsMiddle:hover, [data-theme="darkMode"] .adsRight:hover, [data-theme="darkMode"] .adsBottom:hover {filter: opacity(1)}
[data-theme="darkMode"] input[type="date"]::-webkit-calendar-picker-indicator {filter: invert(0.8); cursor: pointer}

/* Utility Bar & Fast Actions */
.utilityBar {display: flex; justify-content: flex-end; gap: 6px; padding: 6px 10px; background: var(--bgColor); border: 1px solid var(--borderColor); border-bottom: none; border-radius: 6px 6px 0 0; width: 100%}
.utilityBar + .inputArea, .utilityBar + .inputBox, .utilityBar + label .inputArea, .utilityBar + label .inputBox {border-top-left-radius: 0 !important; border-top-right-radius: 0 !important; margin-top: 0 !important}
.utilityBtn {display: inline-flex; align-items: center; justify-content: center; background: var(--cardBg); color: var(--txtMuted); border: 1px solid var(--borderColor); border-radius: 6px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s ease; line-height: 1.2; user-select: none; white-space: nowrap}
.utilityBtn:hover {color: var(--focusBorder); border-color: var(--focusBorder); background: var(--trEvenBgColor)}
.utilityBtn:active {transform: scale(0.96)}
.utilityBtn.success {background: rgba(5, 150, 105, 0.1); border-color: var(--mathGreen); color: var(--mathGreen)}

/* Financial Forms & Numerical Grid */
.blockTool .calcForm input, .blockTool .calcForm select, .blockTool .calcForm textarea, .blockTool .calcForm button {margin: 0}
.calcForm {display: flex; flex-direction: column; gap: 16px; width: 100%}
.formRow {display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; width: 100%}
.formGrid {display: grid; gap: 16px; width: 100%}
.formGrid2 {display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; width: 100%}
.formGrid3 {display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; width: 100%}
.formGrid4 {display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; width: 100%}
.formField {display: flex; flex-direction: column; gap: 6px; flex: 1 1 200px; min-width: 0}
.formFieldFull {width: 100%; max-width: 100%; flex: 1 1 100%}
.formLabel {font-size: 13px; font-weight: 600; color: var(--txtColor); line-height: 1.2}
.calcForm .inputBox {height: 42px; min-height: 42px; padding: 8px 12px; margin: 0}
.fieldActions {display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px}
.fieldActions .utilityBtn {height: 28px; padding: 0 10px; font-size: 12px; border-radius: 4px; align-self: flex-start}
.formActions {display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px}
.formActions .utilityBtn {height: 36px; padding: 0 16px; font-size: 13px; font-weight: 600; border-radius: 6px}
input:disabled, select:disabled, textarea:disabled {background: var(--trEvenBgColor); opacity: 0.65; cursor: not-allowed; border-color: var(--borderColor)}

/* Financial Currency & Percentage Addons */
.inputAddon {display: flex; align-items: stretch; width: 100%; position: relative}
.inputAddon > input {flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; margin: 0; height: 42px}
.inputAddon > input:focus {z-index: 1}
.inputAddon > .addonText, .inputAddon > select {display: inline-flex; align-items: center; justify-content: center; height: 42px; padding: 0 14px; background: var(--trEvenBgColor); border: 1px solid var(--borderColor); border-left: none; border-radius: 0 6px 6px 0; color: var(--txtMuted); font-weight: 600; font-size: 14px; flex-shrink: 0; margin: 0; box-sizing: border-box}
.inputAddon > .addonText:first-child {border-right: none; border-left: 1px solid var(--borderColor); border-radius: 6px 0 0 6px}
.inputAddon > .addonText:first-child + input {border-top-left-radius: 0; border-bottom-left-radius: 0; border-top-right-radius: 6px; border-bottom-right-radius: 6px}
.inputAddon > .inputPercent {width: 75px; flex: 0 0 75px; border-left: none; border-radius: 0; text-align: right; padding-right: 6px}

.inputSuffix {position: relative; width: 100%}
.inputSuffix > input {width: 100%; padding-right: 44px; margin: 0; height: 42px}
.inputSuffix > .suffixText {position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--txtMuted); font-weight: 600; font-size: 14px; pointer-events: none; line-height: 1}

/* Financial Interactive Sliders */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--borderColor);
    border-radius: 3px;
    outline: none;
    padding: 0;
    margin: 8px 0;
    border: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--linkColor);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform 0.15s ease, background 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: var(--linkHover);
}
input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--linkColor);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* Financial Stat Grid & Metrics Display */
.statGrid {display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; width: 100%}
.statCard {background: var(--trEvenBgColor); border: 1px solid var(--borderColor); border-radius: 6px; padding: 14px; text-align: left; transition: border-color 0.2s ease}
.statCard:hover {border-color: var(--focusBorder)}
.statLabel {display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--txtMuted); letter-spacing: 0.5px; margin-bottom: 6px}
.statValue {display: block; font-size: 1.45rem; font-weight: 700; color: var(--txtColor); line-height: 1.25; word-break: break-word}
.statSub {display: block; font-size: 12px; color: var(--txtMuted); margin-top: 6px; line-height: 1.3}

.leadResult {font-size: 1.4rem; font-weight: 700; margin: 10px 0; color: var(--txtColor)}
.unitBadge {display: inline-block; padding: 2px 8px; background: var(--trEvenBgColor); border: 1px solid var(--borderColor); border-radius: 4px; font-size: 12px; font-weight: 600; color: var(--linkColor)}
.unitDesc, .subText {font-size: 0.95rem; font-weight: normal; color: var(--txtMuted)}
.formulaNote {font-size: 0.95rem; color: var(--txtMuted); margin: 6px 0}
.donutChart {max-width: 240px; display: block; margin: 0 auto}

/* Financial Amortization / Cash Flow Table (Strict Tabular Monospace Align) */
.resultTable {width: 100%; border-collapse: collapse; margin: 16px 0; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch}
.resultTable table {width: 100%; border-collapse: collapse}
.resultTable tr:nth-child(even), .resultTable tr.targetRow {background: var(--trEvenBgColor)}
.resultTable tr.targetRow {font-weight: bold}
.resultTable th, .resultTable td {text-align: left; border: 1px solid var(--borderColor); padding: 9px 12px; color: var(--txtColor); word-wrap: break-word; font-size: 14px}
.resultTable th {background: var(--trEvenBgColor); font-weight: 600; white-space: nowrap}
.tabularNums, .resultTable td, .statValue, .calcDisplay {font-variant-numeric: tabular-nums; -webkit-font-feature-settings: "tnum"; font-feature-settings: "tnum"}
.colRight {text-align: right !important}
.colCenter {text-align: center !important}

/* Ratio Bar / DTI / LTV Indicator Track */
.ratioTrack {width: 100%; height: 10px; background: var(--trEvenBgColor); border: 1px solid var(--borderColor); border-radius: 5px; overflow: hidden; margin: 8px 0}
.ratioFill {height: 100%; background: var(--mathGreen); transition: width 0.3s ease}
.ratioFillWarning {background: var(--alertOrange)}
.ratioFillDanger {background: var(--alertRed)}

/* Media Queries & Responsive Refinement */
@media (max-width: 768px) {
    .settingL, .settingR, .headerL, .headerR {width: 100%; float: none; text-align: center; padding: 5px}
    .bodyL, .bodyR {width: 100%; float: none; padding: 10px 0; border: none}
    .header {margin: 10px 0 20px 0}
    .room {width: 100%; float: none; border-bottom: 1px solid var(--borderColor); padding: 10px 6px}
    #sInput {flex: 7} #sButton {flex: 3}
    .formField, .formFieldFull {max-width: 100%; flex: 1 1 100%}
    .formGrid2, .formGrid3, .formGrid4 {grid-template-columns: 1fr}
    .statGrid {grid-template-columns: 1fr}
    .statValue {font-size: 1.3rem}
    .formActions {display: flex; flex-wrap: wrap; gap: 8px; width: 100%}
    .formActions .utilityBtn {flex: 1 1 calc(50% - 8px); height: 38px; min-width: 100px; justify-content: center; padding: 0 10px; white-space: nowrap}
}
@media (min-width: 769px) and (max-width: 1024px) {
    .bodyL {width: 70%} 
    .bodyR {width: 30%}
}
@media (max-width: 576px) {
    .utilityBar {padding: 6px; gap: 4px}
}