:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #5a6b7b;
  --line: #d9e1ea;
  --accent: #1565c0;
  --accent-soft: #e3f0fb;
  --ok: #2e7d32;
  --warn: #c62828;
  --shadow: 0 1px 3px rgba(20, 40, 70, .08), 0 4px 14px rgba(20, 40, 70, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Microsoft YaHei", "Malgun Gothic", "Hiragino Sans", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

#site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  background: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.btn:hover { background: var(--accent-soft); }
#lang-select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}
h1 { font-size: 24px; margin: 6px 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 14px; font-size: 15px; }
.intro { color: var(--muted); margin: 0 0 22px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  box-shadow: var(--shadow);
}
a.card-link { text-decoration: none; color: inherit; display: block; transition: transform .08s ease, border-color .08s ease; }
a.card-link:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: 17px; color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: 14px; }

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 760px) { .calc-grid { grid-template-columns: 1fr; } }

.form-row {
  display: grid;
  grid-template-columns: 1fr 160px 70px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.form-row label { font-size: 14px; }
.form-row input, .form-row select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
}
.form-row .unit { color: var(--muted); font-size: 13px; text-align: left; }

.out-table { width: 100%; border-collapse: collapse; }
.out-table td { padding: 9px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
.out-table td.k { color: var(--muted); }
.out-table td.v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.out-table td.u { color: var(--muted); width: 64px; text-align: right; }

.note {
  margin-top: 18px;
  padding: 12px 14px;
  background: #fff8e6;
  border: 1px solid #f0d79a;
  border-radius: 8px;
  font-size: 13.5px;
  color: #6b5418;
}
.note b { color: #8a6d10; }

.reset-row { margin-top: 14px; }
.btn-primary {
  padding: 9px 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #0d4ea3; }

.btn-secondary {
  margin-left: 8px;
  padding: 9px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--accent-soft); }

.ok-yes { color: var(--ok); font-weight: 700; }
.ok-no { color: var(--warn); font-weight: 700; }

#site-footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  margin-top: 30px;
}
#site-footer .disc { color: var(--warn); font-size: 12.5px; margin: 0; padding: 14px 18px 4px; }
#site-footer .tag { color: var(--muted); font-size: 12.5px; margin: 0; padding: 0 18px 16px; }
#site-footer .disc, #site-footer .tag { max-width: 1100px; margin-left: auto; margin-right: auto; }

/* IEC 60034-1 voltage-unbalance limit band (in symmetrical-components results) */
.out-table td.imbalance-band { font-weight: 700; font-size: 14px; border-top: 2px solid transparent; }
.out-table td.imbalance-band.ok { background: #e6f4ea; color: #1b5e20; border-top-color: #2e7d32; }
.out-table td.imbalance-band.warn { background: #fff4e0; color: #8a5a00; border-top-color: #e08600; }
.out-table td.imbalance-band.bad { background: #fdecea; color: #b71c1c; border-top-color: #c62828; }
.out-table td.imbalance-band.na { background: #eef1f4; color: #5a6b7b; border-top-color: #9aa7b4; }

/* Fortescue phasor diagram (symmetrical-components page) */
.phasor-section { margin-top: 18px; }
.phasor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 760px) { .phasor-grid { grid-template-columns: 1fr; } }
.phasor-panel {
  margin: 0;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.phasor-panel figcaption {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.phasor-panel svg {
  width: 100%;
  height: auto;
  max-width: 240px;
  background:
    radial-gradient(circle at center, #fff 0%, #f3f7fb 100%);
  border-radius: 6px;
}
#ph_legend { background: #f3f7fb; border-color: #dbe5ef; color: #41566b; }
#ph_legend .lg { font-weight: 700; margin: 0 1px; }

/* Load list & single-line diagram */
.diagram { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin: 6px 0; overflow: hidden; }
.out-table th { text-align: left; background: #eef1f4; font-size: 13px; padding: 7px 6px; color: #33414f; border-bottom: 2px solid var(--line); }
.btn-mini { margin-left: 0; padding: 3px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #33414f; font-size: 12px; cursor: pointer; }
.btn-mini:hover { background: #eef1f4; }

/* Share-link toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #1f2933;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 200;
  max-width: 90%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Print report: show only result + inputs, hide chrome. window.print() exports PDF. */
@media print {
  #site-header, #site-footer, .reset-row, .note, .bar, .nav, .brand,
  .btn, .btn-primary, .btn-secondary, .btn-mini, .toast { display: none !important; }
  body { background: #fff; }
  .container { padding: 0; max-width: 100%; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .calc-grid { grid-template-columns: 1fr 1fr; }
  .out-table td.imbalance-band { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .diagram { break-inside: avoid; }
  .phasor-panel { break-inside: avoid; }
}

