/* ============================================================
   Heat Transfer Engineering Tools — Windows standard style
   ============================================================ */
:root {
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC",
          "Meiryo", "Yu Gothic UI", "Malgun Gothic", sans-serif;
  --title-grad-1: #0f2a5f;
  --title-grad-2: #3a6ea5;
  --accent: #0a66c2;
  --accent-hover: #0957a8;
  --accent-soft: #e8f1fb;
  --menu-bg: #f3f3f3;
  --menu-border: #d1d5da;
  --body-bg: #ece9d8;
  --content-bg: #fdfdfb;
  --panel-border: #a8a8a8;
  --panel-bg: #ffffff;
  --input-border: #7f8b99;
  --status-bg: #f0f0f0;
  --text: #1b1b1b;
  --text-dim: #555555;
  --ok: #1a7f37;
  --warn: #b54708;
  --bad: #c62828;
  --zebra: #f2f6fa;
  --kpi-bg: #eaf2ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--body-bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------- Title bar ---------------- */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--title-grad-1), var(--title-grad-2));
  color: #fff;
  height: 42px;
  padding: 0 10px;
  user-select: none;
  flex: none;
}
.tb-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-icon {
  width: 22px; height: 22px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.tb-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 6px; flex: none; }
.tb-btn {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.45);
  color: #fff;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.tb-btn:hover { background: rgba(255,255,255,.3); }
.tb-wbtn {
  width: 34px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 3px;
  font-size: 11px;
  cursor: default;
}
.tb-wbtn.close:hover { background: #c42b1c; }

/* ---------------- Menu bar ---------------- */
.menubar {
  display: flex;
  align-items: stretch;
  background: var(--menu-bg);
  border-bottom: 1px solid var(--menu-border);
  height: 32px;
  flex: none;
  position: relative;
  z-index: 50;
}
.menu-item {
  position: relative;
  display: flex; align-items: center;
  padding: 0 12px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
}
.menu-item:hover, .menu-item.open { background: #fff; border-color: var(--menu-border); }
.menu-pop {
  display: none;
  position: absolute;
  top: 100%; left: 0;
  min-width: 230px;
  background: #fff;
  border: 1px solid var(--menu-border);
  box-shadow: 2px 2px 6px rgba(0,0,0,.18);
  padding: 4px 0;
}
.menu-item.open .menu-pop { display: block; }
.menu-entry {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 22px 6px 26px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none; color: var(--text);
}
.menu-entry:hover { background: var(--accent); color: #fff; }
.menu-entry.sep { padding: 0; margin: 4px 6px; border-top: 1px solid var(--menu-border); cursor: default; }
.menu-entry.sep:hover { background: transparent; }
.menu-entry .m-check { width: 14px; font-size: 11px; }
.menu-entry.disabled { color: #999; pointer-events: none; }

/* ---------------- Toolbar ---------------- */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  background: #fafafa;
  border-bottom: 1px solid var(--menu-border);
  padding: 6px 10px;
  flex: none;
  flex-wrap: wrap;
}
.tb-tool {
  background: #fff;
  border: 1px solid var(--menu-border);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text);
  text-decoration: none;
}
.tb-tool:hover { background: var(--accent-soft); border-color: var(--accent); }
.tb-tool.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tb-gap { flex: 1; }
.tb-label { font-size: 12.5px; color: var(--text-dim); }
.tb-note { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }

/* ---------------- Content ---------------- */
.content {
  flex: 1;
  background: var(--content-bg);
  padding: 18px 20px 30px;
  overflow-y: auto;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}
.page-title { font-size: 20px; font-weight: 600; margin-bottom: 2px; }
.page-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }

/* ---------------- Group box (Windows style) ---------------- */
.groupbox {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 14px 16px 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.groupbox > .gb-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin: -8px 0 10px;
  padding: 0 6px;
  background: #fff;
  display: inline-block;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
}
.gb-formula {
  background: var(--menu-bg);
  border: 1px solid var(--menu-border);
  border-radius: 3px;
  padding: 8px 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 12px;
}

/* ---------------- Form grid ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px 16px;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12.5px; color: var(--text-dim); }
.field .unit { font-size: 11.5px; color: var(--text-dim); margin-left: 4px; }
.input-wrap { display: flex; align-items: center; gap: 6px; }
.input-wrap input[type=number], .input-wrap input[type=text] {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--input-border);
  border-radius: 3px;
  font-size: 13.5px;
  font-family: var(--font);
  background: #fff;
}
.input-wrap input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.input-wrap input[readonly] { background: #f0f0f0; color: var(--text-dim); }
.input-suffix { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
select {
  padding: 5px 8px;
  border: 1px solid var(--input-border);
  border-radius: 3px;
  font-size: 13.5px;
  background: #fff;
  font-family: var(--font);
}
.radio-row { display: flex; gap: 14px; align-items: center; font-size: 13px; }
.radio-row label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: var(--text); font-size: 13px; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }

.btn {
  background: #fff;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------------- Results / KPI ---------------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.kpi {
  background: var(--kpi-bg);
  border: 1px solid #c9dcf2;
  border-radius: 5px;
  padding: 10px 14px;
}
.kpi .k-label { font-size: 12px; color: var(--text-dim); }
.kpi .k-value { font-size: 20px; font-weight: 700; color: var(--accent-hover); margin-top: 2px; }
.kpi .k-unit { font-size: 12px; color: var(--text-dim); font-weight: 400; margin-left: 5px; }
.kpi.invalid { background: #fdf0f0; border-color: #e0b3b3; }
.kpi.invalid .k-value { color: var(--bad); }
.kpi-sep { height: 1px; background: #d9dee4; margin: 16px 0 2px; }
.kpi-note {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--zebra);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  line-height: 1.55;
}

/* ---------------- Segmented control ---------------- */
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; }
.seg .btn + .btn { margin-left: -1px; }
.seg .btn:first-child { border-radius: 4px 0 0 4px; }
.seg .btn:last-child { border-radius: 0 4px 4px 0; }

/* ---------------- Lookup table ---------------- */
.table-wrap { overflow-x: auto; margin-top: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  border: 1px solid #d5dbe2;
  padding: 6px 10px;
  text-align: center;
}
.data-table th { background: var(--kpi-bg); font-weight: 600; white-space: nowrap; }
.data-table tbody tr:nth-child(even) { background: var(--zebra); }
.data-table tbody td:first-child { font-weight: 600; }

/* ---------------- Tables ---------------- */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  background: var(--accent);
  color: #fff;
  text-align: left;
  padding: 7px 10px;
  font-weight: 600;
  white-space: nowrap;
}
table.data td {
  padding: 6px 10px;
  border-bottom: 1px solid #e3e6ea;
  vertical-align: top;
}
table.data tbody tr:nth-child(even) { background: var(--zebra); }
table.data tbody tr:hover { background: #eef4fb; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.hl td { background: #fff3cd; }
table.data tr.warn-row td { color: var(--bad); }
td.side-shell { color: #b54708; font-weight: 600; }
td.side-tube { color: #1a4f9c; font-weight: 600; }
td.flag-star { color: var(--warn); font-weight: 700; }
td.unit-col { color: var(--text-dim); font-size: 12px; }

/* ---------------- Tabs ---------------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 16px;
  background: var(--menu-bg);
  border: 1px solid var(--menu-border);
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-dim);
}
.tab:hover { background: var(--accent-soft); }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* ---------------- Search box ---------------- */
.search-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.search-bar input {
  flex: 1;
  max-width: 380px;
  padding: 6px 10px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 13.5px;
  font-family: var(--font);
}
.search-bar input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.search-count { font-size: 12px; color: var(--text-dim); }

/* ---------------- Cards (home) ---------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.card {
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card h3 { font-size: 15px; color: var(--accent-hover); }
.card p { font-size: 13px; color: var(--text-dim); flex: 1; line-height: 1.5; }
.card .btn { align-self: flex-start; }

/* ---------------- Status bar ---------------- */
.statusbar {
  height: 26px;
  background: var(--status-bg);
  border-top: 1px solid var(--menu-border);
  display: flex; align-items: center;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-dim);
  flex: none;
}

/* ---------------- Modal ---------------- */
.modal-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  width: min(560px, 92vw);
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  background: linear-gradient(180deg, var(--title-grad-1), var(--title-grad-2));
  color: #fff;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 14px;
  border-radius: 6px 6px 0 0;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head .m-close { cursor: pointer; font-size: 15px; padding: 0 4px; }
.modal-body { padding: 14px 18px; font-size: 13.5px; line-height: 1.6; overflow-y: auto; }
.modal-foot { padding: 10px 18px; border-top: 1px solid var(--menu-border); text-align: right; }

/* ---------------- Misc ---------------- */
.note { font-size: 12.5px; color: var(--text-dim); margin-top: 8px; line-height: 1.55; }
.ok-text { color: var(--ok); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
.bad-text { color: var(--bad); font-weight: 600; }
.inline-code { font-family: Consolas, "Courier New", monospace; background: var(--menu-bg); border: 1px solid var(--menu-border); border-radius: 3px; padding: 0 5px; font-size: 12.5px; }
.std-note {
  margin-top: 18px;
  padding: 10px 14px;
  background: var(--menu-bg);
  border: 1px solid var(--menu-border);
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.flex-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }

@media (max-width: 720px) {
  .content { padding: 12px 10px 24px; }
  .tb-btn { padding: 3px 8px; font-size: 11px; }
  .tb-title { max-width: 120px; }
}
