:root {
  --bg: #ffffff;
  --bg-sub: #f6f8fa;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-sub: #64748b;
  --accent: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-hover: #1e40af;
  --green: #15803d;
  --sidebar-w: 272px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.logo {
  font-size: 18px; font-weight: 800; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.logo .mark {
  background: var(--accent); color: #fff;
  border-radius: 6px; padding: 2px 7px; font-size: 15px;
}
.logo:hover { text-decoration: none; }
.header-search { flex: 1; max-width: 420px; }
.header-search input {
  width: 100%; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: var(--bg-sub);
}
.header-search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ===== Layout: sidebar + main ===== */
.layout { display: flex; min-height: calc(100vh - 56px); }

/* ===== Sidebar tree ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-sub);
  padding: 16px 0 40px;
  position: sticky; top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.tree-group { margin-bottom: 2px; }
.tree-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: calc(100% - 16px); margin: 0 8px;
  padding: 8px 10px;
  border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-weight: 700; color: var(--text);
  text-align: left; border-radius: 8px;
}
.tree-toggle:hover { background: #eef2f7; text-decoration: none; }
.tree-toggle .arrow {
  transition: transform .15s ease;
  font-size: 11px; color: var(--text-sub);
}
.tree-group.open > .tree-toggle .arrow { transform: rotate(90deg); }
.tree-items { display: none; padding: 2px 0 6px; }
.tree-group.open > .tree-items { display: block; }
.tree-items a, .tree-items .soon {
  display: block;
  padding: 5px 12px 5px 28px;
  font-size: 13.5px; color: var(--text-sub);
  border-radius: 6px; margin: 0 8px;
}
.tree-items a:hover { background: #e8eef6; color: var(--accent); text-decoration: none; }
.tree-items a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree-items .soon { color: #b6c2d2; cursor: default; }
.tree-items .soon::after { content: " ·soon"; font-size: 11px; }

/* ===== Main ===== */
.main {
  flex: 1; min-width: 0;
  padding: 24px 40px 60px;
  max-width: 980px;
}
.crumbs { font-size: 13px; color: var(--text-sub); margin-bottom: 14px; }
.main h1 { font-size: 28px; line-height: 1.25; margin-bottom: 8px; }
.lede { color: var(--text-sub); font-size: 15px; margin-bottom: 18px; }
.main h2 { font-size: 20px; margin: 24px 0 10px; }
.main h3 { font-size: 16px; margin: 16px 0 8px; }
.main p { margin-bottom: 9px; }

/* ===== Calculator card ===== */
.calc-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--bg);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.calc-card .row {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 10px;
}
.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 150px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-sub); }
.field input, .field select {
  padding: 8px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* results */
.results { margin-top: 6px; border-top: 1px dashed var(--border); padding-top: 8px; }
.result-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 4px 4px; border-bottom: 1px solid #f0f3f7;
}
.result-row .unit-name { color: var(--text-sub); font-size: 14px; }
.result-row .unit-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.result-row.hero { font-size: 17px; background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; }
.result-row.hero .unit-val { color: var(--accent); }

/* ===== Tables ===== */
table.ref { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0 14px; }
table.ref th, table.ref td {
  border: 1px solid var(--border); padding: 5px 10px; text-align: left;
}
table.ref th { background: var(--bg-sub); font-size: 13px; }
table.ref tr:nth-child(even) td { background: #fbfcfe; }

.formula-box {
  background: var(--bg-sub); border-left: 4px solid var(--accent);
  padding: 8px 14px; border-radius: 0 8px 8px 0;
  font-family: Georgia, "Times New Roman", serif; font-size: 16px;
  margin: 10px 0; overflow-x: auto;
}

.faq details {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; margin-bottom: 6px; background: #fff;
}
.faq summary { font-weight: 600; cursor: pointer; }
.faq details p { margin: 6px 0 2px; color: var(--text-sub); }

/* ===== Home cards ===== */
.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px; margin-top: 20px;
}
.cat-card {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; display: block; color: var(--text);
  transition: box-shadow .15s, transform .15s;
}
.cat-card:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-2px); }
.cat-card .ico { font-size: 26px; }
.cat-card .t { font-weight: 700; margin: 8px 0 4px; }
.cat-card .d { font-size: 13px; color: var(--text-sub); }
.cat-card .n { font-size: 12px; color: var(--accent); margin-top: 8px; display: block; }

/* ===== Unit grid tiles (editable boxes, zhuanhuanqi style) ===== */
.ugrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 6px;
}
.utile {
  border: 1px solid #b8dcc0;
  border-radius: 10px;
  padding: 9px 12px 7px;
  background: #f2faf3;
}
.utile:focus-within { border-color: var(--accent); background: #eef6ff; }
.utile .uname { font-size: 12.5px; color: var(--text-sub); margin-bottom: 2px; }
.utile input {
  width: 100%; border: none; background: transparent;
  border-bottom: 1px solid #d3e6d7;
  font-size: 17px; font-weight: 700; padding: 2px 0 4px;
  color: var(--text);
}
.utile input:focus { outline: none; border-bottom-color: var(--accent); }
.utile input::placeholder { color: #c3cfd9; font-weight: 400; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 40px; font-size: 13px; color: var(--text-sub);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.site-footer a { color: var(--text-sub); margin-left: 16px; }

/* ===== Mobile ===== */
.menu-btn { display: none; }
@media (max-width: 900px) {
  .menu-btn {
    display: block; background: none; border: 1px solid var(--border);
    border-radius: 8px; font-size: 18px; padding: 4px 10px; cursor: pointer;
  }
  .sidebar {
    position: fixed; left: -300px; top: 56px; z-index: 99;
    transition: left .2s ease; box-shadow: 4px 0 20px rgba(0,0,0,.1);
  }
  .sidebar.show { left: 0; }
  .main { padding: 22px 18px 60px; }
  .header-search { display: none; }
}
