/* ==========================================================================
   Flow AI Credit Checker · v4.0.0
   Design tokens, landing page and dashboard styles.
   ========================================================================== */

@font-face {
  font-family: "Geist";
  src: url("./fonts/geist-variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Thai";
  src: url("./fonts/noto-sans-thai-variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f5f7fc;
  --bg-soft: #eef2fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0b1220;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e3e8f3;
  --line-strong: #cbd5e1;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-3: #06b6d4;
  --brand-soft: #eef2ff;
  --ok: #0f9f6e;
  --ok-soft: #e7f8f1;
  --warn: #d97706;
  --warn-soft: #fef4e6;
  --danger: #dc2626;
  --danger-soft: #feecec;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 12px 32px -12px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 32px 80px -32px rgba(49, 46, 129, 0.35), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
  --font: "Geist", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --max: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.4);
  outline-offset: 2px;
  border-radius: 6px;
}

.container { width: min(100% - 40px, var(--max)); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn.is-disabled { opacity: 0.55; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(79, 70, 229, 0.7);
}
.btn-primary:hover { box-shadow: 0 14px 30px -10px rgba(79, 70, 229, 0.8); }

.btn-google {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn-google:hover { background: #fbfcff; border-color: var(--brand); }
.btn-google svg { width: 19px; height: 19px; flex: none; }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--surface); border-color: var(--line-strong); }

.btn-soft {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #dfe4ff;
}
.btn-soft:hover { background: #e6ebff; }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f7d3d3;
}
.btn-danger:hover { background: #fde0e0; }

.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 10px; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; border-radius: 10px; }

.spinner {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Brand
   -------------------------------------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 10px; box-shadow: 0 4px 12px -4px rgba(79, 70, 229, 0.5); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 750; font-size: 15.5px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }

/* --------------------------------------------------------------------------
   Nav / footer
   -------------------------------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(245, 247, 252, 0.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(227, 232, 243, 0.9);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; height: 70px; }
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a { color: var(--muted); font-size: 14.5px; font-weight: 550; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-actions { display: flex; align-items: center; gap: 12px; }

.footer { border-top: 1px solid var(--line); margin-top: 72px; padding: 32px 0 40px; color: var(--muted); font-size: 14px; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 20px; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--ink); }

/* --------------------------------------------------------------------------
   Landing hero
   -------------------------------------------------------------------------- */
.hero { position: relative; overflow: hidden; padding: 76px 0 64px; }
.hero::before, .hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
}
.hero::before {
  width: 620px; height: 620px; right: -220px; top: -260px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.16), transparent 65%);
}
.hero::after {
  width: 520px; height: 520px; left: -260px; bottom: -260px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.13), transparent 65%);
}
.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.02fr 0.98fr;
  gap: 56px;
  align-items: center;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid #dfe4ff;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  margin-bottom: 22px;
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(15, 159, 110, 0.14); }
.hero h1 { font-size: clamp(38px, 5.2vw, 60px); font-weight: 780; letter-spacing: -0.035em; }
.hero h1 .grad { background: linear-gradient(120deg, var(--brand), var(--brand-2) 55%, var(--brand-3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-lead { margin-top: 20px; font-size: 17.5px; color: var(--muted); max-width: 520px; line-height: 1.75; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.hero-note { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-size: 13px; color: var(--muted); }
.hero-note svg { width: 16px; height: 16px; color: var(--ok); }

.hero-trust { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--line); }
.trust-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.trust-item svg { width: 16px; height: 16px; color: var(--brand); }

.notice {
  display: none;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--warn-soft);
  border: 1px solid #f6dfb8;
  color: #8a5200;
  font-size: 14px;
  margin-bottom: 22px;
}
.notice.is-visible { display: flex; }
.notice.is-error { background: var(--danger-soft); border-color: #f7d3d3; color: #991b1b; }
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.notice code { background: rgba(255, 255, 255, 0.7); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }

/* Hero preview card */
.preview-wrap { position: relative; }
.preview-wrap::before {
  content: "";
  position: absolute; inset: 18px -12px -18px 22px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.22), rgba(6, 182, 212, 0.16));
  filter: blur(34px);
  border-radius: 32px;
  z-index: 0;
}
.preview {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 20px;
  backdrop-filter: blur(10px);
}
.preview-top { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.preview-dots { display: flex; gap: 6px; }
.preview-dots span { width: 8px; height: 8px; border-radius: 50%; background: #e2e8f0; }
.preview-dots span:first-child { background: #fca5a5; }
.preview-dots span:nth-child(2) { background: #fcd34d; }
.preview-dots span:nth-child(3) { background: #6ee7b7; }
.preview-title { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.preview-body { display: grid; grid-template-columns: 132px 1fr; gap: 18px; align-items: center; padding: 20px 0; }
.ring {
  --pct: 62;
  width: 132px; height: 132px; border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--pct) * 1%), #e8ecf7 0);
  display: grid; place-items: center;
  position: relative;
}
.ring::before { content: ""; position: absolute; inset: 11px; background: #fff; border-radius: 50%; }
.ring-inner { position: relative; text-align: center; }
.ring-value { font-size: 25px; font-weight: 780; letter-spacing: -0.03em; }
.ring-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.preview-stats { display: grid; gap: 10px; }
.preview-stat { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.preview-stat span { font-size: 11.5px; color: var(--muted); }
.preview-stat strong { font-size: 14.5px; letter-spacing: -0.01em; }
.preview-members { display: grid; gap: 9px; padding-top: 4px; }
.preview-member { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px; }
.preview-avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, #c7d2fe, #a5b4fc); display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #3730a3; }
.preview-member:nth-child(2) .preview-avatar { background: linear-gradient(135deg, #bae6fd, #7dd3fc); color: #075985; }
.preview-member:nth-child(3) .preview-avatar { background: linear-gradient(135deg, #fde68a, #fcd34d); color: #92400e; }
.preview-bar { height: 6px; border-radius: 999px; background: #eef1f8; overflow: hidden; }
.preview-bar b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.preview-member small { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.preview-badge {
  position: absolute; z-index: 2; right: -14px; bottom: 42px;
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 13px; box-shadow: var(--shadow); font-size: 12px; font-weight: 600;
}
.preview-badge svg { width: 16px; height: 16px; color: var(--ok); }

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */
.section { padding: 72px 0; }
.section-head { max-width: 640px; margin-bottom: 36px; }
.section-kicker { color: var(--brand); font-size: 12.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 10px; }
.section-head h2 { font-size: clamp(28px, 3.6vw, 38px); font-weight: 760; }
.section-head p { margin-top: 12px; color: var(--muted); font-size: 16.5px; }

.feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.feature {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.feature:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d8def0; }
.feature-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  margin-bottom: 16px;
}
.feature-icon svg { width: 21px; height: 21px; }
.feature h3 { font-size: 17px; font-weight: 700; }
.feature p { margin-top: 8px; color: var(--muted); font-size: 14.5px; line-height: 1.7; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; counter-reset: step; }
.step { position: relative; padding: 26px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.step-num {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 700; font-size: 14px;
  margin-bottom: 14px;
}
.step h3 { font-size: 16px; }
.step p { margin-top: 7px; color: var(--muted); font-size: 14px; }

.cta-band {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, #1e1b4b, #312e81 55%, #0e7490);
  color: #fff;
  padding: 46px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  box-shadow: var(--shadow-lg);
}
.cta-band::after {
  content: ""; position: absolute; width: 380px; height: 380px; right: -120px; top: -180px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.16), transparent 65%);
}
.cta-band h2 { font-size: clamp(24px, 3vw, 32px); }
.cta-band p { margin-top: 8px; color: rgba(255, 255, 255, 0.72); max-width: 560px; font-size: 15px; }
.cta-band .btn { position: relative; z-index: 1; background: #fff; color: #1e1b4b; }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.app-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; height: 66px; }
.app-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #c7d2fe, #818cf8);
  color: #312e81; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.app-user-meta { line-height: 1.25; min-width: 0; }
.app-user-name { font-size: 13.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.app-user-email { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.plan-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.plan-pill.is-pro { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.plan-pill.is-business { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }

.app-main { padding: 34px 0 60px; display: grid; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 760; }
.page-head p { color: var(--muted); margin-top: 5px; font-size: 14.5px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.stat-label svg { width: 15px; height: 15px; }
.stat-value { margin-top: 10px; font-size: 29px; font-weight: 780; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.stat-foot { margin-top: 7px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-accent { position: absolute; right: -18px; top: -18px; width: 78px; height: 78px; border-radius: 50%; background: var(--brand-soft); opacity: 0.7; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.card-title svg { width: 18px; height: 18px; color: var(--brand); }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 22px; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 22px; align-items: start; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }

.credit-overview { display: grid; grid-template-columns: 190px 1fr; gap: 26px; align-items: center; }
.credit-ring { --pct: 0; width: 190px; height: 190px; border-radius: 50%; position: relative; display: grid; place-items: center; background: conic-gradient(var(--brand) calc(var(--pct) * 1%), #edf0f9 0); }
.credit-ring::before { content: ""; position: absolute; inset: 14px; background: #fff; border-radius: 50%; }
.credit-ring-inner { position: relative; text-align: center; }
.credit-ring-value { font-size: 36px; font-weight: 790; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.credit-ring-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.credit-meta { display: grid; gap: 14px; }
.credit-line { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.credit-line:last-child { border-bottom: 0; padding-bottom: 0; }
.credit-line span { font-size: 13px; color: var(--muted); }
.credit-line strong { font-size: 15.5px; font-variant-numeric: tabular-nums; }
.progress { height: 9px; border-radius: 999px; background: #eef1f9; overflow: hidden; }
.progress > b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width 0.4s ease; }
.progress.is-warn > b { background: linear-gradient(90deg, #f59e0b, #f97316); }
.progress.is-danger > b { background: linear-gradient(90deg, #ef4444, #dc2626); }
.cycle-note { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); display: flex; gap: 9px; align-items: flex-start; }
.cycle-note svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--brand); }

/* Member list */
.member-list { display: grid; gap: 6px; }
.member-row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 8px; border-radius: 12px; transition: background 0.15s ease;
}
.member-row:hover { background: var(--surface-2); }
.member-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--brand-soft); color: var(--brand);
}
.member-main { min-width: 0; }
.member-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; }
.member-name .owner-tag { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.member-bar { margin-top: 6px; height: 6px; border-radius: 999px; background: #eef1f9; overflow: hidden; }
.member-bar b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-3)); }
.member-usage { text-align: right; font-variant-numeric: tabular-nums; }
.member-usage strong { font-size: 14px; }
.member-usage span { display: block; font-size: 11.5px; color: var(--muted); }
.member-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 14px; }

/* Chart */
.chart-head-actions { display: flex; align-items: center; gap: 8px; }
.chart-wrap { padding: 8px 8px 0; }
.chart-svg { width: 100%; height: 260px; overflow: visible; }
.chart-grid line { stroke: #eef1f8; stroke-width: 1; }
.chart-axis text { fill: var(--muted-2); font-size: 10.5px; font-family: var(--font); }
.chart-line { fill: none; stroke: url(#lineGradient); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#areaGradient); }
.chart-dot { fill: #fff; stroke: var(--brand); stroke-width: 2; }
.chart-empty { padding: 54px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; padding: 12px 22px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 22px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.15s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 650; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: #f1f5f9; color: var(--muted); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

/* Empty state / skeleton */
.empty-state { padding: 48px 26px; text-align: center; }
.empty-icon { width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 18px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty-icon svg { width: 27px; height: 27px; }
.empty-state h3 { font-size: 17px; }
.empty-state p { max-width: 430px; margin: 8px auto 0; color: var(--muted); font-size: 14px; }
.empty-state .btn { margin-top: 20px; }

.skeleton { position: relative; overflow: hidden; background: #edf1f9; border-radius: 8px; min-height: 14px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* Alert */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 14px; font-size: 13.5px; }
.alert svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.alert-warn { background: var(--warn-soft); border: 1px solid #f6dfb8; color: #8a5200; }
.alert-info { background: var(--brand-soft); border: 1px solid #dfe4ff; color: #3730a3; }
.alert-danger { background: var(--danger-soft); border: 1px solid #f7d3d3; color: #991b1b; }

/* Settings / plan */
.settings-list { display: grid; gap: 0; }
.setting-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row:first-child { padding-top: 0; }
.setting-info h4 { font-size: 14.5px; }
.setting-info p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.input-row { display: flex; gap: 8px; flex-wrap: wrap; }
.input {
  min-height: 42px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; color: var(--ink); min-width: 210px; font-size: 14px;
}
.input:focus { border-color: var(--brand); outline: 3px solid rgba(79, 70, 229, 0.14); }
.input::placeholder { color: var(--muted-2); }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(8, 15, 30, 0.5); backdrop-filter: blur(4px);
}
.modal.is-open { display: flex; }
.modal-card {
  width: min(100%, 560px); max-height: min(86vh, 760px); overflow: auto;
  background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg);
  animation: modalIn 0.18s ease;
}
.modal-card.is-wide { width: min(100%, 720px); }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 18px; }
.modal-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 22px 24px; display: grid; gap: 18px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.close-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; color: var(--muted); }
.close-btn:hover { background: var(--surface-2); color: var(--ink); }
.close-btn svg { width: 17px; height: 17px; }

.token-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.token-meta { min-width: 0; }
.token-name { font-size: 13.5px; font-weight: 650; }
.token-sub { font-size: 11.5px; color: var(--muted); }
.token-value {
  display: flex; gap: 8px; align-items: center; padding: 12px; border-radius: 12px;
  background: #0b1220; color: #a5f3fc; font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px; word-break: break-all;
}
.token-once { font-size: 12px; color: var(--warn); display: flex; gap: 6px; align-items: center; }

/* Toast */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 10px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 260px; max-width: 380px; padding: 13px 15px;
  border-radius: 12px; background: #0b1220; color: #fff;
  box-shadow: var(--shadow-lg); font-size: 13.5px;
  animation: toastIn 0.2s ease;
}
.toast.is-error { background: #7f1d1d; }
.toast.is-ok { background: #064e3b; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* Scan detail */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.detail-item { padding: 13px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.detail-item span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-item strong { display: block; margin-top: 4px; font-size: 15px; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Legal pages
   -------------------------------------------------------------------------- */
.legal { max-width: 900px; padding: 54px 0 20px; }
.legal-head { margin-bottom: 26px; }
.legal-head h1 { font-size: clamp(30px, 4vw, 42px); font-weight: 780; letter-spacing: -0.03em; }
.legal-head p { margin-top: 12px; color: var(--muted); font-size: 16px; max-width: 700px; }
.legal-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 46px); box-shadow: var(--shadow-sm);
}
.legal-card section { margin-bottom: 28px; }
.legal-card section:last-child { margin-bottom: 0; }
.legal-card h2 { font-size: 19px; margin-bottom: 10px; }
.legal-card p, .legal-card li { color: #334155; font-size: 15px; }
.legal-card ul { margin: 10px 0; padding-left: 22px; list-style: disc; }
.legal-card li { margin: 6px 0; }
.legal-card code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.legal-card hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

@media (max-width: 760px) {
  .legal { padding-top: 34px; }
  .legal-card { border-radius: var(--radius); }
}

/* --------------------------------------------------------------------------
   Utilities / responsive
   -------------------------------------------------------------------------- */
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.hidden { display: none !important; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inline-icon { width: 16px; height: 16px; vertical-align: -3px; }

@media (max-width: 1020px) {
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .preview-wrap { max-width: 560px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2-even { grid-template-columns: 1fr; }
  .credit-overview { grid-template-columns: 170px 1fr; }
  .credit-ring { width: 170px; height: 170px; }
}

@media (max-width: 760px) {
  .container { width: min(100% - 28px, var(--max)); }
  .nav-links { display: none; }
  .nav-inner { height: 62px; }
  .app-header-inner { height: 60px; }
  .app-header .brand-sub { display: none; }
  .app-header .brand-name {
    font-size: 13.5px; max-width: 150px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  .app-header .brand img { width: 32px; height: 32px; }
  .app-header .brand { gap: 8px; }
  .app-user { gap: 8px; }
  .plan-pill { font-size: 10.5px; padding: 4px 8px; }
  .preview-badge { display: none; }
  .hero { padding: 48px 0 40px; }
  .hero-lead { font-size: 16px; }
  .hero-cta .btn { flex: 1 1 auto; }
  .section { padding: 52px 0; }
  .feature-grid, .steps { grid-template-columns: 1fr; }
  .feature { padding: 22px; }
  .cta-band { padding: 30px; }
  .app-main { padding-top: 24px; gap: 16px; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .stat { padding: 16px; }
  .stat-value { font-size: 24px; }
  .credit-overview { grid-template-columns: 1fr; justify-items: center; }
  .credit-meta { width: 100%; }
  .card-head, .card-body { padding: 17px; }
  .table th, .table td { padding: 11px 16px; }
  .modal-card { border-radius: 16px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .chart-svg { height: 210px; }
  .app-user-meta { display: none; }
}

@media (max-width: 460px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11.5px; }
  .stat-foot { font-size: 11px; }
  .preview-body { grid-template-columns: 1fr; justify-items: center; }
  .preview-stats { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .member-row { grid-template-columns: 36px 1fr; }
  .member-usage { grid-column: 2; text-align: left; display: flex; gap: 8px; align-items: baseline; }
  .member-usage span { display: inline; }
  .table th:nth-child(4), .table td:nth-child(4) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
