:root {
  --primary: #0d6efd;
  --primary-dark: #0b5ed7;
  --accent: #1f7a4d;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --border: #dce3ee;
  --text: #1f2733;
  --muted: #5b6b7f;
  --ok: #188038;
  --warn: #e6a700;
  --danger: #d93025;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(16, 32, 64, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #0b3d91, #1261d0);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
}
.brand .logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: rgba(255,255,255,.18);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-top, .lang-select {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  background: rgba(255,255,255,.14);
  color: #fff;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,.25);
  cursor: pointer;
  transition: background .15s;
}
.btn-top:hover { background: rgba(255,255,255,.26); }
.btn-top.home { background: #fff; color: #0b3d91; border-color: #fff; }
.btn-top.home:hover { background: #eaf1ff; }
.btn-top.mail { background: rgba(255,255,255,.14); }
.btn-top .icon { font-size: 16px; }
.lang-select { background: #fff; color: #0b3d91; border-color: #fff; font-weight: 600; }
.lang-select:focus { outline: 2px solid #ffd76a; }

/* ---------- Layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 18px 60px; }
.page-head { margin-bottom: 20px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.page-title { font-size: 26px; font-weight: 800; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0; font-size: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 22px;
}
.card h2 {
  font-size: 17px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--bg);
  color: var(--primary-dark);
  display: flex; align-items: center; gap: 8px;
}
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 820px) { .grid.c2,.grid.c3,.grid.c4 { grid-template-columns: 1fr; } }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  transition: border .15s, box-shadow .15s;
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,.15);
}
.field .unit { font-size: 12px; color: var(--muted); margin-top: 3px; }

.semi { background: #fff8e6; }
.num { background: #eef6ff; }

/* ---------- Buttons ---------- */
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 4px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px;
  border-radius: 9px;
  border: none;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-reset { background: #e7ebf2; color: var(--text); }
.btn-reset:hover { background: #dbe1ea; }

/* ---------- Results ---------- */
.result-card { background: linear-gradient(180deg,#eef6ff,#f8fbff); border: 1px solid #cfe0f7; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(230px,1fr)); gap: 12px; }
.result-item {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px;
}
.result-item .r-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.result-item .r-value { font-size: 20px; font-weight: 800; color: var(--primary-dark); margin-top: 2px; }
.result-item .r-value small { font-size: 12px; color: var(--muted); font-weight: 600; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
}
.badge.ok { background: #e5f6ec; color: var(--ok); }
.badge.warn { background: #fff3d6; color: var(--warn); }
.badge.danger { background: #fde8e6; color: var(--danger); }

/* ---------- Tables ---------- */
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
.data-table th, .data-table td {
  border: 1px solid var(--border);
  padding: 8px 10px; text-align: center;
}
.data-table th { background: #f0f4fa; font-weight: 700; color: var(--primary-dark); }
.data-table tr:nth-child(even) td { background: #fafcff; }
.data-table td.input-cell input {
  width: 90px; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px; text-align: center;
}
.data-table td.hl { background: #eef6ff !important; font-weight: 700; }

/* ---------- Unified structure for the other table variants ----------
   .tbl (absorption), .grid-table (filtration), .calc-table (heat-transfer)
   are brought in line with .data-table so every data table looks consistent. */
.tbl, .grid-table, .calc-table {
  width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff;
}
.tbl th, .grid-table th, .calc-table th,
.tbl td, .grid-table td, .calc-table td {
  border: 1px solid var(--border); padding: 8px 10px; text-align: center;
}
.tbl th, .grid-table th, .calc-table th {
  background: #f0f4fa; font-weight: 700; color: var(--primary-dark); white-space: nowrap;
}
.tbl tbody tr:nth-child(even) td,
.grid-table tbody tr:nth-child(even) td,
.calc-table tbody tr:nth-child(even) td { background: #fafcff; }

/* Editable inputs / selects used inside any data table (incl. .tbl-input) */
.tbl td input, .grid-table td input, .calc-table td input,
.tbl td select, .grid-table td select, .calc-table td select,
.tbl-input {
  width: 88px; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px; text-align: center;
  background: #fff; color: var(--text);
}
.tbl td input:focus, .grid-table td input:focus, .calc-table td input:focus,
.tbl td select:focus, .grid-table td select:focus, .calc-table td select:focus,
.tbl-input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,110,253,.15);
}
.tbl td input:read-only, .grid-table td input:read-only, .calc-table td input:read-only,
.tbl-input:read-only { background: #f7f9fc; color: var(--muted); }

/* Highlight & summary rows on all variants */
.tbl td.hl, .grid-table td.hl, .calc-table td.hl, .tbl-input.hl { background: #eef6ff !important; font-weight: 700; }
.tbl tr.tot-row td, .grid-table tr.tot-row td, .calc-table tr.tot-row td {
  font-weight: 800; color: var(--primary-dark); background: #eaf3ff !important; border-top: 2px solid var(--primary);
}

/* Wide tabular variants keep readable columns by scrolling inside .table-scroll */
.table-scroll .tbl, .table-scroll .calc-table { border: none; margin: 0; min-width: 640px; }
.table-scroll .tbl th:first-child, .table-scroll .calc-table th:first-child,
.table-scroll .tbl td:first-child, .table-scroll .calc-table td:first-child { border-left: none; }
.table-scroll .tbl th:last-child, .table-scroll .calc-table th:last-child,
.table-scroll .tbl td:last-child, .table-scroll .calc-table td:last-child { border-right: none; }

@media (max-width: 720px) {
  .tbl th, .grid-table th, .calc-table th,
  .tbl td, .grid-table td, .calc-table td { padding: 6px 7px; font-size: 12.5px; }
  .tbl td input, .grid-table td input, .calc-table td input,
  .tbl-input { width: 74px; font-size: 12px; padding: 5px 6px; }
}

/* ---------- Formula / notes ---------- */
.note { background: #eef7f1; border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 13px; color: #2a4a3a; }
.warn-note { background: #fff6df; border-left-color: var(--warn); color: #5f4a12; }
.formula { background: #f7f9fc; border: 1px dashed var(--border); border-radius: 8px; padding: 10px 14px; font-family: Consolas, monospace; font-size: 13.5px; margin: 8px 0; overflow-x: auto; white-space: nowrap; }

/* ---------- Home grid ---------- */
.hero { background: linear-gradient(135deg,#0b3d91,#1b6fe0); color: #fff; border-radius: var(--radius); padding: 34px 28px; margin-bottom: 26px; }
.hero h1 { margin: 0 0 8px; font-size: 30px; }
.hero p { margin: 0; font-size: 15px; opacity: .92; }
.calc-group { margin-bottom: 26px; }
.calc-group h2 { font-size: 19px; color: var(--primary-dark); border-bottom: 2px solid var(--border); padding-bottom: 8px; margin: 0 0 14px; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(250px,1fr)); gap: 14px; }
.calc-tile {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .1s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.calc-tile:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(16,32,64,.14); border-color: var(--primary); }
.calc-tile .ct-icon { font-size: 26px; }
.calc-tile .ct-title { font-size: 15.5px; font-weight: 700; }
.calc-tile .ct-desc { font-size: 12.5px; color: var(--muted); }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 12px; border-top: 1px solid var(--border); margin-top: 30px; }
footer a { color: var(--primary); }

/* ---------- Step list ---------- */
.step-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.step-list li {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
.step-list .step-no {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.step-list .step-body { flex: 1; font-size: 13.5px; }
.step-list .step-body .k { font-weight: 700; display: block; }
.step-list .step-body .v { color: var(--muted); }

@media (max-width: 720px) {
  .brand { font-size: 15px; }
  .page-title { font-size: 22px; }
}

/* ---------- Supplementary structure & visual styles ---------- */

/* Numbered step badge inside card headings */
.card h2 .step-no {
  flex: 0 0 auto;
  min-width: 26px; height: 26px; padding: 0 5px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #1b6fe0);
  color: #fff;
  font-size: 14px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(13,110,253,.35);
}
.card h2 .card-kicker { flex: 1; min-width: 0; }

/* Short hint line under a section heading */
.sec-hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 14px; }
.card .sec-hint { margin-top: -6px; padding-bottom: 2px; border-bottom: 1px dashed var(--border); }

/* Scrollable table wrapper */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.table-scroll .data-table { border: none; margin: 0; }
.table-scroll .data-table th:first-child, .table-scroll .data-table td:first-child { border-left: none; }
.table-scroll .data-table th:last-child, .table-scroll .data-table td:last-child { border-right: none; }
.data-table { min-width: 480px; } /* for internal tables to keep columns readable when scrolled */

/* Totals / summary row in data tables */
.data-table tr.tot-row td { font-weight: 800; color: var(--primary-dark); background: #eaf3ff !important; border-top: 2px solid var(--primary); }

/* Home page tile icon badge */
.tile-icon {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(13,110,253,.14), rgba(31,122,77,.14));
  border: 1px solid rgba(13,110,253,.16);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin-bottom: 4px;
}

/* Group header chip */
.calc-group h2 { display: flex; align-items: center; gap: 10px; }
.calc-group h2 .grp-ico {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #1b6fe0);
  color: #fff; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Results grid refinements */
.result-grid.compact { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.result-item .r-ahead { float: right; font-size: 11px; font-weight: 700; color: var(--primary); }
.result-item .r-verdict { font-size: 13px; font-weight: 700; margin-top: 4px; }

/* Status verdict panels */
.status-panel { border-radius: var(--radius); padding: 13px 16px; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.status-panel.ok { background: #e5f6ec; color: var(--ok); border: 1px solid #bfe6cd; }
.status-panel.warn { background: #fff3d6; color: #8a6200; border: 1px solid #f2db9b; }
.status-panel.danger { background: #fde8e6; color: var(--danger); border: 1px solid #f6c2bd; }

/* ---------- Print / export (calculation report) ---------- */
.print-btn {
  position: fixed;
  right: 18px; bottom: 18px; z-index: 90;
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #0b3d91, #1261d0);
  color: #fff; border: none; border-radius: 999px; padding: 10px 16px;
  font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(11,61,145,.35);
  transition: transform .1s;
}
.print-btn:hover { transform: translateY(-2px); }
.print-header { display: none; }
.result-item.invalid .r-value { color: var(--danger); }

@media print {
  .no-print, .topbar, footer, .btn-row, .breadcrumb, .print-btn { display: none !important; }
  .print-header {
    display: block; padding: 0 0 12px; margin-bottom: 16px;
    border-bottom: 2px solid #0b3d91; color: #1f2733;
  }
  .print-header .ph-brand { font-size: 11px; letter-spacing: .4px; color: #3a4a5f; text-transform: uppercase; font-weight: 700; }
  .print-header .ph-title { font-size: 20px; font-weight: 800; margin: 2px 0 4px; color: #0b3d91; }
  .print-header .ph-meta { font-size: 11px; color: #5b6b7f; display: flex; gap: 16px; }
  body { background: #fff; }
  .wrap { max-width: 100%; padding-top: 0; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #dce3ee; }
  .result-card { background: #fff; border: 1px solid #cfd8e6; break-inside: avoid; }
  .calc-group, .data-table, .calc-table, .tbl, .grid-table { break-inside: avoid; }
  h1, h2 { page-break-after: avoid; }
  a { color: #0b3d91; text-decoration: none; }
}

/* Small inline code / param chips */
.chip { display: inline-block; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--muted); margin: 2px 4px 0 0; }
.chip b { color: var(--primary-dark); }

/* Formula lines inside the Formula card */
.formula-line { padding: 3px 0; white-space: normal; }

/* Formula box rendered by .formulas container (F1..F5 lines on the calc pages) */
.formula-line, .tool-formula {
  background: #f7f9fc; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 8px; padding: 8px 12px;
  font-family: Consolas, "SF Mono", monospace; font-size: 13px;
  margin: 6px 0; overflow-x: auto;
}
.tool-formula { display: block; white-space: normal; }

/* Collapsible card header caret */
.card.collapsible h2 { cursor: pointer; user-select: none; }
.card.collapsible h2::after { content: "▾"; margin-left: auto; color: var(--muted); font-size: 13px; transition: transform .15s; }
.card.collapsible.collapsed h2::after { transform: rotate(-90deg); }
.card.collapsible.collapsed .card-body { display: none; }

/* Step list refinements (used for calculation steps) */
.step-list.tight { gap: 8px; }
.step-list.tight li { padding: 9px 12px; }
.step-list li .step-no { background: linear-gradient(135deg, var(--primary), #1b6fe0); }

@media (max-width: 720px) {
  .card { padding: 16px; }
  .card h2 { font-size: 15.5px; }
  .page-sub { font-size: 13px; }
  .result-item .r-value { font-size: 18px; }
  .tile-icon { width: 40px; height: 40px; font-size: 21px; }
}