/* ═══════════════════════════════════════════════════════════════
   SCALE AGENTE — Design System v3.0
   Neutral dark premium theme · Bricolage Grotesque + IBM Plex Mono
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  /* Core palette — neutral blacks */
  --color-bg-deepest:    #030303;
  --color-bg-base:       #0A0A0B;
  --color-bg-raised:     #101012;
  --color-bg-surface:    #18181B;
  --color-bg-elevated:   #1F1F23;
  --color-bg-hover:      #27272A;

  /* Brand green */
  --color-primary:       #00E87B;
  --color-primary-hover: #00D06E;
  --color-primary-muted: rgba(0, 232, 123, 0.10);
  --color-primary-subtle:rgba(0, 232, 123, 0.05);
  --color-primary-glow:  rgba(0, 232, 123, 0.20);

  /* Multi-accent */
  --color-blue:          #5B9CFF;
  --color-blue-muted:    rgba(91, 156, 255, 0.10);
  --color-violet:        #A78BFA;
  --color-violet-muted:  rgba(167, 139, 250, 0.08);
  --color-amber:         #FBBF24;
  --color-amber-muted:   rgba(251, 191, 36, 0.08);
  --color-cyan:          #22D3EE;
  --color-cyan-muted:    rgba(34, 211, 238, 0.08);
  --color-rose:          #FB7185;
  --color-rose-muted:    rgba(251, 113, 133, 0.08);

  /* Legacy compat aliases */
  --color-accent:        #FBBF24;
  --color-accent-hover:  #EAB308;
  --color-accent-muted:  rgba(251, 191, 36, 0.10);

  /* Semantic */
  --color-success:       #00E87B;
  --color-warning:       #FBBF24;
  --color-danger:        #EF4444;
  --color-danger-muted:  rgba(239, 68, 68, 0.10);
  --color-info:          #5B9CFF;
  --color-info-muted:    rgba(91, 156, 255, 0.10);

  /* Text hierarchy */
  --color-text-primary:  #F4F4F5;
  --color-text-secondary:#A1A1AA;
  --color-text-tertiary: #71717A;
  --color-text-muted:    #3F3F46;

  /* Borders — neutral, not green-tinted */
  --color-border:        rgba(255,255,255,0.06);
  --color-border-subtle: rgba(255,255,255,0.04);
  --color-border-strong: rgba(255,255,255,0.10);
  --color-border-hover:  rgba(255,255,255,0.14);

  /* Shadows */
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.15);
  --shadow-md:    0 4px 8px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
  --shadow-lg:    0 12px 32px rgba(0,0,0,0.4), 0 4px 10px rgba(0,0,0,0.2);
  --shadow-xl:    0 24px 64px rgba(0,0,0,0.5), 0 8px 20px rgba(0,0,0,0.3);
  --shadow-glow:  0 0 20px rgba(0,232,123,0.10), 0 0 40px rgba(0,232,123,0.04);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* Sidebar */
  --sidebar-width: 260px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: 'Bricolage Grotesque', 'Space Grotesk', system-ui, sans-serif;
  background: var(--color-bg-deepest);
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}

.text-gradient {
  background: linear-gradient(180deg, #F4F4F5 30%, #71717A 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.text-gradient-brand {
  background: linear-gradient(135deg, #00E87B 0%, #22D3EE 50%, #5B9CFF 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-bg-hover); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

::selection { background: rgba(0,232,123,0.18); color: #fff; }

/* ── Backgrounds ── */
.bg-gradient-radial {
  background:
    radial-gradient(ellipse 60% 50% at 30% 0%, rgba(0,232,123,0.04) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 80% 30%, rgba(91,156,255,0.02) 0%, transparent 50%),
    var(--color-bg-deepest);
}

/* ── Cards ── */
.card {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all var(--duration-normal) var(--ease-out);
}
.card:hover {
  border-color: var(--color-border-hover);
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.card-flat {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.card-glass {
  background: rgba(16, 16, 18, 0.75);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.03), var(--shadow-xl);
  position: relative; overflow: hidden;
}
.card-glass::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,232,123,0.25), rgba(91,156,255,0.12), transparent);
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-weight: 600; border: none; cursor: pointer;
  text-decoration: none; transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap; position: relative;
}

.btn-primary {
  background: var(--color-primary); color: #000;
  font-size: 14px; padding: 11px 24px; border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,232,123,0.12);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,232,123,0.25), 0 0 0 1px rgba(0,232,123,0.18);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-secondary {
  background: var(--color-bg-surface); color: var(--color-text-secondary);
  font-size: 14px; padding: 11px 24px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
}
.btn-secondary:hover {
  border-color: var(--color-border-hover); color: var(--color-text-primary);
  background: var(--color-bg-elevated);
}

.btn-ghost {
  background: transparent; color: var(--color-text-secondary);
  font-size: 14px; padding: 11px 24px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover {
  border-color: var(--color-border-hover); color: var(--color-text-primary);
}

.btn-danger {
  background: var(--color-danger); color: white;
  font-size: 14px; padding: 11px 24px; border-radius: var(--radius-md);
}
.btn-danger:hover { background: #DC2626; transform: translateY(-1px); }

.btn-sm { font-size: 13px; padding: 8px 16px; border-radius: var(--radius-sm); }
.btn-lg { font-size: 16px; padding: 14px 32px; border-radius: var(--radius-md); font-weight: 700; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }
.w-full { width: 100%; }

/* ── Inputs ── */
.input {
  width: 100%; background: var(--color-bg-deepest);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  padding: 12px 16px; font-size: 14px; font-family: inherit;
  color: var(--color-text-primary); outline: none;
  transition: all var(--duration-fast) ease;
}
.input::placeholder { color: var(--color-text-muted); }
.input:hover:not(:focus) { border-color: rgba(255,255,255,0.14); }
.input:focus {
  border-color: rgba(0,232,123,0.35);
  box-shadow: 0 0 0 3px rgba(0,232,123,0.06);
}

.input-label {
  display: block; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--color-text-tertiary); margin-bottom: 8px;
}
.input-group { margin-bottom: 20px; }

textarea.input { resize: vertical; min-height: 100px; }
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2371717A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
select.input option {
  background: #1a1a1a;
  color: #f1f1f1;
}

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 12px;
  border-radius: var(--radius-full); white-space: nowrap;
}
.badge-success { background: var(--color-primary-muted); color: var(--color-primary); border: 1px solid rgba(0,232,123,0.15); }
.badge-warning { background: var(--color-amber-muted); color: var(--color-amber); border: 1px solid rgba(251,191,36,0.15); }
.badge-danger  { background: var(--color-danger-muted); color: var(--color-danger); border: 1px solid rgba(239,68,68,0.15); }
.badge-info    { background: var(--color-info-muted); color: var(--color-info); border: 1px solid rgba(91,156,255,0.15); }
.badge-neutral { background: rgba(113,113,122,0.10); color: var(--color-text-tertiary); border: 1px solid rgba(113,113,122,0.12); }

.badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; animation: badge-pulse 2.5s ease infinite;
}
@keyframes badge-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width); min-height: 100vh;
  background: var(--color-bg-base); border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column; position: fixed;
  left: 0; top: 0; bottom: 0; z-index: 30;
}

.sidebar-header {
  padding: 20px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--color-primary); display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #000; flex-shrink: 0;
  box-shadow: 0 0 20px rgba(0,232,123,0.20);
}
.sidebar-brand { font-size: 15px; font-weight: 700; color: var(--color-text-primary); letter-spacing: -0.02em; }
.sidebar-brand-sub { font-size: 11px; color: var(--color-text-muted); margin-top: 1px; font-family: 'IBM Plex Mono', monospace; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-section {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--color-text-muted);
  padding: 0 12px; margin-bottom: 8px; margin-top: 20px;
  font-family: 'IBM Plex Mono', monospace;
}
.sidebar-section:first-child { margin-top: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--color-text-secondary);
  text-decoration: none; transition: all var(--duration-fast) ease;
  position: relative; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.03); color: var(--color-text-primary); }
.nav-item.active {
  background: var(--color-primary-muted); color: var(--color-primary); font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 15%; bottom: 15%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--color-primary); box-shadow: 0 0 8px rgba(0,232,123,0.4);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover svg { opacity: 1; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--color-border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  flex-shrink: 0; background: var(--color-primary-muted); color: var(--color-primary);
  border: 1px solid rgba(0,232,123,0.15);
}

/* ── Page header ── */
.page-header {
  position: sticky; top: 0; z-index: 20;
  padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(10,10,11,0.80);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--color-border);
}
.page-header h1 { font-size: 16px; font-weight: 600; margin: 0; }
.page-header .subtitle { font-size: 13px; color: var(--color-text-tertiary); margin-top: 2px; }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto; border-radius: var(--radius-lg);
  border: 1px solid var(--color-border); background: var(--color-bg-raised);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead tr { background: var(--color-bg-surface); border-bottom: 1px solid var(--color-border); }
.table th {
  text-align: left; padding: 12px 20px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-tertiary);
  font-family: 'IBM Plex Mono', monospace;
}
.table td { padding: 14px 20px; border-bottom: 1px solid var(--color-border-subtle); color: var(--color-text-secondary); }
.table tbody tr { transition: background var(--duration-fast) ease; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── KPI Cards ── */
.kpi-card { padding: 24px; cursor: default; }
.kpi-card .kpi-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: grid; place-items: center;
}
.kpi-card .kpi-value {
  font-size: 32px; font-weight: 800; line-height: 1; letter-spacing: -0.03em;
  color: var(--color-text-primary); margin: 16px 0 4px; font-variant-numeric: tabular-nums;
}
.kpi-card .kpi-label { font-size: 13px; color: var(--color-text-tertiary); }

/* ── Toast ── */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  padding: 14px 24px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-xl);
  transform: translateY(-12px); opacity: 0;
  transition: all 0.3s var(--ease-out); pointer-events: none;
  display: flex; align-items: center; gap: 10px;
}
.toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.toast.ok { background: var(--color-bg-raised); border: 1px solid rgba(0,232,123,0.20); color: var(--color-primary); }
.toast.err { background: var(--color-bg-raised); border: 1px solid rgba(239,68,68,0.20); color: var(--color-danger); }

/* ── Dividers ── */
.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--color-border-strong), transparent); margin: 24px 0; }

/* ── Empty states ── */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 24px; text-align: center; }
.empty-state-icon {
  width: 56px; height: 56px; border-radius: var(--radius-lg);
  background: var(--color-bg-surface); border: 1px solid var(--color-border);
  display: grid; place-items: center;
}
.empty-state-icon svg { width: 24px; height: 24px; color: var(--color-text-tertiary); }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--color-text-secondary); }
.empty-state-desc { font-size: 13px; color: var(--color-text-tertiary); max-width: 320px; }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(3,3,3,0.80);
  backdrop-filter: blur(8px); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--color-bg-raised); border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
  padding: 32px; max-width: 520px; width: 90%;
  transform: translateY(10px) scale(0.98); transition: transform 0.25s var(--ease-out);
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.modal-desc { font-size: 14px; color: var(--color-text-secondary); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ── Auth page backgrounds ── */
.auth-blob { position: fixed; border-radius: 50%; filter: blur(120px); pointer-events: none; }
.auth-blob-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(0,232,123,0.08), transparent 70%);
  top: -200px; left: -100px;
}
.auth-blob-2 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(91,156,255,0.05), transparent 70%);
  bottom: -100px; right: -80px;
}
.auth-blob-3 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(0,232,123,0.04), transparent 70%);
  top: 40%; left: 60%;
}
.auth-grid {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.35;
  background-image: radial-gradient(circle, rgba(255,255,255,0.08) 0.5px, transparent 0.5px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, black 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, black 0%, transparent 70%);
}
.auth-spotlight {
  position: fixed; top: -15%; left: 50%; transform: translateX(-50%);
  width: 800px; height: 400px;
  background: radial-gradient(ellipse at 50% 0%, rgba(0,232,123,0.05) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Autofill ── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--color-bg-deepest) inset;
  -webkit-text-fill-color: var(--color-text-primary);
  caret-color: var(--color-text-primary);
}

/* ── Status ── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot-online { background: var(--color-primary); box-shadow: 0 0 6px rgba(0,232,123,0.5); }
.status-dot-offline { background: var(--color-text-muted); }

/* ── Progress ── */
.progress { height: 4px; background: var(--color-bg-surface); border-radius: 2px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 2px; background: var(--color-primary); transition: width 0.8s var(--ease-out); }

/* ── Animations ── */
@keyframes fade-up { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:none} }
@keyframes fade-in { from{opacity:0} to{opacity:1} }
.animate-in { animation: fade-up 0.5s var(--ease-out) both; }
.delay-1{animation-delay:.05s} .delay-2{animation-delay:.10s}
.delay-3{animation-delay:.15s} .delay-4{animation-delay:.20s}

.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-100%); transition: transform 0.3s var(--ease-out); }
  .sidebar.open { transform: translateX(0); width: 280px; }
  .page-header { padding: 14px 20px; }
}

/* ── Utilities ── */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
