@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-soft: #f2f4fb;
  --surface-2: #eef1fa;
  --line: #e5e8f2;
  --line-2: #edeffe;
  --text: #0f1733;
  --text-2: #2a3458;
  --muted: #6a7497;
  --muted-2: #8590b4;
  --accent: #4d3af8;
  --accent-2: #6f5dff;
  --accent-soft: #ece9ff;
  --success: #18a05f;
  --success-soft: #e3f6ec;
  --warning: #f59f0a;
  --warning-soft: #fef2dc;
  --danger: #e14d5f;
  --danger-soft: #fce6e9;
  --shadow: 0 4px 12px rgba(18, 28, 72, 0.06), 0 1px 3px rgba(18, 28, 72, 0.04);
  --shadow-md: 0 12px 32px rgba(18, 28, 72, 0.09);
  --shadow-accent: 0 10px 24px rgba(77, 58, 248, 0.28);
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 480px at 100% -5%, rgba(77, 58, 248, 0.10), transparent 58%),
    linear-gradient(180deg, #fafbff 0%, var(--bg) 100%);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
svg { flex-shrink: 0; }

/* ── Shell ──────────────────────────────────────────────────────────── */
.dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

/* ── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 12px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  overflow: hidden;
}

.brand {
  display: block;
  padding: 2px 4px 6px;
  flex-shrink: 0;
}

.brand img {
  display: block;
  width: 180px;
  max-width: 100%;
}

/* Nav with sections & icons */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.nav-section {
  margin: 10px 0 4px 10px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
  flex-shrink: 0;
}

.nav-section:first-of-type {
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
}

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

.nav-item:hover .nav-icon { color: var(--accent); }

.nav-item.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.nav-item.active .nav-icon { color: #fff; }

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--muted-2);
  transition: color 0.15s var(--ease);
}

.nav-icon svg {
  width: 15px;
  height: 15px;
}

/* Sidebar footer note */
.sidebar-note {
  flex-shrink: 0;
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, #fff 0%, #f4f6ff 100%);
}

.sidebar-note strong {
  font-size: 12.5px;
  color: var(--text-2);
}

.sidebar-note span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

/* ── Workspace ──────────────────────────────────────────────────────── */
.workspace {
  padding: 24px 26px;
  display: grid;
  gap: 16px;
  align-content: start;
}

/* ── Hero header ────────────────────────────────────────────────────── */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 4px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(22px, 2.8vw, 32px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.meta-line span:not(:empty) {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
  font-weight: 600;
}

.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.primary,
.ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s var(--ease-spring), box-shadow 0.18s var(--ease), background 0.15s var(--ease);
  line-height: 1;
  white-space: nowrap;
}

.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-accent);
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(77, 58, 248, 0.36);
}

.primary:active { transform: translateY(0); }

.ghost {
  color: var(--text-2);
  border-color: var(--line);
  background: #fff;
}

.ghost:hover {
  background: var(--surface-soft);
  border-color: #d0d6ec;
  transform: translateY(-1px);
}

.ghost:active { transform: translateY(0); }

/* ── Card ───────────────────────────────────────────────────────────── */
.card,
.auth-state,
.error-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

/* ── State panels ───────────────────────────────────────────────────── */
.auth-state,
.error-state {
  padding: 36px 28px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.state-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
}

.auth-state .state-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.error-state .state-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.auth-state h2,
.error-state h2 {
  font-size: 18px;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.auth-state p,
.error-state p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 20px;
  max-width: 440px;
}

.state-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Filters ────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 14px 16px;
}

.filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.filters input,
.filters select {
  min-width: 138px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.filters input:focus,
.filters select:focus {
  outline: none;
  border-color: #b0b8f0;
  box-shadow: 0 0 0 3px rgba(77, 58, 248, 0.12);
}

/* ── Skeleton loaders ───────────────────────────────────────────────── */
.loading-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.skeleton {
  min-height: 120px;
  border-radius: var(--radius);
  background: linear-gradient(105deg, #edf1f9 8%, #f6f9ff 20%, #edf1f9 36%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease infinite;
}

@keyframes shimmer {
  to { background-position-x: -200%; }
}

/* ── Setup card ─────────────────────────────────────────────────────── */
.setup {
  padding: 20px;
}

.setup-head,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.setup-head h2,
.section-head h2 {
  font-size: 17px;
  letter-spacing: -0.01em;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.5s var(--ease);
}

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

.setup-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  display: grid;
  gap: 6px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.setup-item:hover {
  border-color: #cdd4f0;
  box-shadow: var(--shadow);
}

.setup-item strong { font-size: 13px; color: var(--text); }
.setup-item a { color: var(--accent); font-weight: 800; font-size: 12px; }
.status-done { color: var(--success); }
.status-not_done { color: var(--warning); }

/* ── KPI cards ──────────────────────────────────────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  padding: 18px 16px 16px;
  display: grid;
  gap: 6px;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease);
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.kpi strong {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}

.kpi em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.kpi.good em { color: var(--success); }
.kpi.bad em { color: var(--danger); }
.kpi.neutral em { color: var(--muted); }

/* ── Grid layout ────────────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 12px;
}

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

.wide {
  grid-column: 1 / -1;
}

.grid .card {
  min-width: 0;
  padding: 20px;
}

/* ── Section head ───────────────────────────────────────────────────── */
.section-head {
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ── Mini table ─────────────────────────────────────────────────────── */
.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.mini-table th,
.mini-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-2);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

.mini-table th {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mini-table tr:last-child td { border-bottom: 0; }

.mini-table tr:hover td { background: var(--surface-soft); }

/* ── Empty state ────────────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 0;
}

.empty-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted-2);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.empty-icon svg {
  width: 18px;
  height: 18px;
}

.empty strong {
  font-size: 14px;
  color: var(--text-2);
}

.empty span,
.empty p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ── Funnel ─────────────────────────────────────────────────────────── */
.funnel {
  display: grid;
  gap: 6px;
}

.funnel a {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-soft);
  transition: background 0.15s var(--ease), transform 0.18s var(--ease-spring);
  font-size: 13px;
  font-weight: 600;
}

.funnel a:hover {
  background: var(--line-2);
  transform: translateX(2px);
}

/* ── Chart ──────────────────────────────────────────────────────────── */
.chart {
  min-height: 200px;
}

.chart svg {
  width: 100%;
  height: 200px;
  display: block;
}

/* ── List items ─────────────────────────────────────────────────────── */
.list {
  display: grid;
  gap: 8px;
}

.list-item {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-soft);
  transition: background 0.15s var(--ease);
}

.list-item:hover { background: var(--line-2); }

.list-item strong,
.list-item span {
  display: block;
}

.list-item strong {
  font-size: 13.5px;
  color: var(--text);
}

.list-item span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.4;
}

/* ── Status pills ───────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}

.pill.success { background: var(--success-soft); color: var(--success); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .dashboard-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; overflow: visible; }
  .sidebar-nav { overflow: visible; max-height: none; }
  .setup-list,
  .kpis,
  .grid.two,
  .loading-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .workspace { padding: 14px 16px; }
  .hero { flex-direction: column; }
  .hero-actions { width: 100%; }
  .setup-list,
  .kpis,
  .grid.two,
  .loading-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .kpi strong { font-size: 24px; }
}
