/* Orifice Flow Meter Calculator - shared styles */
:root {
  --blue-900: #0b3d70;
  --blue-800: #0e4d8a;
  --blue-700: #125ea6;
  --blue-600: #1a6fc0;
  --blue-100: #e8f1fa;
  --ink: #1c2733;
  --ink-2: #46586b;
  --line: #dbe4ee;
  --bg: #f2f5f9;
  --card: #ffffff;
  --ok: #1c8a4d;
  --ok-bg: #e6f6ec;
  --warn: #b45309;
  --warn-bg: #fdf3e3;
  --err: #c0392b;
  --err-bg: #fdecea;
  --accent: #f5a623;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 42, 67, .10), 0 4px 14px rgba(16, 42, 67, .07);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

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

/* ---------------- top bar ---------------- */
.topbar {
  background: linear-gradient(120deg, var(--blue-900) 0%, var(--blue-700) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(11, 61, 112, .35);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255, 255, 255, .16);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.brand small { display: block; font-weight: 400; font-size: 11.5px; opacity: .82; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-top {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff; border-radius: 7px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
  transition: background .15s;
}
.btn-top:hover { background: rgba(255, 255, 255, .26); text-decoration: none; }
select.lang-select {
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff; border-radius: 7px;
  padding: 6px 8px; font-size: 13px; cursor: pointer;
}
select.lang-select option { color: var(--ink); background: #fff; }

/* ---------------- nav ---------------- */
.navbar { background: #fff; border-bottom: 1px solid var(--line); }
.nav-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 20px;
  display: flex; flex-wrap: wrap; gap: 2px;
}
.nav-inner a {
  color: var(--ink-2); padding: 11px 14px; font-size: 14px;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.nav-inner a:hover { color: var(--blue-700); text-decoration: none; }
.nav-inner a.active { color: var(--blue-700); border-bottom-color: var(--blue-600); font-weight: 600; }

/* ---------------- layout ---------------- */
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 22px 20px 40px; }
.page-head { margin-bottom: 18px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; color: var(--blue-900); }
.page-head p { margin: 0; color: var(--ink-2); font-size: 14px; }

footer {
  background: #fff; border-top: 1px solid var(--line);
  color: var(--ink-2); font-size: 12.5px; text-align: center;
  padding: 16px 20px;
}

/* ---------------- cards ---------------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px;
}
.card h2 {
  margin: 0 0 12px; font-size: 16px; color: var(--blue-900);
  padding-bottom: 8px; border-bottom: 2px solid var(--blue-100);
}
.card h3 { margin: 14px 0 8px; font-size: 14.5px; color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 7px; font-size: 14px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(26, 111, 192, .15);
}
.field .unit-hint { font-size: 11.5px; color: var(--ink-2); margin-top: 3px; }

/* ---------------- buttons ---------------- */
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn {
  border: 0; border-radius: 8px; cursor: pointer;
  padding: 9px 22px; font-size: 14px; font-weight: 600;
  background: var(--blue-600); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--blue-700); }
.btn.ghost { background: #fff; color: var(--blue-700); border: 1px solid var(--blue-600); }
.btn.ghost:hover { background: var(--blue-100); }
.btn.sm { padding: 5px 12px; font-size: 12.5px; font-weight: 600; border-radius: 6px; }
.btn.danger { color: #c0392b; border-color: #e3b8b2; }
.btn.danger:hover { background: #fdecea; }

/* ---------------- history & presets ---------------- */
.preset-save { display: flex; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.preset-save input {
  flex: 1 1 200px; min-width: 0; border: 1px solid #d7dee8; border-radius: 8px;
  padding: 8px 12px; font-size: 14px; color: var(--ink);
}
.preset-save input:focus { outline: none; border-color: var(--blue-600); }
.hist-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 20px 0 8px;
}
.hist-head h3 { margin: 0; }
.hist-list { display: flex; flex-direction: column; gap: 8px; }
.hist-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f7f9fc; border: 1px solid #e6ebf3; border-radius: 8px; padding: 9px 12px;
}
.hist-name { font-weight: 700; color: var(--blue-900); font-size: 14px; }
.hist-time { font-size: 12px; color: var(--ink-2); }
.hist-summary { font-size: 12.5px; color: var(--ink-2); flex: 1 1 100%; }
.hist-acts { display: inline-flex; gap: 6px; margin-left: auto; }
.hist-empty { font-size: 13px; color: var(--ink-2); padding: 6px 2px; }

/* ---------------- pipe series / export controls ---------------- */
.hint { font-size: 12.5px; color: var(--ink-2); margin: -4px 0 12px; line-height: 1.5; }
.seg { display: inline-flex; border: 1px solid var(--blue-600); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.seg-btn {
  border: 0; background: #fff; color: var(--blue-700); cursor: pointer;
  padding: 7px 16px; font-size: 13.5px; font-weight: 600;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--blue-600); }
.seg-btn.active { background: var(--blue-600); color: #fff; }
.dn-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; }
.chk {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13.5px; color: var(--ink); cursor: pointer;
}
.chk input { width: 15px; height: 15px; accent-color: var(--blue-600); }
.row-total { font-size: 13px; color: var(--ink-2); padding-top: 9px; }
.row-total b { color: var(--blue-900); font-size: 15px; }

/* ---------------- results ---------------- */
.result-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px;
}
.stat {
  background: var(--blue-100); border-radius: 8px; padding: 10px 12px;
}
.stat .k { font-size: 12px; color: var(--ink-2); }
.stat .v { font-size: 17px; font-weight: 700; color: var(--blue-900); font-variant-numeric: tabular-nums; }
.stat .u { font-size: 12px; color: var(--ink-2); }

.warnbox {
  border-radius: 8px; padding: 10px 14px; margin-top: 12px; font-size: 13.5px;
}
.warnbox.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f3d9ae; }
.warnbox.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe6cd; }
.warnbox.err { background: var(--err-bg); color: var(--err); border: 1px solid #f3c0ba; }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data {
  border-collapse: collapse; width: 100%; font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  border: 1px solid var(--line); padding: 7px 10px; text-align: center; white-space: nowrap;
}
table.data th { background: var(--blue-100); color: var(--blue-900); font-weight: 600; }
table.data tr:nth-child(even) td { background: #f8fafd; }
table.data td.hl { background: #fff6e5; font-weight: 700; color: var(--blue-900); }
table.data td.minmax { background: #eaf7ee; }
table.data input.inline {
  width: 84px; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 13.5px; text-align: center;
}

/* ---------------- formula display ---------------- */
.formula {
  background: #f8fafd; border: 1px dashed var(--blue-600);
  border-radius: 8px; padding: 12px 16px;
  font-family: "Cambria Math", Cambria, "Times New Roman", serif;
  font-size: 16.5px; text-align: center; color: var(--blue-900);
}
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 18px; margin-top: 10px; }
.kv .row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted var(--line); padding: 4px 0; font-size: 13.5px; }
.kv .row b { font-variant-numeric: tabular-nums; }

/* ---------------- home ---------------- */
.hero {
  background: linear-gradient(135deg, var(--blue-900), var(--blue-600));
  color: #fff; border-radius: 14px; padding: 34px 30px; margin-bottom: 22px;
}
.hero h1 { margin: 0 0 8px; font-size: 27px; }
.hero p { margin: 0; opacity: .92; max-width: 760px; }
.home-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.home-card {
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  padding: 20px; display: block; color: var(--ink);
  transition: transform .12s, box-shadow .12s;
}
.home-card:hover { transform: translateY(-3px); box-shadow: 0 6px 22px rgba(16,42,67,.14); text-decoration: none; }
.home-card .ic { font-size: 26px; }
.home-card h3 { margin: 8px 0 6px; color: var(--blue-800); }
.home-card p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.feature-list { list-style: none; margin: 0; padding: 0; }
.feature-list li { padding: 7px 0 7px 26px; position: relative; font-size: 14px; color: var(--ink-2); border-bottom: 1px dotted var(--line); }
.feature-list li::before { content: "✓"; position: absolute; left: 2px; color: var(--ok); font-weight: 700; }
.feature-list li:last-child { border-bottom: 0; }

/* ---------------- responsive ---------------- */
@media (max-width: 720px) {
  .top-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
  .nav-inner a { padding: 9px 10px; font-size: 13px; }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 21px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 14px; }
}

/* ---------------- report / print ---------------- */
.rep-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rep-table th, .rep-table td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.rep-table th { background: var(--blue-100); color: var(--blue-900); font-weight: 600; white-space: nowrap; }
.rep-table td:first-child { color: var(--ink-2); white-space: nowrap; }
.rep-table td:last-child { font-variant-numeric: tabular-nums; }
.rep-meta { font-size: 12.5px; color: var(--ink-2); }
.rep-empty { color: var(--ink-2); font-size: 14px; padding: 24px 0; text-align: center; }
.rep-chart svg { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }

@media print {
  .topbar, .navbar, .btn-row, footer, .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #d0d7df; break-inside: avoid; }
  .rep-table th, .rep-table td { border-color: #c3ccd6; }
  .rep-chart svg { border: 1px solid #c3ccd6; }
}


.quick-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.quick-label { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; line-height: 1; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--blue-600); color: var(--blue-700); background: #fff;
  cursor: pointer; transition: background .15s ease;
}
.chip:hover { background: var(--blue-100); }
@media print { .quick-row, #factor-hint { display: none !important; } }
