:root {
  --surface: #0f172a;
  --surface-soft: rgba(15, 23, 42, 0.72);
  --surface-strong: rgba(15, 23, 42, 0.92);
  --surface-border: rgba(148, 163, 184, 0.18);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #cbd5e1;
  --accent: #5eead4;
  --accent-strong: #0d9488;
  --accent-soft: rgba(14, 165, 233, 0.16);
  --shadow-lg: 0 36px 80px rgba(0, 0, 0, 0.24);
  --shadow-sm: 0 12px 28px rgba(0, 0, 0, 0.18);
  --radius: 28px;
  --radius-sm: 18px;
  --transition: 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
}
body {
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(14, 165, 233, 0.14), transparent 28%),
              radial-gradient(circle at bottom right, rgba(248, 113, 113, 0.10), transparent 22%),
              #0f172a;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at top, rgba(255,255,255,0.08), transparent 24%);
  opacity: 0.65;
  z-index: -1;
}
body.auth-passed {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.45s ease-out both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.stage-header {
  display: grid;
  grid-template-columns: minmax(220px, auto) 1fr minmax(220px, auto);
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: rgba(15, 23, 42, 0.80);
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.04), 0 24px 60px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(22px);
  position: sticky;
  top: 0;
  z-index: 99;
}
.stage-header > * {
  min-width: 0;
}
.stage-header .stage-title {
  display: grid;
  gap: 0.35rem;
}
.stage-header .title-main {
  font-family: 'Inter', 'Montserrat', sans-serif; font-weight: 900; letter-spacing: -0.5px;
  font-size: clamp(1.4rem, 2vw, 2.2rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.stage-header .title-subtitle {
  color: var(--text-secondary);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-weight: 700;
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.85rem;
}
.stage-actions .action-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.stage-actions .btn {
  min-height: 52px;
  min-width: 52px;
  padding: 0 18px;
  border-radius: 999px;
}
.stage-actions .btn-icon {
  width: 52px;
  min-width: 52px;
  padding: 0;
  border-radius: 18px;
}

.glass-panel {
  position: relative;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(150%);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  transform: translateZ(0);
}
.glass-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), transparent 58%);
  opacity: 0.8;
}
.glass-panel:hover {
  transform: translateY(-4px);
  box-shadow: 0 46px 100px rgba(0,0,0,0.24);
}
.glass-panel > * {
  position: relative;
  z-index: 1;
}

.panel-title {
  font-family: 'Inter', 'Montserrat', sans-serif; font-weight: 900; letter-spacing: -0.5px;
  font-size: clamp(1.2rem, 1.4vw, 1.6rem);
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-weight: 900;
}
.panel-title + * {
  margin-top: 0.5rem;
}
.panel-title .panel-icon {
  color: var(--accent);
  margin-right: 0.55rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.28s var(--transition), box-shadow 0.28s ease, background 0.28s ease;
  will-change: transform, box-shadow;
  touch-action: manipulation;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(1px) scale(0.98);
}
.btn-primary {
  background: linear-gradient(135deg, #10b981, #0d9488);
  color: #fff;
  box-shadow: 0 18px 40px rgba(13, 148, 136, 0.22);
}
.btn-primary:hover {
  box-shadow: 0 22px 48px rgba(13, 148, 136, 0.28);
}
.btn-outline {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
.btn-outline:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.24);
}
.btn-danger {
  background: #dc2626;
  color: white;
  box-shadow: 0 14px 35px rgba(220, 38, 38, 0.22);
}
.btn .icon {
  margin-right: 0.65rem;
}

.input-dark,
.input-elegant {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.82);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.input-dark:focus,
.input-elegant:focus {
  border-color: rgba(14, 165, 233, 0.9);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18);
  background: rgba(15, 23, 42, 0.95);
}
.input-dark::placeholder,
.input-elegant::placeholder {
  color: rgba(255,255,255,0.55);
}
select.input-elegant {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.32) 50%),
                    linear-gradient(135deg, rgba(255,255,255,0.32) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 14px) center;
  background-size: 10px 10px, 10px 10px;
  background-repeat: no-repeat;
}

.pipeline-step {
  display: grid;
  grid-auto-flow: column;
  gap: 0.85rem;
  overflow-x: auto;
  padding: 0.35rem 0.25rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.05);
}
.pipeline-step::-webkit-scrollbar {
  height: 6px;
}
.pipeline-step::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.16);
  border-radius: 999px;
}
.pipeline-step span {
  padding: 0.75rem 1rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-secondary);
  white-space: nowrap;
}
.pipeline-step span.active {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(14, 165, 233, 0.28);
  color: var(--accent);
}
.pipeline-step span.done {
  background: rgba(5, 150, 105, 0.14);
  border-color: rgba(16, 185, 129, 0.28);
  color: #a5f3fc;
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar {
  display: none;
}
.tab-btn {
  min-height: 58px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  text-align: center;
  transition: background 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}
.tab-btn:hover,
.tab-btn:focus {
  background: rgba(255,255,255,0.1);
}
.tab-btn.active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.18), rgba(16, 185, 129, 0.14));
  border-color: rgba(14, 165, 233, 0.35);
  color: #fff;
  box-shadow: 0 16px 32px rgba(0,0,0,0.15);
}

.kpi-grid,
.chart-grid,
.form-grid {
  display: grid;
  gap: 1rem;
}
.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.chart-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.kpi-card {
  position: relative;
  overflow: hidden;
  min-height: 170px;
  padding: 1.4rem 1.6rem;
  display: grid;
  gap: 0.75rem;
}
.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.18), transparent 40%);
  opacity: 0.24;
}
.kpi-label {
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.72);
}
.kpi-value {
  font-size: clamp(2rem, 3vw, 2.8rem);
  color: #fff;
  font-family: 'Inter', 'Montserrat', sans-serif; font-weight: 900; letter-spacing: -0.5px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: 24px;
  background: rgba(255,255,255,0.04);
  padding: 0.25rem;
}
table.data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text-primary);
}
table.data-table th,
table.data-table td {
  padding: 1rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
table.data-table th {
  color: var(--text-secondary);
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  text-transform: uppercase;
  background: rgba(255,255,255,0.03);
}
table.data-table tr:hover {
  background: rgba(255,255,255,0.06);
}
.table-responsive td:first-child {
  min-width: 180px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.badge-green {
  background: rgba(16, 185, 129, 0.16);
  color: #84ffda;
  border: 1px solid rgba(16, 185, 129, 0.24);
}
.badge-red {
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.24);
}
.badge-amber {
  background: rgba(245, 158, 11, 0.16);
  color: #ffe8a0;
  border: 1px solid rgba(245, 158, 11, 0.24);
}
.badge-blue {
  background: rgba(59, 130, 246, 0.16);
  color: #bfdbfe;
  border: 1px solid rgba(59, 130, 246, 0.24);
}
.badge-orange {
  background: rgba(249, 115, 22, 0.16);
  color: #fed7aa;
  border: 1px solid rgba(249, 115, 22, 0.24);
}

#toast-container {
  position: fixed;
  inset: auto 1rem 1rem auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  z-index: 9999;
  pointer-events: none;
}
.premium-toast {
  min-width: 300px;
  max-width: 380px;
  padding: 1rem 1.2rem;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.25);
  color: var(--text-primary);
  backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.premium-toast.error {
  border-color: rgba(248, 113, 113, 0.5);
}
.premium-toast.warning {
  border-color: rgba(250, 204, 21, 0.3);
}
@keyframes slideInRight {
  from { transform: translateX(100%) scale(0.98); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

@media (max-width: 960px) {
  .stage-header {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    text-align: center;
    justify-items: center;
  }
  .stage-actions {
    justify-content: center;
  }
  .kpi-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 680px) {
  .tab-bar {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
  .btn,
  .tab-btn,
  .input-dark,
  .input-elegant {
    min-height: 48px;
    border-radius: 16px;
  }
  .panel-title {
    font-size: 1.2rem;
  }
}
@media print {
  body { background: #fff; color: #000; }
  body * { visibility: hidden !important; }
  .print-section,
  .print-section * { visibility: visible !important; }
  .print-section { position: absolute; inset: 0; background: #fff; color: #000; }
  .glass-panel { box-shadow: none; border: none; background: #fff; }
  .badge { border: 1px solid #000; background: transparent; color: #000; }
  .stage-header,
  .tab-bar,
  .btn,
  .dropdown-menu,
  .no-print { display: none !important; }
}