/* =========================================================
   Electrical Component Selection Tool - Common Styles
   ========================================================= */
:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --primary-light: #e3f2fd;
  --accent: #ff8f00;
  --accent-light: #fff3e0;
  --success: #2e7d32;
  --success-light: #e8f5e9;
  --danger: #c62828;
  --danger-light: #fdecea;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #dde3ea;
  --text: #1f2937;
  --text-muted: #64748b;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, .12);
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "Noto Sans", "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

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

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

/* ---------------- Top bar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #0d47a1 0%, #1565c0 60%, #1976d2 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13, 71, 161, .35);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-link {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-link:hover { text-decoration: none; opacity: .92; }
.brand .version {
  font-size: 11px;
  background: rgba(255, 255, 255, .18);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-color: rgba(255, 255, 255, .35);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .22); }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #e65100; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-excel { background: #217346; color: #fff; }
.btn-excel:hover { background: #1a5c37; }
.btn-outline {
  background: #fff;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.lang-select {
  background: rgba(255, 255, 255, .15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  max-width: 140px;
}
.lang-select option { color: var(--text); background: #fff; }

/* ---------------- Main nav ---------------- */
.mainnav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  overflow-x: auto;
}
.mainnav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 4px;
}
.mainnav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13.5px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.mainnav a:hover { color: var(--primary); text-decoration: none; }
.mainnav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-light);
}

/* ---------------- Layout ---------------- */
.page {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}
.page-head { margin-bottom: 18px; }
.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-subtitle { color: var(--text-muted); margin-top: 4px; font-size: 13.5px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .badge { margin-left: auto; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------- Form controls ---------------- */
label.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 10px 0 4px;
}
.input, .select, textarea.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, .15);
}
.input[readonly] { background: var(--bg); color: var(--text-muted); }
.input-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.input-row > div { flex: 1; min-width: 140px; }

/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  background: #f0f4f9;
  color: var(--primary-dark);
  text-align: left;
  padding: 9px 10px;
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.tbl td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef1f5;
  vertical-align: middle;
}
.tbl tbody tr:hover { background: #f7fafd; }
.tbl tbody tr:nth-child(even) { background: #fbfcfe; }
.tbl tbody tr:nth-child(even):hover { background: #f2f7fc; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .center { text-align: center; }
.tbl .qty-input {
  width: 68px;
  text-align: center;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}
.tbl .qty-input:focus { outline: none; border-color: var(--primary); }

/* ---------------- Badges & chips ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-orange { background: var(--accent-light); color: #b45309; }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #eef1f5; color: var(--text-muted); }

.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  background: #eef2f7;
  color: var(--text);
  font-size: 12px;
  border: 1px solid var(--border);
}

/* ---------------- Search & filters ---------------- */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.search-bar .input { flex: 1; min-width: 220px; }
.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.filter-row .select { width: auto; min-width: 160px; }

/* ---------------- Result / highlight ---------------- */
.result-box {
  background: var(--success-light);
  border: 1px solid #c8e6c9;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--success);
  margin-top: 10px;
}
.result-box .big {
  font-size: 20px;
  font-weight: 800;
  color: var(--success);
  margin-top: 2px;
}
.empty-tip {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 10px;
  font-size: 14px;
}

/* ---------------- Hero (home) ---------------- */
.hero {
  background: linear-gradient(135deg, #0d47a1 0%, #1565c0 55%, #1e88e5 100%);
  border-radius: var(--radius);
  padding: 34px 30px;
  color: #fff;
  margin-bottom: 22px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.hero h1 { font-size: 26px; font-weight: 800; margin-bottom: 8px; }
.hero p { font-size: 14px; opacity: .92; max-width: 640px; }
.hero .badges { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Tool cards ---------------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: block;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  color: var(--text);
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  text-decoration: none;
}
.tool-card .icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 14px;
}
.icon-blue { background: var(--primary-light); }
.icon-orange { background: var(--accent-light); }
.icon-green { background: var(--success-light); }
.icon-gray { background: #eef1f5; }
.tool-card h3 { font-size: 16px; font-weight: 800; color: var(--primary-dark); margin-bottom: 6px; }
.tool-card p { color: var(--text-muted); font-size: 13px; }


/* ---------------- Step guide ---------------- */
.step {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
}
.step-num {
  flex: 0 0 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}
.step-body { flex: 1; }
.step-body h4 { font-size: 14px; margin-bottom: 4px; color: var(--primary-dark); }
.step-body p, .step-body li { color: var(--text-muted); font-size: 13px; }
.step-body ul { padding-left: 18px; }

/* ---------------- Formula note ---------------- */
.formula-note {
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #7c4a03;
  margin-top: 12px;
}
.formula-box {
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: "Consolas", "Menlo", monospace;
  font-size: 12.5px;
  color: var(--primary-dark);
  margin-top: 8px;
  overflow-x: auto;
}

/* ---------------- Footer ---------------- */
.site-footer {
  background: #10233f;
  color: #9fb3c8;
  padding: 22px 16px;
  text-align: center;
  font-size: 12.5px;
  margin-top: auto;
}
.site-footer a { color: #cfe0f5; }

/* ---------------- Toast ---------------- */
#toastBox {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #1f2937;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: toastIn .25s ease;
  max-width: 300px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Misc ---------------- */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-end { justify-content: flex-end; }
.grow { flex: 1; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.bold { font-weight: 700; }
.nowrap { white-space: nowrap; }
.tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 4px;
}
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .brand-link { font-size: 15px; }
  .top-actions { width: 100%; justify-content: flex-end; }
  .btn { padding: 7px 10px; font-size: 12px; }
  .page { padding: 14px 10px 40px; }
  .page-title { font-size: 18px; }
  .search-bar .input { min-width: 100%; }
  .filter-row .select { min-width: 100%; }
}
