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

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  transition: all 0.2s ease;
}

/* Base Topbar */
.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.brand b {
  color: var(--blue);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons and Interactivity */
.pill {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 99px;
  padding: 8px 14px;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.pill:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.icon-btn:hover {
  background: #f1f5f9;
}

.btn-blue {
  border: 0;
  background: var(--blue);
  color: #fff;
  border-radius: 99px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.btn-blue:hover {
  background: var(--blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* Layout */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 64px);
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.shell.sidebar-collapsed {
  grid-template-columns: 0 1fr;
}

.shell.sidebar-collapsed .sidebar {
  opacity: 0;
  pointer-events: none;
}

.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 16px;
  transition: opacity 0.2s ease;
}

.nav {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 4px;
  font-weight: 500;
  color: var(--muted);
}

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

.nav.active {
  background: #eff6ff;
  color: var(--blue);
  font-weight: 600;
}

.content {
  padding: 32px 40px;
}

.page {
  display: none;
  max-width: 1000px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

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

h1 {
  margin: 0 0 6px;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card + .card {
  margin-top: 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }

/* Forms */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}

.input, .select, .textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  font-size: 0.95rem;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

/* General Buttons */
.btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn.primary {
  border: 0;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.btn.primary:hover {
  background: var(--blue-hover);
  box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.small {
  font-size: 0.8rem;
  color: var(--muted);
}

/* KPIs */
.kpi {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 8px 0;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  border-bottom: 1px solid var(--line);
  padding: 14px 10px;
  text-align: left;
  font-size: 0.9rem;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

/* Status Tags */
.status {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 99px;
  font-weight: 700;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.st-done { background: #dcfce7; color: #166534; }
.st-run { background: #dbeafe; color: #1e40af; }
.st-queue { background: #fef3c7; color: #92400e; }
.st-err { background: #fee2e2; color: #991b1b; }

/* History Lists */
.hist {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.hist:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

/* Wizard */
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 24px 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 600;
  position: relative;
}

.bullet {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  background: #fff;
  transition: all 0.3s ease;
}

.step.active {
  color: var(--text);
}

.step.active .bullet, .step.done .bullet {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.mat {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mat:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.mat.selected {
  border-color: var(--blue);
  background: #eff6ff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.15);
}

.chip {
  font-size: 0.75rem;
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  border-radius: 99px;
  padding: 4px 10px;
  display: inline-block;
  margin-top: 10px;
}

/* Dropdown */
.dropdown {
  position: relative;
}

.menu {
  position: absolute;
  right: 0;
  top: 48px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 220px;
  display: none;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu.show {
  display: block;
}

.menu button {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  font-weight: 500;
}

.menu button:hover {
  background: #f1f5f9;
  color: var(--blue);
}

/* Toast */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #0f172a;
  color: #fff;
  padding: 14px 20px;
  border-radius: 10px;
  display: none;
  z-index: 60;
  font-weight: 500;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

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

/* Credits / Checkout */
.credits-summary {
  display: flex;
  align-items: center;
  gap: 16px;
}

.credits-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1d4ed8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.5);
}

.pkg-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.pkg-card {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  transition: all 0.3s ease;
}

.pkg-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.pkg-card.best {
  border-color: #2563eb;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.15);
}

.pkg-badge {
  position: absolute;
  right: 16px;
  top: -12px;
  background: #2563eb;
  color: #fff;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.pkg-name {
  font-weight: 800;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--text);
}

.pkg-price {
  margin-top: 14px;
  color: #2563eb;
  font-weight: 800;
  font-size: 1.8rem;
  line-height: 1;
}

.pkg-foot {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.pay-card {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pay-chip {
  font-size: 0.75rem;
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  padding: 4px 10px;
  font-weight: 600;
}

/* Mobile */
.sidebar-overlay {
  display: none;
}

.mobile-nav {
  display: none;
}

@media (max-width: 960px) {
  .topbar { padding: 0 16px; height: 60px; }
  .top-actions { gap: 8px; }
  .pill { padding: 8px 12px; }
  #topBalancePill { display: none; }
  #buyTopBtn { padding: 8px 14px; }
  
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    height: calc(100vh - 60px);
    width: 260px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }
  
  .content { padding: 20px 16px 90px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .pkg-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
  
  .sidebar-overlay.show {
    display: block;
    position: fixed;
    inset: 60px 0 0 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 49;
    animation: fadeIn 0.2s ease;
  }
  
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    z-index: 55;
    box-shadow: 0 -4px 10px -5px rgba(0,0,0,0.05);
  }
  
  .mnav {
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.1;
  }
  
  .mnav .ico { font-size: 1.3rem; }
  .mnav.active { color: var(--blue); }
}
