/* =========================================================
   ALEN ELECTRICO CRM — Design system
   Palette: charcoal-navy void, electric amber + voltage cyan
   Type: Space Grotesk (display) / Inter (body) / JetBrains Mono (data)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root{
  --bg-void: #0A0D13;
  --bg-panel: #121722;
  --bg-panel-light: #1A2130;
  --bg-raised: #212A3D;
  --accent-amber: #F5B916;
  --accent-amber-dim: #8A6A16;
  --accent-cyan: #29D6E8;
  --accent-danger: #FF5A5A;
  --accent-green: #3ADD8C;
  --text-primary: #ECF1F8;
  --text-muted: #8892A6;
  --text-faint: #545E72;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(245,185,22,0.35);
  --radius: 14px;
  --shadow-elev: 0 20px 40px -12px rgba(0,0,0,0.55);
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }
body{
  margin:0;
  background: var(--bg-void);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(41,214,232,0.06), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(245,185,22,0.05), transparent 45%);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4, .display{
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.01em;
}
.mono{ font-family: 'JetBrains Mono', monospace; }
a{ color: inherit; text-decoration: none; }
::selection{ background: var(--accent-amber); color:#0A0D13; }

/* Focus visibility */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible{
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- Circuit trace signature element ---------- */
.circuit-trace{
  position: relative;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--border-strong) 15%, var(--border-strong) 85%, transparent);
  overflow: visible;
  margin: 0;
}
.circuit-trace::before{
  content:'';
  position:absolute;
  top:-3px; left:0;
  width:8px; height:8px;
  border-radius:50%;
  background: var(--accent-amber);
  box-shadow: 0 0 12px 3px rgba(245,185,22,0.8);
  animation: trace-flow 3.2s linear infinite;
}
@keyframes trace-flow{
  0%{ left:0; opacity:0; }
  8%{ opacity:1; }
  92%{ opacity:1; }
  100%{ left:100%; opacity:0; }
}

/* ---------- Layout ---------- */
.app-shell{ display:flex; min-height:100vh; }

.sidebar{
  width: 250px;
  flex-shrink:0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display:flex;
  flex-direction:column;
  position: fixed;
  top:0; left:0; bottom:0;
  z-index: 40;
  transition: transform .25s ease;
}
.sidebar-brand{
  padding: 22px 20px 16px;
  display:flex;
  align-items:center;
  gap:10px;
}
.sidebar-brand .bolt{
  width:34px; height:34px;
  display:flex; align-items:center; justify-content:center;
  background: linear-gradient(145deg, var(--accent-amber), #C98F0E);
  border-radius: 9px;
  color:#1A1300;
  font-weight:700;
  box-shadow: 0 6px 14px -4px rgba(245,185,22,0.5);
}
.sidebar-brand .name{ font-family:'Space Grotesk'; font-weight:700; font-size:15.5px; line-height:1.1; }
.sidebar-brand .sub{ font-size:11px; color:var(--text-muted); }

.nav-group{ padding: 6px 12px; }
.nav-label{ font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; color:var(--text-faint); padding: 14px 12px 6px; }
.nav-link{
  display:flex; align-items:center; gap:11px;
  padding:10px 12px;
  margin: 2px 0;
  border-radius:10px;
  color: var(--text-muted);
  font-size:14px; font-weight:500;
  position:relative;
  transition: background .15s, color .15s;
}
.nav-link svg{ width:18px; height:18px; flex-shrink:0; opacity:.85; }
.nav-link:hover{ background: var(--bg-panel-light); color: var(--text-primary); }
.nav-link.active{ background: linear-gradient(90deg, rgba(245,185,22,0.14), transparent); color: var(--accent-amber); }
.nav-link.active::before{
  content:''; position:absolute; left:-12px; top:8px; bottom:8px; width:3px;
  background: var(--accent-amber); border-radius:3px;
  box-shadow: 0 0 8px var(--accent-amber);
}

.sidebar-footer{ margin-top:auto; padding:16px; border-top:1px solid var(--border); }
.user-chip{ display:flex; align-items:center; gap:10px; }
.user-avatar{ width:34px; height:34px; border-radius:50%; background: var(--bg-raised); display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:600; color:var(--accent-cyan); }
.logout-link{ font-size:12.5px; color: var(--text-faint); }
.logout-link:hover{ color: var(--accent-danger); }

.main{ margin-left:250px; flex:1; min-width:0; }
.topbar{
  height:66px;
  display:flex; align-items:center; justify-content:space-between;
  padding: 0 28px;
  border-bottom:1px solid var(--border);
  position: sticky; top:0; background: rgba(10,13,19,0.85); backdrop-filter: blur(10px); z-index:30;
}
.menu-toggle{ display:none; background:none; border:none; color:var(--text-primary); font-size:22px; cursor:pointer; }
.page-title{ font-size:19px; font-weight:600; }
.page-content{ padding: 26px 28px 60px; }

/* ---------- Cards (3D tilt-friendly) ---------- */
.card{
  background: linear-gradient(160deg, var(--bg-panel-light), var(--bg-panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-elev);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  transform-style: preserve-3d;
}
.card:hover{
  transform: translateY(-3px) rotateX(1deg);
  border-color: var(--border-strong);
}

.stat-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap:18px; margin-bottom:24px; }
.stat-card{ position:relative; overflow:hidden; }
.stat-card .icon-badge{
  width:40px; height:40px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(245,185,22,0.1); color: var(--accent-amber); margin-bottom:14px;
}
.stat-card.cyan .icon-badge{ background: rgba(41,214,232,0.1); color: var(--accent-cyan); }
.stat-card.green .icon-badge{ background: rgba(58,221,140,0.1); color: var(--accent-green); }
.stat-card.danger .icon-badge{ background: rgba(255,90,90,0.1); color: var(--accent-danger); }
.stat-card .label{ font-size:12.5px; color:var(--text-muted); margin-bottom:4px; }
.stat-card .value{ font-family:'Space Grotesk'; font-size:26px; font-weight:700; }
.stat-card .spark{ position:absolute; right:14px; bottom:14px; width:64px; height:22px; opacity:.55; }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; gap:8px;
  padding: 10px 18px;
  border-radius: 9px;
  font-size: 13.5px; font-weight:600;
  border: 1px solid transparent;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .2s ease, background .15s ease;
}
.btn:active{ transform: translateY(1px); }
.btn-primary{ background: linear-gradient(135deg, var(--accent-amber), #C98F0E); color:#181200; box-shadow: 0 8px 18px -6px rgba(245,185,22,0.45); }
.btn-primary:hover{ box-shadow: 0 10px 22px -6px rgba(245,185,22,0.65); }
.btn-outline{ background: transparent; border-color: var(--border); color: var(--text-primary); }
.btn-outline:hover{ border-color: var(--border-strong); background: var(--bg-panel-light); }
.btn-danger{ background: rgba(255,90,90,0.12); color: var(--accent-danger); border-color: rgba(255,90,90,0.3); }
.btn-sm{ padding:7px 12px; font-size:12.5px; }
.btn-icon{ padding:8px; }

/* ---------- Forms ---------- */
label{ display:block; font-size:12.5px; font-weight:500; color:var(--text-muted); margin-bottom:6px; }
input, select, textarea{
  width:100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 13px;
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus{ border-color: var(--accent-cyan); }
.field{ margin-bottom: 16px; }
.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.grid-3{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }

/* ---------- Table ---------- */
.table-wrap{ overflow-x:auto; border-radius: var(--radius); border:1px solid var(--border); }
table{ width:100%; border-collapse:collapse; min-width:640px; }
thead th{
  text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:.05em;
  color: var(--text-faint); background: var(--bg-panel-light);
  padding: 13px 16px; border-bottom:1px solid var(--border);
}
tbody td{ padding: 14px 16px; border-bottom:1px solid var(--border); font-size:14px; }
tbody tr{ transition: background .12s; }
tbody tr:hover{ background: rgba(255,255,255,0.02); }
tbody tr:last-child td{ border-bottom:none; }

.badge{ display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:20px; font-size:11.5px; font-weight:600; }
.badge-amber{ background: rgba(245,185,22,0.14); color: var(--accent-amber); }
.badge-cyan{ background: rgba(41,214,232,0.14); color: var(--accent-cyan); }
.badge-green{ background: rgba(58,221,140,0.14); color: var(--accent-green); }
.badge-danger{ background: rgba(255,90,90,0.14); color: var(--accent-danger); }
.badge-gray{ background: rgba(255,255,255,0.08); color: var(--text-muted); }

/* ---------- Login page ---------- */
.login-wrap{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background: var(--bg-void);
  background-image: radial-gradient(circle at 50% 0%, rgba(245,185,22,0.08), transparent 55%);
  padding: 20px;
  position: relative;
  overflow:hidden;
}
.login-wrap svg.bg-schematic{ position:absolute; inset:0; width:100%; height:100%; opacity:.08; }
.login-card{
  width:100%; max-width:400px;
  background: linear-gradient(160deg, var(--bg-panel-light), var(--bg-panel));
  border:1px solid var(--border);
  border-radius:18px;
  padding: 38px 34px 32px;
  box-shadow: var(--shadow-elev);
  position:relative; z-index:2;
}
.login-logo{ display:flex; align-items:center; gap:12px; margin-bottom:22px; }
.login-logo .bolt{
  width:46px; height:46px; border-radius:12px;
  background: linear-gradient(145deg, var(--accent-amber), #C98F0E);
  display:flex; align-items:center; justify-content:center;
  box-shadow: 0 8px 20px -6px rgba(245,185,22,0.55);
}
.login-title{ font-size:20px; font-weight:700; }
.login-sub{ font-size:12.5px; color:var(--text-muted); }
.error-box{ background: rgba(255,90,90,0.1); border:1px solid rgba(255,90,90,0.3); color:var(--accent-danger); padding:10px 14px; border-radius:9px; font-size:13px; margin-bottom:16px; }

/* ---------- Utility ---------- */
.flex{ display:flex; }
.items-center{ align-items:center; }
.justify-between{ justify-content:space-between; }
.gap-2{ gap:8px; } .gap-3{ gap:12px; } .gap-4{ gap:16px; }
.mb-2{ margin-bottom:8px; } .mb-3{ margin-bottom:12px; } .mb-4{ margin-bottom:18px; } .mb-5{ margin-bottom:26px; }
.text-muted{ color:var(--text-muted); }
.text-sm{ font-size:13px; }
.w-full{ width:100%; }
.empty-state{ text-align:center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon{ font-size:34px; margin-bottom:10px; opacity:.6; }

/* ---------- Responsive / mobile ---------- */
@media (max-width: 900px){
  .sidebar{ transform: translateX(-100%); }
  .sidebar.open{ transform: translateX(0); }
  .main{ margin-left:0; }
  .menu-toggle{ display:block; }
  .grid-2, .grid-3{ grid-template-columns: 1fr; }
  .page-content{ padding: 18px 16px 40px; }
  .topbar{ padding: 0 16px; }
  .sidebar-overlay{ display:none; position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:35; }
  .sidebar-overlay.show{ display:block; }
  table{ min-width: 560px; }
}
@media print{
  .sidebar, .topbar, .no-print{ display:none !important; }
  .main{ margin-left:0 !important; }
  body{ background:#fff; color:#111; }
}
