/*
 * PowerTools Design System
 * "Industrial Precision" — engineering toolkit aesthetic
 */

/* ===== VARIABLES ===== */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #d97706;
  --accent-light: #fffbeb;
  --blue: #1d4ed8;
  --blue-light: #eff6ff;
  --green: #059669;
  --green-light: #ecfdf5;
  --red: #dc2626;
  --red-light: #fef2f2;
  --amber: #d97706;
  --purple: #7c3aed;
  --teal: #0d9488;
  --f: 'Outfit', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --r: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
}

/* ===== RESET ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--f);
  background: var(--bg);
  background-image: radial-gradient(circle, #d1d5db 0.5px, transparent 0.5px);
  background-size: 20px 20px;
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--f); }
input, select, textarea { font-family: var(--mono); }

/* ===== ACCENT BAR ===== */
.accent-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--blue) 100%);
  flex-shrink: 0;
}

/* ===== TOPBAR ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  color: var(--text-2);
  transition: all 0.15s;
  flex-shrink: 0;
}
.back-btn:hover { background: var(--bg); color: var(--text); }
.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  flex: 1;
}
.topbar-tag {
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text-3);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ===== CONTAINER ===== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}
.container.narrow { max-width: 560px; }
.container.wide { max-width: 960px; }

/* ===== PAGE HEADER ===== */
.page-header { margin-bottom: 24px; }
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.page-desc {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 12px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.card-body { padding: 4px 20px 12px; }

/* ===== FORM ELEMENTS ===== */
.form-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 8px;
}
.form-row:last-child { border-bottom: none; }
.form-label {
  flex: 1;
  font-size: 13px;
  font-family: var(--f);
  color: var(--text-2);
  line-height: 1.3;
}
.form-input {
  width: 128px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  text-align: right;
  transition: all 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.08);
}
.form-input[readonly] {
  background: #eef0f2;
  color: var(--text-3);
  cursor: default;
}
.form-input.wide { width: 180px; text-align: left; }
select.form-input { text-align: left; cursor: pointer; }
.input-unit {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
  min-width: 32px;
  text-align: left;
}
.form-divider {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  padding: 14px 0 4px;
  border-bottom: 1px solid var(--border-light);
}
.form-note {
  font-size: 11px;
  color: var(--text-3);
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 6px;
  margin-top: 8px;
  line-height: 1.5;
}

/* ===== BUTTONS ===== */
.actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.btn {
  padding: 12px 28px;
  border: 1px solid transparent;
  border-radius: var(--r);
  font-family: var(--f);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  flex: 1;
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.btn-primary:hover { background: #1e293b; box-shadow: var(--shadow); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }
.btn-add {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border: 1.5px dashed var(--border);
  border-radius: var(--r);
  background: none;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--f);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-add:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.btn-remove {
  width: 32px; height: 32px;
  border: none;
  border-radius: 6px;
  background: var(--red-light);
  color: var(--red);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-remove:hover { background: #fecaca; }

/* ===== RESULT PANEL ===== */
.result-panel {
  background: var(--text);
  border-radius: var(--r);
  padding: 24px;
  color: #fff;
  margin-bottom: 16px;
  border-left: 4px solid var(--accent);
}
.result-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  margin-bottom: 4px;
}
.result-value {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.result-value.green { color: #34d399; }
.result-value.blue { color: #60a5fa; }
.result-value.red { color: #f87171; }
.result-sub {
  font-family: var(--mono);
  font-size: 14px;
  color: #64748b;
  margin-top: 2px;
  margin-bottom: 16px;
}
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-top: 1px solid #1e293b;
}
.result-row span:first-child { font-size: 12px; color: #64748b; }
.result-row span:last-child { font-family: var(--mono); font-size: 13px; font-weight: 500; }

/* ===== BREAKDOWN ===== */
.breakdown { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.bk-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dotted var(--border);
}
.bk-row:last-child { border-bottom: none; }
.bk-val { color: var(--text); font-weight: 500; }

/* ===== DATA TABLES ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--f);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--mono);
  color: var(--text-2);
}
.data-table tr:hover td { background: #fafbfc; }
.data-table tr.row-selected td { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.data-table tr.row-warn td { background: #fffbeb; color: #92400e; }
.data-table tr.row-bad td { background: var(--red-light); color: var(--red); font-weight: 600; }

/* ===== STATUS ===== */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.ok { background: var(--green); }
.status-dot.warn { background: var(--amber); }
.status-dot.bad { background: var(--red); }
.status-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--f);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-ok { background: rgba(5,150,105,0.1); color: var(--green); }
.badge-warn { background: rgba(217,119,6,0.1); color: var(--amber); }
.badge-danger { background: rgba(220,38,38,0.1); color: var(--red); }

/* ===== LOAD BAR ===== */
.load-bar { height: 8px; border-radius: 4px; background: #1e293b; overflow: hidden; margin-top: 6px; }
.load-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease, background 0.3s; }

/* ===== TWO COLUMN LAYOUT ===== */
.cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 700px) { .cols-2 { grid-template-columns: 1fr; } }

/* ===== WARNING BOX ===== */
.warn-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.warn-box strong { font-size: 13px; color: #92400e; display: block; margin-bottom: 2px; }
.warn-box p { font-size: 12px; color: #a16207; line-height: 1.5; }

/* ===== FOOTER ===== */
.page-footer {
  margin-top: 32px;
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  font-family: var(--mono);
}

/* ===== HOMEPAGE: HERO ===== */
.home-hero {
  padding: 32px 0 8px;
}
.home-hero h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.home-hero p {
  font-size: 14px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ===== HOMEPAGE: SEARCH ===== */
.home-search {
  margin-bottom: 28px;
}
.home-search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.home-search-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.08);
}
.home-search-box svg { color: var(--text-3); flex-shrink: 0; }
.home-search-box input {
  border: none;
  outline: none;
  background: none;
  font-family: var(--f);
  font-size: 14px;
  color: var(--text);
  width: 100%;
}
.home-search-box input::placeholder { color: var(--text-3); }

/* ===== HOMEPAGE: TOOL GRID ===== */
.grid-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}
.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--card-accent, var(--border));
  border-radius: var(--r);
  padding: 20px 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.tool-card:hover {
  border-top-color: var(--card-accent, var(--accent));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.tool-card:active { transform: translateY(0) scale(0.98); }
.tool-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  background: var(--icon-bg, var(--bg));
}
.tool-card-icon svg { width: 22px; height: 22px; color: var(--icon-color, var(--text-2)); }
.tool-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
}
.tool-card p {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.35;
}

/* ===== HOMEPAGE: BOTTOM BAR ===== */
.home-footer {
  padding: 24px 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}

/* ===== EQUIP LIST ===== */
.equip-header {
  display: grid;
  grid-template-columns: 1fr 90px 60px 32px;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.equip-item {
  display: grid;
  grid-template-columns: 1fr 90px 60px 32px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.equip-item input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 12px;
  color: var(--text);
  transition: all 0.15s;
  width: 100%;
}
.equip-item input[type="text"] { font-family: var(--f); text-align: left; }
.equip-item input[type="number"] { font-family: var(--mono); text-align: right; }
.equip-item input:focus { outline: none; border-color: var(--blue); background: var(--surface); box-shadow: 0 0 0 3px rgba(29,78,216,0.08); }

/* ===== TEMPLATE CHIPS ===== */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface);
  font-family: var(--f);
}
.chip:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

/* ===== VOLT/OHM GRIDS ===== */
.data-grid {
  display: grid;
  gap: 6px 10px;
  align-items: center;
  margin-top: 8px;
}
.data-grid .dg-label {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--mono);
}
.data-grid input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  text-align: right;
  width: 100%;
  transition: all 0.15s;
}
.data-grid input:focus { outline: none; border-color: var(--blue); background: var(--surface); box-shadow: 0 0 0 3px rgba(29,78,216,0.08); }

/* ===== CHART ===== */
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding: 0 4px;
}
.chart-bar {
  flex: 1;
  min-width: 4px;
  border-radius: 2px 2px 0 0;
  transition: height 0.4s ease;
  cursor: pointer;
  position: relative;
}
.chart-bar:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--mono);
  white-space: nowrap;
  z-index: 10;
}
.chart-labels {
  display: flex;
  gap: 3px;
  padding: 4px 4px 0;
}
.chart-labels span {
  flex: 1;
  text-align: center;
  font-size: 8px;
  color: var(--text-3);
  font-family: var(--mono);
  overflow: hidden;
}

/* ===== TIMELINE ===== */
.timeline { margin-top: 12px; }
.tl-item { display: flex; gap: 12px; padding: 8px 0; }
.tl-dot-wrap { display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.tl-line { width: 2px; flex: 1; background: var(--border-light); margin-top: 4px; }
.tl-item:last-child .tl-line { display: none; }
.tl-content strong { font-size: 12px; color: var(--text); display: block; }
.tl-content span { font-size: 11px; color: var(--text-3); }
.tl-past .tl-dot { background: var(--green); }
.tl-now .tl-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(217,119,6,0.15); }

/* ===== LOOKUP ===== */
.lookup-toggle {
  font-size: 12px;
  color: var(--blue);
  cursor: pointer;
  font-weight: 600;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f);
}
.lookup-toggle:hover { color: #1e40af; }
.lookup-body { display: none; margin-top: 8px; }
.lookup-body.show { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .container { padding: 20px 16px 40px; }
  .topbar-inner { padding: 0 16px; }
  .home-hero h1 { font-size: 22px; }
  .page-title { font-size: 20px; }
  .result-value { font-size: 28px; }
  .card-body { padding: 4px 16px 12px; }
  .card-header { padding: 12px 16px; }
}

@media (max-width: 400px) {
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
  .equip-header, .equip-item { grid-template-columns: 1fr 70px 50px 32px; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeUp 0.3s ease both; }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.tool-card { animation: fadeUp 0.35s ease both; }
.tool-card:nth-child(1) { animation-delay: 0.02s; }
.tool-card:nth-child(2) { animation-delay: 0.04s; }
.tool-card:nth-child(3) { animation-delay: 0.06s; }
.tool-card:nth-child(4) { animation-delay: 0.08s; }
.tool-card:nth-child(5) { animation-delay: 0.10s; }
.tool-card:nth-child(6) { animation-delay: 0.12s; }
.tool-card:nth-child(7) { animation-delay: 0.14s; }
.tool-card:nth-child(8) { animation-delay: 0.16s; }
