:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --line: #e8e8ed;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --danger: #d7373f;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 28px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          system-ui, "Inter", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}
a { color: inherit; text-decoration: none; }

/* ---- Translucent top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 22px;
  height: 52px; display: flex; align-items: center; gap: 26px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.logo-img { width: 28px; height: 28px; display: block; }
.logo-img-lg { width: 56px; height: 56px; }
.brand-login { flex-direction: column; gap: 10px; }
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: -0.02em; }
.four { color: #2aa7a3; }
.nav { display: flex; gap: 2px; }
.nav a {
  padding: 6px 12px; border-radius: 980px; font-size: 14px; font-weight: 500;
  color: var(--muted); transition: color .15s, background .15s;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); background: rgba(0,0,0,.06); }
.search { margin-left: auto; }
.search input {
  width: 200px; padding: 7px 14px; border: none; border-radius: 980px;
  font-size: 13.5px; background: rgba(0,0,0,.05); color: var(--ink); font-family: inherit;
  transition: width .2s, background .2s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; width: 240px; background: rgba(0,0,0,.07); }
.logout { font-size: 13.5px; color: var(--accent); font-weight: 500; }

.container { max-width: 1080px; margin: 0 auto; padding: 40px 22px 64px; }

/* ---- Type ---- */
.display { font-size: 40px; line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.025em; margin: 0; }
.section-title { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.card-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 16px; }
.lede { font-size: 17px; color: var(--muted); margin: 8px 0 0; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; color: var(--muted); margin: 0 0 6px; }
.eyebrow .four { color: #2aa7a3; }
.subtle { color: var(--muted); font-size: 14px; }
.muted { color: var(--faint); font-weight: 400; }
.req { color: var(--danger); }
.link { color: var(--accent); font-weight: 500; font-size: 14px; }
.link:hover { text-decoration: underline; }
.back { display: inline-block; color: var(--accent); font-size: 14px; margin-bottom: 16px; font-weight: 500; }

.hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  margin-bottom: 30px;
}
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 14px; }
.section-head:first-child { margin-top: 0; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; margin-bottom: 18px;
}
.card.flush { padding: 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head .card-title { margin: 0; }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 8px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px 26px;
}
.stat-value { font-size: 44px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.stat-label { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* ---- Note list (dashboard / history / search) ---- */
.note-list { list-style: none; margin: 0; padding: 0; }
.note-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 18px; border-radius: 14px; cursor: pointer; transition: background .12s;
}
.note-row:hover { background: rgba(0,0,0,.035); }
.note-row + .note-row { border-top: 1px solid var(--line); }
.note-row-title { font-size: 15.5px; font-weight: 600; display: block; }
.note-row-sub { font-size: 13.5px; color: var(--muted); display: block; margin-top: 2px; }
.note-row-meta { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.note-row-meta .date { font-size: 13px; color: var(--faint); }
.pill {
  display: inline-block; padding: 3px 11px; border-radius: 980px; font-size: 11.5px;
  font-weight: 600; background: rgba(0,113,227,.1); color: var(--accent); letter-spacing: 0;
}
.empty { color: var(--muted); font-size: 15px; padding: 22px; text-align: center; }
.empty a { color: var(--accent); }

/* ---- Forms ---- */
.gen-head { margin-bottom: 22px; }
.gen-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 7px; }
input, textarea, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14.5px; background: #fbfbfd; color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
  outline: none; background: #fff; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0,113,227,.12);
}
textarea { resize: vertical; line-height: 1.5; }
.inputs-list p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.55; color: var(--muted); }
.inputs-list strong { color: var(--ink); font-weight: 600; }
.actions { display: flex; gap: 10px; margin-top: 2px; }
.disclaimer { font-size: 12.5px; color: var(--faint); margin: 16px 0 0; }
.out-actions { display: flex; gap: 8px; align-items: center; }
.output-card .output {
  width: 100%; min-height: 480px; font-size: 14.5px; line-height: 1.65;
  background: #fbfbfd; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px;
}

/* ---- Buttons (Apple pill) ---- */
.btn {
  border: none; border-radius: 980px; padding: 10px 20px; font-size: 14.5px; font-weight: 500;
  cursor: pointer; font-family: inherit; letter-spacing: -0.01em; transition: all .15s;
}
.btn:active { transform: scale(.97); }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-secondary { background: rgba(0,0,0,.06); color: var(--ink); }
.btn-secondary:hover { background: rgba(0,0,0,.1); }
.btn-secondary:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: rgba(0,113,227,.08); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: rgba(215,55,63,.08); }

/* ---- Note view ---- */
.note-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 14px; margin-top: 10px; }
.note-meta strong { color: var(--ink); font-weight: 600; }
.prewrap { white-space: pre-wrap; line-height: 1.7; margin: 0; }
.note-text { font-size: 15.5px; }

/* ---- Flash + toast ---- */
.flash {
  max-width: 1080px; margin: 18px auto 0; padding: 12px 18px;
  background: #fff8e6; border: 1px solid #ffe2a8; color: #8a6100; border-radius: 12px; font-size: 14px;
}
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(29,29,31,.92); color: #fff; padding: 11px 20px; border-radius: 980px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60;
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(215,55,63,.95); }

/* ---- Login ---- */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #eaf2ff 0%, #f5f5f7 55%);
}
.login-card {
  background: var(--surface); border-radius: 22px; padding: 40px 36px; width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.12); text-align: center;
}
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 14.5px; margin: 4px 0 24px; }
.login-card label { text-align: left; }
.login-card .btn { margin-top: 16px; width: 100%; }

/* ---- Account chip in nav ---- */
.acct { font-size: 13px; color: var(--muted); font-weight: 500; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- OAuth buttons + divider ---- */
.oauth-row { display: flex; flex-direction: column; gap: 10px; }
.btn-oauth {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 600;
}
.btn-oauth:hover { background: #f7f7f9; }
.oauth-mark { font-weight: 800; width: 18px; text-align: center; }
.divider { display: flex; align-items: center; text-align: center; color: var(--faint);
  font-size: 12px; margin: 18px 0; gap: 10px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-foot { font-size: 13px; color: var(--muted); margin: 18px 0 0; }
.login-foot a { color: var(--accent); font-weight: 500; }

/* ---- Marketing / pricing ---- */
.marketing-body { background: #fafbfc; }
.mk-top { max-width: 1120px; margin: 0 auto; padding: 20px 24px; display: flex;
  align-items: center; justify-content: space-between; }
.mk-top-actions { display: flex; align-items: center; gap: 18px; }
.btn-sm { padding: 8px 16px; font-size: 13.5px; }
.mk-hero { text-align: center; max-width: 720px; margin: 18px auto 36px; padding: 0 22px; }
.mk-hero .lede { margin-top: 12px; }
.price-grid { max-width: 1120px; margin: 0 auto; padding: 0 24px; display: grid;
  grid-template-columns: repeat(3, 1fr); gap: 22px; align-items: stretch; }
.price-card { background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 30px 26px; display: flex; flex-direction: column; text-align: center; position: relative; }
.price-card.featured { border: 2px solid #16314f; box-shadow: 0 18px 50px rgba(22,49,79,.14); }
.badge { position: absolute; top: 0; left: 0; right: 0; background: #16314f; color: #fff;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; padding: 7px; border-radius: 18px 18px 0 0; }
.price-card.featured { padding-top: 46px; }
.price-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  margin: 0 auto 14px; font-size: 24px; color: #fff; }
.price-icon.teal { background: #2aa7a3; } .price-icon.navy { background: #16314f; }
.tier { font-size: 19px; font-weight: 800; letter-spacing: .03em; margin: 0; }
.teal-t { color: #2aa7a3; } .navy-t { color: #16314f; }
.tier-sub { color: var(--muted); font-size: 14px; margin: 8px 0 18px; min-height: 38px; }
.price { display: flex; align-items: baseline; justify-content: center; gap: 4px;
  border-top: 1px solid var(--line); padding-top: 18px; }
.price .amt { font-size: 46px; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); }
.price .per { color: var(--muted); font-size: 15px; }
.price-note { font-weight: 600; font-size: 14px; margin: 4px 0 18px; }
.feat { list-style: none; padding: 0; margin: 0 0 22px; text-align: left; flex: 1; }
.feat li { position: relative; padding: 7px 0 7px 26px; font-size: 14px; color: #333; }
.feat li::before { content: "✓"; position: absolute; left: 0; color: #2aa7a3; font-weight: 800; }
.btn-tier { width: 100%; color: #fff; font-weight: 700; padding: 13px; }
.teal-bg { background: #2aa7a3; } .teal-bg:hover { background: #248f8c; }
.navy-bg { background: #16314f; } .navy-bg:hover { background: #0f2438; }
.trial-note { font-size: 12.5px; color: var(--faint); margin: 10px 0 0; }
.founding { max-width: 1120px; margin: 26px auto 0; padding: 22px 28px; display: flex;
  align-items: center; gap: 26px; background: #eef6f6; border: 1px solid #cfe7e6; border-radius: 18px; }
.founding-mark { width: 52px; height: 52px; border-radius: 50%; background: #2aa7a3; color: #fff;
  display: grid; place-items: center; font-size: 24px; flex: none; }
.founding-text h3 { margin: 0 0 4px; color: #16314f; font-size: 16px; letter-spacing: .03em; }
.founding-text p { margin: 0; color: var(--muted); font-size: 14px; }
.founding-price { margin-left: auto; text-align: right; }
.founding-badge { display: inline-block; background: #16314f; color: #fff; font-weight: 700;
  padding: 9px 16px; border-radius: 980px; font-size: 14.5px; }
.founding-price p { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); max-width: 240px; }
.mk-foot { text-align: center; color: var(--muted); font-size: 13.5px; padding: 36px 0 48px; }

/* ---- Admin ---- */
.admin-add { display: grid; grid-template-columns: 1.2fr 1.6fr .9fr 1fr 1.4fr auto; gap: 10px; align-items: end; }
.admin-add .btn { white-space: nowrap; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; color: var(--faint); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.acct-name { font-weight: 600; } .acct-email { color: var(--muted); font-size: 13px; }
.status { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 980px; }
.status-active { background: #e6f6ee; color: #1a7f4b; }
.status-suspended { background: #fdeaea; color: #b3322f; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.btn-mini { padding: 6px 12px; font-size: 12.5px; background: rgba(0,0,0,.06); color: var(--ink); }
.btn-mini:hover { background: rgba(0,0,0,.1); }
.btn-danger { background: #fdeaea; color: #b3322f; }
.btn-danger:hover { background: #fbd9d9; }
.activate-form { display: flex; gap: 4px; align-items: center; }
.mini-select { width: auto; padding: 5px 8px; font-size: 12.5px; border-radius: 8px; }
.btn-go { background: #e6f6ee; color: #1a7f4b; }
.btn-go:hover { background: #d3f0e0; }
.pill-soft { background: rgba(0,0,0,.06); color: var(--muted); font-size: 11px; }

/* ---- Clients ---- */
.add-panel { display: none; }
.add-panel.open { display: block; }
.mini-link { display: inline-block; color: var(--accent); font-size: 13px; font-weight: 500; margin: -6px 0 14px; }
.about-text { white-space: pre-wrap; line-height: 1.6; margin: 0; color: #333; font-size: 15px; }
.note-list.tight .note-row { padding: 12px 14px; }
.btn-danger-text { color: var(--danger); margin-top: 12px; }
.client-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 2px; min-width: 120px; transition: box-shadow .15s; }
.chip:hover { box-shadow: var(--shadow); }
.chip-name { font-weight: 600; font-size: 14.5px; }
.chip-meta { font-size: 12.5px; color: var(--muted); }

/* ---- Multi-select diagnosis picker ---- */
.dx-multi { display: flex; flex-direction: column; gap: 8px; }
.dx-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.dx-chip { display: inline-flex; align-items: center; gap: 7px; background: #eef6f6;
  color: #16314f; border: 1px solid #cfe7e6; border-radius: 980px;
  padding: 5px 6px 5px 13px; font-size: 13px; font-weight: 500; }
.dx-x { border: none; background: rgba(22,49,79,.1); color: #16314f; cursor: pointer;
  width: 18px; height: 18px; border-radius: 50%; font-size: 13px; line-height: 1;
  display: grid; place-items: center; padding: 0; }
.dx-x:hover { background: rgba(22,49,79,.22); }
.dx-input { width: 100%; }

/* ---- Trial banner ---- */
.trial-banner { max-width: 1080px; margin: 14px auto 0; padding: 11px 18px;
  background: #eef6f6; border: 1px solid #cfe7e6; color: #16314f; border-radius: 12px;
  font-size: 14px; font-weight: 500; }
.trial-banner a { color: #2aa7a3; font-weight: 600; }
.trial-banner.warn { background: #fdeaea; border-color: #f3c9c9; color: #b3322f; }
.trial-banner.warn a { color: #b3322f; }
.notice { background: #eef6f6; border-color: #cfe7e6; }
.notice.warn { background: #fdeaea; border: 1px solid #f3c9c9; }

/* ---- Billing plan cards ---- */
.bill-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.bill-card { background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 18px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.bill-card.current { border: 2px solid #2aa7a3; }
.bill-name { font-weight: 700; color: #16314f; letter-spacing: .02em; }
.bill-price { font-size: 30px; font-weight: 800; color: var(--ink); }
.bill-price span { font-size: 14px; font-weight: 500; color: var(--muted); }
.bill-blurb { font-size: 13px; color: var(--muted); margin-bottom: 12px; min-height: 32px; }
.bill-card .btn { width: 100%; margin-top: auto; }

@media (max-width: 820px) { .bill-grid { grid-template-columns: 1fr 1fr; } }

@media (max-width: 920px) {
  .price-grid { grid-template-columns: 1fr; max-width: 460px; }
  .founding { flex-direction: column; text-align: center; }
  .founding-price { margin: 0; text-align: center; }
  .admin-add { grid-template-columns: 1fr 1fr; }
  .admin-table { font-size: 13px; }
}
@media (max-width: 820px) {
  .gen-grid, .field-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .display { font-size: 32px; }
  .nav { display: none; }
  .search input { width: 130px; }
  .acct { display: none; }
}
