:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #1d7f5f;
  --accent-dark: #136448;
  --warning: #fff4dd;
  --warning-line: #f0b74a;
  --danger: #fff0f0;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { font-weight: 800; color: var(--text); }
.topbar nav { display: flex; gap: 16px; flex-wrap: wrap; }
main { width: min(1160px, calc(100% - 24px)); margin: 0 auto; padding: 28px 0 80px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding: 32px;
  margin-bottom: 20px;
  border-radius: 28px;
  background: linear-gradient(135deg, #e8fff6, #ffffff 65%);
  border: 1px solid var(--line);
}
.hero.compact { padding: 24px 32px; }
.hero h1 { margin: 6px 0 10px; font-size: clamp(28px, 5vw, 46px); line-height: 1.05; }
.hero p { margin: 0; max-width: 780px; color: var(--muted); font-size: 17px; }
.eyebrow { font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: 13px !important; }

.calc-card, .result-card, .table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 14px 40px rgba(16, 24, 40, .06);
  padding: clamp(18px, 4vw, 30px);
  margin-bottom: 20px;
}

.step { display: none; }
.step.active { display: block; }
.step h2 { margin-top: 0; }
.step h3 { margin-top: 26px; }
.choice-grid, .grid-3, .admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.choice-grid label, .grid-3 label, .equipment-row, .muted-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}
.choice-grid label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.grid-3 label { display: grid; gap: 8px; color: var(--muted); font-size: 14px; }
label.inline { display: flex !important; align-items: center; gap: 10px; color: var(--text); }
input, select, button {
  font: inherit;
}
input[type="number"], input[type="text"], select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}
.wide-input { max-width: 520px; }
.hint { color: var(--muted); }
.warning {
  padding: 14px;
  border-radius: 16px;
  background: var(--warning);
  border: 1px solid var(--warning-line);
}
.muted-box { color: var(--muted); background: #f9fafb; margin-top: 14px; }
.hidden, .phase-three-only { display: none !important; }
.phase-three .phase-three-only { display: grid !important; }
.input-panel { display: none; margin-top: 18px; }
.input-panel.active { display: block; }
.toolbar, .form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar { margin: 12px 0 16px; }
.form-actions { justify-content: flex-end; margin-top: 24px; }
button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button.secondary, #prev-step { background: #eef2f6; color: var(--text); }
button.secondary:hover, #prev-step:hover { background: #e4e7ec; }

.equipment-row {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, minmax(90px, .8fr)) repeat(2, minmax(120px, .8fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.equipment-row label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.equipment-row .remove { background: #f04438; }

.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.result-summary div, .variant {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: #fff;
}
.result-summary strong { display: block; font-size: 24px; }
.variant { margin: 14px 0; }
.variant h3 { margin: 0 0 8px; }
.product-list { display: grid; gap: 10px; margin-top: 12px; }
.product-item { border: 1px dashed var(--line); border-radius: 14px; padding: 12px; }
.product-item strong { display: block; }
.warn-list { background: var(--warning); border: 1px solid var(--warning-line); border-radius: 16px; padding: 14px 18px; }

.admin-grid { margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
}
.stat-card strong { display: block; font-size: 32px; }
.stat-card span { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.badge { display: inline-flex; padding: 4px 10px; border-radius: 999px; background: #eef2f6; font-size: 13px; }
.status-active { background: #dcfae6; }
.status-new, .status-requires_params { background: #fff4dd; }
.status-hidden, .status-disabled { background: #eef2f6; }
.status-missing_on_site { background: var(--danger); }
.event-list { display: grid; gap: 12px; }
.event-list article { border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.event-list span { color: var(--muted); margin-left: 8px; }
.event-list p { margin-bottom: 0; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .equipment-row { grid-template-columns: 1fr; }
  .form-actions { justify-content: stretch; }
  .form-actions button { flex: 1; }
}

.product-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #e8fff6;
  font-weight: 700;
}
.compatibility-note {
  display: block;
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.45;
}

.field-block {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.lookup-row {
  display: grid;
  grid-template-columns: minmax(180px, 320px) auto;
  gap: 12px;
  align-items: end;
}
.lookup-row label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.hint-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  padding: 0;
  border-radius: 999px;
  background: #eef8f3;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  vertical-align: middle;
}
.hint-icon:hover { background: #dff5eb; color: var(--accent-dark); }
.hint-bubble {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: calc(100% + 8px);
  width: min(300px, 80vw);
  transform: translateX(-50%);
  display: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  box-shadow: 0 14px 40px rgba(16, 24, 40, .14);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
}
.hint-icon:hover .hint-bubble,
.hint-icon:focus .hint-bubble { display: block; }
.saved-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f9fafb;
}
@media (max-width: 760px) {
  .lookup-row { grid-template-columns: 1fr; }
}

/* Кастомные подсказки вместо стандартного браузерного title. */
.has-custom-tooltip {
  position: relative;
}
.custom-tooltip {
  position: absolute;
  z-index: 50;
  left: 16px;
  bottom: calc(100% + 10px);
  width: min(340px, 86vw);
  display: none;
  padding: 11px 13px;
  border-radius: 13px;
  background: #101828;
  color: #ffffff;
  box-shadow: 0 18px 45px rgba(16, 24, 40, .28);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.38;
  text-align: left;
  pointer-events: none;
}
.custom-tooltip::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 100%;
  border-width: 7px 7px 0 7px;
  border-style: solid;
  border-color: #101828 transparent transparent transparent;
}
.has-custom-tooltip:hover > .custom-tooltip,
.has-custom-tooltip:focus-within > .custom-tooltip {
  display: block;
}
button.has-custom-tooltip .custom-tooltip {
  left: auto;
  right: 0;
  bottom: calc(100% + 10px);
  min-width: 260px;
}
button.has-custom-tooltip .custom-tooltip::after {
  left: auto;
  right: 18px;
}
.equipment-toolbar {
  align-items: end;
}
.typical-device-field {
  min-width: min(360px, 100%);
  flex: 1 1 360px;
}
.equipment-row input[type="checkbox"] {
  flex: 0 0 auto;
}

.product-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}
.cart-button {
  padding: 8px 12px;
  border-radius: 12px;
}

/* Важные температурные поля для PV-расчёта. */
.important-field {
  border-color: #f0b74a !important;
  background: #fffaf0 !important;
  box-shadow: 0 0 0 3px rgba(240, 183, 74, .16);
}
.important-field input {
  border-color: #f0b74a !important;
  background: #fffdf7;
}
.important-note {
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid #f0b74a;
  background: #fff8e8;
  color: #5f4100;
  line-height: 1.45;
}
.pv-temp-preview {
  margin-top: 12px;
  font-weight: 700;
  color: #5f4100;
}

.macro-cell { min-width: 320px; }
.macro-select {
  width: min(420px, 100%);
  padding: 8px 10px;
  font-size: 14px;
}
.macro-filename {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-card {
  width: min(460px, 100%);
  margin: 42px auto;
  padding: clamp(22px, 5vw, 34px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 14px 40px rgba(16, 24, 40, .08);
}
.login-card h1 { margin: 6px 0 8px; }
.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}
.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.login-form input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}
.form-error {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #fecdca;
  border-radius: 14px;
  background: #fff0f0;
  color: #b42318;
  line-height: 1.45;
}
.auth-user {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 13px;
}
.logout-link { color: #b42318; }
