:root {
  --blue: #0d67e8;
  --navy: #082e63;
  --ink: #11213c;
  --muted: #687892;
  --line: #dce5f1;
  --bg: #f2f6fc;
  --green: #20b765;
  --red: #e34b5f;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

.app-shell {
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: 235px minmax(0, 1fr);
}

@media screen and (min-width: 1151px) {
  body { zoom: .8; }
  .app-shell {
    width: 125vw;
    height: 125vh;
  }
}

.sidebar {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #092f64, #061f45);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.brand {
  min-height: 116px;
  padding: 30px 20px;
  display: grid;
  align-content: center;
  gap: 5px;
  background: #fff;
  text-decoration: none;
}

.brand strong { color: #1262d2; font-size: 25px; font-weight: 900; }
.brand span { color: #263b58; font-size: 14px; }
.sidebar nav { padding: 20px 12px; display: grid; gap: 8px; }
.sidebar nav p { margin: 4px 8px; color: #9eb9da; font-size: 12px; }

.sidebar nav a,
.sidebar nav button {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dceaff;
  text-align: left;
  text-decoration: none;
  font: inherit;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.sidebar nav .active { background: var(--blue); color: #fff; }
.sidebar footer { margin-top: auto; padding: 20px; color: #9eb9da; font-size: 13px; }

main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: 0 0 116px;
  min-height: 116px;
  padding: 17px 28px 16px;
  background: linear-gradient(105deg, #ffffff 0%, #f7faff 58%, #edf5ff 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(29, 79, 145, .06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  position: relative;
  z-index: 2;
}

.topbar::after { content: ""; position: absolute; left: 28px; bottom: -1px; width: 58px; height: 3px; border-radius: 3px; background: var(--blue); }
.topbar-heading { min-width: 0; display: grid; gap: 5px; }
.product-kicker { color: #1765d8; font-size: 12px; line-height: 1; font-weight: 800; letter-spacing: 1.15px; }
.title-row { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar h1 { margin: 0; color: #092c5c; font-size: 25px; line-height: 1.1; font-weight: 850; letter-spacing: -.35px; }
.standard-badge { padding: 5px 9px; border: 1px solid #b9d5fa; border-radius: 999px; background: #eaf3ff; color: #1765d8; font-size: 11px; font-weight: 800; white-space: nowrap; }
.topbar p { margin: 0; color: #687892; font-size: 14px; }
.actions { display: flex; gap: 10px; }

.language-picker {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid #bfd3ee;
  border-radius: 8px;
  background: #fff;
  color: #1765d8;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 10px rgba(30, 76, 136, .04);
}
.language-picker > span { font-size: 16px; font-weight: 800; }
.language-picker select { border: 0; outline: 0; background: transparent; color: #123866; font: inherit; font-weight: 800; cursor: pointer; }

.actions button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #23405f;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-shadow: 0 3px 10px rgba(30, 76, 136, .04);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.actions button:hover { border-color: #9cbfec; box-shadow: 0 6px 16px rgba(30, 89, 170, .11); transform: translateY(-1px); }
.actions button span { color: #1765d8; font-size: 14px; line-height: 1; }
.actions .primary { border-color: var(--blue); background: linear-gradient(135deg, #1474ed, #075fd7); color: #fff; box-shadow: 0 8px 18px rgba(13, 103, 232, .2); }
.actions .primary span { color: #fff; }

.workspace {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(540px, .95fr) minmax(520px, 1.05fr);
  gap: 20px;
}

.left-column,
.right-column {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  align-content: start;
  gap: 20px;
}

.left-column {
  overflow: hidden;
  grid-template-rows: max-content max-content max-content;
}

.right-column {
  grid-auto-rows: max-content;
  overflow-y: scroll;
  overflow-x: hidden;
  padding-right: 8px;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  scrollbar-color: #7189a6 #e7edf6;
}

.right-column::-webkit-scrollbar { width: 12px; }
.right-column::-webkit-scrollbar-track { background: #e7edf6; border-radius: 10px; }
.right-column::-webkit-scrollbar-thumb { background: #7189a6; border-radius: 10px; border: 2px solid #e7edf6; }
.right-column::-webkit-scrollbar-thumb:hover { background: #4f6886; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(30, 70, 130, .07);
  overflow: hidden;
}

.panel-title {
  min-height: 62px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title > div { display: flex; align-items: center; gap: 10px; }
.panel-title span { width: 31px; height: 31px; border-radius: 8px; background: #e9f2ff; color: var(--blue); display: grid; place-items: center; font-size: 12px; font-weight: 900; }
.panel-title h2 { margin: 0; color: #092c5c; font-size: 20px; line-height: 1.2; font-weight: 850; letter-spacing: -.2px; }
.section-icon {
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  padding: 3px;
  border-radius: 6px;
  background: #f1f6fd;
  fill: none;
  stroke: #1765d8;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.panel-title small { color: var(--muted); font-size: 13px; }

.input-grid { padding: 20px 20px 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.input-grid label { display: grid; gap: 5px; }
.input-grid label > span { font-weight: 700; }
.input-grid label > small { color: var(--muted); font-size: 13px; }
.input-grid label > div { display: grid; grid-template-columns: 1fr auto; border: 1px solid #cfdaea; border-radius: 7px; overflow: hidden; }
.input-grid input { min-width: 0; height: 43px; border: 0; outline: 0; padding: 0 12px; font-size: 16px; }
.input-grid label b { min-width: 62px; padding: 0 10px; background: #f1f5fb; color: #526784; display: grid; place-items: center; font-size: 13px; }

.message { margin: 0 20px 20px; padding: 12px; border-radius: 7px; background: #fff0f2; color: #b5293d; }
.message.warning { background: #fff8e5; color: #8a6100; }

.result-grid { padding: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.result-grid article { min-height: 124px; padding: 15px; border: 1px solid #e2e9f3; border-radius: 9px; display: grid; align-content: start; grid-template-columns: 1fr auto; gap: 5px; background: #fbfdff; }
.result-grid article > span { grid-column: 1 / -1; color: #52637e; font-size: 13px; min-height: 31px; }
.result-grid strong { font-size: 24px; color: #123b77; }
.result-grid article > b { align-self: end; color: #75849b; font-size: 12px; }
.result-grid article > small { grid-column: 1 / -1; color: #8290a5; font-size: 12px; }
.result-grid .highlight { border-color: #9fc4ff; background: #edf5ff; }
.result-grid .highlight strong { color: var(--blue); }

.service-card {
  padding: 18px 20px;
  border: 1px solid #cfe0f5;
  border-radius: 12px;
  background: linear-gradient(120deg, #f8fbff 0%, #edf5ff 100%);
  box-shadow: 0 10px 24px rgba(30, 70, 130, .06);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}
.service-copy { min-width: 0; }
.service-kicker { color: #1765d8; font-size: 11px; font-weight: 900; letter-spacing: 1px; }
.service-card h3 { margin: 4px 0 11px; color: #123866; font-size: 16px; }
.service-card ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 7px; }
.service-card li { padding: 5px 9px; border: 1px solid #d6e5f7; border-radius: 999px; background: rgba(255,255,255,.78); color: #526784; font-size: 12px; white-space: nowrap; }
.service-card li::before { content: "✓"; margin-right: 5px; color: #20a862; font-weight: 900; }
.service-card > a { min-height: 39px; padding: 0 13px; border: 1px solid #a9caf4; border-radius: 8px; background: #fff; color: #1765d8; text-decoration: none; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.service-card > a:hover { border-color: #1765d8; box-shadow: 0 6px 16px rgba(23,101,216,.12); }
.service-card > a span { font-size: 15px; }

.tank-panel #tank-view { height: 190px; padding: 18px; }
.tank-svg { width: 100%; height: 100%; }
.chart-panel svg { width: 100%; height: auto; display: block; background: #fff; }
.cycle-kpis { padding: 14px 18px 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; background: #f8fbff; }
.cycle-kpis article { min-width: 0; padding: 11px 12px; border: 1px solid #dfe8f4; border-radius: 9px; background: #fff; display: grid; grid-template-columns: 1fr auto; gap: 3px 6px; }
.cycle-kpis span { grid-column: 1 / -1; color: #687892; font-size: 11px; font-weight: 700; }
.cycle-kpis strong { color: #123b77; font-size: 19px; white-space: nowrap; }
.cycle-kpis small { align-self: end; color: #8794a6; font-size: 10px; }
.cycle-kpis .ready-kpi strong { color: #168a50; }
.cycle-tabs { padding: 10px 18px; border-bottom: 1px solid #dfe8f4; display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 8px; overflow-x: auto; background: #fff; }
.cycle-tabs button { min-width: 140px; min-height: 55px; padding: 9px 11px; border: 1px solid #dfe8f4; border-radius: 8px; background: #f8fbff; color: #687892; font: inherit; text-align: left; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.cycle-tabs button > b { width: 31px; height: 31px; flex: 0 0 31px; border-radius: 7px; background: #e9f2ff; color: #1765d8; display: grid; place-items: center; font-size: 11px; }
.cycle-tabs button > span { min-width: 0; display: grid; gap: 2px; }
.cycle-tabs button strong { color: #244467; font-size: 14px; line-height: 1.2; }
.cycle-tabs button small { overflow: hidden; color: #74849a; font-size: 11px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.cycle-tabs button:hover { border-color: #9fc4f5; background: #f2f7ff; }
.cycle-tabs button.active { border-color: #74aef6; background: #eaf3ff; box-shadow: inset 0 -3px 0 #1765d8; }
.cycle-tabs button.active > b { background: #1765d8; color: #fff; }
.cycle-tabs button.active strong { color: #0b55bd; }
.axis { stroke: #73839a; stroke-width: 1; }
.axis-tick { stroke: #73839a; stroke-width: 1; }
.axis-value { fill: #405571; font-size: 12px; font-weight: 600; }
.flow-axis, .flow-axis-tick { stroke: #b16c16; stroke-width: 1; }
.flow-axis-value { fill: #8b570f; font-size: 12px; font-weight: 600; }
.flow-axis-title { fill: #8b570f; font-size: 12px; font-weight: 700; }
.water-axis, .water-axis-tick { stroke: #1597b8; stroke-width: 1; }
.water-axis-value, .water-axis-title { fill: #087d9b; font-size: 12px; font-weight: 700; }
.grid { stroke: #e6ecf4; stroke-width: 1; stroke-dasharray: 4 5; }
.label { fill: #60718a; font-size: 12px; }
.legend { fill: #263b58; font-size: 12px; }
.chart-legend text { fill: #263b58; font-size: 12px; font-weight: 700; }
#cycle-chart, #pv-chart, #ts-chart { min-height: 360px; touch-action: pan-y; }
#cycle-chart, #pv-chart, #ts-chart { cursor: crosshair; }
.chart-touch-hint { display: none; }
.charging-band { fill: #eaf3ff; }
.discharging-band { fill: #fff3e5; }
.phase-divider { stroke: #6f7f94; stroke-width: 1.5; stroke-dasharray: 5 4; }
.phase-labels text { fill: #244467; font-size: 9px; font-weight: 800; letter-spacing: .15px; }
.charging-label-bg { fill: #cfe3ff; stroke: #91bdf7; }
.discharging-label-bg { fill: #ffe0b7; stroke: #f0b46c; }
.hover-line { stroke: #163a6b; stroke-width: 1; stroke-dasharray: 4 4; opacity: .72; }
#cycle-hover-point { fill: #fff; stroke: #1267d8; stroke-width: 2; }
#pv-hover-point { fill: #fff; stroke: #e34b5f; stroke-width: 2; }
#ts-hover-point { fill: #fff; stroke: #7a4ed1; stroke-width: 2; }
#cycle-hover-tip rect, #pv-hover-tip rect, #ts-hover-tip rect { fill: #244b75; opacity: .80; }
#cycle-hover-tip text, #pv-hover-tip text, #ts-hover-tip text { fill: #fff; stroke: none; font-size: 12px; font-weight: 600; }
.empty-chart { fill: #8a98ab; font-size: 14px; }

@media (hover:none), (pointer:coarse) {
  #cycle-chart, #pv-chart, #ts-chart { cursor: default; }
  #cycle-hover-point, #pv-hover-point, #ts-hover-point { r: 6px; stroke-width: 2.5; }
  .chart-touch-hint {
    display: block;
    margin: 0;
    padding: 7px 18px 2px;
    color: #687892;
    background: #fff;
    font-size: 11px;
    text-align: center;
  }
}
.chart-title { fill: #263b58; font-size: 12px; font-weight: 700; }

@media (max-width: 1150px) {
  html, body { height: auto; overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; overflow: visible; grid-template-columns: 205px minmax(0, 1fr); }
  main { height: auto; overflow: visible; display: block; }
  .workspace { grid-template-columns: 1fr; overflow: visible; }
  .left-column, .right-column { height: auto; overflow: visible; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { height: auto; }
  .sidebar nav { grid-template-columns: 1fr 1fr; }
  .sidebar footer { display: none; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .workspace { padding: 12px; }
  .input-grid, .result-grid { grid-template-columns: 1fr; }
  .actions { flex-wrap: wrap; }
  .service-card { grid-template-columns: 1fr; }
  .service-card > a { justify-self: start; }
  .cycle-kpis { grid-template-columns: 1fr 1fr; }
  .cycle-tabs { grid-template-columns: repeat(4, minmax(155px, 1fr)); }
}

@media print {
  @page { size: A4 portrait; margin: 12mm; }

  html, body {
    width: auto;
    height: auto;
    overflow: visible;
    background: #fff;
  }

  body {
    zoom: 1;
    color: #11213c;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-shell {
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
  }

  .sidebar,
  .actions,
  .topbar::after {
    display: none;
  }

  main {
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
  }

  .topbar {
    min-height: 0;
    padding: 0 0 9mm;
    margin: 0 0 7mm;
    background: #fff;
    border-bottom: 2px solid #1765d8;
    box-shadow: none;
  }

  .topbar-heading { gap: 3px; }
  .topbar h1 { font-size: 22px; }

  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 6mm;
    width: auto;
    height: auto;
    padding: 0;
    overflow: visible;
  }

  .left-column {
    display: contents;
  }

  .right-column { display: contents; }

  .panel {
    width: 100%;
    margin: 0 0 7mm;
    border: 1px solid #cfd9e7;
    border-radius: 8px;
    box-shadow: none;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .left-column .panel { margin-bottom: 0; }
  .left-column .panel-title { padding: 11px 13px; }
  .left-column .panel-title small { display: none; }
  .input-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 13px;
  }
  .input-grid input { height: 36px; }
  .result-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 13px;
  }
  .result-grid article { min-height: 94px; padding: 11px; }
  .result-grid strong { font-size: 19px; }
  .tank-panel .panel-title {
    min-height: 46px;
    padding: 8px 13px;
  }
  .tank-panel #tank-view {
    height: 118px;
    padding: 8px 16px;
  }
  .tank-panel {
    grid-column: 1 / -1;
    margin-bottom: 0;
    break-after: page;
    page-break-after: always;
  }
  .chart-panel { grid-column: 1 / -1; }
  .service-card {
    order: 99;
    grid-column: 1 / -1;
    margin: 0;
    padding: 11px 14px;
    border: 1px solid #c9d9ed;
    border-radius: 8px;
    background: #f4f8fd;
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .service-card h3 { margin: 2px 0 7px; font-size: 14px; }
  .service-card ul { gap: 5px; }
  .service-card li { padding: 3px 7px; font-size: 9px; }
  .service-card > a { min-height: 32px; padding: 0 10px; font-size: 10px; }
  #cycle-chart, #pv-chart, #ts-chart { min-height: 0; }
  .chart-panel svg { width: 100%; height: auto; }
}
