/* CableCalc — Ultra Vibrant Glassmorphism Design System
   Rich Cyber-Violet Aurora Palette with Frosted Glass Finish & Neon Highlights.
   Fonts: Plus Jakarta Sans (UI) & JetBrains Mono (Numeric/Data). */

:root {
  /* Stacking Context / Z-Index Hierarchy */
  --z-base: 1;
  --z-sticky-table: 10;
  --z-topbar: 100;
  --z-dropdown: 200;
  --z-backdrop: 900;
  --z-drawer: 1000;
  --z-modal-back: 2000;
  --z-modal: 2010;
  --z-toast: 3000;

  /* Color Palette — Vibrant Glass Theme */
  --bg: #090616;
  --surface: rgba(26, 18, 52, 0.65);
  --surface-elevated: rgba(34, 24, 68, 0.75);
  --surface-subtle: rgba(20, 14, 42, 0.55);
  
  --ink: #f5f3ff;
  --ink-2: #e9d5ff;
  --muted: #c084fc;
  --faint: #a855f7;
  --line: rgba(255, 255, 255, 0.12);
  --line-soft: rgba(255, 255, 255, 0.07);

  /* Rail Navigation Colors */
  --rail-bg: rgba(16, 10, 34, 0.7);
  --rail-border: rgba(192, 132, 252, 0.15);
  --rail-text: #e9d5ff;
  --rail-text-muted: #a855f7;
  --rail-hover: rgba(168, 85, 247, 0.15);
  --rail-active: linear-gradient(135deg, rgba(168, 85, 247, 0.35) 0%, rgba(236, 72, 153, 0.25) 100%);
  --rail-active-text: #ffffff;

  /* Vibrant Accent Colors */
  --accent: #a855f7;
  --accent-light: #c084fc;
  --accent-dark: #7e22ce;
  --accent-soft: rgba(168, 85, 247, 0.15);
  --accent-line: rgba(192, 132, 252, 0.35);
  --accent-gradient: linear-gradient(135deg, #a855f7 0%, #ec4899 50%, #06b6d4 100%);

  /* Neon Status Tones */
  --ok: #34d399;
  --ok-soft: rgba(16, 185, 129, 0.18);
  --ok-line: rgba(52, 211, 153, 0.4);
  --warn: #fbbf24;
  --warn-soft: rgba(245, 158, 11, 0.18);
  --warn-line: rgba(251, 191, 36, 0.4);
  --fail: #fb7185;
  --fail-soft: rgba(244, 63, 94, 0.18);
  --fail-line: rgba(251, 113, 133, 0.4);

  /* Radii */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  /* Glass Shadows & Glows */
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.25);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-md: 0 12px 40px rgba(168, 85, 247, 0.15), 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 40px rgba(168, 85, 247, 0.25);
  --shadow-glow: 0 0 24px rgba(168, 85, 247, 0.5), 0 0 40px rgba(236, 72, 153, 0.3);

  /* Fonts */
  --sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

/* Cosmic Dynamic Ambient Background Orbs */
body::before {
  content: ""; position: fixed; top: -15%; left: -10%; width: 70vw; height: 70vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.22) 0%, rgba(236, 72, 153, 0.12) 45%, transparent 70%);
  filter: blur(90px); pointer-events: none; z-index: -1;
  animation: floatGlow 18s ease-in-out infinite alternate;
}
body::after {
  content: ""; position: fixed; bottom: -15%; right: -10%; width: 65vw; height: 65vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.22) 0%, rgba(16, 185, 129, 0.15) 50%, transparent 70%);
  filter: blur(90px); pointer-events: none; z-index: -1;
  animation: floatGlow2 22s ease-in-out infinite alternate;
}

@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, 40px) scale(1.1); }
}
@keyframes floatGlow2 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-50px, -30px) scale(1.08); }
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-light); text-decoration: none; transition: color .15s; }
a:hover { color: #f472b6; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.02em; color: #fff; }
.num { font-variant-numeric: tabular-nums; font-family: var(--mono); color: #f5f3ff; }

/* Custom Glass Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: rgba(16, 10, 34, 0.4); }
::-webkit-scrollbar-thumb { background: rgba(192, 132, 252, 0.3); border-radius: 99px; border: 1px solid rgba(255,255,255,0.1); }
::-webkit-scrollbar-thumb:hover { background: rgba(192, 132, 252, 0.6); }

/* ---------------------------------------------------------------- layout */

#app { display: flex; min-height: 100vh; position: relative; }

/* Rail Navigation Sidebar (Glassmorphic) */
.rail {
  width: 245px; flex: 0 0 245px;
  background: var(--rail-bg);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  color: var(--rail-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: var(--z-topbar);
  border-right: 1px solid var(--rail-border);
  box-shadow: 4px 0 30px rgba(0,0,0,0.5);
  transition: transform .28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Topbar Layout Mode Override */
#app.topbar-layout {
  flex-direction: column;
}
#app.topbar-layout .rail {
  width: 100%;
  flex: 0 0 auto;
  height: auto;
  position: sticky;
  top: 0;
  flex-direction: row;
  align-items: center;
  border-right: none;
  border-bottom: 1px solid var(--rail-border);
  padding: 0 16px;
  z-index: var(--z-topbar);
  box-shadow: 0 4px 25px rgba(0,0,0,0.5);
}
#app.topbar-layout .rail .brand {
  border-bottom: none;
  padding: 12px 16px 12px 0;
}
#app.topbar-layout .rail nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  overflow-y: hidden;
}
#app.topbar-layout .rail nav .group-label {
  display: none;
}
#app.topbar-layout .rail button.navitem {
  width: auto;
  margin-bottom: 0;
  padding: 8px 14px;
  white-space: nowrap;
}
#app.topbar-layout .rail .whoami {
  border-top: none;
  border-left: 1px solid var(--rail-border);
  padding: 8px 12px;
  margin-left: auto;
  background: transparent;
}

/* Icon-only Glass Button (Layout Toggle) */
.btn-icon-glass {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-soft);
  color: #c084fc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: 8px;
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  flex: none;
}
.btn-icon-glass:hover {
  background: var(--surface-hover);
  border-color: var(--border-bright);
  color: #fff;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.45);
}
.btn-icon-glass:active {
  transform: translateY(0) scale(0.95);
}

/* Topbar User Profile Menu & Dropdown */
.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-soft);
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  color: #fff;
  cursor: pointer;
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  margin-left: 8px;
}
.user-menu-trigger:hover {
  background: var(--surface-hover);
  border-color: var(--border-bright);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
}
.user-menu-trigger .avatar.sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  display: grid;
  place-items: center;
}
.user-name-text {
  font-size: 13px;
  font-weight: 600;
  color: #f5f3ff;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 230px;
  background: rgba(15, 10, 32, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  padding: 8px 0;
  box-shadow: 0 12px 35px rgba(0,0,0,0.6), 0 0 24px rgba(168, 85, 247, 0.25);
  z-index: 1000;
  display: none;
}
.user-dropdown-menu.open {
  display: block;
  animation: dropdownFade .18s ease-out;
}
@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.dropdown-header {
  padding: 8px 16px 10px;
}
.dropdown-header .dropdown-nm {
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
}
.dropdown-header .dropdown-em {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 6px 0;
}
.dropdown-item {
  width: 100%;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
}
.dropdown-item:hover {
  background: rgba(168, 85, 247, 0.18);
  color: #fff;
}
.dropdown-item.danger {
  color: #fb7185;
}
.dropdown-item.danger:hover {
  background: rgba(244, 63, 94, 0.22);
  color: #fff;
}

.rail .brand {
  padding: 22px 20px 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--rail-border);
  position: relative;
}

.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: var(--accent-gradient);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: var(--shadow-glow);
}

.brand-text { flex: 1; min-width: 0; }
.brand-name { color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.02em; text-shadow: 0 0 12px rgba(168, 85, 247, 0.6); }
.brand-sub { font-size: 11px; color: var(--rail-text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rail-close-btn {
  display: none; background: none; border: 0; color: #c084fc;
  font-size: 24px; line-height: 1; cursor: pointer; padding: 4px;
}
.rail-close-btn:hover { color: #fff; }

.rail nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.rail .group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .12em;
  color: #a855f7; padding: 18px 10px 8px; font-weight: 800; text-shadow: 0 0 8px rgba(168, 85, 247, 0.4);
}

.rail button.navitem {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 4px; border-radius: 10px;
  background: none; border: 1px solid transparent; color: var(--rail-text); cursor: pointer;
  font-size: 13.5px; font-weight: 600; text-align: left;
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
}
.rail button.navitem:hover {
  background: var(--rail-hover); color: #fff; border-color: rgba(192, 132, 252, 0.25);
  transform: translateX(3px); box-shadow: 0 4px 16px rgba(168, 85, 247, 0.15);
}
.rail button.navitem.active {
  background: var(--rail-active); color: #fff; font-weight: 700;
  border-color: rgba(192, 132, 252, 0.5);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.3), inset 0 0 15px rgba(236, 72, 153, 0.2);
}
.rail button.navitem .ico { width: 18px; text-align: center; font-size: 15px; flex: none; filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.6)); }

.rail .whoami {
  border-top: 1px solid var(--rail-border); padding: 16px 18px;
  display: flex; align-items: center; gap: 12px; background: rgba(10, 6, 24, 0.5);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--accent-gradient); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
}
.whoami-info { flex: 1; min-width: 0; }
.whoami .nm { color: #f5f3ff; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.whoami .rl { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.whoami button#signout {
  margin-left: auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fb7185;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
  flex: none;
}
.whoami button#signout:hover {
  color: #fff;
  background: rgba(244, 63, 94, 0.45);
  border-color: rgba(244, 63, 94, 0.6);
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.5);
  transform: scale(1.06);
}

/* Glass Backdrop overlay for mobile menu */
.rail-backdrop {
  position: fixed; inset: 0; background: rgba(9, 6, 22, 0.75);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-backdrop); opacity: 0; pointer-events: none; transition: opacity .28s;
}
.rail-backdrop.open { opacity: 1; pointer-events: auto; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Top Header Glass Bar */
.topbar {
  background: rgba(20, 14, 42, 0.65);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--line);
  padding: 18px 30px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: var(--z-topbar);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.mobile-toggle-btn {
  display: none; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 9px; color: #fff; cursor: pointer;
  transition: background .15s; align-items: center; justify-content: center;
}
.mobile-toggle-btn:hover { background: rgba(168, 85, 247, 0.25); border-color: rgba(192, 132, 252, 0.4); }

.topbar-title-wrap { display: flex; flex-direction: column; gap: 2px; }
.topbar h1 { font-size: 21px; font-weight: 800; letter-spacing: -.025em; text-shadow: 0 0 16px rgba(168, 85, 247, 0.4); }
.topbar .sub { font-size: 13px; color: var(--ink-2); }
.topbar .spacer { flex: 1; }

.page { padding: 30px 30px 60px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* Quick Layout Grid */
.quick-layout {
  display: grid; grid-template-columns: 420px 1fr; gap: 24px; align-items: start;
}
@media (max-width: 1100px) {
  .quick-layout { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- pieces */

.card {
  background: var(--surface);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  overflow: hidden; transition: all .25s ease;
}
.card:hover {
  background: var(--surface-elevated);
  border-color: rgba(192, 132, 252, 0.3);
  box-shadow: var(--shadow-md);
}
.card + .card { margin-top: 24px; }
.card-head {
  padding: 18px 24px; border-bottom: 1px solid var(--line-soft);
  background: rgba(20, 14, 42, 0.4); display: flex; align-items: center; gap: 12px;
}
.card-head h3 { font-size: 16px; font-weight: 700; color: #fff; text-shadow: 0 0 10px rgba(168, 85, 247, 0.3); }
.card-head .hint { font-size: 13px; color: var(--ink-2); }
.card-body { padding: 24px; }
.card-body.tight { padding: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07); color: #f5f3ff; cursor: pointer;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn:hover {
  background: rgba(168, 85, 247, 0.2); border-color: rgba(192, 132, 252, 0.4);
  color: #fff; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(168, 85, 247, 0.25);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary {
  background: var(--accent-gradient); border-color: rgba(255, 255, 255, 0.25); color: #fff;
  box-shadow: var(--shadow-glow); text-shadow: 0 0 8px rgba(0,0,0,0.3);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #c084fc 0%, #f472b6 50%, #22d3ee 100%);
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.7), 0 0 45px rgba(236, 72, 153, 0.4);
}
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.btn.danger { color: #fb7185; border-color: rgba(244, 63, 94, 0.4); background: rgba(244, 63, 94, 0.15); }
.btn.danger:hover { background: rgba(244, 63, 94, 0.35); border-color: #f43f5e; box-shadow: 0 0 20px rgba(244, 63, 94, 0.4); }
.btn.sm { padding: 7px 13px; font-size: 12px; border-radius: 8px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; color: #e9d5ff; display: flex; justify-content: space-between; }
.field .unit { color: var(--muted); font-weight: 500; font-size: 12px; }
.field input, .field select, .field textarea {
  padding: 10px 14px; border: 1px solid rgba(192, 132, 252, 0.25); border-radius: 10px;
  background: rgba(12, 8, 26, 0.65); outline: none; width: 100%; color: #f5f3ff;
  backdrop-filter: blur(12px); font-size: 14px;
  transition: all .2s ease;
}
.field select option { background: #160f2d; color: #f5f3ff; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #c084fc; box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.35), 0 0 24px rgba(168, 85, 247, 0.3);
}
.field input:disabled { background: rgba(12, 8, 26, 0.3); color: var(--muted); cursor: not-allowed; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* Table Component (Glass Styled) */
.table-wrap {
  overflow-x: auto; max-height: 70vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch; border-radius: var(--r);
}
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; text-align: left; }
table.data th {
  padding: 13px 16px; background: rgba(24, 16, 48, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line); font-size: 11.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em; color: #d8b4fe;
  white-space: nowrap; position: sticky; top: 0; z-index: var(--z-sticky-table);
  text-shadow: 0 0 8px rgba(168, 85, 247, 0.3);
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: #f5f3ff; }
table.data tbody tr { transition: background .15s; }
table.data tbody tr:hover { background: rgba(168, 85, 247, 0.14); }
table.data tbody tr.expanded { background: rgba(168, 85, 247, 0.22); }
table.data td.right, table.data th.right { text-align: right; }

/* Status Badges & Pills */
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); box-shadow: 0 0 14px rgba(52, 211, 153, 0.25); }
.pill.warning { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); box-shadow: 0 0 14px rgba(251, 191, 36, 0.25); }
.pill.fail { background: var(--fail-soft); color: var(--fail); border-color: var(--fail-line); box-shadow: 0 0 14px rgba(251, 113, 133, 0.25); }
.pill.incomplete { background: rgba(255, 255, 255, 0.08); color: var(--muted); border-color: var(--line); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }

/* Tab Navigation */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding: 0 20px; overflow-x: auto; }
.tabs button {
  padding: 13px 18px; background: none; border: 0; border-bottom: 3px solid transparent;
  color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 700; white-space: nowrap;
  transition: all .18s;
}
.tabs button:hover { color: #fff; text-shadow: 0 0 8px rgba(255,255,255,0.5); }
.tabs button.active { color: #f472b6; border-bottom-color: #f472b6; text-shadow: 0 0 12px rgba(244, 114, 182, 0.6); }

/* Stat Widgets (Glass Cards) */
.stat {
  padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(20, 14, 42, 0.55); backdrop-filter: blur(12px); box-shadow: var(--shadow-sm);
}
.stat .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: #c084fc; font-weight: 800; }
.stat .v { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; color: #fff; text-shadow: 0 0 14px rgba(168, 85, 247, 0.4); }
.stat .s { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.stat.ok { background: rgba(16, 185, 129, 0.12); border-color: var(--ok-line); }
.stat.fail { background: rgba(244, 63, 94, 0.12); border-color: var(--fail-line); }
.stat.warning { background: rgba(245, 158, 11, 0.12); border-color: var(--warn-line); }

.meter { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.1); overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--ok); box-shadow: 0 0 10px var(--ok); transition: width .35s ease; }
.meter i.warning { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.meter i.fail { background: var(--fail); box-shadow: 0 0 10px var(--fail); }

.checkrow {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px;
  border: 1px solid var(--line); border-radius: var(--r); background: rgba(20, 14, 42, 0.5);
  backdrop-filter: blur(12px); transition: border-color .15s;
}
.checkrow + .checkrow { margin-top: 12px; }
.checkrow.ok { border-color: var(--ok-line); background: var(--ok-soft); }
.checkrow.fail { border-color: var(--fail-line); background: var(--fail-soft); }
.checkrow.warning { border-color: var(--warn-line); background: var(--warn-soft); }
.checkrow .mark { font-size: 18px; line-height: 1.2; }
.checkrow .lbl { font-weight: 700; font-size: 14px; color: #fff; }
.checkrow .msg { font-size: 13px; color: #e9d5ff; margin-top: 2px; }

.trace { font-size: 13px; }
.trace td { padding: 9px 14px; }
.trace .basis { color: var(--muted); font-size: 12px; }
.badge-interp {
  font-size: 10.5px; padding: 2px 7px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent-light); font-weight: 700; border: 1px solid var(--accent-line);
}

.empty { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty .big { font-size: 44px; opacity: .5; margin-bottom: 16px; filter: drop-shadow(0 0 12px rgba(168,85,247,0.5)); }
.empty h3 { font-size: 17px; color: #fff; margin-bottom: 8px; }
.empty p { font-size: 14px; max-width: 460px; margin: 0 auto 24px; line-height: 1.6; color: var(--ink-2); }

.note {
  padding: 14px 18px; border-radius: var(--r); font-size: 13.5px; line-height: 1.65;
  background: rgba(168, 85, 247, 0.15); border: 1px solid var(--accent-line); color: #f5f3ff;
  backdrop-filter: blur(10px);
}
.note.warn { background: rgba(245, 158, 11, 0.18); border-color: var(--warn-line); color: #fde68a; }
.note.err { background: rgba(244, 63, 94, 0.18); border-color: var(--fail-line); color: #fecaca; }

/* ------------------------------------------------------------- overlays */

.modal-back {
  position: fixed; inset: 0; background: rgba(9, 6, 22, 0.75);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: grid; place-items: center; z-index: var(--z-modal-back); padding: 20px;
  animation: fadeIn .2s ease-out;
}
.modal {
  background: rgba(24, 16, 50, 0.85); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 580px; max-height: 90vh; display: flex; flex-direction: column;
  z-index: var(--z-modal); animation: scaleUp .24s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden; border: 1px solid rgba(192, 132, 252, 0.3);
}
.modal.wide { max-width: 940px; }
.modal-head { padding: 22px 26px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; background: rgba(16, 10, 36, 0.6); }
.modal-head h3 { font-size: 17.5px; font-weight: 800; color: #fff; text-shadow: 0 0 12px rgba(168, 85, 247, 0.4); }
.modal-body { padding: 26px; overflow-y: auto; color: #f5f3ff; }
.modal-foot { padding: 18px 26px; border-top: 1px solid var(--line-soft); display: flex; gap: 12px; justify-content: flex-end; background: rgba(16, 10, 36, 0.6); }

#toasts { position: fixed; right: 26px; bottom: 26px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 12px; }
.toast {
  background: rgba(24, 16, 52, 0.9); color: #fff; padding: 14px 20px; border-radius: 12px;
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px rgba(168,85,247,0.3);
  font-size: 14px; font-weight: 600; max-width: 420px;
  animation: rise .26s cubic-bezier(0.16, 1, 0.3, 1); border: 1px solid rgba(192, 132, 252, 0.3);
}
.toast.err { background: rgba(244, 63, 94, 0.9); border-color: rgba(251, 113, 133, 0.5); }
.toast.ok { background: rgba(16, 185, 129, 0.9); border-color: rgba(52, 211, 153, 0.5); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleUp { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------- auth */

.auth-wrap {
  min-height: 100vh; width: 100%; display: grid; grid-template-columns: 1.1fr 0.9fr;
}
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-art { display: none; } }
.auth-art {
  background: linear-gradient(145deg, #0b071a 0%, #170b2c 50%, #051829 100%);
  color: #e2e8f0; padding: 68px; display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.auth-art::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(168, 85, 247, 0.12) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(168, 85, 247, 0.12) 1px, transparent 1px);
  background-size: 52px 52px; mask-image: radial-gradient(ellipse at 40% 40%, #000, transparent 80%);
}
.auth-art > * { position: relative; z-index: 1; }
.auth-art h2 { font-size: 36px; color: #fff; line-height: 1.25; margin-bottom: 20px; letter-spacing: -.03em; text-shadow: 0 0 20px rgba(168, 85, 247, 0.5); }
.auth-art p { color: #e9d5ff; line-height: 1.7; max-width: 460px; font-size: 15px; }
.auth-art ul { list-style: none; padding: 0; margin: 36px 0 0; }
.auth-art li { padding: 11px 0; color: #f5f3ff; font-size: 14.5px; display: flex; gap: 14px; align-items: flex-start; }
.auth-art li b { color: #22d3ee; font-weight: 700; text-shadow: 0 0 10px rgba(34, 211, 238, 0.6); }

.auth-panel { display: grid; place-items: center; padding: 40px 30px; background: transparent; }
.auth-form {
  width: 100%; max-width: 420px; padding: 36px;
  background: var(--surface); backdrop-filter: blur(28px);
  border: 1px solid rgba(192, 132, 252, 0.3); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.auth-form h1 { font-size: 28px; margin-bottom: 8px; letter-spacing: -.03em; text-shadow: 0 0 14px rgba(168, 85, 247, 0.4); }
.auth-form .lead { color: var(--ink-2); font-size: 14.5px; margin-bottom: 30px; }
.auth-form .field { margin-bottom: 18px; }
.auth-form .btn { width: 100%; padding: 12px; margin-top: 10px; font-size: 15px; }
.auth-switch { margin-top: 24px; font-size: 14px; color: var(--muted); text-align: center; }
.auth-switch button { background: none; border: 0; color: #f472b6; cursor: pointer; font-weight: 700; padding: 0; }

.seg { display: inline-flex; background: rgba(12, 8, 26, 0.6); border-radius: 12px; padding: 4px; gap: 4px; border: 1px solid var(--line); }
.seg button {
  padding: 8px 18px; border: 0; background: none; border-radius: 9px;
  cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted);
  transition: all .18s;
}
.seg button.active { background: var(--accent-gradient); color: #fff; box-shadow: 0 0 14px rgba(168, 85, 247, 0.4); }

.crumb { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); margin-bottom: 4px; }
.crumb button { background: none; border: 0; color: #f472b6; cursor: pointer; padding: 0; font-size: 13.5px; font-weight: 600; }
.crumb button:hover { text-decoration: underline; text-shadow: 0 0 8px rgba(244, 114, 182, 0.6); }

.skeleton {
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.1) 0%, rgba(236, 72, 153, 0.2) 50%, rgba(168, 85, 247, 0.1) 100%);
  background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: 10px; height: 16px;
}
@keyframes sk { to { background-position: -200% 0; } }

.ai-box {
  border: 1px solid rgba(192, 132, 252, 0.4);
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2) 0%, rgba(236, 72, 153, 0.15) 100%);
  backdrop-filter: blur(16px);
  border-radius: var(--r-lg); padding: 18px 22px; font-size: 14px; line-height: 1.7; color: #f5f3ff;
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.15);
}
.ai-box .who { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; color: #f472b6; margin-bottom: 8px; text-shadow: 0 0 8px rgba(244, 114, 182, 0.6); }

/* ------------------------------------------------------- data & analysis */

.viz-root {
  --surface-1: rgba(20, 14, 42, 0.6);
  --series-1: #38bdf8;
  --series-2: #fb923c;
  --series-3: #34d399;
  --series-4: #facc15;
  --grid: rgba(255, 255, 255, 0.1);
  --limit: #fb7185;
}
.chart-wrap { position: relative; background: var(--surface-1); backdrop-filter: blur(12px); border-radius: var(--r); border: 1px solid var(--line); }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-wrap .gridline { stroke: var(--grid); stroke-width: 1; }
.chart-wrap .axis-text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.chart-wrap .axis-title { fill: #d8b4fe; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.chart-wrap .serieline { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; filter: drop-shadow(0 0 6px currentColor); }
.chart-wrap .limitline { stroke: var(--limit); stroke-width: 1.8; stroke-dasharray: 4 4; filter: drop-shadow(0 0 6px var(--limit)); }
.chart-wrap .limitlabel { fill: var(--limit); font-size: 11px; font-weight: 800; }
.chart-wrap .nowline { stroke: #c084fc; stroke-width: 1; stroke-dasharray: 2 2; }
.chart-wrap .nowlabel { fill: var(--muted); font-size: 11px; font-weight: 700; }
.chart-wrap .endlabel { font-size: 11px; font-weight: 800; fill: #fff; }
.chart-wrap .crosshair { stroke: #fff; stroke-width: 1; opacity: .4; }
.chart-wrap .hoverdot { stroke: #180e34; stroke-width: 3; }
.chart-tip {
  position: absolute; pointer-events: none; background: rgba(16, 10, 36, 0.9); color: #fff;
  padding: 10px 15px; border-radius: 10px; font-size: 12.5px; line-height: 1.6;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg); white-space: nowrap; transform: translate(-50%, -110%);
  opacity: 0; transition: opacity .12s; border: 1px solid rgba(192, 132, 252, 0.4);
}
.chart-tip .k { color: var(--muted); }
.chart-tip b { font-family: var(--mono); color: #38bdf8; }
.legend { display: flex; flex-wrap: wrap; gap: 20px; padding: 16px 4px 0; }
.legend span { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: #e9d5ff; font-weight: 600; }
.legend i { width: 18px; height: 5px; border-radius: 3px; display: inline-block; box-shadow: 0 0 8px currentColor; }

.finding {
  border: 1px solid var(--line); border-left-width: 5px; border-radius: var(--r);
  padding: 16px 20px; background: rgba(20, 14, 42, 0.55); backdrop-filter: blur(12px); box-shadow: var(--shadow-sm);
}
.finding + .finding { margin-top: 12px; }
.finding.fail { border-left-color: var(--fail); background: var(--fail-soft); }
.finding.warning { border-left-color: var(--warn); background: var(--warn-soft); }
.finding.info { border-left-color: var(--accent-light); background: var(--accent-soft); }
.finding h4 { font-size: 14.5px; margin-bottom: 6px; color: #fff; }
.finding p { margin: 0; font-size: 13.5px; line-height: 1.65; color: #e9d5ff; }
.finding .sugg { margin-top: 9px; font-size: 13px; color: var(--muted); font-style: italic; }
.finding .tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 7px; }
.finding .tags b {
  font-size: 11.5px; font-family: var(--mono); background: rgba(168, 85, 247, 0.2);
  padding: 4px 9px; border-radius: 7px; font-weight: 700; color: #e9d5ff; border: 1px solid rgba(192, 132, 252, 0.3);
}

.memo { font-size: 14.5px; line-height: 1.75; color: #e9d5ff; }
.memo p { margin: 0 0 16px; }
.memo p:last-child { margin-bottom: 0; }

.askbar { display: flex; gap: 12px; }
.askbar input { flex: 1; padding: 12px 16px; border: 1px solid rgba(192, 132, 252, 0.3); border-radius: 12px; outline: none; font-size: 14px; background: rgba(12, 8, 26, 0.65); color: #fff; }
.askbar input:focus { border-color: #c084fc; box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.35), 0 0 20px rgba(168, 85, 247, 0.3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chips button {
  font-size: 12.5px; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(192, 132, 252, 0.25); background: rgba(20, 14, 42, 0.6); color: var(--muted); font-weight: 600;
  transition: all .18s; backdrop-filter: blur(10px);
}
.chips button:hover { border-color: #f472b6; color: #fff; background: rgba(236, 72, 153, 0.25); box-shadow: 0 0 14px rgba(236, 72, 153, 0.4); }

.reviewrow { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 1180px) { .reviewrow { grid-template-columns: 1fr 1fr; } }

.dropzone {
  border: 2px dashed rgba(192, 132, 252, 0.3); border-radius: var(--r-lg); padding: 32px;
  text-align: center; color: var(--muted); font-size: 14px; transition: all .18s;
  background: rgba(16, 10, 36, 0.4); backdrop-filter: blur(12px);
}
.dropzone.over { border-color: #f472b6; background: rgba(236, 72, 153, 0.2); box-shadow: 0 0 30px rgba(236, 72, 153, 0.3); }
.rowbad { background: rgba(245, 158, 11, 0.18); }

/* --------------------------------------------------- Media Queries for Mobile */

@media (max-width: 900px) {
  .rail {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 285px; z-index: var(--z-drawer);
    transform: translateX(-100%);
    box-shadow: 10px 0 40px rgba(0,0,0,0.6);
  }
  .rail.open { transform: translateX(0); }
  .rail-close-btn { display: block; }
  .mobile-toggle-btn { display: inline-flex; }
  
  .topbar { padding: 14px 20px; }
  .topbar h1 { font-size: 18px; }
  .topbar .sub { font-size: 12px; }

  .page { padding: 18px 18px 45px; }
  .card-head { padding: 16px 18px; }
  .card-body { padding: 18px; }

  .modal-head { padding: 18px 20px; }
  .modal-body { padding: 20px; }
  .modal-foot { padding: 16px 20px; }

  table.data th, table.data td { padding: 11px 11px; font-size: 12.5px; }
  .stat .v { font-size: 20px; }
}

/* ---------------------------------------------- inline table-cell editors
   Rule and configuration grids edit in place, so bare inputs inside a data
   table need the same treatment as a .field input — otherwise they inherit the
   browser default (white box, dark text) and vanish against the dark surface. */

table.data td > input[type="text"],
table.data td > input[type="number"],
table.data td > input:not([type]),
table.data td > select {
  width: 100%; padding: 7px 10px; font-size: 13px;
  color: var(--ink);
  background: rgba(12, 8, 26, 0.55);
  border: 1px solid rgba(192, 132, 252, 0.18);
  border-radius: 8px; outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
table.data td > select option { background: #160f2d; color: var(--ink); }
table.data td > input:hover, table.data td > select:hover {
  border-color: rgba(192, 132, 252, 0.4);
}
table.data td > input:focus, table.data td > select:focus {
  border-color: #c084fc; background: rgba(12, 8, 26, 0.85);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.28);
}
table.data td > input:disabled, table.data td > select:disabled {
  opacity: .55; cursor: not-allowed;
}
table.data td input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: #a855f7; cursor: pointer;
}
table.data td label { color: var(--ink-2); cursor: pointer; }
