/* ===== Gas Pipe Calculator — styles ===== */
:root {
  --eng: #1f6feb;          /* Eng highlight */
  --tool: #f5a623;         /* Tool highlight */
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #697586;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --ok: #0f9d58;
  --warn: #d93025;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 4px 16px rgba(16,24,40,.06);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "Noto Sans", "Noto Sans CJK SC", "Microsoft YaHei", "Hiragino Sans",
    "Malgun Gothic", "Apple SD Gothic Neo", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- Header ---- */
.site-header {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(90deg, #0b3d91 0%, #1f6feb 60%, #2b7de0 100%);
  color: #fff; padding: 10px 18px; box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.brand-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; font-weight: 700; }
.brand-mark { font-size: 20px; color: var(--tool); }
.brand-name { font-size: 16px; letter-spacing: .2px; }
.top-nav { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.nav-link {
  color: #e8f0fe; text-decoration: none; padding: 6px 12px; border-radius: 8px;
  font-size: 14px; white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,.14); }
.nav-link.active { background: #fff; color: #0b3d91; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.lang-select select {
  border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.12); color: #fff;
  border-radius: 8px; padding: 6px 8px; font-size: 13px; cursor: pointer;
}
.lang-select select option { color: #1f2733; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
}
.btn-home { background: var(--tool); color: #1b2a3a; }
.btn-home:hover { filter: brightness(1.05); }
.btn-email { background: #fff; color: #0b3d91; }
.btn-email:hover { background: #eef4ff; }

/* ---- Layout ---- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 18px 60px; }
.page-head { margin: 6px 0 18px; }
.page-head h1 { font-size: 22px; margin: 0 0 4px; }
.page-head p { margin: 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.panel h2 { font-size: 16px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.panel h2 .tag { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field .unit { color: var(--muted); font-size: 12px; margin-left: 4px; }
.input-row { display: flex; gap: 8px; align-items: center; }
input[type=number], select, input[type=text] {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line-strong);
  border-radius: 8px; font-size: 14px; background: #fff; color: var(--ink);
}
input[type=number]:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { cursor: pointer; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }

.row-inline { display: flex; gap: 8px; align-items: center; }
.row-inline input[type=number] { flex: 1 1 auto; min-width: 0; }
.dn-select { flex: 0 0 120px; width: 120px; cursor: pointer; }
@media (max-width: 520px) { .row-inline { flex-wrap: wrap; } .dn-select { flex: 1 1 100%; width: 100%; } }

.actions { display: flex; gap: 10px; margin-top: 6px; }
.btn-primary {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: #1a5fd0; }
.btn-ghost {
  background: #fff; color: var(--ink); border: 1px solid var(--line-strong);
  padding: 10px 18px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.btn-ghost:hover { background: #f1f5f9; }

/* ---- Results ---- */
.result-card { background: #f8fbff; border: 1px solid #d8e6ff; border-radius: 10px; padding: 16px; }
.result-main { font-size: 26px; font-weight: 700; color: #0b3d91; }
.result-main .u { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-top: 14px; }
.res-grid .item { border-top: 1px dashed var(--line); padding-top: 8px; }
.res-grid .k { font-size: 12px; color: var(--muted); }
.res-grid .v { font-size: 16px; font-weight: 600; }
@media (max-width: 520px) { .res-grid { grid-template-columns: 1fr; } }

.note {
  margin-top: 14px; font-size: 12.5px; color: var(--muted);
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 12px;
}
.note b { color: #92670a; }
.formula {
  margin-top: 12px; font-size: 13px; color: #334155; background: #f1f5f9;
  border-radius: 8px; padding: 10px 12px; font-family: "SFMono-Regular", Consolas, monospace;
  overflow-x: auto;
}
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.hidden { display: none !important; }

footer.site-foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px; }
footer.site-foot a { color: var(--accent); text-decoration: none; }

/* segmented control */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 120px; padding: 9px 10px; border: 1px solid var(--line-strong);
  background: #fff; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--ink);
}
.seg button.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

.pill { display:inline-block; font-size:11px; padding:2px 8px; border-radius:999px; background:var(--accent-soft); color:var(--accent); margin-left:6px;}

/* ---- PDF report button ---- */
.btn-pdf {
  background: #0b3d91; color: #fff; border: 1px solid #0b3d91;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-pdf:hover { background: #082e6e; }

/* ---- Standard DN rounding card ---- */
.dn-round {
  background: #f3f8ff; border: 1px solid #cfe0ff; border-radius: 10px; padding: 14px 16px; margin-bottom: 16px;
}
.dn-round h2 { font-size: 15px; margin: 0 0 10px; }
.dn-round #dnRoundExtra { margin-bottom: 12px; }
.dn-round .note { margin-top: 12px; }

/* =========================================================================
 * Printable report (PDF) — only #report is shown when printing
 * ========================================================================= */
#report { display: none; }

.rep { color: #111; font-size: 13px; line-height: 1.5; max-width: 780px; margin: 0 auto; padding: 8px 4px; }
.rep-head { border-bottom: 2px solid #0b3d91; padding-bottom: 10px; margin-bottom: 14px; }
.rep-brand { color: #0b3d91; font-weight: 700; font-size: 13px; }
.rep-head h1 { font-size: 20px; margin: 4px 0 2px; color: #0b3d91; }
.rep-sub { color: #444; font-size: 13px; }
.rep-meta { display: flex; flex-wrap: wrap; gap: 18px; font-size: 12px; color: #333; margin-bottom: 14px; }
.rep-meta b { color: #0b3d91; }
.rep h2 { font-size: 14px; color: #0b3d91; border-left: 3px solid #1f6feb; padding-left: 8px; margin: 16px 0 6px; }
.rep-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rep-tbl td { border: 1px solid #cfd8e3; padding: 6px 10px; }
.rep-tbl .rk { width: 62%; color: #333; background: #f5f8fc; }
.rep-tbl .rv { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rep-formula { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 10px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.rep-notes { margin: 6px 0; padding-left: 18px; font-size: 12px; color: #333; }
.rep-notes li { margin-bottom: 4px; }
.rep-foot { margin-top: 22px; padding-top: 10px; border-top: 1px solid #cfd8e3; font-size: 11.5px; color: #555; text-align: center; }

@media print {
  #site-header, .wrap { display: none !important; }
  #report { display: block !important; }
  body { background: #fff; }
  @page { margin: 14mm; }
}

@media (max-width: 520px) {
  .actions { flex-wrap: wrap; }
  .btn-pdf { width: 100%; }
}
