:root {
  --ink: #17312c;
  --muted: #6b7d78;
  --brand: #286455;
  --brand-dark: #19483e;
  --mint: #dceee7;
  --cream: #f7f4ed;
  --paper: #fffefa;
  --line: #dce5e1;
  --danger: #a63a3a;
  --shadow: 0 18px 55px rgba(30, 71, 61, .10)
}

* {
  box-sizing: border-box
}

html {
  min-height: 100%;
  background: var(--cream)
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 15.5px/1.55 Inter, "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(145deg, #f7f4ed 0%, #edf5f0 55%, #f8f4ed 100%);
  display: flex;
  flex-direction: column
}

.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
  z-index: -1
}

.ambient-a {
  width: 420px;
  height: 420px;
  right: -140px;
  top: 70px;
  background: rgba(151, 204, 181, .22)
}

.ambient-b {
  width: 300px;
  height: 300px;
  left: -120px;
  bottom: 40px;
  background: rgba(233, 197, 133, .16)
}

.topbar {
  height: 76px;
  padding: 0 max(24px, calc((100vw - 1180px)/2));
  display: flex;
  align-items: center;
  gap: 28px;
  background: rgba(255, 254, 250, .88);
  border-bottom: 1px solid rgba(206, 220, 214, .8);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font: 600 24px Georgia, serif
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: white;
  background: linear-gradient(145deg, #2f7563, #193f37);
  box-shadow: 0 8px 18px rgba(34, 91, 76, .23);
  font: 700 19px Inter, "Segoe UI", system-ui, sans-serif
}

.main-nav {
  display: flex;
  gap: 6px
}

.main-nav a {
  padding: 9px 12px;
  border-radius: 9px;
  color: #4c625d;
  text-decoration: none;
  font-weight: 600
}

.main-nav a:hover {
  background: var(--mint);
  color: var(--brand-dark)
}

.account-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px
}

.account-copy {
  display: grid;
  text-align: right;
  line-height: 1.25
}

.account-copy span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--brand);
  font-size: 18px;
  cursor: pointer
}

.shell {
  width: min(1180px, calc(100% - 34px));
  margin: 42px auto 60px;
  flex: 1
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em
}

h1,
h2,
h3 {
  font-family: Georgia, serif;
  line-height: 1.08;
  margin-top: 0
}

h1 {
  font-size: clamp(36px, 5vw, 56px);
  margin-bottom: 7px
}

h2 {
  font-size: 27px;
  margin-bottom: 8px
}

h3 {
  font-size: 21px
}

.lead {
  max-width: 700px;
  color: var(--muted);
  font-size: 17px;
  margin: 0
}

.grid {
  display: grid;
  gap: 20px
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr))
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr))
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px
}

.card {
  background: rgba(255, 254, 250, .94);
  border: 1px solid rgba(211, 224, 218, .9);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow)
}

.card.flat {
  box-shadow: none
}

.card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px
}

.card-head p {
  margin: 0
}

.stat {
  padding: 20px
}

.stat .value {
  font: 600 34px Georgia, serif
}

.stat .label {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em
}

.soft {
  background: linear-gradient(145deg, rgba(220, 238, 231, .92), rgba(255, 254, 250, .94))
}

.stack {
  display: grid;
  gap: 17px
}

.field {
  display: grid;
  gap: 7px
}

label {
  font-weight: 700;
  font-size: 14px
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #bdcec7;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: .2s
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(40, 100, 85, .11)
}

textarea {
  resize: vertical;
  min-height: 120px
}

.button,
button.primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 11px;
  padding: 11px 17px;
  background: linear-gradient(145deg, #2e705f, #205347);
  color: white;
  text-decoration: none;
  font: 700 14px Inter, "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(31, 83, 70, .18)
}

.button.secondary,
button.secondary {
  background: white;
  color: var(--brand-dark);
  border: 1px solid var(--line);
  box-shadow: none
}

.button.danger,
button.danger {
  background: #fff2f0;
  color: var(--danger);
  border: 1px solid #f0cfcb;
  box-shadow: none
}

.button.small,
button.small {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap
}

.muted {
  color: var(--muted)
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0
}

.badge {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700
}

.badge.manager {
  background: #eee7ff;
  color: #62449b
}

.badge.patient {
  background: #eaf1f8;
  color: #3d607c
}

.badge.used {
  background: #f0f0ed;
  color: #73736d
}

.code {
  font: 700 13px ui-monospace, monospace;
  background: #eef5f1;
  padding: 6px 9px;
  border-radius: 8px;
  color: #23584b
}

.table-wrap {
  overflow-x: auto
}

table {
  width: 100%;
  border-collapse: collapse
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid #e6ece9;
  text-align: left;
  vertical-align: middle
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted)
}

tr:last-child td {
  border-bottom: 0
}

.flash {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 13px 16px;
  border-radius: 12px;
  background: #e3f1ea;
  color: #215c4b;
  margin-bottom: 18px;
  border: 1px solid #c5e0d4
}

.flash.error {
  background: #fff0ee;
  color: #8d3131;
  border-color: #f1d0cb
}

.flash span {
  font-weight: 800
}

.auth-wrap {
  min-height: calc(100vh - 220px);
  display: grid;
  place-items: center
}

.auth-card {
  width: min(490px, 100%);
  padding: 34px
}

.auth-card .brand-mark {
  margin-bottom: 22px
}

.auth-links {
  text-align: center;
  margin: 18px 0 0
}

.message {
  max-width: 78%;
  padding: 14px 17px;
  margin: 12px 0;
  border-radius: 16px;
  background: #edf3f0;
  white-space: pre-wrap
}

.message.user {
  margin-left: auto;
  background: var(--brand);
  color: white;
  border-bottom-right-radius: 4px
}

.message.assistant {
  border-bottom-left-radius: 4px
}

.message-meta {
  display: block;
  font-size: 11px;
  opacity: .72;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .07em
}

.chat-window {
  min-height: 280px;
  max-height: 58vh;
  overflow-y: auto
}

.source-list {
  display: grid;
  gap: 10px;
  margin-top: 14px
}

.source {
  padding: 12px;
  border-radius: 11px;
  background: #f2f6f4;
  font-size: 13px
}

.empty {
  padding: 32px;
  text-align: center;
  color: var(--muted)
}

details summary {
  cursor: pointer;
  font-weight: 700
}

.usage-bars {
  display: grid;
  gap: 10px
}

.usage-row {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 12px;
  align-items: center
}

.bar {
  height: 10px;
  background: #e8eeeb;
  border-radius: 999px;
  overflow: hidden
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3d846f, #8ebca9);
  border-radius: inherit
}

footer {
  width: min(1180px, calc(100% - 34px));
  margin: 0 auto;
  padding: 22px 0 28px;
  border-top: 1px solid rgba(194, 210, 203, .7);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px
}

footer a,
.legal-copy a,
.legal-note a {
  color: var(--brand-dark);
  text-underline-offset: 3px
}

.legal-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center
}

.privacy-page {
  width: min(920px, 100%);
  margin: 0 auto
}

.privacy-warning {
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid #e8c87a;
  border-radius: 12px;
  color: #654e17;
  background: #fff8df
}

.legal-copy {
  padding: clamp(24px, 5vw, 48px)
}

.legal-copy h2 {
  margin-top: 34px;
  padding-top: 4px;
  font-size: 24px
}

.legal-copy h2:first-of-type {
  margin-top: 24px
}

.legal-copy li + li {
  margin-top: 8px
}

.legal-copy th {
  min-width: 220px
}

.chat-composer {
  border-top: 1px solid var(--line);
  padding-top: 20px
}

.message-body {
  display: block
}

.message.streaming {
  box-shadow: inset 0 0 0 1px rgba(40, 100, 85, .12)
}

.message.stream-error {
  background: #fff0ee;
  color: #8d3131
}

.stream-status {
  color: var(--muted);
  font-style: italic
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 8px;
  vertical-align: middle
}

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
  animation: typing 1.1s infinite ease-in-out
}

.typing-dots i:nth-child(2) {
  animation-delay: .15s
}

.typing-dots i:nth-child(3) {
  animation-delay: .3s
}

button:disabled,
textarea:disabled {
  opacity: .65;
  cursor: not-allowed
}

@keyframes typing {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: .35
  }

  30% {
    transform: translateY(-4px);
    opacity: 1
  }
}

@media(max-width:800px) {
  .topbar {
    height: auto;
    min-height: 68px;
    padding: 12px 18px;
    flex-wrap: wrap
  }

  .main-nav {
    order: 3;
    width: 100%;
    overflow: auto
  }

  .account-copy {
    display: none
  }

  .shell {
    margin-top: 28px
  }

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

  .grid.two,
  .grid.three,
  .chat-layout {
    grid-template-columns: 1fr
  }

  .message {
    max-width: 92%
  }

  footer {
    flex-direction: column;
    gap: 5px
  }

  .usage-row {
    grid-template-columns: 76px 1fr auto
  }
}
