/* =========================================================================
 * style.css  —  Clean, responsive, light theme for the Electrical Calc app
 * ========================================================================= */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #65727f;
  --line: #e2e8f0;
  --brand: #1565c0;
  --brand-d: #0d47a1;
  --accent: #00897b;
  --ok: #2e7d32;
  --bad: #c62828;
  --warn: #ef6c00;
  --shadow: 0 1px 3px rgba(15, 35, 60, .08), 0 4px 16px rgba(15, 35, 60, .06);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "Noto Sans CJK SC",
    "Microsoft YaHei", "Hiragino Sans", "Malgun Gothic", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 18px;
  background: linear-gradient(120deg, var(--brand), var(--brand-d));
  color: #fff; box-shadow: var(--shadow);
}
.brand { font-size: 1.15rem; font-weight: 700; letter-spacing: .3px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lang { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: #e8f0fe; }
.lang select {
  border: none; border-radius: 8px; padding: 6px 8px; font-size: .85rem;
  background: #fff; color: var(--ink); cursor: pointer;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 8px; text-decoration: none;
  font-size: .9rem; font-weight: 600; cursor: pointer; border: none;
  transition: transform .05s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-home { background: #fff; color: var(--brand-d); }
.btn-email { background: var(--accent); color: #fff; }
.btn-email:hover { background: #00796b; }

/* Tabs */
.tabs {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 52px; z-index: 40;
}
.tab {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.tab:hover { border-color: var(--brand); color: var(--brand); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Sections */
main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.section { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
h2 { margin: 4px 0 16px; font-size: 1.35rem; }
h3 { margin: 18px 0 10px; font-size: 1.05rem; color: var(--brand-d); }

/* Form rows */
.row1 { display: grid; grid-template-columns: minmax(220px, 1fr); gap: 12px; margin-bottom: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 600; }
input, select {
  font: inherit; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }

.mode { display: flex; gap: 18px; margin-bottom: 14px; flex-wrap: wrap; }
.mode label { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }

/* Buttons (inline) */
.btn:not(.btn-home):not(.btn-email) {
  background: var(--brand); color: #fff; margin: 6px 0 14px;
}
.btn:not(.btn-home):not(.btn-email):hover { background: var(--brand-d); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 12px; }
table.grid { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.grid th, table.grid td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--line); }
table.grid th { background: #f1f5fb; color: var(--brand-d); font-weight: 700; white-space: nowrap; }
table.grid td input { width: 100%; min-width: 70px; padding: 6px 8px; }
.out { font-weight: 700; color: var(--brand); }
tr.sel { background: #e3f2fd !important; }
td.idx { color: var(--muted); width: 30px; }
.x { border: none; background: transparent; color: var(--bad); cursor: pointer; font-size: 1rem; padding: 4px 8px; }
.x:hover { background: #ffebee; border-radius: 6px; }

/* Results */
.result { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 14px 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.card span { font-size: .8rem; color: var(--muted); font-weight: 600; }
.card b { font-size: 1.15rem; color: var(--ink); }
.card.ok b { color: var(--ok); }
.card.bad b { color: var(--bad); }
.card.warn b { color: var(--warn); }

/* Sub-rows (short-circuit) */
.subrow { display: grid; grid-template-columns: 110px repeat(auto-fit, minmax(120px, 1fr)) 36px; gap: 10px; align-items: end; margin-bottom: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.subrow .tag { font-weight: 700; color: var(--brand); align-self: center; }
.subrow label { font-size: .78rem; }

/* Panels (current calc) */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.panel .result { margin: 8px 0 0; }

/* Reference */
.ref-block { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.ref-block code { display: block; margin-top: 6px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: .9rem; color: var(--brand-d); word-break: break-word; }

.note { color: var(--muted); font-size: .85rem; background: #eef4fb; border-radius: 8px; padding: 10px 12px; margin-top: 10px; }

/* Export bar (P2-7) */
.export-bar { display: flex; align-items: center; gap: 8px; margin: 16px 0 4px; padding: 10px 12px; background: #f1f5fb; border: 1px dashed var(--line); border-radius: 10px; flex-wrap: wrap; }
.export-bar .exp-label { font-size: .82rem; color: var(--muted); font-weight: 700; }
.btn.sm { padding: 5px 12px; font-size: .8rem; margin: 0; background: var(--accent); }
.btn.sm:hover { background: #00796b; }

.footer { text-align: center; padding: 18px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.footer a { color: var(--brand); text-decoration: none; }

/* Responsive */
@media (max-width: 720px) {
  .row3 { grid-template-columns: 1fr 1fr; }
  .brand { font-size: 1rem; }
  .topbar { padding: 8px 12px; }
  .tabs { top: 50px; }
  .subrow { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 460px) {
  .row3 { grid-template-columns: 1fr; }
}
