/* Sage Matters member portal — brand tokens copied from
   sage-matters-website/src/styles/theme.css. Cream only; the site has no dark
   theme and this must not invent one. */

:root {
  --paper: #f6f1e8;
  --paper-deep: #efe7d8;
  --card: #fffdf8;
  --ink: #262b2d;
  --ink-soft: rgba(38, 43, 45, 0.74);
  --ink-faint: rgba(38, 43, 45, 0.55);
  --line: rgba(38, 43, 45, 0.12);
  --sage: #6f9573;
  --sage-footer-deep: #5d8064;
  --sage-dark: #44604a;
  --sage-deep: #2f4536;
  --sage-glow: #a3d199;
  --sand-deep: #e7dcc6;
  --forest-deep: #3f5a44;
  --danger: #9b4a3f;

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Tenor Sans', 'Inter', sans-serif;
  --font-display: 'Fraunces', Georgia, serif;

  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-xl: 36px;
  --shadow-soft: 0 18px 50px rgba(38, 43, 45, 0.10);
  --shadow-card: 0 10px 34px rgba(38, 43, 45, 0.08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-heading); font-weight: 400; letter-spacing: 0.01em; margin: 0; }
.accent { font-family: var(--font-display); font-style: italic; }

button { font-family: inherit; font-size: inherit; cursor: pointer; }

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  background: linear-gradient(135deg, var(--sage-glow), var(--sage));
  color: var(--sage-deep);
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-card);
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.btn-quiet {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 18px;
  color: var(--ink-soft);
  box-shadow: none;
  font-weight: 500;
}
.btn-quiet:hover { border-color: var(--sage); color: var(--sage-dark); }

.btn-link {
  background: none; border: none; padding: 0;
  color: var(--ink-faint); text-decoration: underline; font-size: 13px;
}
.btn-link:hover { color: var(--danger); }

label { display: block; font-size: 13px; color: var(--ink-faint); margin-bottom: 6px; letter-spacing: .03em; text-transform: uppercase; }

input[type=text], input[type=email], input[type=password], textarea {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(111, 149, 115, .16);
}

.note { font-size: 13px; color: var(--ink-faint); }
.error {
  background: rgba(155, 74, 63, .08);
  border: 1px solid rgba(155, 74, 63, .25);
  color: var(--danger);
  border-radius: var(--radius-md);
  padding: 11px 15px;
  font-size: 14px;
}
.hidden { display: none !important; }

/* ---------- sign in ---------- */

#login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 480px at 50% -10%, rgba(163, 209, 153, .28), transparent 70%),
    var(--paper);
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  padding: 42px 38px 34px;
}
.login-card h1 { font-size: 30px; margin-bottom: 6px; }
.login-card .sub { color: var(--ink-soft); font-size: 15px; margin: 0 0 26px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; margin-top: 10px; }
.brandmark {
  font-family: var(--font-heading);
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--sage-dark);
  margin-bottom: 22px;
}

/* ---------- app shell ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 30px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .who { font-size: 14px; color: var(--ink-faint); }

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 30px 24px 60px;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 940px) { main { grid-template-columns: 1fr; } }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 26px 26px 22px;
}
.panel > header { margin-bottom: 18px; }
.panel h2 { font-size: 21px; }
.panel .lede { color: var(--ink-soft); font-size: 14px; margin: 5px 0 0; }

/* ---------- documents ---------- */

.dropzone {
  border: 1.5px dashed rgba(111, 149, 115, .45);
  border-radius: var(--radius-md);
  background: var(--paper-deep);
  padding: 26px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  transition: background .15s ease, border-color .15s ease;
}
.dropzone.over { background: rgba(163, 209, 153, .22); border-color: var(--sage); }
.dropzone .btn-quiet { margin-top: 12px; background: var(--card); }

.doclist { list-style: none; margin: 20px 0 0; padding: 0; }
.doclist li {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.doclist .meta { flex: 1; min-width: 0; }
.doclist .name {
  font-weight: 500; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doclist .sub { font-size: 12.5px; color: var(--ink-faint); }
.doclist .actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.pill {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px;
  background: var(--sand-deep); color: var(--forest-deep);
}
.empty { color: var(--ink-faint); font-size: 14px; padding: 22px 0 4px; text-align: center; }

/* ---------- chat ---------- */

.chat { display: flex; flex-direction: column; min-height: 560px; }
.thread { flex: 1; overflow-y: auto; max-height: 60vh; padding-right: 6px; }
.msg { margin-bottom: 18px; max-width: 92%; }
.msg.user { margin-left: auto; }
.msg .bubble {
  border-radius: var(--radius-md);
  padding: 13px 18px;
  font-size: 15px;
}
.msg.user .bubble { background: var(--paper-deep); }
.msg.sage .bubble { background: rgba(163, 209, 153, .16); border: 1px solid rgba(111, 149, 115, .22); }
.msg .bubble p:first-child { margin-top: 0; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13.5px; }
.msg .bubble th, .msg .bubble td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.msg .bubble th { font-weight: 600; color: var(--ink-soft); }
.msg .who { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 5px; }
.msg.user .who { text-align: right; }

.composer { display: flex; gap: 12px; align-items: flex-end; margin-top: 18px; }
.composer textarea { resize: none; min-height: 54px; max-height: 160px; }

.disclaimer {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  padding-top: 13px;
}

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(111, 149, 115, .3);
  border-top-color: var(--sage);
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- chat header + history ---------- */

.chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.chat-actions { display: flex; gap: 8px; flex-shrink: 0; }
.chat-actions .btn-quiet { padding: 6px 15px; font-size: 14px; }

.history-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px;
}
#historylist li { cursor: pointer; }
#historylist .name { font-weight: 500; }
#historylist li:hover .name { color: var(--sage-dark); }

/* The upload promise problem: a button that says "upload your labs" inside a
   portal with a doctor's name on it implies a doctor reads them. Until a
   clinician owns a review queue, the page has to say plainly that nobody has. */
.standing-note {
  margin: 16px 0 0;
  padding: 12px 15px;
  border-radius: var(--radius-md);
  background: var(--paper-deep);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}
/* Review state. Quiet by design — a document's status is information, not an
   alert, and a member's own record should not shout at them. */
.pill-received { background: var(--paper-deep); color: var(--ink-faint); }
.pill-awaiting { background: var(--paper-deep); color: var(--ink-soft); border-color: var(--ink-faint); }
.pill-reviewed { background: var(--paper-deep); color: var(--ink); border-color: var(--ink-soft); }

/* Utility classes replacing inline style attributes, so the page's
   Content-Security-Policy can forbid inline styles outright. */
.brandmark-bar { margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.note-tight { margin: 8px 0 0; }
.note-gap { margin: 16px 0 0; }
.error-gap { margin-top: 14px; }
