
:root { color-scheme: light; --border: #111; --muted: #666; --bg: #fff; --ink: #111; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; text-decoration: none; }
.toast { position: fixed; top: 18px; right: 18px; z-index: 20; max-width: min(360px, calc(100vw - 36px)); padding: 12px 14px; border: 1px solid var(--border); background: #fff; box-shadow: 0 12px 28px rgba(0,0,0,.08); opacity: 0; transform: translateY(-8px); pointer-events: none; }
.toast.show { animation: toastfade 2s ease forwards; }
.topbar { position: sticky; top: 0; z-index: 1; display: flex; gap: 24px; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); background: #fff; }
.brand-wrap { align-items: baseline; display: flex; flex-wrap: wrap; gap: 10px; }
.brand { font-weight: 700; }
.today-label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.today-label time { display: inline; font-size: inherit; margin: 0; }
nav { display: flex; flex-wrap: wrap; gap: 12px; }
nav a { padding: 4px 0; border-bottom: 1px solid transparent; }
nav a:hover { border-color: var(--ink); }
main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
body:has(.chat-layout) { overflow: hidden; }
body:has(.chat-layout) main { height: calc(100vh - 57px); max-width: 1440px; padding-bottom: 20px; }
h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 17px; letter-spacing: 0; }
p { margin: 0 0 12px; }
.page-heading { margin-bottom: 16px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.filter-row button { width: auto; }
.filter-row button.active { background: #111; color: #fff; }
.notes p, .timeline p { white-space: pre-wrap; }
.hero { padding: 18px 0 28px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.login-wrap { min-height: 70vh; display: grid; place-items: center; }
.login { width: min(100%, 380px); }
.error { color: #8a0000; }
.muted, span { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
article, .panel { border: 1px solid var(--border); padding: 16px; border-radius: 4px; background: #fff; }
.wide { grid-column: 1 / -1; }
ul, ol { margin: 0; padding-left: 20px; }
li { margin: 8px 0; }
.log-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inline-delete { margin: 0; width: auto; }
.med-plan-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.med-plan { align-items: center; border: 1px solid #bbb; border-left: 4px solid #111; border-radius: 4px; display: flex; gap: 12px; justify-content: space-between; margin: 0; padding: 10px 12px; }
.med-plan > div { display: grid; gap: 3px; }
.med-plan strong { display: block; }
.med-plan em { color: var(--muted); font-style: normal; font-weight: 700; }
.med-plan form { margin: 0; min-width: 140px; }
.med-plan-actions { display: grid; gap: 8px; min-width: 150px; }
.med-plan button:disabled { border-color: #6ca678; color: #1f6b35; cursor: default; }
.med-plan button:disabled:hover { background: #eef8f0; color: #1f6b35; }
.med-plan-done { background: #eef8f0; border-color: #6ca678; border-left-color: #208a3c; }
.med-plan-done em { color: #1f6b35; }
.med-plan-partial { background: #fff8e8; border-color: #d7b35a; border-left-color: #b87900; }
.med-plan-partial em { color: #7a4d00; }
.med-plan-times { display: block; }
.table-actions { display: grid; gap: 8px; min-width: 150px; }
.source-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
table { width: 100%; border-collapse: collapse; border: 1px solid var(--border); background: #fff; }
th, td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid #ccc; }
th { font-size: 13px; text-transform: uppercase; font-weight: 700; }
.med-row { cursor: pointer; }
.med-row:hover, .med-row:focus { background: #f7f7f4; outline: none; }
label { display: grid; gap: 5px; margin-bottom: 12px; font-weight: 600; }
input, textarea, select, button { width: 100%; border: 1px solid var(--border); border-radius: 4px; background: #fff; color: #111; font: inherit; padding: 8px 9px; }
input[type="radio"], input[type="checkbox"] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
button { cursor: pointer; font-weight: 700; }
button:hover { background: #111; color: #fff; }
.danger-btn { width: auto; padding: 6px 10px; white-space: nowrap; }
td form { margin: 0; }
.schedule-builder { border: 1px solid var(--border); border-radius: 4px; display: grid; gap: 8px; margin: 0 0 12px; padding: 12px; }
.schedule-builder legend { font-weight: 700; padding: 0 6px; }
.choice-card { align-items: center; border: 1px solid #bbb; border-radius: 4px; display: flex; gap: 8px; margin: 0; padding: 9px; }
.choice-card:has(input:checked) { border-color: #111; box-shadow: inset 0 0 0 1px #111; }
.schedule-fields[hidden] { display: none; }
.weekday-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.weekday-grid label { align-items: center; border: 1px solid #bbb; border-radius: 4px; display: flex; gap: 6px; justify-content: center; margin: 0; padding: 8px 6px; }
.agent-layout aside { display: grid; gap: 16px; }
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; height: 100%; min-height: 0; }
.chat-app { border: 1px solid var(--border); border-radius: 6px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; overflow: hidden; background: #fff; }
.chat-header { align-items: center; border-bottom: 1px solid var(--border); display: flex; gap: 16px; justify-content: space-between; padding: 14px 16px; }
.chat-header h1 { font-size: 20px; margin: 0 0 2px; }
.chat-header p { color: var(--muted); font-size: 13px; margin: 0; }
.chat-header form { margin: 0; width: auto; }
.chat-header button { white-space: nowrap; }
.chat-thread { display: flex; flex-direction: column; gap: 14px; list-style: none; margin: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 18px; }
.chat-message { display: flex; margin: 0; }
.chat-message.user { justify-content: flex-end; }
.chat-message.assistant, .chat-message.system { justify-content: flex-start; }
.chat-bubble { border: 1px solid #ccc; border-radius: 8px; max-width: min(74ch, 78%); padding: 10px 12px; }
.chat-message.user .chat-bubble { background: #111; border-color: #111; color: #fff; }
.chat-message.assistant .chat-bubble, .chat-message.system .chat-bubble { background: #f7f7f4; }
.chat-message.pending .chat-bubble { min-width: 74px; }
.chat-bubble p { margin: 6px 0 0; white-space: pre-wrap; }
.chat-bubble small { display: block; font-size: 12px; margin-top: 8px; opacity: .72; }
.chat-meta { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
.chat-meta time { color: inherit; display: inline; font-size: 12px; margin: 0; opacity: .68; }
.chat-empty { border: 1px dashed #bbb; border-radius: 8px; color: var(--muted); justify-self: center; margin: auto 0; max-width: 420px; padding: 18px; text-align: center; }
.chat-empty p { margin: 8px 0 0; }
.chat-composer { align-items: end; border-top: 1px solid var(--border); display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; margin: 0; padding: 12px; }
.chat-composer textarea { max-height: 180px; min-height: 44px; overflow: auto; resize: none; }
.chat-composer button { min-height: 44px; width: auto; }
.chat-composer.is-loading textarea { background: #f7f7f4; color: var(--muted); }
.typing-indicator { align-items: center; display: flex; gap: 5px; height: 24px; justify-content: center; }
.typing-indicator span { animation: typingpulse 1s infinite ease-in-out; background: #777; border-radius: 50%; display: block; height: 7px; width: 7px; }
.typing-indicator span:nth-child(2) { animation-delay: .14s; }
.typing-indicator span:nth-child(3) { animation-delay: .28s; }
.chat-sidebar { display: grid; gap: 14px; max-height: 100%; overflow: auto; padding-right: 2px; }
.chat-sidebar details.panel summary { cursor: pointer; font-weight: 700; }
.chat-sidebar details.panel summary + * { margin-top: 12px; }
.stack { display: grid; gap: 16px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.quick-grid summary { cursor: pointer; font-weight: 700; margin-bottom: 12px; }
.quick-list { display: grid; gap: 8px; margin-bottom: 12px; }
.quick-pill { margin: 0; }
.inline-form { display: grid; gap: 10px; margin-top: 12px; }
.profile-layout { grid-template-columns: minmax(0, 1fr) 380px; }
.profile-form textarea { min-height: 120px; }
.profile-form label span { font-weight: 400; font-size: 13px; }
.chatbox { border: 1px solid var(--border); border-radius: 4px; padding: 16px; margin: 18px 0; }
.button-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.timeline, .notes { list-style: none; padding: 0; display: grid; gap: 10px; }
.timeline li, .notes li { border-left: 3px solid #111; padding: 8px 0 8px 12px; }
.notes .user { border-left-style: double; }
.notes small { display: block; color: var(--muted); margin-top: 6px; }
.notes .error { color: #8a0000; white-space: pre-wrap; }
.actions form { margin: 0; }
.compact { max-height: 420px; overflow: auto; }
time { display: block; color: var(--muted); font-size: 13px; margin-bottom: 2px; }
@keyframes toastfade {
  0% { opacity: 0; transform: translateY(-8px); }
  10% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-8px); }
}
@keyframes typingpulse {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .grid, .split, .button-row, .quick-grid { grid-template-columns: 1fr; }
  body:has(.chat-layout) { overflow: auto; }
  body:has(.chat-layout) main { height: auto; min-height: calc(100vh - 120px); }
  .chat-layout { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .chat-app { height: calc(100vh - 190px); min-height: 460px; }
  .chat-header { align-items: flex-start; flex-direction: column; }
  .chat-header form, .chat-header button { width: 100%; }
  .chat-thread { min-height: 0; padding: 16px 12px; }
  .chat-bubble { max-width: 92%; }
  .chat-composer { grid-template-columns: 1fr; }
  .chat-composer button { width: 100%; }
  .chat-sidebar { max-height: none; overflow: visible; }
  main { padding: 20px 14px 50px; }
  table { display: block; overflow-x: auto; }
  .toast { left: 14px; right: 14px; max-width: none; }
  .log-row, .med-plan { align-items: flex-start; flex-direction: column; }
  .med-plan form, .med-plan-actions { min-width: 0; width: 100%; }
  .weekday-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
