/* ═══════════════════════════════════════════
   BESS Kalkulačka — hlavný stylesheet
   Dyness Stack100 + Bojler bytový dom
   ═══════════════════════════════════════════ */

:root {
    --bg:        #0d0f12;
    --bg2:       #13161b;
    --bg3:       #1a1e26;
    --bg4:       #222733;
    --border:    #2a2f3d;
    --border2:   #353d50;
    --green:     #22c55e;
    --green-d:   #16a34a;
    --green-bg:  #0d2218;
    --blue:      #3b82f6;
    --blue-d:    #1d4ed8;
    --blue-bg:   #0d1a38;
    --amber:     #f59e0b;
    --amber-bg:  #221a05;
    --red:       #ef4444;
    --red-bg:    #220d0d;
    --text:      #e8eaf0;
    --text2:     #8892a4;
    --text3:     #4e5a70;
    --accent:    #00e5a0;
    --accent2:   #00b37d;
    --mono:      'DM Mono', 'Courier New', monospace;
    --sans:      'Syne', 'Segoe UI', sans-serif;
    --body:      'Inter', 'Helvetica Neue', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 14px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-weight: 300;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── HEADER ── */
.site-header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 200;
}
.header-logo {
    font-family: var(--sans);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.5px;
    color: var(--accent);
    text-decoration: none;
}
.header-logo span {
    color: var(--text2);
    font-weight: 400;
    font-size: 13px;
    margin-left: 10px;
    letter-spacing: 0;
}
.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-badge {
    font-family: var(--mono);
    font-size: 10px;
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid var(--green-d);
    border-radius: 4px;
    padding: 3px 9px;
}
.header-tag {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text3);
    letter-spacing: 0.05em;
}

/* ── LOADING OVERLAY ── */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    transition: opacity .4s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loader-logo {
    font-family: var(--sans);
    font-weight: 800;
    font-size: 32px;
    color: var(--accent);
    letter-spacing: -1px;
}
.loader-bar {
    width: 200px;
    height: 2px;
    background: var(--bg3);
    border-radius: 2px;
    overflow: hidden;
}
.loader-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    animation: load-anim 1.2s ease-in-out forwards;
}
@keyframes load-anim { from { width: 0 } to { width: 100% } }
.loader-text { font-size: 12px; color: var(--text3); font-family: var(--mono); }

/* ── MAIN LAYOUT ── */
.main-wrap { max-width: 1300px; margin: 0 auto; padding: 2rem; }

.hero {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}
.hero h1 {
    font-family: var(--sans);
    font-weight: 700;
    font-size: 28px;
    letter-spacing: -0.5px;
    line-height: 1.2;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p { color: var(--text2); font-size: 13px; margin-top: 6px; max-width: 520px; }
.hero-meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text3);
    text-align: right;
    line-height: 1.8;
}

/* ── TWO-COLUMN LAYOUT ── */
.layout { display: grid; grid-template-columns: 340px 1fr; gap: 1.5rem; align-items: start; }

/* ── PANEL ── */
.panel {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.panel-hd {
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-hd .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.panel-hd h2 {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text2);
}
.panel-body { padding: 16px; }

/* ── CONTROL GROUPS ── */
.ctrl-group { margin-bottom: 22px; }
.ctrl-group:last-child { margin-bottom: 0; }
.ctrl-group-title {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--accent2);
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.ctrl { margin-bottom: 14px; }
.ctrl:last-child { margin-bottom: 0; }
.ctrl-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}
.ctrl-label .ctrl-name { font-size: 12px; color: var(--text2); }
.ctrl-val {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}

/* Range inputs */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    height: 3px;
    background: var(--bg4);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 1px var(--accent2);
    cursor: pointer;
    transition: transform .15s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.3); }
input[type=range]::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    cursor: pointer;
}
select {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border2);
    color: var(--text);
    font-size: 12px;
    font-family: var(--body);
    padding: 7px 10px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    margin-top: 4px;
    transition: border-color .2s;
}
select:focus { border-color: var(--accent2); }
select option, select optgroup { background: var(--bg3); }

/* ── RIGHT COLUMN ── */
.right-col { display: flex; flex-direction: column; gap: 1.5rem; }

/* ── METRICS GRID ── */
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metric-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
    transition: border-color .2s;
}
.metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    opacity: 0.3;
    transition: opacity .3s, background .3s;
}
.metric-card.ok::before    { background: var(--green); opacity: 0.8; }
.metric-card.warn::before  { background: var(--amber); opacity: 0.8; }
.metric-card.err::before   { background: var(--red);   opacity: 0.8; }
.metric-card:hover { border-color: var(--border2); }
.m-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; letter-spacing: 0.02em; }
.m-val {
    font-family: var(--sans);
    font-weight: 700;
    font-size: 22px;
    color: var(--text);
    line-height: 1;
    display: flex;
    align-items: baseline;
    gap: 4px;
}
.m-val .unit { font-size: 12px; color: var(--text2); font-weight: 400; }
.m-sub { font-size: 11px; color: var(--text3); margin-top: 5px; }

/* ── TABS ── */
.tabs {
    display: flex;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
}
.tab-btn {
    flex: 1;
    padding: 11px 8px;
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text3);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all .2s;
    border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: var(--text2); background: var(--bg4); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--bg2); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── CHART ── */
.chart-hd {
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.chart-hd h3 {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text2);
}
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.chart-legend span {
    display: flex; align-items: center; gap: 5px;
    font-size: 11px; color: var(--text3);
}
.ld { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-body { padding: 16px; }
.chart-canvas-wrap { position: relative; height: 220px; }

/* ── TIMELINE ── */
.timeline-wrap { padding: 14px 16px 0; }
.timeline {
    display: flex;
    height: 36px;
    border-radius: 6px;
    overflow: hidden;
    gap: 1px;
    background: var(--bg);
    margin-bottom: 6px;
}
.tl-seg { flex: 1; cursor: default; transition: opacity .2s; }
.tl-seg:hover { opacity: 0.65; }
.tl-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text3);
    padding: 0 2px;
    margin-bottom: 10px;
}

/* ── TABLE ── */
.table-scroll { overflow-x: auto; max-height: 360px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead { position: sticky; top: 0; z-index: 5; }
thead tr { background: var(--bg3); }
th {
    padding: 9px 12px;
    text-align: left;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--text3);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text2);
    white-space: nowrap;
}
tbody tr:hover { background: var(--bg3); }
tbody tr:last-child td { border-bottom: none; }
.mono-cell { font-family: var(--mono); color: var(--text); }
.green-cell { color: var(--green); font-family: var(--mono); }
.accent-cell { color: var(--accent); font-family: var(--mono); font-weight: 500; }

/* ── BADGE ── */
.badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 4px;
    font-family: var(--mono);
    letter-spacing: 0.04em;
}
.badge-green { background: var(--green-bg); color: var(--green);  border: 1px solid var(--green-d); }
.badge-blue  { background: var(--blue-bg);  color: var(--blue);   border: 1px solid var(--blue-d); }
.badge-amber { background: var(--amber-bg); color: var(--amber);  border: 1px solid #78490a; }
.badge-red   { background: var(--red-bg);   color: var(--red);    border: 1px solid #7a1c1c; }
.badge-gray  { background: var(--bg4);      color: var(--text3);  border: 1px solid var(--border); }

/* ── SAVINGS ROW ── */
.savings-row {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: var(--green-bg);
    border-top: 1px solid var(--green-d);
    padding: 12px 16px;
    flex-wrap: wrap;
}
.savings-row .s-lbl { font-size: 11px; color: var(--green-d); margin-bottom: 2px; }
.savings-row .s-val {
    font-family: var(--sans);
    font-weight: 700;
    font-size: 20px;
    color: var(--green);
}

/* ── BOTTLENECK ── */
.bottleneck {
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid;
    margin-bottom: 6px;
    line-height: 1.5;
}
.bottleneck:last-child { margin-bottom: 0; }
.bn-ok   { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.bn-warn { border-color: var(--amber); background: var(--amber-bg); color: var(--amber); }
.bn-err  { border-color: var(--red);   background: var(--red-bg);   color: var(--red);  }

/* ── HW GRID ── */
.hw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hw-item {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
}
.hw-lbl {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--accent2);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.hw-val { font-size: 13px; color: var(--text); line-height: 1.6; }

/* ── DATASHEET GRID ── */
.ds-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ds-item {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
}
.ds-item .ds-k { font-size: 11px; color: var(--text3); margin-bottom: 3px; }
.ds-item .ds-v { font-family: var(--mono); font-size: 11px; color: var(--text); font-weight: 500; }
.ds-full { grid-column: 1 / -1; }

/* ── PHYSICS TABLE ── */
.phys-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.phys-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.phys-table td:first-child { color: var(--text2); width: 35%; }
.phys-table td:nth-child(2) { font-family: var(--mono); font-size: 11px; color: var(--text3); width: 40%; }
.phys-table td:last-child { color: var(--accent); font-family: var(--mono); font-weight: 500; text-align: right; }
.phys-table tr:last-child td { border-bottom: none; }

/* ── SPINNER ── */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FOOTER ── */
.site-footer {
    margin-top: 3rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text3);
    max-width: 1300px;
    margin-left: auto;
    margin-right: auto;
}
.site-footer a { color: var(--accent2); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 12px;
    color: var(--text);
    z-index: 1000;
    transform: translateY(80px);
    opacity: 0;
    transition: all .3s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.err { border-color: var(--red); color: var(--red); }

/* ── RESPONSIVE ── */
@media (max-width: 1050px) {
    .layout { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .hw-grid      { grid-template-columns: 1fr; }
    .ds-grid      { grid-template-columns: repeat(2, 1fr); }
    .hero         { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 500px) {
    .main-wrap    { padding: 1rem; }
    .site-header  { padding: 0 1rem; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
}
