:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #17212b;
  background: #f3f6f8;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: #075d56; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 5vw; background: #fff; border-bottom: 1px solid #dfe6e9; }
.brand { color: #123b38; font-weight: 750; font-size: 1.15rem; text-decoration: none; }
.brand span { color: #087c70; }
nav { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; }
nav a, .nav-button { color: #29444a; text-decoration: none; font-size: .94rem; }
.nav-button { border: 0; background: none; cursor: pointer; padding: 0; }
.page { width: min(1120px, 94vw); margin: 1.5rem auto; flex: 1; }
.site-footer { padding: 1rem 5vw; color: #667780; border-top: 1px solid #dfe6e9; font-size: .85rem; text-align: center; }
.panel, .card { background: #fff; border: 1px solid #dfe6e9; border-radius: .75rem; box-shadow: 0 3px 14px #183d4410; overflow: hidden; }
.panel { padding: 1.4rem; }
.card-header, .card-footer { padding: .9rem 1.1rem; background: #f8fafb; border-bottom: 1px solid #e4eaed; }
.card-footer { border: 0; border-top: 1px solid #e4eaed; }
.card-body { padding: 1.1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 1rem; }
.grid-wide { grid-column: 1 / -1; }
h1 { margin-top: 0; font-size: clamp(1.45rem, 3vw, 2rem); }
h2 { font-size: 1.15rem; }
p { line-height: 1.55; }
label { display: block; font-weight: 600; margin: .8rem 0 .35rem; }
input, select, textarea { width: 100%; padding: .68rem .75rem; font: inherit; border: 1px solid #bdc9ce; border-radius: .45rem; background: #fff; }
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }
.form-text, .muted, small { color: #667780; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid #087c70; border-radius: .45rem; padding: .62rem .9rem; font: inherit; font-weight: 650; color: #fff; background: #087c70; text-decoration: none; cursor: pointer; }
.btn:hover { background: #06665d; }
.btn-secondary { background: #fff; color: #24434a; border-color: #b7c5ca; }
.btn-danger { background: #a43030; border-color: #a43030; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.inline-form { display: inline; }
.alert { padding: .85rem 1rem; border-radius: .5rem; margin: 0 0 .75rem; background: #eef4f7; border: 1px solid #cbd9df; }
.alert-success { background: #e8f6ee; border-color: #a9ddbd; }
.alert-danger { background: #fff0ef; border-color: #edb6b1; }
.alert-warning { background: #fff8e6; border-color: #eed58a; }
.alert-info { background: #edf5fb; border-color: #bad8ec; }
.flash-list { margin-bottom: 1rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { padding: .72rem; text-align: left; vertical-align: top; border-bottom: 1px solid #e4eaed; }
th { background: #f7f9fa; font-size: .86rem; }
.badge { display: inline-block; padding: .24rem .48rem; border-radius: 2rem; background: #e7eef0; font-size: .8rem; }
.badge-success { color: #14542f; background: #e1f4e8; }
.badge-warning { color: #684f0a; background: #fff3cc; }
.badge-danger { color: #702b2b; background: #ffe4e1; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 1rem; }
video { display: block; width: 100%; min-height: 220px; background: #15252b; border-radius: .5rem; }
.chat-log { min-height: 150px; max-height: 320px; overflow-y: auto; padding: .7rem; border: 1px solid #dfe6e9; border-radius: .5rem; display: flex; flex-direction: column; }
.chat-message { width: fit-content; max-width: min(84%, 720px); align-self: flex-start; padding: .65rem .75rem; margin: .35rem 0; border-radius: .75rem .75rem .75rem .2rem; background: #f1f5f6; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message.mine { background: #e7f5f1; }
.chat-message.mine { align-self: flex-end; border-radius: .75rem .75rem .2rem .75rem; }
.chat-message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message-footer { display: flex; justify-content: flex-start; align-items: center; gap: .45rem; margin-top: .35rem; color: #667780; font-size: .75rem; }
.chat-message.mine .chat-message-footer { justify-content: flex-end; }
.message-status { font-weight: 750; letter-spacing: -.08em; color: #738087; white-space: nowrap; }
.message-status.read { color: #168bd2; }
.message-status.failed { color: #a43030; letter-spacing: normal; }
.message-retry { padding: 0; border: 0; color: #a43030; background: transparent; font: inherit; font-size: .75rem; text-decoration: underline; cursor: pointer; }
.message-retry:disabled { opacity: .6; cursor: wait; }
.chat-message-attachment { display: grid; gap: .35rem; margin: .45rem 0; }
.chat-message-attachment img { display: block; max-width: min(100%, 360px); max-height: 300px; border-radius: .5rem; object-fit: contain; }
.chat-message-attachment a { overflow-wrap: anywhere; }
.chat-attachment-meta { color: #667780; font-size: .78rem; }
.conversation-presence { min-height: 1.2em; color: #667780; font-size: .85rem; }
.conversation-presence.online { color: #177547; }
.conversation-presence.activity { color: #087c70; }
.voice-note-entry { min-width: min(84%, 320px); }
.voice-note-player audio { display: block; width: min(100%, 320px); margin-top: .35rem; }
.voice-note-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-top: .65rem; }
.voice-note-controls .form-text { margin: 0; }
.voice-note-review { display: grid; gap: .6rem; margin-top: .75rem; padding: .75rem; border: 1px solid #dfe6e9; border-radius: .5rem; background: #f8fafb; }
.voice-note-review audio { display: block; width: min(100%, 420px); }
.text-right { text-align: right; }
.hidden { display: none !important; }
.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1rem; }
.messaging-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: stretch; gap: 0; min-height: 520px; }
.messaging-sidebar { min-width: 0; border-right: 1px solid #dfe6e9; }
.messaging-sidebar-body { max-height: 70vh; overflow-y: auto; }
.messaging-panel { min-width: 0; min-height: 520px; }
.conversation-empty { display: grid; min-height: 520px; place-items: center; padding: 2rem; color: #667780; text-align: center; }
.conversation-empty p { max-width: 22rem; }
.conversation-content { min-width: 0; }
.messaging-panel .card-body { display: flex; min-height: 0; flex-direction: column; }
.messaging-compose { flex-wrap: nowrap; align-items: flex-end; gap: .45rem; }
.messaging-compose textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 180px; padding: .65rem .75rem; line-height: 1.35; resize: none; overflow-y: hidden; }
.messaging-icon-button { display: grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; padding: .5rem; border: 1px solid #b7c5ca; border-radius: 50%; color: #24434a; background: #fff; cursor: pointer; }
.messaging-icon-button:hover { border-color: #087c70; color: #075d56; background: #eff8f6; }
.messaging-icon-button:disabled { opacity: .5; cursor: not-allowed; }
.messaging-icon-button svg, .messaging-back-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.send-icon-button { border-color: #087c70; color: #fff; background: #087c70; }
.send-icon-button:hover { color: #fff; background: #06665d; }
.conversation-heading { display: flex; align-items: center; gap: .65rem; }
.messaging-back-button { display: none; flex: 0 0 40px; width: 40px; height: 40px; place-items: center; padding: .5rem; border: 1px solid #b7c5ca; border-radius: 50%; color: #24434a; background: #fff; cursor: pointer; }
.recipient-section { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid #e4eaed; }
.recipient-section > strong { display: block; }
.messaging-list { display: grid; gap: .45rem; margin-top: .75rem; }
.messaging-item { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: .5rem; padding: .65rem; border: 1px solid #dfe6e9; border-radius: .45rem; color: #17212b; background: #fff; text-align: left; cursor: pointer; }
.messaging-item:hover, .messaging-item[aria-current="true"] { border-color: #087c70; background: #eff8f6; }
.messaging-item:disabled { color: #667780; background: #f7f9fa; cursor: not-allowed; }
.messaging-item small { display: block; }
.messaging-group { margin: .55rem 0; border: 1px solid #e4eaed; border-radius: .5rem; }
.messaging-group summary { padding: .65rem; font-weight: 650; cursor: pointer; }
.messaging-group-content { display: grid; gap: .4rem; padding: 0 .55rem .55rem; }
.messaging-chat-log { min-height: 280px; max-height: 52vh; }
.messaging-compose { margin-top: .75rem; }
.messaging-compose input { flex: 1; min-width: 120px; }
.appointment-access-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; padding: .3rem 0 .55rem; }
.appointment-access-controls select { min-width: 0; padding: .4rem; }
.call-panel { border-top: 1px solid #e4eaed; padding: 1rem; }
.call-panel video { min-height: 160px; }
.call-overlay { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 1rem; background: #102327b8; }
.call-dialog { width: min(460px, 100%); max-height: min(90vh, 760px); overflow-y: auto; padding: clamp(1.25rem, 5vw, 2rem); border: 1px solid #dfe6e9; border-radius: 1rem; background: #fff; box-shadow: 0 1.5rem 5rem #0005; text-align: center; }
.call-avatar { display: grid; width: 5rem; height: 5rem; place-items: center; margin: 0 auto 1rem; border-radius: 50%; color: #fff; background: #087c70; font-size: 1.5rem; font-weight: 750; }
.call-direction { margin: 0; color: #667780; }
.call-status { min-height: 1.5em; margin: .65rem 0; }
.call-duration { font-variant-numeric: tabular-nums; font-weight: 700; }
.call-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.btn-success { color: #fff; background: #177547; border-color: #177547; }
.btn-success:hover { background: #125f3a; }
.call-audio-help { display: grid; gap: .6rem; justify-items: center; margin: 1rem 0; padding: .8rem; border: 1px solid #eed58a; border-radius: .5rem; background: #fff8e6; }
.call-overlay .video-grid { margin-top: 1rem; text-align: left; }
.call-overlay video { min-height: 130px; max-height: 28vh; }
#remote-audio { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
@media (max-width: 720px) { .site-header { align-items: flex-start; flex-direction: column; } nav { gap: .7rem; } .two-column { grid-template-columns: 1fr; } }
@media (max-width: 850px) {
  .messaging-layout { grid-template-columns: 1fr; }
  .messaging-sidebar { border-right: 0; border-bottom: 1px solid #dfe6e9; }
  .messaging-sidebar-body { max-height: 38vh; }
  .messaging-panel { display: none; min-height: 420px; }
  .messaging-layout.mobile-chat-open .messaging-sidebar { display: none; }
  .messaging-layout.mobile-chat-open .messaging-panel { display: block; }
  .messaging-back-button { display: grid; }
  .conversation-empty { min-height: 420px; }
  .messaging-chat-log { max-height: 45vh; }
}
