/* ============================================================
 *  WeighTech — Spectrum Design System
 *  Premium B2B SaaS aesthetic with dark glassmorphism
 * ============================================================ */

:root {
  /* Core palette */
  --void: #050813;
  --ink: #0A1024;
  --slate: #131B33;
  --slate-2: #1A2240;
  --line: rgba(255,255,255,0.08);
  --line-bright: rgba(255,255,255,0.16);
  --text: #F5F7FB;
  --text-soft: #9AA3BF;
  --text-faint: #5D6585;

  /* Spectrum accents */
  --emerald: #00E5A4;
  --emerald-deep: #00926A;
  --lime: #C8FF3E;
  --cobalt: #4B7EFF;
  --magenta: #FF4E9F;
  --amber: #FFB627;

  /* Spacing */
  --gap-xs: 6px;
  --gap-sm: 12px;
  --gap-md: 20px;
  --gap-lg: 32px;
  --gap-xl: 48px;
}

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

html, body {
  background: var(--void);
  color: var(--text);
  font-family: 'Bricolage Grotesque', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  overflow-x: hidden;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ─── Atmospheric background ─── */
body::before {
  content: '';
  position: fixed;
  inset: -10%;
  background:
    radial-gradient(circle 600px at 15% 10%, rgba(75, 126, 255, 0.30), transparent),
    radial-gradient(circle 700px at 85% 20%, rgba(0, 229, 164, 0.22), transparent),
    radial-gradient(circle 500px at 50% 90%, rgba(200, 255, 62, 0.10), transparent),
    radial-gradient(circle 400px at 90% 90%, rgba(255, 78, 159, 0.08), transparent);
  z-index: 0;
  animation: drift 22s ease-in-out infinite alternate;
  filter: blur(20px);
}
@keyframes drift {
  0%   { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-3%, 4%) rotate(1deg); }
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 64px 64px;
  z-index: 1;
}

/* ─── Layout ─── */
.app {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ─── SIDEBAR ─── */
.sidebar {
  background: rgba(10, 16, 36, 0.6);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; padding: 0 8px; }
.brand .logo {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: #050813
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%2300E5A4'/%3E%3Cstop offset='100%25' stop-color='%234B7EFF'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='14' y='20' width='22' height='3' rx='1.5' fill='url(%23g)'/%3E%3Crect x='30' y='20' width='4' height='22' rx='1' fill='url(%23g)'/%3E%3Crect x='8' y='42' width='48' height='4' rx='2' fill='url(%23g)'/%3E%3Ccircle cx='22' cy='14' r='5' fill='url(%23g)'/%3E%3Ccircle cx='50' cy='38' r='2.5' fill='%23ffffff'/%3E%3C/svg%3E") center/72% no-repeat;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 0 30px rgba(0, 229, 164, 0.35);
}
.brand .name { font-weight: 700; font-size: 19px; letter-spacing: -0.03em; }
.brand .name span { color: var(--emerald); }
.brand .name em {
  display: block; font-family: 'Instrument Serif', serif;
  font-style: italic; font-weight: 400; font-size: 11px;
  color: var(--text-soft); letter-spacing: 0; margin-top: 2px;
}

.conn-status {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  margin: 0 8px 22px;
  display: flex; align-items: center; gap: 8px;
}
.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: all 0.3s;
}
.conn-status.connected .conn-dot { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); animation: pulse 2s infinite; }
.conn-status.demo .conn-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.conn-status.error .conn-dot { background: var(--magenta); animation: blink 1s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
@keyframes blink { 50% { opacity: 0.3; } }
.conn-status .label { color: var(--text-soft); letter-spacing: 0.05em; }

/* Language toggle */
.lang-toggle {
  display: block;
  width: calc(100% - 16px);
  margin: -10px 8px 22px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text-soft);
  cursor: pointer;
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  transition: all 0.2s;
}
.lang-toggle:hover {
  border-color: var(--emerald);
  color: var(--emerald);
  background: rgba(0, 229, 164, 0.04);
}
.lang-toggle::before {
  content: '';
  display: inline-block; width: 11px; height: 11px;
  margin-right: 6px; vertical-align: -1px;
  background: url("../images/weightech-mark.svg") center/contain no-repeat;
  opacity: 0.7;
}

.nav-group { margin-bottom: 22px; }
.nav-label {
  font-family: 'Geist Mono', monospace;
  font-size: 10px; color: var(--text-faint);
  letter-spacing: 0.18em; text-transform: uppercase;
  margin: 0 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 13px; color: var(--text-soft);
  cursor: pointer; margin-bottom: 2px;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--slate); color: var(--text); }
.nav-item.active {
  background: rgba(0, 229, 164, 0.12);
  color: var(--emerald);
  border-left: 2px solid var(--emerald);
  padding-left: 10px;
}
.nav-item .badge {
  margin-left: auto;
  background: var(--magenta);
  color: var(--void);
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 100px;
  font-family: 'Geist Mono', monospace;
}

.sidebar-footer {
  margin-top: auto; padding: 16px 12px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .ava {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--magenta), var(--amber));
  display: grid; place-items: center;
  color: var(--void); font-weight: 700; font-size: 13px;
}
.sidebar-footer .info { flex: 1; }
.sidebar-footer .nm { font-size: 12px; font-weight: 600; }
.sidebar-footer .rl { font-size: 10px; color: var(--text-faint); }

/* ─── MAIN ─── */
.main { padding: 28px 36px 60px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.topbar h1 {
  font-weight: 200; font-size: 42px; line-height: 1;
  letter-spacing: -0.045em;
}
.topbar h1 b {
  font-weight: 700;
  background: linear-gradient(135deg, var(--emerald), var(--cobalt));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topbar h1 em { font-family: 'Instrument Serif', serif; font-weight: 400; font-style: italic; }
.topbar .timestamp {
  margin-top: 6px;
  font-family: 'Geist Mono', monospace;
  font-size: 11px; color: var(--text-soft);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.topbar .actions { display: flex; gap: 10px; }

/* ─── Buttons ─── */
.btn {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600; font-size: 13px;
  padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--line-bright);
  background: var(--slate); color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--slate-2); }
.btn.primary {
  background: var(--emerald); color: var(--void);
  border-color: var(--emerald);
  box-shadow: 0 8px 32px rgba(0, 229, 164, 0.4);
}
.btn.primary:hover { background: var(--lime); box-shadow: 0 8px 32px rgba(200, 255, 62, 0.5); }
.btn.danger { background: var(--magenta); color: var(--void); border-color: var(--magenta); }
.btn.ghost { background: transparent; }
.btn.lg { padding: 14px 28px; font-size: 14px; }
.btn.sm { padding: 6px 12px; font-size: 11px; }

/* ─── Panels & Cards ─── */
.panel {
  background: rgba(19, 27, 51, 0.55);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative; overflow: hidden;
}
.panel-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 24px; }
.panel-head h2 { font-weight: 300; font-size: 24px; letter-spacing: -0.02em; margin-bottom: 2px; }
.panel-head h2 b { font-weight: 700; }
.panel-head h2 em { font-family: 'Instrument Serif', serif; font-style: italic; font-weight: 400; }
.panel-head p { font-size: 12px; color: var(--text-soft); }

/* ─── Stat cards ─── */
.stat {
  background: rgba(19, 27, 51, 0.55);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 24px;
  backdrop-filter: blur(20px);
  position: relative; overflow: hidden;
  transition: all 0.3s;
}
.stat:hover { border-color: var(--accent, var(--emerald)); transform: translateY(-2px); }
.stat::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--accent, var(--emerald)), transparent);
}
.stat.s1 { --accent: var(--emerald); }
.stat.s2 { --accent: var(--cobalt); }
.stat.s3 { --accent: var(--lime); }
.stat.s4 { --accent: var(--magenta); }
.stat .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.stat .lbl {
  font-family: 'Geist Mono', monospace;
  font-size: 11px; color: var(--text-soft);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.stat .icon-box {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--accent); font-size: 16px;
}
.stat .v {
  font-weight: 200; font-size: 44px; line-height: 1;
  letter-spacing: -0.04em; margin-bottom: 8px;
  display: flex; align-items: baseline;
}
.stat .v b { font-weight: 700; }
.stat .v small { font-size: 16px; color: var(--text-soft); margin-left: 4px; font-weight: 400; }
.stat .delta {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 100px;
  background: rgba(0, 229, 164, 0.1); color: var(--emerald);
}
.stat.s4 .delta { background: rgba(255, 78, 159, 0.1); color: var(--magenta); }

/* ─── Forms ─── */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.input, .select, .textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(0, 229, 164, 0.15);
}
.textarea { min-height: 100px; resize: vertical; }

/* ─── Table ─── */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.table th {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 500;
}
.table tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ─── Badge ─── */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.tag.success { background: rgba(0, 229, 164, 0.15); color: var(--emerald); }
.tag.warning { background: rgba(255, 182, 39, 0.15); color: var(--amber); }
.tag.danger  { background: rgba(255, 78, 159, 0.15); color: var(--magenta); }
.tag.info    { background: rgba(75, 126, 255, 0.15); color: var(--cobalt); }
.tag.gray    { background: rgba(255, 255, 255, 0.08); color: var(--text-soft); }
.tag.lime    { background: rgba(200, 255, 62, 0.15); color: var(--lime); }

/* ─── Animations ─── */
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-rise { animation: rise 0.6s cubic-bezier(.16,1,.3,1) forwards; opacity: 0; }
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.10s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.20s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.30s; }

/* ─── Toast ─── */
.toast {
  position: fixed; top: 24px; right: 24px;
  background: var(--slate);
  border: 1px solid var(--emerald);
  border-radius: 12px;
  padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
  z-index: 1000;
  font-size: 13px;
  box-shadow: 0 16px 48px rgba(0, 229, 164, 0.2);
  transform: translateX(420px);
  transition: transform 0.4s cubic-bezier(.16,1,.3,1);
  pointer-events: none;
}
.toast.show { transform: translateX(0); }
.toast .ic {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(0,229,164,0.15);
  display: grid; place-items: center;
  color: var(--emerald);
}
.toast b { display: block; font-weight: 600; margin-bottom: 2px; }
.toast .meta { font-family: 'Geist Mono', monospace; font-size: 10px; color: var(--text-soft); }

/* ─── Grid utilities ─── */
.grid { display: grid; gap: var(--gap-md); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-aside { grid-template-columns: 1.5fr 1fr; }

/* ─── Responsive ─── */
@media (max-width: 1200px) {
  .grid-aside { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .main { padding: 20px; }
  .topbar { flex-direction: column; gap: 16px; align-items: flex-start; }
  .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr 1fr; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--line-bright); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
