/* =====================================================
   GearLab — Industrial Steel Design System
   Dark: Steel Black  |  Light: White Lab
   Accent: Teal #00BFFF  |  Font: Roboto
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700;800&display=swap');

/* ---- Global tokens ---- */
:root {
  --neon:     #00BFFF;
  --neon-br:  #40D4FF;
  --neon-dk:  #0080FF;
  --neon-glow: rgba(0,191,255,.18);
  --neon-bg:   rgba(0,191,255,.1);
  --fail:  #ef4444;
  --warn:  #f59e0b;
  --pass:  #22c55e;
  --info:  #38bdf8;
  --sidebar-w: 230px;
  --topbar-h:  52px;
  --tr: .18s ease;
  --font: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- Dark mode: Industrial Steel ---- */
[data-theme="dark"] {
  --bg:         #0d0f14;
  --bg-card:    #161b22;
  --bg-sidebar: #0a0c10;
  --bg-input:   #0d1117;
  --bg-hover:   rgba(255,255,255,.04);
  --bg-result:  #0d1117;
  --border:     #30363d;
  --border-dim: #21262d;
  --text:       #e6edf3;
  --text-muted: #8b949e;
  --text-dim:   #484f58;
  --primary:    #00BFFF;
  --primary-br: #40D4FF;
  --primary-dk: #0080FF;
  --plate:      #1c2128;
  --shadow:     rgba(0,0,0,.4);
}

/* ---- Light mode: White Lab ---- */
[data-theme="light"] {
  --bg:         #f0f4f8;
  --bg-card:    #ffffff;
  --bg-sidebar: #1c2128;
  --bg-input:   #ffffff;
  --bg-hover:   rgba(0,0,0,.04);
  --bg-result:  #f0fafa;
  --border:     #d0d7de;
  --border-dim: #e8ecf0;
  --text:       #1c2128;
  --text-muted: #57606a;
  --text-dim:   #9ca3af;
  --primary:    #0070CC;
  --primary-br: #00BFFF;
  --primary-dk: #0055AA;
  --plate:      #e8ecf0;
  --shadow:     rgba(0,0,0,.08);
}

/* ======================================================
   BASE
   ====================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--tr), color var(--tr);
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-br); }
button, input, select, textarea { font-family: inherit; }
input[type="number"]::-webkit-inner-spin-button { opacity: .5; }

/* ======================================================
   SIDEBAR
   ====================================================== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 2px solid var(--neon);
  box-shadow: 2px 0 24px rgba(0,191,255,.08);
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(0,191,255,.15);
}
.sidebar-logo svg { width: 32px; height: 32px; flex-shrink: 0; }
.sidebar-logo-text {
  font-size: 17px; font-weight: 800;
  color: #fff; letter-spacing: -.3px;
}
.sidebar-logo-text span { color: var(--neon); }
.sidebar-section {
  padding: 16px 16px 6px;
  font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255,255,255,.25);
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px; margin: 1px 8px;
  border-radius: 7px; font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,.5);
  transition: all var(--tr); cursor: pointer;
  text-decoration: none; position: relative;
}
.nav-item:hover { background: rgba(0,191,255,.08); color: rgba(255,255,255,.85); }
.nav-item.active {
  background: rgba(0,191,255,.15);
  color: #fff; font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 22px;
  background: var(--neon); border-radius: 2px;
}
.nav-item.soon { opacity: .4; cursor: default; }
.nav-item.soon:hover { background: none; }
.nav-badge-soon {
  margin-left: auto; font-size: 8px; font-weight: 700;
  color: var(--warn); border: 1px solid var(--warn);
  padding: 1px 5px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .5px;
}
.nav-icon { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-bottom {
  margin-top: auto; padding: 10px 8px 14px;
  border-top: 1px solid rgba(0,191,255,.12);
}
.sidebar-credit {
  font-size: 10px; font-weight: 500; letter-spacing: .2px;
  color: rgba(0,191,255,.5); text-align: center;
  padding: 0 8px 8px; line-height: 1.4;
}
.sidebar-bottom .nav-item { color: rgba(255,255,255,.35); font-size: 12px; }

/* ======================================================
   TOPBAR
   ====================================================== */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px; z-index: 99;
  box-shadow: 0 1px 8px var(--shadow);
}
.topbar-breadcrumb { font-size: 13px; color: var(--text-muted); }
.topbar-breadcrumb strong { color: var(--text); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  background: var(--bg-hover); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 7px;
  padding: 6px 8px; cursor: pointer; display: flex;
  align-items: center; transition: all var(--tr);
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }

/* ======================================================
   MAIN CONTENT
   ====================================================== */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 24px;
  min-height: calc(100vh - var(--topbar-h));
}
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.page-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ======================================================
   CARDS
   ====================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border-dim);
  font-weight: 700; font-size: 14px;
}
.card-body { padding: 20px; }

/* ======================================================
   CALCULATOR LAYOUT
   ====================================================== */
.calc-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) { .calc-grid { grid-template-columns: 1fr; } }

/* Input panel */
.input-panel { display: flex; flex-direction: column; gap: 14px; }
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .5px;
}
.field-label span { font-weight: 400; color: var(--text-dim); text-transform: none; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-unit {
  font-size: 12px; color: var(--text-muted);
  background: var(--plate); border: 1px solid var(--border);
  border-radius: 6px; padding: 0 10px;
  height: 38px; display: flex; align-items: center;
  white-space: nowrap; flex-shrink: 0;
}

input[type="number"], input[type="text"], select {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: 14px;
  font-weight: 500; transition: border-color var(--tr);
  outline: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--neon-bg); }
select { cursor: pointer; }

/* Divider */
.field-divider {
  border: none; border-top: 1px dashed var(--border-dim);
  margin: 4px 0;
}

/* Calc button */
.btn-calc {
  width: 100%; padding: 11px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 8px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all var(--tr);
  letter-spacing: .3px;
}
.btn-calc:hover { background: var(--primary-br); transform: translateY(-1px); box-shadow: 0 4px 16px var(--neon-glow); }

/* Result panel */
.result-panel { display: flex; flex-direction: column; gap: 12px; }
.result-section-title {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-dim);
  margin-bottom: 4px;
}
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.result-item {
  background: var(--bg-result);
  border: 1px solid var(--border-dim);
  border-radius: 9px; padding: 12px 14px;
  transition: border-color var(--tr);
}
.result-item:hover { border-color: var(--border); }
.result-item.highlight { border-color: var(--primary); background: var(--neon-bg); }
.result-label { font-size: 10px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.result-value {
  font-size: 20px; font-weight: 800;
  color: var(--primary); letter-spacing: -.5px; line-height: 1;
}
.result-value.large { font-size: 28px; }
.result-unit { font-size: 11px; color: var(--text-dim); margin-top: 2px; font-weight: 500; }
.result-empty { color: var(--text-dim); font-size: 20px; font-weight: 300; }

/* Formula card */
.formula-card {
  background: var(--bg-card); border: 1px solid var(--border-dim);
  border-radius: 10px; padding: 16px 20px;
}
.formula-card h4 {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-dim); margin-bottom: 10px;
}
.formula-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border-dim);
  font-size: 12px;
}
.formula-row:last-child { border-bottom: none; }
.formula-name { color: var(--text-muted); }
.formula-expr { color: var(--text); font-family: 'Courier New', monospace; font-size: 11px; }

/* Tip box */
.tip-box {
  background: var(--neon-bg); border: 1px solid rgba(0,191,255,.25);
  border-radius: 8px; padding: 12px 16px; font-size: 12px;
  color: var(--text-muted); line-height: 1.6;
}
.tip-box strong { color: var(--primary); }

/* ======================================================
   DASHBOARD HERO
   ====================================================== */
.hero-card {
  background: linear-gradient(135deg, #0a0c10 0%, #161b22 50%, rgba(0,191,255,.08) 100%);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; display: flex; align-items: center;
  gap: 32px; margin-bottom: 24px; overflow: hidden;
  position: relative;
}
[data-theme="light"] .hero-card {
  background: linear-gradient(135deg, #1c2128 0%, #2d333b 50%, rgba(0,191,255,.12) 100%);
}
.hero-card::before {
  content: ''; position: absolute;
  top: -60px; right: -60px; width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(0,191,255,.08) 0%, transparent 70%);
  pointer-events: none;
}
.hero-gear-wrap { flex-shrink: 0; }
.hero-gear { width: 100px; height: 100px; animation: spin-slow 12s linear infinite; }
@keyframes spin-slow { to { transform: rotate(360deg); } }
.hero-text h1 { font-size: 28px; font-weight: 900; color: #fff; letter-spacing: -.5px; }
.hero-text h1 span { color: var(--neon); }
.hero-text p { color: rgba(255,255,255,.55); margin-top: 6px; font-size: 14px; }

/* Quick calc strip */
.quick-calc {
  background: rgba(0,191,255,.06); border: 1px solid rgba(0,191,255,.2);
  border-radius: 10px; padding: 16px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 18px;
}
.quick-calc label { font-size: 11px; font-weight: 700; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .5px; }
.quick-calc input {
  width: 120px; height: 34px; background: rgba(0,0,0,.3);
  border: 1px solid rgba(0,191,255,.3); color: #fff;
  border-radius: 6px; padding: 0 10px; font-size: 13px;
  font-weight: 600;
}
.quick-calc input:focus { border-color: var(--neon); outline: none; }
.quick-arrow { color: rgba(0,191,255,.5); font-size: 18px; }
.quick-result { font-size: 22px; font-weight: 900; color: var(--neon); min-width: 120px; }
.quick-result-unit { font-size: 11px; color: rgba(255,255,255,.4); margin-left: 4px; }

/* Module cards grid */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.module-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; cursor: pointer;
  transition: all var(--tr); text-decoration: none; color: inherit;
  display: block;
}
.module-card:hover {
  border-color: var(--primary); transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--neon-glow);
}
.module-card.soon { opacity: .5; cursor: default; }
.module-card.soon:hover { transform: none; box-shadow: none; border-color: var(--border); }
.module-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--neon-bg); border: 1px solid rgba(0,191,255,.2);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; color: var(--primary);
}
.module-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.module-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.module-badge {
  display: inline-block; margin-top: 8px;
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; padding: 2px 7px; border-radius: 4px;
  background: rgba(245,158,11,.1); color: var(--warn);
  border: 1px solid rgba(245,158,11,.3);
}

/* ======================================================
   UNIT CONVERTER
   ====================================================== */
.converter-section { margin-bottom: 24px; }
.converter-section h3 {
  font-size: 13px; font-weight: 700;
  color: var(--primary); margin-bottom: 12px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border-dim);
}
.converter-row {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 10px; align-items: center; margin-bottom: 8px;
}
.converter-eq {
  text-align: center; font-size: 18px;
  color: var(--text-dim); font-weight: 300;
}

/* ======================================================
   UTILITY
   ====================================================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-teal  { color: var(--primary); }
.text-sm    { font-size: 12px; }
.fw-700     { font-weight: 700; }

/* Toast */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; color: #fff; box-shadow: 0 4px 20px rgba(0,0,0,.3); animation: toast-in .2s ease; }
.toast.pass { background: var(--pass); }
.toast.fail { background: var(--fail); }
@keyframes toast-in { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: none; } }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--steel-lt, #8b949e); }

/* SVG diagram */
.diagram-wrap {
  background: var(--bg-input); border: 1px solid var(--border-dim);
  border-radius: 10px; padding: 12px;
  display: flex; justify-content: center; align-items: center;
}
.diagram-wrap svg { max-width: 100%; height: auto; }
