:root {
  --bg: #f9fafb;
  --bg-subtle: #f3f4f6;
  --bg-elev: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-deep: #4338ca;
  --primary-soft: #e0e7ff;
  --accent: #14b8a6;
  --accent-soft: #ccfbf1;
  --danger: #f87171;
  --danger-soft: #fee2e2;
  --stroke: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius-sm: 10px;
  --radius-md: 14px;
  --transition: 200ms ease;
  --max-width: 1100px;
  --font-body: "Inter", "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-subtle) 100%);
  min-height: 100vh;
  line-height: 1.6;
}

h1,
h2,
h3 {
  font-weight: 700;
  letter-spacing: -0.015em;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
.button:focus-visible,
.nav-link:focus-visible,
.text-link:focus-visible,
.button-link:focus-visible {
  outline: 2px solid rgba(79, 70, 229, 0.6);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--stroke);
  background: rgba(249, 250, 251, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-inner {
  width: min(100% - 48px, var(--max-width));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-deep);
}

.nav-links {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all var(--transition);
}

.nav-link:hover {
  background: var(--primary-soft);
  border-color: rgba(79, 70, 229, 0.25);
  transform: translateY(-1px);
}

.button-link {
  border: none;
  background: transparent;
  cursor: pointer;
}

.button_to {
  display: inline;
  margin: 0;
}

.button_to button {
  font: inherit;
}

.main-content {
  width: min(100% - 48px, var(--max-width));
  margin: 0 auto;
  padding: 32px 0 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 32px;
  align-items: center;
}

.hero h1 {
  font-size: clamp(2rem, 2.6vw, 2.8rem);
  line-height: 1.15;
  margin: 0 0 12px;
}

.hero-card,
.card,
.stat-card,
.highlight-card {
  background: var(--bg-elev);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 500;
}

.input {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--bg-elev);
  font-size: 1rem;
  color: var(--ink);
  transition: border var(--transition), box-shadow var(--transition);
}

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

.input:focus-visible {
  outline: none;
  border-color: rgba(79, 70, 229, 0.5);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}

select.input {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

select.input option {
  background: var(--bg-elev);
  color: var(--ink);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
  gap: 6px;
}

.button.primary {
  background: var(--primary);
  color: #fff;
  border-color: rgba(79, 70, 229, 0.7);
  box-shadow: var(--shadow-sm);
}

.button.primary:hover {
  background: var(--primary-deep);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.button.ghost {
  background: var(--bg-elev);
  border-color: var(--stroke);
  color: var(--ink);
}

.button.ghost:hover {
  border-color: rgba(79, 70, 229, 0.5);
  color: var(--primary-deep);
  transform: translateY(-1px);
}

.helper {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.highlights {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.highlight-card h3 {
  margin-top: 0;
}

.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.billing-card {
  background: linear-gradient(135deg, rgba(224, 231, 255, 0.55), rgba(204, 251, 241, 0.45));
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.billing-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.billing-meter {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meter {
  height: 10px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 100%);
  transition: width var(--transition);
}

.billing-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 600;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-label {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2rem;
  margin: 0;
}

.stat-sub {
  color: var(--muted);
  margin: 6px 0 0;
}

.dashboard-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.card-header {
  margin-bottom: 16px;
}

.progress-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-height: 180px;
}

.progress-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.progress-bar .bar {
  width: 100%;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
  transition: height var(--transition);
}

.pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  background: var(--primary-soft);
  color: var(--primary-deep);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--stroke);
}

.text-link {
  font-weight: 600;
  color: var(--primary-deep);
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.flash-notice {
  background: var(--accent-soft);
  color: #0f766e;
}

.flash-alert {
  background: var(--danger-soft);
  color: #b91c1c;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: "SFMono-Regular", "Menlo", monospace;
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--stroke);
  overflow-x: auto;
}

/* Utility components for future UI additions */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--stroke);
  border-radius: var(--radius-md);
  transition: background var(--transition);
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}

.toggle.is-on {
  background: rgba(79, 70, 229, 0.45);
}

.toggle.is-on::after {
  transform: translateX(20px);
}

.slider {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-md);
  background: var(--stroke);
  position: relative;
  overflow: hidden;
}

.slider::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: var(--primary);
  border-radius: inherit;
  transition: width var(--transition);
}

.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: help;
}

.tooltip .tooltip-content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.8rem;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.tooltip:hover .tooltip-content,
.tooltip:focus-within .tooltip-content {
  opacity: 1;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
}

.toast.success {
  border-color: rgba(20, 184, 166, 0.35);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.4);
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--stroke);
  border-radius: var(--radius-sm);
  min-height: 14px;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.6s infinite;
}

.status-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-weight: 600;
}

.status-check::before {
  content: "OK";
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 0.6rem;
  letter-spacing: 0.02em;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-subtle: #111827;
    --bg-elev: #111827;
    --ink: #f8fafc;
    --muted: #94a3b8;
    --primary: #818cf8;
    --primary-deep: #a5b4fc;
    --primary-soft: rgba(129, 140, 248, 0.18);
    --accent: #2dd4bf;
    --accent-soft: rgba(45, 212, 191, 0.2);
    --danger: #fda4af;
    --danger-soft: rgba(253, 164, 175, 0.18);
    --stroke: rgba(148, 163, 184, 0.25);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.4);
    --shadow-md: 0 10px 26px rgba(15, 23, 42, 0.5);
  }

  .top-nav {
    background: rgba(15, 23, 42, 0.85);
  }

  .tooltip .tooltip-content {
    background: #0b1220;
  }

  .skeleton {
    background: rgba(148, 163, 184, 0.2);
  }
}

@media (max-width: 720px) {
  .top-nav {
    padding: 16px 0;
  }

  .nav-inner {
    width: min(100% - 32px, var(--max-width));
  }

  .main-content {
    width: min(100% - 32px, var(--max-width));
    padding: 24px 0 48px;
  }

  .nav-links {
    gap: 8px;
  }

  .progress-bars {
    min-height: 140px;
  }
}
