:root {
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --border: #dce3ee;
  --text: #0f172a;
  --text-soft: #475569;
  --primary: #2f6df6;
  --primary-strong: #1d4ed8;
  --success-bg: #e8f8ef;
  --success-fg: #166534;
  --danger-bg: #feecec;
  --danger-fg: #9f1239;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

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

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #e6eeff 0%, var(--bg) 35%, var(--bg) 100%);
  line-height: 1.5;
}

a {
  color: var(--primary-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.65rem;
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6 50%, #7c3aed);
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.topbar-nav a {
  padding: 0.45rem 0.8rem;
  border-radius: 0.6rem;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.94rem;
  transition: all 120ms ease-in-out;
}

.topbar-nav a.active,
.topbar-nav a:hover {
  text-decoration: none;
  color: var(--primary-strong);
  background: #e8eeff;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.user-pill {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.82rem;
  font-weight: 600;
}

.page-content {
  width: min(1100px, calc(100% - 2rem));
  margin: 1.5rem auto 2.25rem;
}

.page-content.narrow {
  width: min(520px, calc(100% - 2rem));
  margin-top: 4rem;
}

h1,
h2,
h3 {
  margin: 0 0 0.9rem;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.4rem, 1.2rem + 0.9vw, 2rem);
}

.page-subtitle {
  margin-top: -0.2rem;
  color: var(--text-soft);
}

.card {
  padding: 1.2rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stack {
  display: grid;
  gap: 1rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.metric-label {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  margin: 0.2rem 0 0;
  font-size: 1.8rem;
  font-weight: 800;
}

.metric-footnote {
  margin: 0.45rem 0 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.dashboard-metrics .metric-card {
  position: relative;
  overflow: hidden;
}

.dashboard-metrics .metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: 0.95rem 0 0 0.95rem;
  background: #cbd5e1;
}

.dashboard-metrics .metric-primary::before {
  background: #3b82f6;
}

.dashboard-metrics .metric-success::before {
  background: #10b981;
}

.dashboard-metrics .metric-warning::before {
  background: #f59e0b;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.dashboard-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}

.dashboard-card-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.muted-copy {
  margin: 0;
  color: var(--text-soft);
}

.insight-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.insight-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--surface-muted);
}

.insight-list span {
  display: grid;
}

.insight-list small {
  color: var(--text-soft);
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #92400e;
  background: #fef3c7;
}

.status-pill-paid {
  color: #166534;
  background: #dcfce7;
}

form {
  display: grid;
  gap: 0.75rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

input[type="email"],
input[type="password"],
input[type="search"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.inline-form input[type="search"] {
  width: min(430px, 100%);
}

button,
input[type="submit"],
.btn {
  display: inline-block;
  padding: 0.6rem 0.95rem;
  border: 0;
  border-radius: 0.65rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease-in-out;
}

button:hover,
input[type="submit"]:hover,
.btn:hover {
  text-decoration: none;
  background: var(--primary-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
}

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

.data-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
}

.data-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: var(--surface);
}

.data-table th,
.data-table td {
  padding: 0.78rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table tbody tr:hover {
  background: #f8faff;
}

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

.flash {
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
}

.flash-notice {
  background: var(--success-bg);
  border-color: #bbf7d0;
  color: var(--success-fg);
}

.flash-alert {
  background: var(--danger-bg);
  border-color: #fecdd3;
  color: var(--danger-fg);
}

.helper-links {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.2rem;
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .user-actions {
    justify-content: space-between;
  }

  .topbar-nav {
    justify-content: center;
  }

  .page-content {
    width: calc(100% - 1rem);
    margin-top: 1rem;
  }

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

  .dashboard-card-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
