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

:root {
  --bg: #0f172a;
  --bg-elevated: #020617;
  --bg-card: #020617;
  --bg-card-soft: #02081f;
  --border-subtle: rgba(148, 163, 184, 0.28);
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --accent-strong: rgba(59, 130, 246, 0.9);
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #f97373;
  --warning: #facc15;
  --success: #22c55e;
  --radius-lg: 18px;
  --radius-full: 999px;
  --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.8);
  --shadow-subtle: 0 10px 30px rgba(15, 23, 42, 0.6);
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #1d283a 0, #020617 42%, #020617 100%);
}

body {
  display: flex;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: 100%;
  max-width: 1320px;
  margin: 24px auto;
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.98));
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

/* Sidebar */

.sidebar {
  background: radial-gradient(circle at top, #020617 0, #020617 45%, #020617 100%);
  border-right: 1px solid rgba(31, 41, 55, 0.9);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 64, 175, 0.6));
  border: 1px solid rgba(59, 130, 246, 0.6);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.9);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 0, #60a5fa, #1d4ed8);
  color: white;
  font-weight: 650;
  font-size: 14px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 14px;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.nav-item {
  appearance: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.7);
}

.nav-item:hover {
  background: rgba(15, 23, 42, 0.85);
  color: var(--text);
  transform: translateY(-1px);
}

.nav-item.active {
  background: radial-gradient(circle at top left, #1e293b, #020617);
  color: var(--text);
  box-shadow: var(--shadow-subtle);
}

.nav-item.active .nav-dot {
  background: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  border-radius: 16px;
  background: radial-gradient(circle at top left, rgba(30, 64, 175, 0.26), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(37, 99, 235, 0.6);
}

.footer-label {
  font-size: 11px;
  color: var(--text-muted);
}

.footer-chip {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
}

/* Main */

.main {
  padding: 18px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.main-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.main-header h1 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 520px;
}

.header-metrics {
  display: flex;
  gap: 12px;
}

.metric {
  padding: 8px 10px;
  border-radius: 14px;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 1), rgba(15, 23, 42, 0.95));
  border: 1px solid var(--border-subtle);
  min-width: 120px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.metric-value {
  font-size: 14px;
  font-weight: 600;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(34, 197, 94, 0.16);
  color: var(--success);
}

/* Views */

.views {
  flex: 1;
  display: flex;
}

.view {
  display: none;
  width: 100%;
}

.view-active {
  display: block;
}

.card {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 1));
  border-radius: var(--radius-lg);
  padding: 14px 16px 14px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-subtle);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

.card-subtitle {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 12px;
}

.field-group {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 14px;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 1), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(31, 41, 55, 0.9);
}

.field-group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
}

.field-group-caption {
  font-size: 11px;
  color: var(--text-muted);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 11px;
  color: var(--text-muted);
}

.field input,
.field select {
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  padding: 6px 10px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field input:focus,
.field select:focus {
  border-color: rgba(59, 130, 246, 0.9);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.8);
  background: rgba(15, 23, 42, 1);
}

.field input[type="range"] {
  padding: 0;
  background: transparent;
  border-radius: 999px;
}

.range-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.range-label span:nth-child(2) {
  color: var(--accent);
}

/* Buttons */

.actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.primary-btn,
.ghost-btn {
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease,
    color 0.15s ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-strong), #60a5fa);
  color: white;
  font-weight: 500;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.7);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 36px rgba(37, 99, 235, 0.8);
}

.ghost-btn {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
  border: 1px solid rgba(55, 65, 81, 0.9);
}

.ghost-btn:hover {
  background: rgba(15, 23, 42, 1);
  color: var(--text);
}

/* Divider */

.divider {
  height: 1px;
  margin: 10px 0;
  background: linear-gradient(to right, transparent, rgba(148, 163, 184, 0.3), transparent);
}

/* Results */

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.result-item {
  padding: 8px 9px;
  border-radius: 12px;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 1), rgba(15, 23, 42, 0.97));
  border: 1px solid rgba(31, 41, 55, 0.9);
}

.result-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.result-value {
  font-size: 14px;
  font-weight: 600;
}

.result-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Insights */

.insights {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(75, 85, 99, 0.8);
}

.insights-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  color: var(--text-muted);
}

.chip-ai {
  border-color: rgba(56, 189, 248, 0.8);
  color: #67e8f9;
}

.insights-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.insights-list li {
  font-size: 12px;
  color: var(--text-muted);
}

/* Dashboard placeholder chart */

.placeholder-chart {
  margin-top: 12px;
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 120px;
  padding: 8px 6px 4px;
  border-radius: 12px;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 1), rgba(15, 23, 42, 0.96));
  border: 1px dashed rgba(75, 85, 99, 0.9);
}

.placeholder-bar {
  flex: 1;
  border-radius: 999px;
  background: linear-gradient(to top, rgba(59, 130, 246, 0.6), rgba(56, 189, 248, 0.8));
}

.placeholder-caption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Table */

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

.table th,
.table td {
  border-bottom: 1px solid rgba(55, 65, 81, 0.9);
  padding: 6px 8px;
  text-align: left;
}

.table th {
  font-weight: 500;
  color: var(--text-muted);
}

/* Alerts */

.alerts-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-item {
  padding: 7px 10px;
  border-radius: 12px;
  background: radial-gradient(circle at top left, rgba(30, 64, 175, 0.2), rgba(15, 23, 42, 1));
  border: 1px solid rgba(37, 99, 235, 0.7);
  font-size: 12px;
}

.alert-item strong {
  color: #bfdbfe;
}

.alerts-empty {
  font-size: 12px;
  color: var(--text-muted);
}

/* Risk color helpers */

.risk-pill-ok {
  background: rgba(34, 197, 94, 0.16);
  color: var(--success);
}

.risk-pill-warn {
  background: rgba(250, 204, 21, 0.12);
  color: var(--warning);
}

.risk-pill-high {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
}

/* Responsive */

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
    margin: 12px;
  }

  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .header-metrics {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .main-header {
    flex-direction: column;
  }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }
}
