:root {
  --bg: #f4f5f9;
  --panel: #ffffff;
  --panel-2: #f7f8fb;
  --border: #e6e8ee;
  --text: #171b26;
  --muted: #6b7280;
  --accent: #5468f2;
  --accent-hover: #4457df;
  --accent-soft: #edf0ff;
  --accent-2: #12a37c;
  --on-accent: #ffffff;
  --danger: #e0455a;
  --warn: #d9860a;
  --radius: 0.75rem;
  --shadow: 0 0.0625rem 0.125rem rgba(23, 27, 38, 0.04), 0 0.25rem 1rem rgba(23, 27, 38, 0.06);
  --shadow-sm: 0 0.0625rem 0.125rem rgba(23, 27, 38, 0.05);
  --shadow-lg: 0 0.5rem 1.875rem rgba(23, 27, 38, 0.08);
}

* { box-sizing: border-box; }

/* Any element toggled via the `hidden` attribute/DOM property must stay
   hidden even when its own class also sets `display` (e.g. flex/grid
   utility classes) - the UA stylesheet's `[hidden] { display: none }` is
   User-Agent origin, which always loses to a same-page author rule
   regardless of specificity, so without `!important` here a class like
   `.checkout-summary-row { display: flex }` silently overrides `hidden`
   and the element shows anyway. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Figtree", sans-serif;
  background:
    radial-gradient(45rem 26.25rem at 12% -8%, rgba(84, 104, 242, 0.07), transparent),
    radial-gradient(40rem 23.75rem at 100% 0%, rgba(18, 163, 124, 0.05), transparent),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 0.875rem;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}

/* ---------- Brand mark ---------- */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.4375rem;
  background: linear-gradient(135deg, var(--accent), #8b6cf2);
  color: #fff;
  font-weight: 800;
  font-size: 0.6875rem;
  letter-spacing: -0.02em;
  margin-right: 0.5rem;
  vertical-align: middle;
  box-shadow: 0 0.125rem 0.5rem rgba(84, 104, 242, 0.35);
  overflow: hidden;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand-mark.large {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1rem;
  font-size: 1.375rem;
  margin: 0 0 1rem;
}

/* ---------- App shell: fixed sidebar + main area ---------- */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 15.625rem;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 0.0625rem solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; font-weight: 800; letter-spacing: -0.02em; font-size: 0.9375rem; padding: 0 0.5rem 1.25rem; }

.main-area { flex: 1; min-width: 0; }

/* ---------- Sidebar user block ---------- */
.session-info { display: flex; flex-direction: column; gap: 0.625rem; padding: 0 0.5rem 1rem; margin-bottom: 0.75rem; border-bottom: 0.0625rem solid var(--border); }
.user-block { display: flex; align-items: center; gap: 0.625rem; }
.user-meta { min-width: 0; display: flex; flex-direction: column; gap: 0.1875rem; }
.user-name { font-size: 0.7812rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-info select { background: var(--panel-2); color: var(--text); border: 0.0625rem solid var(--border); border-radius: 0.4375rem; padding: 0.375rem 0.5rem; font-family: inherit; font-size: 0.7812rem; width: 100%; }

/* ---------- Avatars ---------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b6cf2);
  color: #fff;
  font-weight: 700;
  font-size: 0.7812rem;
  flex-shrink: 0;
}
.avatar-sm { width: 1.375rem; height: 1.375rem; font-size: 0.625rem; vertical-align: middle; margin-right: 0.25rem; }

/* ---------- Sidebar nav ---------- */
nav.tabs {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex: 1;
}
nav.tabs button {
  display: flex;
  align-items: center;
  gap: 0.5625rem;
  background: transparent;
  border: none;
  text-align: left;
  color: var(--muted);
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  border-radius: 0.5625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  transition: color 0.15s ease, background 0.15s ease;
}
nav.tabs button.active { color: var(--accent); background: var(--accent-soft); }
nav.tabs button:hover { color: var(--text); background: var(--panel-2); }

.sidebar-footer { margin-top: auto; padding-top: 1rem; }
.sidebar-promo {
  background: linear-gradient(160deg, var(--accent), #7c5cf0);
  border-radius: var(--radius);
  padding: 1rem;
  color: #fff;
}
.sidebar-promo strong { font-size: 0.8125rem; }
.sidebar-promo p { font-size: 0.75rem; opacity: 0.9; margin: 0.375rem 0 0.75rem; line-height: 1.4; }
.sidebar-promo .btn.secondary { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
.sidebar-promo .btn.secondary:hover { background: rgba(255, 255, 255, 0.26); }

/* ---------- Top greeting bar ---------- */
header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.375rem 2rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(244, 245, 249, 0.85);
  backdrop-filter: blur(0.625rem);
}
.greeting h1 { font-size: 1.375rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 0.25rem; }
.greeting p { margin: 0; font-size: 0.8125rem; }

.topbar-actions { display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap; }
.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel);
  border: 0.0625rem solid var(--border);
  border-radius: 62.4375rem;
  padding: 0.5rem 0.875rem;
  min-width: 15rem;
  box-shadow: var(--shadow-sm);
}
.search-box input { border: none; background: transparent; padding: 0; min-width: 7.5rem; box-shadow: none; }
.search-box input:focus { box-shadow: none; }
.search-icon { color: var(--muted); font-size: 0.875rem; }
.kbd { font-size: 0.6562rem; color: var(--muted); background: var(--panel-2); border: 0.0625rem solid var(--border); border-radius: 0.3125rem; padding: 0.125rem 0.3125rem; font-weight: 700; }
.quick-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

main { max-width: 68.75rem; margin: 0 auto; padding: 0.25rem 2rem 5rem; }

.view { display: none; }
.view.active { display: block; animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(0.25rem); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.1875rem 0.5625rem;
  border-radius: 62.4375rem;
  background: var(--panel-2);
  color: var(--muted);
  border: 0.0625rem solid var(--border);
}
.badge.admin { color: #7a4d00; background: #fdf1d9; border-color: #f6dea3; }
.badge.ok { color: #0d6b4f; background: #e4f7f0; border-color: #bfeadb; }
.badge.trial { color: #5a3ec8; background: #f0ecfe; border-color: #dcd2fb; }
.badge.warn { color: #92610a; background: #fdf0d9; border-color: #f6dba3; }
.badge.danger { color: #a2293b; background: #fce8ea; border-color: #f5c4cb; }
.badge.muted { color: var(--muted); background: var(--panel-2); border-color: var(--border); }

/* ---------- Cards ---------- */
.card {
  background: var(--panel);
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.375rem;
  margin-bottom: 1.125rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card h2 { margin: 0 0 0.875rem; font-size: 0.9375rem; font-weight: 700; letter-spacing: -0.015em; }
.card h3 { margin: 1.125rem 0 0.5rem; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }

/* ---------- Stat tiles ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; }
.stat {
  background: var(--panel-2);
  border: 0.0625rem solid var(--border);
  border-left: 0.1875rem solid var(--accent);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat:hover { transform: translateY(-0.0625rem); box-shadow: var(--shadow-sm); }
.stat .label { color: var(--muted); font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.stat .value { font-size: 1.4375rem; font-weight: 800; margin-top: 0.25rem; letter-spacing: -0.02em; }
.stat .value-id { font-size: 0.7812rem; font-weight: 600; font-family: ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; letter-spacing: 0; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
th, td { text-align: left; padding: 0.6875rem 0.625rem; border-bottom: 0.0625rem solid var(--border); }
th { color: var(--muted); font-weight: 700; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .05em; }
tr:hover td { background: var(--panel-2); }
td code { background: var(--accent-soft); color: var(--accent-hover); border-radius: 0.3125rem; padding: 0.1875rem 0.4375rem; font-size: 0.75rem; font-weight: 600; }

/* ---------- Forms ---------- */
form.inline { display: flex; gap: 0.625rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.3125rem; }
.field label { font-size: 0.7188rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
  background: var(--panel);
  border: 0.0625rem solid var(--border);
  color: var(--text);
  padding: 0.5625rem 0.6875rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  min-width: 8.75rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 0.1875rem var(--accent-soft);
}
textarea { min-height: 3.75rem; font-family: inherit; }

/* ---------- Buttons ---------- */
/* `a.btn` alongside `button.btn` - checkout.html/pricing.html both use
   .btn on anchors (e.g. "Sign In", "Buy Now") as well as <button>. */
button.btn, a.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5625rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 0.0625rem 0.125rem rgba(84, 104, 242, 0.15), 0 0.25rem 0.625rem rgba(84, 104, 242, 0.18);
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}
button.btn:hover, a.btn:hover { background: var(--accent-hover); box-shadow: 0 0.125rem 0.25rem rgba(84, 104, 242, 0.2), 0 0.375rem 0.875rem rgba(84, 104, 242, 0.24); }
button.btn:active, a.btn:active { transform: translateY(0.0625rem); }
button.btn.secondary, a.btn.secondary { background: var(--panel); border: 0.0625rem solid var(--border); color: var(--text); box-shadow: none; }
button.btn.secondary:hover, a.btn.secondary:hover { background: var(--panel-2); box-shadow: none; }
button.btn.danger, a.btn.danger { background: var(--danger); box-shadow: 0 0.25rem 0.625rem rgba(224, 69, 90, 0.2); }
button.btn.danger:hover, a.btn.danger:hover { background: #c73549; }
button.btn.small, a.btn.small { padding: 0.375rem 0.75rem; font-size: 0.75rem; }

/* ---------- Auth / login screen ---------- */
.auth-hero {
  text-align: center;
  max-width: 35rem;
  margin: 3.5rem auto 0.5rem;
  padding: 0 1.25rem;
}
.auth-hero h1 { font-size: 1.625rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
.auth-hero p { margin: 0; font-size: 0.875rem; }

.login-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
  gap: 1.25rem;
  max-width: 56.25rem;
  margin: 2rem auto 3.75rem;
  padding: 0 1.25rem;
}
.login-wrap .card { margin: 0; }
.auth-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-0.125rem); }
.auth-choice {
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.login-wrap-single {
  grid-template-columns: minmax(0, 26.25rem);
  justify-content: center;
}
.card-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.0625rem;
  margin-bottom: 0.75rem;
}

.checkout-plan-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 0.25rem;
  padding: 0.125rem 0.3125rem;
  margin-right: 0.375rem;
}

.muted { color: var(--muted); }
.error-msg { color: var(--danger); font-size: 0.8125rem; margin-top: 0.5rem; white-space: pre-wrap; }
.success-msg { color: var(--accent-2); font-size: 0.8125rem; margin-top: 0.5rem; }
.empty { color: var(--muted); font-style: italic; padding: 0.875rem 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: none; border-top: 0.0625rem solid var(--border); margin: 1rem 0; }

/* ---------- Donut chart ---------- */
.donut-row { display: flex; align-items: center; gap: 1.75rem; flex-wrap: wrap; padding: 0.375rem 0; }
.donut {
  width: 9.25rem;
  height: 9.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.donut::before {
  content: '';
  position: absolute;
  inset: 1.125rem;
  background: var(--panel);
  border-radius: 50%;
}
.donut-center { position: relative; z-index: 1; text-align: center; }
.donut-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.donut-sub { font-size: 0.6562rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.donut-legend { display: flex; flex-direction: column; gap: 0.625rem; }
.donut-legend-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; font-weight: 600; }
.donut-legend-item strong { margin-left: 0.25rem; }
.donut-legend-item .dot { width: 0.5625rem; height: 0.5625rem; border-radius: 50%; flex-shrink: 0; }

/* ---------- Segmented sub-tabs ---------- */
.subtabs {
  display: inline-flex;
  gap: 0.125rem;
  margin-bottom: 1.125rem;
  flex-wrap: wrap;
  background: var(--panel-2);
  border: 0.0625rem solid var(--border);
  border-radius: 0.625rem;
  padding: 0.1875rem;
}
.subtabs button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.4375rem 0.875rem;
  border-radius: 0.4375rem;
  font-size: 0.7812rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.subtabs button:hover { color: var(--text); }
.subtabs button.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ---------- Responsive ---------- */
@media (max-width: 53.75rem) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-brand { padding: 0 0.5rem 0 0; }
  .session-info { flex-direction: row; align-items: center; padding: 0 0.5rem; margin: 0; border: none; }
  nav.tabs { flex-direction: row; flex: none; }
  .sidebar-footer { display: none; }
  main { padding: 0.25rem 1rem 3.75rem; }
  header.topbar { padding: 1rem; }
}
