:root {
  --bg: #070b14;
  --bg-sidebar: #0a0f1a;
  --surface: #0f1629;
  --surface-2: #141d33;
  --surface-hover: #1a2540;
  --border: rgba(148, 163, 184, 0.1);
  --border-strong: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --danger: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --purple: #a855f7;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.35);
  --sidebar-w: 268px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-lg {
  width: 28px;
  height: 28px;
}

.icon-xl {
  width: 40px;
  height: 40px;
}

.icon-spin {
  animation: spin 1s linear infinite;
  color: var(--primary-light);
}

.hidden {
  display: none !important;
}

/* ── Login ── */
.login-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99, 102, 241, 0.22), transparent),
    radial-gradient(ellipse 50% 40% at 100% 50%, rgba(168, 85, 247, 0.1), transparent),
    var(--bg);
}

.login-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.6;
}

.login-card {
  position: relative;
  width: min(100%, 420px);
  padding: 36px;
  background: rgba(15, 22, 41, 0.85);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.login-brand {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 8px;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.brand-logo-sm {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

/* ── Layout ── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 10px 24px;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-brand span {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.nav-section {
  display: block;
  padding: 0 12px 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.25);
  color: var(--primary-light);
}

.nav-item.active .icon {
  color: var(--primary-light);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.status-chip.ok {
  color: var(--success);
  background: var(--success-bg);
  border-color: rgba(16, 185, 129, 0.2);
}

.status-chip.bad {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(244, 63, 94, 0.2);
}

.status-chip.running {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.2);
}

.main {
  padding: 28px 32px 40px;
  background:
    radial-gradient(ellipse 70% 50% at 0% 0%, rgba(99, 102, 241, 0.06), transparent),
    var(--bg);
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.topbar h2 {
  margin: 0;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Views ── */
.view {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s, transform 0.2s;
}

.stat-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.stat-card-featured {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(15, 22, 41, 0.9));
  border-color: rgba(99, 102, 241, 0.22);
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
}

.stat-icon-blue {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
}

.stat-icon-purple {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
}

.stat-icon-green {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
}

.stat-icon-amber {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.stat-label {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-value {
  display: block;
  margin: 6px 0 4px;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Panels ── */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel-export-bar {
  margin-bottom: 16px;
}

.panel-export-bar .panel-header {
  border-bottom: none;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.panel-header-split {
  flex-wrap: wrap;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
}

.panel-title h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.panel-subtitle {
  margin: 6px 0 0 30px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.panel-body {
  padding: 20px 22px;
}

/* ── Forms ── */
.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-stack,
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form {
  margin-top: 28px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.input-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrap input {
  padding-left: 42px;
}

input,
select {
  width: 100%;
  padding: 11px 14px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.select-compact {
  width: auto;
  min-width: 200px;
}

.input-wrap-search input {
  padding-left: 40px;
  min-width: 260px;
}

.form-error {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--danger);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 24px var(--primary-glow);
}

.btn-ghost {
  color: var(--text-secondary);
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-hover);
}

.btn-danger {
  color: #fda4af;
  background: var(--danger-bg);
  border-color: rgba(244, 63, 94, 0.25);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

/* ── Info list ── */
.info-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child {
  border-bottom: 0;
}

.info-row span {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.info-row strong {
  font-size: 0.875rem;
  font-weight: 600;
  text-align: right;
}

.text-danger {
  color: var(--danger) !important;
}

.pill {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.pill.ok {
  color: var(--success);
  background: var(--success-bg);
  border-color: rgba(16, 185, 129, 0.25);
}

.pill.bad {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(244, 63, 94, 0.25);
}

.pill.running {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.25);
}

/* ── Table ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 12px 22px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.data-table tbody tr {
  transition: background 0.12s;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.col-actions {
  width: 120px;
  text-align: right;
}

.amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--primary-light);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.empty-cell,
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}

.page-info {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ── History ── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.history-item-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.history-item-icon.ok {
  background: var(--success-bg);
  color: var(--success);
}

.history-item-icon.bad {
  background: var(--danger-bg);
  color: var(--danger);
}

.history-item-body strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.875rem;
}

.history-item-body span {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Toast & Loading ── */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: slideUp 0.25s ease;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.35);
}

.toast.error {
  border-color: rgba(244, 63, 94, 0.35);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(7, 11, 20, 0.72);
  backdrop-filter: blur(4px);
}

.loader-icon {
  width: 40px;
  height: 40px;
}

.loading-overlay p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav-section {
    width: 100%;
  }

  .sidebar-footer {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .panel-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1;
  }

  .panel-header-split,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .input-wrap-search input,
  .select-compact {
    width: 100%;
    min-width: 0;
  }

  .main {
    padding: 20px 16px 32px;
  }
}
