/* ==========================================================================
   Equipment Operating Cost Calculator – styles
   ========================================================================== */

:root {
    --brand: #1d4ed8;
    --brand-600: #2563eb;
    --brand-700: #1e40af;
    --brand-soft: #dbeafe;
    --accent: #f59e0b;

    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;

    --success: #059669;
    --success-soft: #d1fae5;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --info: #0284c7;
    --info-soft: #e0f2fe;

    /* cost components */
    --c-depreciation: #f59e0b;
    --c-finance: #8b5cf6;
    --c-insurance: #14b8a6;
    --c-other: #64748b;
    --c-maintenance: #a855f7;
    --c-fuel: #ef4444;
    --c-repairs: #ec4899;
    --c-operator: #3b82f6;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
    --brand: #60a5fa;
    --brand-600: #3b82f6;
    --brand-700: #2563eb;
    --brand-soft: #1e3a8a;
    --bg: #0b1220;
    --surface: #111a2e;
    --surface-2: #16213a;
    --surface-3: #1c2a47;
    --border: #243352;
    --border-strong: #334766;
    --text: #e6edf7;
    --text-2: #a6b3c9;
    --text-3: #6f7f9c;
    --success-soft: #064e3b;
    --danger-soft: #450a0a;
    --warning-soft: #451a03;
    --info-soft: #0c2a3f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    /* keep Bootstrap components (cards, modals, tables) in sync with the theme */
    --bs-body-color: #e6edf7;
    --bs-body-bg: #0b1220;
    --bs-border-color: #243352;
    --bs-secondary-color: #a6b3c9;
    --bs-tertiary-bg: #16213a;
    --bs-heading-color: #e6edf7;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
small, .muted { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.app-header {
    position: sticky; top: 0; z-index: 1020;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.app-header .inner {
    max-width: 1320px; margin: 0 auto; padding: .65rem 1rem;
    display: flex; align-items: center; gap: 1rem;
}
.brand {
    display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--text);
    font-weight: 700; font-size: 1.05rem; white-space: nowrap;
}
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-700)); color: #fff; font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--text-2); line-height: 1.1; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.select-pill {
    height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); padding: 0 2rem 0 .8rem; font-weight: 600; font-size: .9rem; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%2394a3b8' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .7rem center;
}
.nav-links { display: flex; gap: .25rem; }
.nav-links a {
    text-decoration: none; color: var(--text-2); font-weight: 500; font-size: .9rem;
    padding: .45rem .7rem; border-radius: 8px;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); }

/* ---------- hero ---------- */
.hero { max-width: 1320px; margin: 0 auto; padding: 1.75rem 1rem .5rem; }
.hero h1 { font-size: clamp(1.4rem, 2.6vw, 2rem); }
.hero p { margin: .4rem 0 0; color: var(--text-2); max-width: 760px; }
.hero .chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.chip i { color: var(--success); }

/* ---------- layout ---------- */
.layout {
    max-width: 1320px; margin: 0 auto; padding: 1rem 1rem 6rem;
    display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1.25rem; align-items: start;
}
@media (max-width: 991px) { .layout { grid-template-columns: minmax(0, 1fr); padding-bottom: 7rem; } }
.form-col, .results-col { min-width: 0; }
.results-col { position: sticky; top: 76px; }
@media (max-width: 991px) { .results-col { position: static; } }

/* ---------- cards / sections ---------- */
.card {
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 1rem; overflow: visible;
}
.card-head h2, .model-card .mc-name, .seg button.active { color: var(--text); }
.card-head {
    display: flex; align-items: center; gap: .75rem; padding: .95rem 1.1rem; border-bottom: 1px solid var(--border);
}
.card-head .step {
    width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none;
    background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .85rem;
}
.card-head h2 { font-size: 1rem; }
.card-head .hint { margin-left: auto; font-size: .8rem; color: var(--text-3); }
.card-body { padding: 1rem 1.1rem; }
.card-body + .card-body { border-top: 1px solid var(--border); }

/* ---------- forms ---------- */
.grid { display: grid; gap: .9rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 575px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-2.keep { grid-template-columns: 1fr 1fr; } }
.field label, .label {
    display: flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: .35rem;
}
.field label .req { color: var(--danger); }
.help { color: var(--text-3); cursor: help; font-size: .85rem; }
.input, .select, textarea.input {
    width: 100%; height: 44px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); padding: 0 .85rem; font: inherit; font-size: .95rem;
    transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: .6rem .85rem; }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 18%, transparent); }
.input.is-invalid { border-color: var(--danger); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.select { appearance: none; -webkit-appearance: none; padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16'%3E%3Cpath fill='%2394a3b8' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .8rem center; }
.affix { position: relative; }
.affix .input { padding-left: 2.4rem; }
.affix.suffix .input { padding-left: .85rem; padding-right: 4.2rem; }
.affix .pre, .affix .post {
    position: absolute; top: 50%; transform: translateY(-50%); font-size: .85rem; font-weight: 600; color: var(--text-3); pointer-events: none;
}
.affix .pre { left: .85rem; }
.affix .post { right: .85rem; }
.field-note { font-size: .75rem; color: var(--text-3); margin-top: .3rem; }
.field-note b { color: var(--text-2); font-weight: 600; }
.error-note { font-size: .75rem; color: var(--danger); margin-top: .3rem; display: none; }
.input.is-invalid ~ .error-note, .is-invalid + .error-note { display: block; }

/* segmented toggle */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; width: 100%; }
.seg button {
    flex: 1; border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 600; font-size: .85rem;
    padding: .5rem .6rem; border-radius: 8px; cursor: pointer; white-space: nowrap; transition: all .15s;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.seg button:disabled { opacity: .5; cursor: not-allowed; }

/* range */
input[type="range"].range { width: 100%; accent-color: var(--brand-600); }

/* ---------- category chips ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
@media (max-width: 575px) {
    .cat-grid { display: flex; overflow-x: auto; padding-bottom: .4rem; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
    .cat-grid .cat { flex: 0 0 140px; scroll-snap-align: start; }
}
.cat {
    display: flex; align-items: center; gap: .55rem; padding: .6rem .7rem; border-radius: 10px; cursor: pointer;
    border: 1.5px solid var(--border); background: var(--surface); color: var(--text); text-align: left; font: inherit;
    font-size: .82rem; font-weight: 600; line-height: 1.25; transition: all .15s;
}
.cat i { font-size: 1.15rem; color: var(--text-3); flex: none; }
.cat:hover { border-color: var(--border-strong); background: var(--surface-2); }
.cat.active { border-color: var(--brand-600); background: var(--brand-soft); color: var(--brand-700); }
[data-theme="dark"] .cat.active { color: #fff; }
.cat.active i { color: var(--brand); }
.cat-group-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin: .75rem 0 .4rem; }
.cat-group-label:first-child { margin-top: 0; }

/* ---------- combobox (model picker) ---------- */
.combo { position: relative; }
.combo .input { padding-right: 2.5rem; }
.combo .combo-clear {
    position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent;
    color: var(--text-3); cursor: pointer; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
}
.combo .combo-clear:hover { background: var(--surface-2); color: var(--text); }
.combo-list {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1050; max-height: 360px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); display: none;
}
.combo-list.show { display: block; }
.combo-group { position: sticky; top: 0; background: var(--surface-2); font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: .4rem .85rem; border-bottom: 1px solid var(--border); }
.combo-item {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .85rem; cursor: pointer; border-bottom: 1px solid var(--border);
}
.combo-item:last-child { border-bottom: 0; }
.combo-item:hover, .combo-item.active { background: var(--brand-soft); }
.combo-item .ci-main { flex: 1; min-width: 0; }
.combo-item .ci-name { font-weight: 600; font-size: .9rem; }
.combo-item .ci-spec { font-size: .75rem; color: var(--text-2); }
.combo-item .ci-price { font-weight: 700; font-size: .85rem; white-space: nowrap; color: var(--success); }
.combo-item.custom-item { background: var(--surface-2); }
.combo-item.custom-item .ci-name { color: var(--brand); }
.combo-item mark { background: var(--warning-soft); color: inherit; padding: 0; }
.combo-empty { padding: 1rem; text-align: center; color: var(--text-2); font-size: .9rem; }

/* model card */
.model-card {
    display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center;
    background: linear-gradient(135deg, var(--brand-soft), transparent); border: 1px solid var(--border);
    border-radius: 12px; padding: .8rem .95rem; margin-top: .9rem;
}
.model-card .mc-icon { width: 42px; height: 42px; border-radius: 10px; background: var(--surface); display: grid; place-items: center; font-size: 1.3rem; color: var(--brand); }
.model-card .mc-name { font-weight: 700; }
.model-card .mc-meta { font-size: .78rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: .3rem .75rem; }
.model-card .mc-price { text-align: right; }
.model-card .mc-price .v { font-weight: 800; font-size: 1.1rem; color: var(--success); }
.model-card .mc-price .l { font-size: .7rem; color: var(--text-3); }
@media (max-width: 575px) { .model-card { grid-template-columns: auto 1fr; } .model-card .mc-price { grid-column: 1 / -1; text-align: left; } }

/* ---------- cost factor switches ---------- */
.factor { border: 1.5px solid var(--border); border-radius: 12px; margin-bottom: .6rem; background: var(--surface); transition: border-color .15s; }
.factor.on { border-color: color-mix(in srgb, var(--brand-600) 55%, var(--border)); }
.factor-head { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; cursor: pointer; user-select: none; }
.factor-head .f-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 1rem; color: #fff; flex: none; }
.factor-head .f-title { font-weight: 700; font-size: .92rem; }
.factor-head .f-sub { font-size: .76rem; color: var(--text-2); }
.factor-head .f-value { margin-left: auto; font-weight: 700; font-size: .85rem; color: var(--text-2); white-space: nowrap; }
.factor-body { display: none; padding: 0 .9rem .9rem; border-top: 1px dashed var(--border); padding-top: .8rem; }
.factor.on .factor-body { display: block; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + .track { background: var(--brand-600); }
.switch input:checked + .track::after { transform: translateX(20px); }

/* ---------- service rows ---------- */
.svc-head, .svc-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 36px; gap: .5rem; align-items: center; }
.svc-head { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 0 .2rem .35rem; }
.svc-row { margin-bottom: .5rem; }
.svc-row .input { height: 40px; font-size: .9rem; }
.svc-row .btn-x { width: 36px; height: 40px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.svc-row .btn-x:hover { color: var(--danger); border-color: var(--danger); }
@media (max-width: 575px) {
    .svc-head { display: none; }
    .svc-row { grid-template-columns: 1fr 1fr 36px; grid-template-areas: 'name name x' 'int cost x'; background: var(--surface-2); padding: .5rem; border-radius: 10px; }
    .svc-row .a-name { grid-area: name; } .svc-row .a-int { grid-area: int; } .svc-row .a-cost { grid-area: cost; } .svc-row .btn-x { grid-area: x; height: 100%; }
}
.svc-foot { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .25rem; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem; height: 44px; padding: 0 1.1rem;
    border-radius: 10px; border: 1.5px solid transparent; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
    text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--brand-600), var(--brand-700)); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(37, 99, 235, .4); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-sm { height: 36px; padding: 0 .8rem; font-size: .82rem; border-radius: 8px; }
.btn-lg { height: 50px; padding: 0 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-success { background: var(--success); color: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ---------- results ---------- */
.result-hero {
    background: linear-gradient(135deg, #0f172a, #1e3a8a 70%, #2563eb); color: #fff; border-radius: var(--radius);
    padding: 1.25rem 1.3rem; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; margin-bottom: 1rem;
}
.result-hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.result-hero .rh-label { font-size: .8rem; opacity: .85; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.result-hero .rh-value { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: .2rem 0; }
.result-hero .rh-value small { font-size: 1rem; font-weight: 600; opacity: .8; }
.result-hero .rh-name { font-size: .9rem; opacity: .9; }
.result-hero .rh-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-top: 1rem; }
.result-hero .rh-mini { background: rgba(255, 255, 255, .12); border-radius: 10px; padding: .55rem .7rem; }
.result-hero .rh-mini .l { font-size: .68rem; opacity: .8; text-transform: uppercase; letter-spacing: .04em; }
.result-hero .rh-mini .v { font-weight: 700; font-size: .98rem; }
.result-hero .rh-status { position: absolute; top: .9rem; right: .9rem; font-size: .72rem; font-weight: 600; background: rgba(255, 255, 255, .15); padding: .25rem .55rem; border-radius: 999px; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-2); }
.empty-state i { font-size: 3rem; color: var(--text-3); }
.empty-state h3 { margin-top: .5rem; font-size: 1.1rem; color: var(--text); }
.empty-state ul { list-style: none; padding: 0; margin: 1rem auto 0; max-width: 300px; text-align: left; font-size: .9rem; }
.empty-state li { padding: .2rem 0; }
.empty-state li i { font-size: 1rem; color: var(--success); margin-right: .4rem; }

.stack-bar { display: flex; height: 18px; border-radius: 999px; overflow: hidden; background: var(--surface-3); margin: .6rem 0 .9rem; }
.stack-bar span { display: block; height: 100%; transition: width .4s ease; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .9rem; }
@media (max-width: 420px) { .legend { grid-template-columns: 1fr; } }
.legend-item { display: flex; align-items: center; gap: .5rem; font-size: .85rem; padding: .3rem 0; border-bottom: 1px dashed var(--border); }
.legend-item .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-item .n { flex: 1; color: var(--text-2); min-width: 0; }
.legend-item .v { font-weight: 700; white-space: nowrap; }
.legend-item .p { font-size: .72rem; color: var(--text-3); width: 42px; text-align: right; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.kpi { border: 1px solid var(--border); border-radius: 12px; padding: .7rem .85rem; background: var(--surface-2); }
.kpi .l { font-size: .72rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: .35rem; }
.kpi .v { font-size: 1.15rem; font-weight: 800; margin-top: .15rem; }
.kpi .s { font-size: .74rem; color: var(--text-3); }

.rental-box { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: .85rem .95rem; background: var(--surface-2); }
.rental-box .rb-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.rental-box .rb-val { font-weight: 800; font-size: 1.2rem; color: var(--success); }
.rental-box .rb-sub { font-size: .78rem; color: var(--text-2); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: .75rem; }
.tabs button { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: .85rem; color: var(--text-2); padding: .5rem .75rem; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.chart-wrap { position: relative; height: 260px; }
@media (max-width: 575px) { .chart-wrap { height: 220px; } }

.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: .5rem .6rem; border-bottom: 1px solid var(--border); font-weight: 700; }
.table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tr.total td { font-weight: 700; background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

details.disclosure { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: .75rem; }
details.disclosure summary { cursor: pointer; list-style: none; padding: .8rem 1rem; font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: .6rem; }
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure summary::after { content: '\F282'; font-family: 'bootstrap-icons'; margin-left: auto; color: var(--text-3); transition: transform .2s; }
details.disclosure[open] summary::after { transform: rotate(180deg); }
details.disclosure .d-body { padding: 0 1rem 1rem; }

/* ---------- sticky mobile bar ---------- */
.sticky-bar {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; padding: .6rem .9rem calc(.6rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, .12); align-items: center; gap: .75rem;
}
.sticky-bar .sb-val { flex: 1; min-width: 0; }
.sticky-bar .sb-val .l { font-size: .68rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.sticky-bar .sb-val .v { font-weight: 800; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 991px) { .sticky-bar { display: flex; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 80px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; max-width: calc(100vw - 32px); }
.toast-msg { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--success); border-radius: 10px; padding: .7rem 1rem; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: .6rem; font-size: .9rem; animation: slideIn .25s ease; }
.toast-msg.error { border-left-color: var(--danger); }
.toast-msg.warning { border-left-color: var(--warning); }
.toast-msg.info { border-left-color: var(--info); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); z-index: 3000; display: none; place-items: center; }
.overlay.show { display: grid; }
.spinner { width: 48px; height: 48px; border: 4px solid rgba(255, 255, 255, .3); border-top-color: #fff; border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Bootstrap modal theming */
.modal-content { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; }
.modal-header, .modal-footer { border-color: var(--border); }
[data-theme="dark"] .btn-close { filter: invert(1); }
.share-row { display: flex; gap: .5rem; }
.share-row .input { flex: 1; }
.share-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; margin-top: .75rem; }
@media (max-width: 420px) { .share-btns { grid-template-columns: 1fr; } }

/* tooltips */
.tooltip-inner { font-size: .78rem; max-width: 260px; }

/* ---------- content sections ---------- */
.content { max-width: 1320px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.content h2 { font-size: 1.3rem; margin-bottom: .35rem; }
.content .lead { color: var(--text-2); margin: 0 0 1.25rem; max-width: 800px; }
.catalog-browse { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .75rem; }
.catalog-browse .cb { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: .85rem .95rem; }
.catalog-browse .cb h3 { font-size: .95rem; display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.catalog-browse .cb h3 i { color: var(--brand); }
.catalog-browse .cb p { font-size: .8rem; color: var(--text-2); margin: 0; }
.catalog-browse .cb .cnt { font-size: .72rem; color: var(--text-3); margin-top: .35rem; }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary { cursor: pointer; padding: .8rem 0; font-weight: 600; list-style: none; display: flex; gap: .5rem; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: '\F4FE'; font-family: 'bootstrap-icons'; color: var(--brand); }
.faq details[open] summary::before { content: '\F2EA'; }
.faq p { color: var(--text-2); font-size: .92rem; margin: 0 0 .9rem; }
.formula { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .75rem .9rem; font-size: .85rem; }
.formula code { font-family: var(--mono); color: var(--brand); font-size: .82rem; }
.formula li { margin-bottom: .3rem; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); padding: 1.5rem 1rem 2rem; margin-top: 1rem; }
.footer .inner { max-width: 1320px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; font-size: .85rem; color: var(--text-2); }
.footer a { color: var(--text-2); text-decoration: none; margin-right: 1rem; }
.footer a:hover { color: var(--brand); }
/* keep the footer links clear of the sticky mobile bar */
@media (max-width: 991px) { .footer { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); } }

/* ---------- print ---------- */
@media print {
    .app-header, .hero, .sticky-bar, .toasts, .no-print, .footer, .content, .form-col, .tabs, .chart-wrap, .actions { display: none !important; }
    body { background: #fff; color: #000; }
    .layout { display: block; padding: 0; }
    .results-col { position: static; }
    .card, .result-hero { box-shadow: none; break-inside: avoid; }
    .result-hero { background: #1e3a8a !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    details.disclosure { border: 0; }
    details.disclosure:not([open]) .d-body { display: block; }
    .print-only { display: block !important; }
}
.print-only { display: none; }
