:root {
  --bg: #f3f3f3;
  --panel: #ffffff;
  --border: #bdbdbd;
  --text: #111;
  --muted: #555;
  --input-bg: #ffffff;
  --input-border: #9b9b9b;
  --btn-bg: #efefef;
  --btn-border: #9b9b9b;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.menubar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 6px 10px;
  background: #e9e9e9;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  justify-self: center;
}

.brand-icon {
  width: 68px;
  height: 68px;
  max-width: 68px;
  max-height: 68px;
  object-fit: contain;
}

.lang-toggle {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.lang-btn {
  height: 24px;
  padding: 4px 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  cursor: pointer;
}

.lang-btn.is-active {
  background: #2d7dff;
  border-color: #2d7dff;
  color: #fff;
  font-weight: 600;
}

.content {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-icon {
  display: flex;
  justify-content: center;
  margin: 14px 0 2px;
}

.page-icon img {
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.row {
  display: grid;
  gap: 12px;
}

.row-2col {
  grid-template-columns: 1fr 1fr;
}

.row-3 {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

@media (max-width: 1200px) {
  .row-2col, .row-3 { grid-template-columns: 1fr; }
}

.group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  min-width: 0;
}

.group > legend {
  padding: 0 6px;
  color: var(--text);
}

.grid {
  display: grid;
  gap: 8px 12px;
  align-items: center;
}

.grid-2 {
  grid-template-columns: minmax(220px, 1fr) 260px;
}

.label {
  font-size: 13px;
  color: var(--text);
}

.label-inline {
  font-size: 13px;
  color: var(--text);
}

.math {
  white-space: nowrap;
}

.input, .select {
  width: 100%;
  height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  font: inherit;
}

.input:disabled {
  background: #f2f2f2;
  color: #333;
}

.input-sm {
  width: 100px;
}

.input.sum-ok,
.input.sum-ok:disabled {
  background: #d9f7d9;
}

.input.sum-bad,
.input.sum-bad:disabled {
  background: #ffd6d6;
}

.select {
  width: 300px;
}

.input-lock {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 6px;
  align-items: center;
}

.lock {
  width: 34px;
  height: 28px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  cursor: pointer;
}

.btn {
  height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  font: inherit;
  cursor: pointer;
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  text-decoration: none;
}

.btn-lg {
  height: 36px;
}

.btn-col {
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

.btn-recalc {
  font-weight: 700;
}

.is-hidden {
  display: none !important;
}

.blink {
  animation: blink 1s steps(1, end) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.mix-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mix-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0 4px;
}

.mix-meta {
  font-size: 12px;
  color: var(--muted);
}

.btn-danger {
  background: #ffe8e8;
  border-color: #e28a8a;
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.mix-source {
  display: flex;
  gap: 16px;
  padding: 6px 0;
  color: var(--muted);
}

.radio {
  font-size: 13px;
  color: var(--text);
}

.radio input { margin-right: 6px; }

.mix-params { margin-top: 4px; }

.table-wrap {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: auto;
  background: #fff;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th, .table td {
  border-bottom: 1px solid #e6e6e6;
  padding: 8px 8px;
  text-align: center;
}

.table th {
  background: #f7f7f7;
  font-weight: 700;
}

.table tbody tr:hover {
  background: #f6f9ff;
}

.table tbody tr.row-selected {
  background: #eaf3ff;
}

.table tbody tr.row-editing {
  background: #fff7d6;
}

.table .row-input {
  width: 100%;
  height: 24px;
  padding: 2px 6px;
  border: 1px solid var(--input-border);
  background: #fff;
  font: inherit;
}

.hydro {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 10px;
  align-items: start;
}

@media (max-width: 1200px) {
  .hydro { grid-template-columns: 1fr; }
}

.hydro-left .radio {
  display: block;
  margin-bottom: 6px;
}

/* Landing page */
.home-intro {
  max-width: 820px;
  line-height: 1.4;
}

.home-calc-desc {
  max-width: 820px;
  line-height: 1.4;
}

.home-actions {
  max-width: 320px;
  margin-top: 12px;
}

.hydro-right {
  display: flex;
  justify-content: flex-end;
}

.hydro-image {
  width: 100%;
  max-width: 350px;
  height: 175px;
  border: 1px solid var(--border);
  display: grid;
  place-items: start center;
  background: #fff;
  overflow: hidden;
}

.hydro-image.align-center {
  place-items: center;
}

.hydro-image img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: top center;
}

.schema-img.origin-center {
  transform-origin: center center;
}

.right-col {
  min-width: 0;
}

.statusbar {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #e9e9e9;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.spacer { flex: 1 1 auto; }

.input.is-warning {
  outline: 2px solid #ffcc00;
  outline-offset: 1px;
}
