/* Quantum Resource Estimator - Main Styles */

/* ===== CSS VARIABLES ===== */
:root {
    /* --primary-color: #1b365d; */
    --primary-color: #14163A;
    /* --primary-color: #251F69; */
    /* --accent-color: #ffc845; */
    --accent-color: #bfcee4;
    --accent-hover: #e6b43e;
    --page-bg-1: #010101;
    --page-bg-2: #001F60;
    --text-light: rgba(255, 255, 255, 0.8);
    --sidebar-bg: rgba(200, 210, 230, 0.95);
    --card-bg: rgba(70, 90, 130, 0.2);
    --navbar-width: 60px;
    --param-sidebar-width: min(380px, 92vw);
}

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

/* ===== BODY & BACKGROUND ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    background: radial-gradient(900px 400px at 10% -20%, #141414 20%, transparent 70%),
                linear-gradient(180deg, var(--page-bg-1), var(--page-bg-2));
}

/* ===== NAVBAR ===== */
.navbar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--navbar-width);
    height: 100vh;
    background: var(--primary-color);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.navbar-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    height: 100%;
    justify-content: space-between;
}

.navbar-top {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.nav-icon {
    width: 45px;
    height: 45px;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.nav-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

.nav-icon.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--primary-color);
}

/* ===== PARAMETER SIDEBAR ===== */
.param-sidebar {
    position: fixed;
    left: var(--navbar-width);
    top: 0;
    width: var(--param-sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.param-sidebar.open {
    transform: translateX(0);
}

/* ===== SIDEBAR HEADER ===== */
.sidebar-header {
    background: #5a6b8c;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}
.sidebar-info {
    background: #14163a95;
    color: white;
    padding: 20px;
    padding-left: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: static;
    top: 0;
    z-index: 10;
}

.sidebar-header h2 {
    font-size: 1.2em;
}

.reset-btn {
    background: transparent;
    border: 2px solid white;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.reset-btn:hover {
    background: white;
    color: #5a6b8c;
}

/* ===== SIDEBAR CONTENT ===== */
.sidebar-content {
    padding: 12px;
}

.preset-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #aaa;
}

.preset-section h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.preset-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.preset-btn {
    flex: 1;
    padding: 10px;
    background: #5a6b8c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
}

.preset-btn:hover {
    background: #4a5b7c;
}

.preset-btn.active {
    background: #3a4b6c;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.section {
    background: rgba(255, 255, 255, 0.6);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    width: 100%;
}

.section h4 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1em;
    padding-bottom: 8px;
    border-bottom: 2px solid #5a6b8c;
}
.input-column h5 {
    color: #2c3e50; /* match other sidebar headings */
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.section .section-subtitle {
    color: #2c3e50;
    font-size: 0.975rem;
    font-weight: 600;
    margin: 2px 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(90, 107, 140, 0.45);
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    margin-bottom: 4px;
    color: #333;
    font-size: 0.85em;
    font-weight: 500;
}

.note-text {
    margin: 0;
    color: #2c3e50;
    font-size: 0.82em;
    line-height: 1.35;
}

.math-equation {
    margin: 4px 0;
    font-size: 0.95em;
    line-height: 1.45;
    letter-spacing: 0.01em;
    font-family: "Times New Roman", Times, serif;
}

.input-group input,
.input-group select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 8px;
    border: 1px solid #aaa;
    border-radius: 4px;
    font-size: 0.9em;
    background: white;
}

.param-sidebar .input-group {
    position: relative;
}

.param-sidebar .input-group select.native-select-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    width: 0;
}

.custom-select {
    position: relative;
}

.custom-select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid #7f8daa;
    border-radius: 6px;
    background: #fff;
    color: #2c3e50;
    font-size: 0.9em;
    text-align: left;
    cursor: pointer;
}

.custom-select-trigger::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid #5a6b8c;
    border-bottom: 2px solid #5a6b8c;
    transform: rotate(45deg) translateY(-1px);
    flex-shrink: 0;
}

.custom-select.open .custom-select-trigger {
    border-color: #5a6b8c;
    box-shadow: 0 0 0 2px rgba(90, 107, 140, 0.2);
}

.custom-select.is-disabled .custom-select-trigger {
    cursor: not-allowed;
    background: #e9edf5;
    color: #7a879d;
    border-color: #b7c1d3;
    box-shadow: none;
    opacity: 0.9;
}

.custom-select.is-disabled .custom-select-trigger::after {
    border-right-color: #8e99ad;
    border-bottom-color: #8e99ad;
}

.custom-select.is-disabled .custom-select-menu {
    display: none !important;
}

.input-group input:disabled {
    cursor: not-allowed;
    background: #e9edf5;
    color: #7a879d;
    border-color: #b7c1d3;
    opacity: 0.9;
}

.custom-select-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #7f8daa;
    border-radius: 6px;
    list-style: none;
    padding: 4px 0;
    margin: 0;
    z-index: 50;
}

.custom-select.open .custom-select-menu {
    display: block;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.custom-select-option {
    width: 100%;
    border: 0;
    background: #fff;
    color: #2c3e50;
    font-size: 0.9em;
    text-align: left;
    padding: 8px 10px;
    cursor: pointer;
}

.custom-select-option:hover,
.custom-select-option:focus {
    background: rgba(90, 107, 140, 0.12);
    outline: none;
}

.custom-select-option.is-selected {
    background: rgba(90, 107, 140, 0.2);
    font-weight: 600;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--navbar-width);
    padding: 40px;
    height: 100vh;
    overflow-y: auto;
    transition: margin-left 0.3s ease;
}

.main-content.landing-mode {
    padding: 0;
}

/* When param sidebar is open, add extra margin */
body.param-sidebar-open .main-content {
    margin-left: calc(var(--navbar-width) + var(--param-sidebar-width));
}

/* ===== PAGE HEADER ===== */
/* .page-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 100px;
    flex-wrap: wrap;
    position: relative;
    width: 100%;
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: clamp(2em, 5vw, 2.5em);
    font-weight: 400;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    color: white;
    text-align: center;
} */
.page-header {
    position: fixed;                    /* Fix it in place */
    top: 0;
    left: var(--navbar-width);          /* Start after navbar */
    right: 0;                           /* Stretch to right edge */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, var(--page-bg-1) 0%, transparent 100%);
    z-index: 100;
    margin-bottom: 0;
}

.page-header h1 {
    font-size: clamp(2em, 5vw, 2.5em);
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    color: white;
    text-align: center;
}
.home-view,
.estimator-view,
.documentation-view {
    padding-top: 120px;                 /* Space for fixed header */
}


/* ===== HOME VIEW ===== */
.home-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.home-intro {
    max-width: 900px;
    width: 100%;
    margin: 0 auto 30px auto;           /* Center it horizontally */
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 30px;
}

.intro-text {
    color: #333;
    font-size: clamp(0.9em, 2vw, 1em);
    line-height: 1.6;
    margin-bottom: 20px;
}

.steps-overview {
    list-style: none;
    padding-left: 25px;
    margin: 20px 0;
}

.steps-overview li {
    color: var(--text-light);
    margin-bottom: 12px;
    line-height: 1.5;
}

.steps-overview li strong {
    color: #ffffff;
}

/* ===== ESTIMATOR VIEW ===== */
.estimator-view {
    /* max-width: 1400px;
    margin: 0 auto; */
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.estimator-view {
    padding-top: 160px;
}

/* ===== RESULTS GRID ===== */
.results-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

body.param-sidebar-open .results-container {
    width: 100%;
    max-width: clamp(760px, 82vw, 1080px);
    padding: 0 clamp(8px, 1.8vw, 18px);
}

.results-header {
    display: grid;
    grid-template-columns: 100px repeat(5, 1fr);
    gap: 15px;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    font-size: clamp(0.9em, 1.5vw, 1.1em);
    text-align: center;
}

.results-header div:first-child {
    text-align: left;
}

.results-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-row {
    display: grid;
    grid-template-columns: 100px repeat(5, 1fr);
    gap: 15px;
    align-items: center;
}

.row-label {
    color: white;
    font-size: clamp(1.5em, 3vw, 2em);
    font-weight: bold;
    text-align: center;
    display: flex;
    flex-direction: column;    /* Stack vertically */
    align-items: center;
    justify-content: center;
    gap: 8 px;
}

.row-title {
    /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    font-size: 0.5em;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 8px;
    border-radius: 4px;
}

.result-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: clamp(0.9em, 1.5vw, 1.2em);
    font-weight: 500;
    text-align: center;
    transition: all 0.3s;
}

.result-card[data-drilldown-key] {
    cursor: pointer;
    position: relative;
}

.result-card.result-card-active {
    border-color: rgba(191, 206, 228, 0.9);
    box-shadow: 0 0 16px rgba(191, 206, 228, 0.35);
    transform: translateY(-2px);
}

.result-card:hover {
    background: rgba(90, 110, 150, 0.9);
    transform: translateY(-2px);
}

.result-drilldown-overlay {
    position: fixed;
    display: none;
    z-index: 2100;
    background: rgba(9, 24, 58, 0.96);
    border: 1px solid rgba(191, 206, 228, 0.55);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    padding: 14px 14px 12px;
    color: #e7edf8;
}

.result-drilldown-overlay.open {
    display: block;
}

.result-drilldown-close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    font-size: 1.25em;
    cursor: pointer;
    padding: 2px 6px;
}

.result-drilldown-close:hover {
    color: white;
}

.result-drilldown-title {
    font-size: 0.92em;
    margin: 0 24px 10px 0;
    color: rgba(255, 255, 255, 0.86);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.result-drilldown-body {
    display: grid;
    gap: 7px;
}

.drilldown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    border-radius: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.06);
}

.drilldown-label {
    font-size: 0.84em;
    color: rgba(255, 255, 255, 0.82);
}

.drilldown-value {
    font-size: 0.86em;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}

.result-row.result-row-boxed {
    padding: 0;
    border: 1px solid rgba(191, 206, 228, 0);
    border-radius: 14px;
    background: rgba(191, 206, 228, 0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0);
    gap: 15px;
}

.result-row.result-row-boxed .result-card {
    min-height: 95px;
    padding: 24px;
    background: rgba(95, 125, 175, 0.3);
    border-color: rgba(191, 206, 228, 0.6);
    box-shadow: 0 0 12px rgba(191, 206, 228, 0.2);
}

/* ===== LEVEL 7/8 GROUP ===== */
.result-row-l78,
.result-row.result-row-boxed.result-row-l78 {
    padding: clamp(20px, 4vw, 25px);
    border-radius: 18px;
    border: 1px solid rgba(191, 206, 228, 0.28);
    background: rgba(12, 31, 72, 0.45);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
    gap: clamp(10px, 2vw, 14px);
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
    grid-template-columns: fit-content(120px) repeat(5, minmax(0, 1fr));
    overflow-x: auto;
}
.result-row-l78 .row-label {
    gap: 5px;
}

.result-row.result-row-l78 .row-label {
    min-width: max-content;   /* keep full subtitle width inside label column */
    padding-right: 5px;      /* hard separation from first card */
}

.result-row.result-row-l78 .row-title-l78 {
    white-space: nowrap;      /* or normal if you prefer wrapping */
}


.result-row-l78 .row-number {
    font-size: clamp(1.25em, 2.6vw, 1.9em);
}

.result-row-l78 .row-title {
    padding: 0;
    border-radius: 0;
}

.row-title-l78 {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.5em;
    color: rgba(255, 255, 255, 0.74);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.row-title-l78 .row-title-block {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.15;
}

.row-title-l78 .row-title-separator {
    width: 1px;
    height: 2.4em;
    background: rgba(255, 255, 255, 0.74);
    opacity: 1;
}

.result-row-l78 .result-card {
    min-height: clamp(80px, 12vw, 104px);
    padding: clamp(15px, 2.5vw, 20px);
    font-size: clamp(0.9em, 1.8vw, 1.44em);
    flex-shrink: 0;
}


/* ===== TARGETS VIEW ===== */
.targets-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding-top: 160px;
}

.targets-container {
    display: grid;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    align-items: center;
    padding: 0 clamp(15px, 5vw, 40px);
}

.targets-grid {
    display: grid;
    grid-template-columns: 120px repeat(6, 1fr);
    gap: 12px;
    width: 100%;
    padding: 20px;
    background: rgba(12, 31, 72, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(191, 206, 228, 0.3);
}

.targets-header-row {
    display: contents;
}

.targets-label-cell {
    background: transparent;
    border: none;
}

.targets-header-cell {
    background: rgba(90, 110, 150, 0.4);
    border: 1px solid rgba(191, 206, 228, 0.4);
    border-radius: 6px;
    padding: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    text-align: center;
    font-size: 0.95em;
}

.targets-data-row {
    display: contents;
}

.targets-row-label {
    background: rgba(90, 110, 150, 0.4);
    border: 1px solid rgba(191, 206, 228, 0.4);
    border-radius: 6px;
    padding: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    text-align: center;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.targets-cell {
    background: rgba(70, 90, 130, 0.3);
    border: 1px solid rgba(191, 206, 228, 0.3);
    border-radius: 6px;
    padding: 16px 12px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9em;
    text-align: center;
}

.targets-cell.targets-disabled {
    background: rgba(100, 100, 100, 0.2);
    border: 1px solid rgba(150, 150, 150, 0.2);
    cursor: not-allowed;
}

.targets-cell.targets-input-container {
    padding: 8px;
    background: rgba(60, 80, 120, 0.4);
    border: 1px solid rgba(191, 206, 228, 0.5);
}

.targets-cell.targets-output {
    background: rgba(70, 90, 130, 0.3);
    border: 1px dashed rgba(191, 206, 228, 0.4);
    color: rgba(255, 255, 255, 0.6);
}

.targets-input {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(191, 206, 228, 0.6);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    font-size: 0.9em;
    text-align: center;
}

.targets-input:focus {
    outline: none;
    border-color: rgba(191, 206, 228, 1);
    box-shadow: 0 0 8px rgba(191, 206, 228, 0.4);
}

.targets-input::placeholder {
    color: rgba(100, 100, 100, 0.6);
}

.targets-logo {
    position: fixed !important;
    top: 16px;
    right: 24px !important;
    left: auto !important;
    z-index: 300;
}

body.param-sidebar-open .targets-container {
    width: 100%;
    max-width: 1200px;
}

/* ===== DOCUMENTATION VIEW ===== */
.documentation-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.doc-content {
    max-width: 800px;                     /* Content stays at 800px */
    width: 100%;
    margin: 0 auto;                       /* Center it */
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 30px;
}

.doc-content h1 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.doc-content p {
    color: #333;
    line-height: 1.6;
    margin-bottom: 15px;
}

/* ===== HEADER WITH LOGO ===== */
.header-with-logo {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    position: relative;
    width: 100%;
}

.header-with-logo h1 {
    grid-column: 2;
    margin: 0;
}

.header {
    text-align: center;
    flex-shrink: 0;               /* Prevent title from shrinking */
}

.header-logo {
    grid-column: 3;
    justify-self: end;
    max-width: min(220px, 28vw);
    display: flex;
    align-items: center;
    z-index: 20;
}

.home-logo {
    position: fixed !important;
    top: 16px;
    right: 24px !important;
    left: auto !important;
    z-index: 300;
}

.estimator-logo {
    position: fixed !important;
    top: 16px;
    right: 24px !important;
    left: auto !important;
    z-index: 300;
}

.header-logo img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* ===== SCROLLBAR ===== */
.param-sidebar::-webkit-scrollbar {
    width: 8px;
}

.param-sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.param-sidebar::-webkit-scrollbar-thumb {
    background: #5a6b8c;
    border-radius: 4px;
}

.main-content::-webkit-scrollbar {
    width: 10px;
}

.main-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.main-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}
/* ===== TOOl TIP===== */
.label-with-tooltip {
    position: relative;
    display: block;      /* full available width in sidebar section */
    width: 100%;
    cursor: help;
    color: #2c3e50;
    font-size: 0.95em;
    font-weight: 600;
    z-index: 0;
    isolation: isolate;
}

.row-label .label-with-tooltip.row-label-tooltip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: 1.1;
    isolation: isolate;
}

.label-with-tooltip .tooltip-box {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-65%);  /* auto horizontal centering */
    width: min(280px, calc(var(--param-sidebar-width) - 36px));
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid #7f8daa;
    background: rgba(200, 210, 230, 0.98);
    color: #223146;
    font-size: 0.98em;
    line-height: 1.45;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    z-index: 8000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.row-label .label-with-tooltip.row-label-tooltip .tooltip-box {
    left: 120%;
    transform: translateX(-50%);
    min-width: 220px;
    max-width: min(320px, 70vw);
    font-size: 0.95rem;
    font-weight: 600;
}

/* Nudge a single tooltip slightly to the right without affecting others */
.label-with-tooltip.tooltip-nudge-right .tooltip-box {
    left: 100%;
    transform: translateX(-60%);
}

.label-with-tooltip:hover,
.label-with-tooltip:focus-within {
    z-index: 10;
}

.label-with-tooltip:hover .tooltip-box,
.label-with-tooltip:focus-within .tooltip-box {
    opacity: 1;
    visibility: visible;
}

/* ===== RESPONSIVE DESIGN ===== */

/* ===== Laptops/Medium Screens (769px to 1440px) ===== */
@media screen and (min-width: 769px) and (max-width: 1440px) {

    .results-container {
        width: 100%;
        max-width: clamp(980px, 96vw, 1380px);
        margin: 0 auto;
        padding: 0 clamp(10px, 2.2vw, 24px);
        height: 50%;
        transition: max-width 0.3s ease, padding 0.3s ease;
    }
    
    .results-grid {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: clamp(10px, 1.3vw, 13px);
    }
    
    .results-header,
    .result-row {
        grid-template-columns: clamp(68px, 7vw, 88px) repeat(5, minmax(0, 1fr));
        gap: clamp(8px, 1.2vw, 12px);
        width: 100%;
        transition: gap 0.3s ease, grid-template-columns 0.3s ease;
    }
    
    .results-header {
        margin-bottom: clamp(4px, 0.6vw, 8px);
        font-size: clamp(0.82em, 1vw, 0.98em);
    }
    
    .results-header > div {
        padding: clamp(8px, 1vw, 11px);
    }
    
    .row-label {
        font-size: clamp(1.02em, 1.45vw, 1.28em);
    }

    .result-card {
        padding: clamp(10px, 1.35vw, 14px);
        /* TUNE: laptop card height (regular result cards) */
        min-height: clamp(68px, 7vw, 72px);
        font-size: clamp(0.8em, 1.05vw, 0.95em);
        transition: padding 0.3s ease, font-size 0.3s ease, min-height 0.3s ease;
    }

    .result-row.result-row-boxed .result-card {
        /* TUNE: laptop card height (boxed rows) */
        min-height: clamp(60px, 8vw, 82px);
        padding: clamp(12px, 1.6vw, 16px);
    }
    
    .result-row.result-row-boxed.result-row-l78 {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .result-row-l78,
    .result-row.result-row-boxed.result-row-l78 {
        padding: clamp(14px, 2.2vw, 20px);
        gap: clamp(8px, 1.1vw, 12px);
        grid-template-columns: clamp(68px, 7vw, 88px) repeat(5, minmax(0, 1fr));
        overflow-x: clip;
    }

    .result-row.result-row-l78 .row-label {
        min-width: 0;
        padding-right: 0;
    }

    .result-row-l78 .result-card {
        /* TUNE: laptop card height (L7/L8 row cards) */
        min-height: clamp(70px, 8.4vw, 88px);
        padding: clamp(12px, 1.8vw, 16px);
        font-size: clamp(0.84em, 1.08vw, 1.02em);
    }
    
    body.param-sidebar-open .main-content {
        margin-left: calc(var(--navbar-width) + var(--param-sidebar-width));
    }

    body.param-sidebar-open .results-container {
        width: 100%;
        max-width: clamp(760px, 82vw, 1080px);
        padding: 0 clamp(8px, 1.8vw, 18px);
    }

    body.param-sidebar-open .results-header,
    body.param-sidebar-open .result-row {
        grid-template-columns: clamp(60px, 6.2vw, 76px) repeat(5, minmax(0, 1fr));
        gap: clamp(7px, 1vw, 10px);
    }

    body.param-sidebar-open .results-header > div {
        padding: clamp(7px, 0.9vw, 10px);
    }

    body.param-sidebar-open .row-label {
        font-size: clamp(0.95em, 1.15vw, 1.12em);
    }

    body.param-sidebar-open .result-card {
        padding: clamp(8px, 1.25vw, 12px);
        min-height: clamp(58px, 6.8vw, 68px);
        font-size: clamp(0.76em, 0.95vw, 0.88em);
    }

    body.param-sidebar-open .result-row.result-row-boxed .result-card {
        min-height: clamp(64px, 7.4vw, 76px);
        padding: clamp(10px, 1.35vw, 14px);
    }

    body.param-sidebar-open .result-row-l78,
    body.param-sidebar-open .result-row.result-row-boxed.result-row-l78 {
        padding: clamp(12px, 1.8vw, 16px);
        gap: clamp(7px, 0.9vw, 10px);
    }

    body.param-sidebar-open .result-row-l78 .result-card {
        min-height: clamp(66px, 7.8vw, 80px);
        padding: clamp(10px, 1.4vw, 14px);
        font-size: clamp(0.78em, 0.98vw, 0.9em);
    }
    
    .param-sidebar {
        z-index: 999;
    }
    
    .header-logo img {
        height: clamp(48px, 4.5vw, 60px);
    }
}

/* ===== Small Tablets (900px and below, desktop overlap only) ===== */
@media screen and (min-width: 769px) and (max-width: 900px) {
    :root {
        --param-sidebar-width: clamp(248px, 31vw, 280px);
    }

    .results-container {
        width: 100%;
        max-width: clamp(760px, 95vw, 880px);
        padding: 0 clamp(8px, 1.9vw, 16px);
    }

    body.param-sidebar-open .results-container {
        width: 100%;
        max-width: clamp(700px, 90vw, 820px);
        padding: 0 clamp(7px, 1.5vw, 14px);
    }
    
    .results-header,
    .result-row {
        grid-template-columns: clamp(58px, 6.6vw, 68px) repeat(5, minmax(0, 1fr));
        gap: clamp(7px, 1vw, 9px);
    }

    .row-label {
        font-size: clamp(0.92em, 1.6vw, 1.04em);
    }
    
    .result-card {
        padding: clamp(8px, 1.15vw, 10px);
        min-height: clamp(56px, 6.8vw, 62px);
        height: clamp(56px, 6.8vw, 62px);
        font-size: clamp(0.75em, 0.95vw, 0.84em);
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .result-row.result-row-boxed .result-card {
        min-height: clamp(62px, 7.2vw, 70px);
        height: clamp(62px, 7.2vw, 70px);
        padding: clamp(9px, 1.3vw, 12px);
    }

    .result-row-l78,
    .result-row.result-row-boxed.result-row-l78 {
        grid-template-columns: clamp(58px, 6.6vw, 68px) repeat(5, minmax(0, 1fr));
        overflow-x: clip;
    }

    .result-row.result-row-l78 .row-label {
        min-width: 0;
        padding-right: 0;
    }

    .result-row-l78 .result-card {
        min-height: clamp(64px, 7.6vw, 74px);
        padding: clamp(10px, 1.5vw, 13px);
        font-size: clamp(0.8em, 1vw, 0.9em);
    }

    body.param-sidebar-open .results-header,
    body.param-sidebar-open .result-row {
        grid-template-columns: clamp(54px, 5.8vw, 62px) repeat(5, minmax(0, 1fr));
        gap: clamp(6px, 0.8vw, 8px);
    }

    body.param-sidebar-open .result-card {
        padding: clamp(7px, 1vw, 9px);
        min-height: clamp(54px, 6.4vw, 60px);
        height: clamp(54px, 6.4vw, 60px);
        font-size: clamp(0.72em, 0.88vw, 0.8em);
    }

    body.param-sidebar-open .result-row.result-row-boxed .result-card {
        min-height: clamp(60px, 6.8vw, 66px);
        height: clamp(60px, 6.8vw, 66px);
        padding: clamp(8px, 1.1vw, 11px);
    }
}

/* ===== Mobile/Tablets (768px and below) ===== */
@media screen and (max-width: 768px) {
    :root {
        --navbar-width: 50px;
        --param-sidebar-width: 280px;
    }
    
    .navbar {
        width: var(--navbar-width);
        padding: 15px 0;
    }
    
    .navbar-content {
        gap: 10px;
    }
    
    .navbar-top {
        gap: 10px;
    }
    
    .nav-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }
    
    .header-logo img {
        height: 50px;
    }
    
    .main-content {
        margin-left: var(--navbar-width);
        padding: clamp(15px, 3vw, 20px);
        height: 100vh;
    }
    
    body.param-sidebar-open .main-content {
        margin-left: var(--navbar-width);
    }
    
    .param-sidebar {
        left: var(--navbar-width);
        width: min(92vw, 360px);
    }

    .input-row {
        grid-template-columns: 1fr;
    }
    
    .results-container {
        width: min(98vw, 100%);
        padding: 0 clamp(8px, 2vw, 15px);
    }

    .results-header,
    .result-row {
        grid-template-columns: 50px repeat(5, 1fr);
        gap: clamp(5px, 1vw, 6px);
        width: 100%;
        overflow-x: auto;
    }

    .result-row-l78,
    .result-row.result-row-boxed.result-row-l78 {
        grid-template-columns: 50px repeat(5, 1fr);
        overflow-x: auto;
    }

    .result-row.result-row-l78 .row-label {
        min-width: max-content;
        padding-right: 5px;
    }
    
    .result-card {
        padding: clamp(6px, 1.2vw, 8px);
        min-height: 50px;
        font-size: clamp(0.7em, 1.1vw, 0.75em);
        flex-shrink: 0;
        min-width: fit-content;
    }

    .row-label {
        font-size: clamp(0.9em, 2vw, 1.1em);
    }
    
    .home-intro,
    .doc-content {
        padding: 20px;
    }
    
    .intro-text {
        font-size: 0.9em;
    }
    
    .steps-overview {
        padding-left: 20px;
    }
    
    .result-row.result-row-boxed.result-row-l78 {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding: clamp(12px, 3vw, 15px);
    }

}

/* ===== Small Mobile (600px and below) ===== */
@media screen and (max-width: 600px) {
    :root {
        --navbar-width: 50px;
        --param-sidebar-width: calc(100vw - 50px); 
    }
    
    .param-sidebar {
        left: var(--navbar-width);                   
        width: var(--param-sidebar-width);           
        transform: translateX(-100%);                
    }
    
    .param-sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: var(--navbar-width);
        padding: 15px;
    }
    
    .header-with-logo {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 10px;
    }

    .header-with-logo h1,
    .header-logo {
        grid-column: 1;
        justify-self: center;
    }
    
    .header-logo img {
        height: 40px;
    }
    
    /* Results grid becomes single column cards */
    .results-header {
        display: none;
    }
    
    .results-grid {
        gap: 15px;
    }
    
    .result-row {
        grid-template-columns: 1fr;
        gap: 8px;
        background: rgba(255, 255, 255, 0.05);
        padding: 15px;
        border-radius: 10px;
    }

    .result-row.result-row-boxed.result-row-l78 {
        border-radius: 14px;
        background: rgba(12, 31, 72, 0.48);
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        grid-template-columns: 1fr;
    }

    .result-row.result-row-l78 .row-label {
        min-width: 0;
        padding-right: 0;
    }

    .result-row.result-row-l78 .row-title-l78 {
        white-space: normal;
    }
    
    .row-label {
        text-align: center;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    }

    
    .result-card {
        display: block;
        min-height: auto;
        padding: 12px;
        text-align: left;
    }
    
    .result-card::before {
        content: attr(data-label) ": ";
        color: var(--accent-color);
        font-size: 0.85em;
        font-weight: 600;
    }
    
    .logo {
        bottom: 15px;
        right: 15px;
    }
    
    .logo img {
        height: 40px;
    }
    
    .sidebar-header {
        padding: 15px;
    }
    
    .sidebar-header h2 {
        font-size: 1em;
    }
    
    .sidebar-content {
        padding: 15px;
    }
    
    .section {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .section h4 {
        font-size: 0.9em;
        margin-bottom: 10px;
    }
    
    .input-group input,
    .input-group select,
    .custom-select-trigger,
    .custom-select-option {
        font-size: 0.85em;
        padding: 6px;
    }
    
    .input-row {
        gap: 8px;
    }
}

/* ===== Extra Small Mobile (480px and below) ===== */
@media screen and (max-width: 480px) {
    .navbar {
        width: 45px;
        padding: 10px 0;
    }
    
    .nav-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }
    
    .header-logo img {
        height: 35px;
    }
    
    .result-row {
        padding: 10px;
    }
    
    .result-card {
        padding: 10px;
        font-size: 0.7em;
    }
}

/* ===== OUTPUT HEADER ===== */
.output-header {
    color: white;
    padding: 10px 20px 20px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.output-header h2 {
    font-size: 1.2em;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 5px;
}
