:root {
  --bg0: #07121c;
  --bg1: #0c1c2a;
  --bg2: #122636;
  --panel: rgba(14, 32, 48, 0.82);
  --line: rgba(148, 196, 214, 0.16);
  --text: #e8f2f6;
  --muted: #8eacba;
  --brand: #2ec4b6;
  --brand-deep: #1a8f86;
  --accent: #f0b429;
  --danger: #f07167;
  --ok: #3dd68c;
  --user-bubble: linear-gradient(135deg, #1a8f86, #147a72);
  --bot-bubble: rgba(255, 255, 255, 0.06);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Outfit", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(46, 196, 182, 0.22), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(240, 180, 41, 0.12), transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 45%, #0a1824);
}

.app {
  height: 100%;
  max-width: 1480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  padding: 16px;
  transition: grid-template-columns 0.25s ease;
}

.app.chart-open,
.app.imaging-open {
  grid-template-columns: 220px minmax(0, 1fr) 360px;
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius) 0 0 var(--radius);
  backdrop-filter: blur(16px);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: rise 0.6s ease both;
}

.brand-link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
  width: fit-content;
  border-radius: 8px;
  transition: opacity 0.15s, transform 0.15s;
}
.brand-link:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}
.brand-link:focus-visible {
  outline: 2px solid rgba(46, 196, 182, 0.55);
  outline-offset: 4px;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.brand-mark span {
  color: var(--brand);
}

.brand-tag {
  color: var(--muted);
  font-size: 0.85rem;
}

.context-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  animation: rise 0.7s ease both;
}

.context-card h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.context-empty {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.patient-active-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.patient-active-meta {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.quick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-list button {
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.quick-list button:hover {
  border-color: rgba(46, 196, 182, 0.5);
  background: rgba(46, 196, 182, 0.08);
  transform: translateX(2px);
}

.sidebar-foot {
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  background: rgba(8, 20, 30, 0.55);
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 0;
}

.chat-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.chat-header h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 550;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--ok);
  background: rgba(61, 214, 140, 0.1);
  border: 1px solid rgba(61, 214, 140, 0.25);
  border-radius: 999px;
  padding: 4px 10px;
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(61, 214, 140, 0.2);
  animation: pulse 2s ease infinite;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.msg {
  max-width: min(720px, 92%);
  animation: rise 0.35s ease both;
}

.msg.user {
  align-self: flex-end;
}

.msg.assistant {
  align-self: flex-start;
}

.bubble {
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.55;
  font-size: 0.98rem;
  white-space: pre-wrap;
}

.msg.user .bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 6px;
}

.msg.assistant .bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

.bubble strong {
  color: #fff;
  font-weight: 600;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
  text-align: left;
  color: inherit;
  font: inherit;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(46, 196, 182, 0.45);
  background: rgba(46, 196, 182, 0.08);
}

.card-type {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--brand);
  margin-bottom: 4px;
}

.card-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.card-sub {
  color: var(--muted);
  font-size: 0.86rem;
}

.card-status {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(240, 180, 41, 0.15);
  color: var(--accent);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 22px 12px;
}

.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.chip:hover {
  background: rgba(46, 196, 182, 0.12);
  border-color: rgba(46, 196, 182, 0.4);
  transform: translateY(-1px);
}

.composer {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}

.composer-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 52px;
  max-height: 140px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 14px 16px;
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.composer textarea:focus {
  border-color: rgba(46, 196, 182, 0.55);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.15);
}

.composer textarea::placeholder {
  color: rgba(142, 172, 186, 0.7);
}

.send-btn {
  border: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #062821;
  font: inherit;
  font-weight: 700;
  border-radius: 14px;
  padding: 0 20px;
  min-height: 52px;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}

.send-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.logout-link {
  color: var(--brand);
  font-size: 0.86rem;
  text-decoration: none;
}
.logout-link:hover { text-decoration: underline; }

.typing {
  display: inline-flex;
  gap: 5px;
  padding: 14px 16px;
}

.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

.error-banner {
  margin: 12px 22px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(240, 113, 103, 0.12);
  border: 1px solid rgba(240, 113, 103, 0.35);
  color: #ffc4bf;
  font-size: 0.9rem;
  display: none;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.open-chart-btn {
  margin-top: 12px;
  width: 100%;
  border: 1px solid rgba(46, 196, 182, 0.45);
  background: rgba(46, 196, 182, 0.14);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.open-chart-btn:hover {
  background: rgba(46, 196, 182, 0.22);
  transform: translateY(-1px);
}

.chart-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  backdrop-filter: blur(16px);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease both;
  min-height: 0;
}

.app.chart-open .chat-shell {
  border-radius: 0;
}

.chart-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.chart-panel-kicker {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  font-weight: 600;
}

.chart-panel-head h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 2px;
}

.chart-close {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.chart-close:hover { color: var(--text); border-color: rgba(46, 196, 182, 0.4); }

.chart-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.chart-step {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 7px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.chart-step.is-active {
  color: #062821;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  border-color: transparent;
}

.chart-step.is-done {
  color: var(--brand);
  border-color: rgba(46, 196, 182, 0.35);
}

.chart-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.chart-section h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.chart-section .hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  opacity: 0.85;
}

.cc-row {
  display: flex;
  gap: 8px;
}
.cc-row input,
#findingDetail {
  flex: 1;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.92rem;
  outline: none;
}
.cc-row input:focus,
#findingDetail:focus {
  border-color: rgba(46, 196, 182, 0.5);
}
.cc-row button {
  border: none;
  background: rgba(46, 196, 182, 0.2);
  color: var(--text);
  border-radius: 10px;
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.odontogram {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.odo-row {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 3px;
}

.odo-mid {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--muted);
  padding: 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tooth {
  aspect-ratio: 1;
  min-height: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 6px;
  font: inherit;
  font-size: 0.62rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.tooth:hover {
  border-color: rgba(46, 196, 182, 0.55);
  transform: scale(1.06);
}
.tooth.is-selected {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #062821;
  border-color: transparent;
}
.tooth.has-finding:not(.is-selected) {
  border-color: rgba(240, 180, 41, 0.55);
  box-shadow: inset 0 0 0 1px rgba(240, 180, 41, 0.25);
}

.chart-selected {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}
.chart-selected.has-tooth {
  color: var(--brand);
  font-weight: 600;
}

.linkish {
  margin-top: 6px;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.linkish:hover { color: var(--brand); }

.issue-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.issue-chip,
.sev-chip,
.surf-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 6px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.issue-chip:hover,
.sev-chip:hover,
.surf-chip:hover {
  border-color: rgba(46, 196, 182, 0.45);
  transform: translateY(-1px);
}
.issue-chip.is-selected,
.surf-chip.is-selected {
  background: rgba(46, 196, 182, 0.22);
  border-color: rgba(46, 196, 182, 0.55);
}

.sev-row,
.surf-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sev-chip { flex: 1; min-width: 64px; text-transform: capitalize; }
.sev-chip.is-selected.sev-mild { background: rgba(61, 214, 140, 0.2); border-color: rgba(61, 214, 140, 0.5); }
.sev-chip.is-selected.sev-moderate { background: rgba(240, 180, 41, 0.2); border-color: rgba(240, 180, 41, 0.5); }
.sev-chip.is-selected.sev-severe,
.sev-chip.is-selected.sev-urgent { background: rgba(240, 113, 103, 0.2); border-color: rgba(240, 113, 103, 0.5); }

.surf-chip {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

.save-finding-btn {
  margin-top: 10px;
  width: 100%;
  border: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #062821;
  font: inherit;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s, opacity 0.15s;
}
.save-finding-btn:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}
.save-finding-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chart-save-hint {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.findings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.finding-item {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.15);
}
.finding-item.sev-severe,
.finding-item.sev-urgent { border-left-color: var(--danger); }
.finding-item.sev-mild { border-left-color: var(--ok); }
.finding-item.sev-moderate { border-left-color: var(--accent); }

.finding-top {
  font-size: 0.86rem;
  margin-bottom: 2px;
}
.finding-text {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}
.finding-meta {
  margin-top: 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .app.chart-open {
    grid-template-columns: 1fr;
  }
  .chart-panel {
    border-left: 1px solid var(--line);
    border-radius: var(--radius);
    max-height: 70vh;
    order: 3;
  }
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.field-head h3 {
  margin-bottom: 0;
}

.mic-btn {
  border: 1px solid rgba(46, 196, 182, 0.4);
  background: rgba(46, 196, 182, 0.12);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.mic-btn:hover {
  background: rgba(46, 196, 182, 0.22);
}
.mic-btn.mic-primary {
  padding: 7px 12px;
}
.mic-btn.is-listening {
  background: rgba(240, 113, 103, 0.22);
  border-color: rgba(240, 113, 103, 0.55);
  box-shadow: 0 0 0 3px rgba(240, 113, 103, 0.15);
  animation: pulse 1.2s ease infinite;
}
.mic-btn.mic-unavailable {
  opacity: 0.55;
}

.voice-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: -4px 0 10px;
  line-height: 1.4;
}
.voice-hint.is-listening {
  color: var(--brand);
  font-weight: 600;
}
.voice-hint.is-error {
  color: #ffc4bf;
}

.doctor-notes-sec textarea {
  min-height: 110px;
}

.note-actions {
  margin-top: 10px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-new-appt,
.quick-list .qa-primary,
.quick-list .qa-secondary {
  border: 1px solid rgba(46, 196, 182, 0.35);
  background: rgba(46, 196, 182, 0.08);
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  box-shadow: none;
}
.header-new-appt:hover,
.quick-list .qa-primary:hover,
.quick-list .qa-secondary:hover {
  background: rgba(46, 196, 182, 0.16);
  border-color: rgba(46, 196, 182, 0.55);
  color: #b8fff6;
  filter: none;
  transform: none;
}
.header-tx {
  border-color: rgba(240, 180, 41, 0.35);
  background: rgba(240, 180, 41, 0.08);
  color: var(--accent);
}
.header-tx:hover {
  background: rgba(240, 180, 41, 0.16);
  border-color: rgba(240, 180, 41, 0.55);
  color: #ffe6a3;
}
.quick-list .qa-primary,
.quick-list .qa-secondary {
  text-align: center;
  margin-bottom: 6px;
  width: 100%;
  border-radius: 12px;
  padding: 11px 14px;
}
.quick-list .qa-secondary {
  border-color: rgba(240, 180, 41, 0.35);
  background: rgba(240, 180, 41, 0.08);
  color: var(--accent);
}
.quick-list .qa-secondary:hover {
  background: rgba(240, 180, 41, 0.16);
  border-color: rgba(240, 180, 41, 0.55);
  color: #ffe6a3;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 10, 16, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(10px);
  animation: rise 0.25s ease both;
}
.modal-backdrop[hidden] {
  display: none !important;
}

.appt-modal {
  width: min(480px, 100%);
  max-height: min(90vh, 760px);
  overflow-y: auto;
  background:
    radial-gradient(600px 280px at 0% 0%, rgba(46, 196, 182, 0.12), transparent 55%),
    linear-gradient(165deg, #102938 0%, #0a1924 55%, #08141d 100%);
  border: 1px solid rgba(148, 196, 214, 0.14);
  border-radius: 22px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
  display: flex;
  flex-direction: column;
}

.appt-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px 0;
}
.appt-modal-head h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.appt-close {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.appt-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.appt-progress {
  display: flex;
  gap: 6px;
  padding: 14px 22px 4px;
}
.appt-progress .appt-step {
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  padding: 0;
  display: block;
}
.appt-progress .appt-step.is-active,
.appt-progress .appt-step.is-done {
  background: var(--brand);
}

.appt-block {
  margin: 12px 16px 0;
  padding: 14px 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 196, 214, 0.1);
}

.appt-block-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: 12px;
}

.appt-patient-search {
  display: flex;
  gap: 8px;
}

.appt-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.appt-field span {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}
.appt-field span em {
  font-style: normal;
  opacity: 0.7;
}
.appt-field-full {
  margin-top: 12px;
}

.appt-patient-search input,
.appt-field input,
.appt-field select,
#apptReason {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 196, 214, 0.16);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
  font-size: 0.92rem;
  outline: none;
  color-scheme: dark;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.appt-field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
.appt-patient-search input:focus,
.appt-field input:focus,
.appt-field select:focus,
#apptReason:focus {
  border-color: rgba(46, 196, 182, 0.45);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.12);
}

.appt-field input[type="date"],
.appt-field input[type="time"] {
  min-height: 42px;
}
.appt-field input[type="date"]::-webkit-calendar-picker-indicator,
.appt-field input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.75);
  opacity: 0.7;
  cursor: pointer;
}

.appt-use-active {
  border: 1px solid rgba(46, 196, 182, 0.28);
  background: transparent;
  color: var(--brand);
  border-radius: 12px;
  padding: 0 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s;
}
.appt-use-active:hover {
  background: rgba(46, 196, 182, 0.1);
}

.appt-patient-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  max-height: 140px;
  overflow-y: auto;
}
.appt-patient-hit {
  text-align: left;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.appt-patient-hit:hover {
  background: rgba(46, 196, 182, 0.08);
}
.appt-patient-hit.is-selected {
  border-color: rgba(46, 196, 182, 0.4);
  background: rgba(46, 196, 182, 0.12);
}
.appt-patient-hit strong {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
}
.appt-patient-hit span {
  font-size: 0.78rem;
  color: var(--muted);
}

.appt-selected-patient {
  margin-top: 10px;
  font-size: 0.86rem;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}
.appt-selected-patient.has-patient {
  color: #b8fff6;
  background: rgba(46, 196, 182, 0.1);
  border: 1px solid rgba(46, 196, 182, 0.2);
}

.appt-when-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 0.85fr;
  gap: 10px;
  margin-top: 12px;
}

.appt-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.appt-times {
  margin-top: 12px;
  max-height: 96px;
  overflow-y: auto;
  padding-right: 2px;
}
.appt-chip {
  border: 1px solid rgba(148, 196, 214, 0.12);
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 11px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.appt-chip:hover {
  color: var(--text);
  border-color: rgba(46, 196, 182, 0.3);
}
.appt-chip.is-selected {
  background: rgba(46, 196, 182, 0.18);
  border-color: rgba(46, 196, 182, 0.45);
  color: #b8fff6;
}

.appt-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}
.appt-type {
  border: 1px solid rgba(148, 196, 214, 0.12);
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  border-radius: 12px;
  padding: 11px 6px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.appt-type:hover {
  color: var(--text);
  border-color: rgba(46, 196, 182, 0.28);
}
.appt-type.is-selected {
  background: rgba(46, 196, 182, 0.16);
  border-color: rgba(46, 196, 182, 0.45);
  color: #b8fff6;
  font-weight: 600;
}

.appt-form-error {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(240, 113, 103, 0.12);
  border: 1px solid rgba(240, 113, 103, 0.3);
  color: #ffc4bf;
  font-size: 0.86rem;
}

.appt-footer {
  padding: 16px 16px 18px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, #08141d 28%);
}

.appt-book-btn {
  width: 100%;
  border: 1px solid rgba(46, 196, 182, 0.4);
  background: rgba(46, 196, 182, 0.14);
  color: #b8fff6;
  font: inherit;
  font-weight: 600;
  font-size: 0.98rem;
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.appt-book-btn:hover:not(:disabled) {
  background: rgba(46, 196, 182, 0.24);
  border-color: rgba(46, 196, 182, 0.6);
}
.appt-book-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tx-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -4px 0 12px;
  line-height: 1.4;
}

.tx-proc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 2px;
}

.tx-proc {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  border: 1px solid rgba(148, 196, 214, 0.12);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tx-proc:hover {
  border-color: rgba(240, 180, 41, 0.35);
  background: rgba(240, 180, 41, 0.06);
}
.tx-proc.is-selected {
  border-color: rgba(240, 180, 41, 0.5);
  background: rgba(240, 180, 41, 0.12);
}
.tx-proc-code {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.tx-proc-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.3;
}
.tx-proc-fee {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.tx-add-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}
.tx-add-btn {
  border: 1px solid rgba(240, 180, 41, 0.35);
  background: rgba(240, 180, 41, 0.1);
  color: var(--accent);
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  height: 42px;
}
.tx-add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tx-add-btn:hover:not(:disabled) {
  background: rgba(240, 180, 41, 0.18);
}

.tx-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}
.tx-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(148, 196, 214, 0.1);
}
.tx-item-main {
  min-width: 0;
}
.tx-item-main strong {
  display: block;
  font-size: 0.88rem;
}
.tx-item-main span {
  font-size: 0.78rem;
  color: var(--muted);
}
.tx-item-fee {
  font-weight: 600;
  font-size: 0.86rem;
}
.tx-item-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 6px;
}
.tx-item-remove:hover {
  color: var(--danger);
}

.tx-total {
  margin-top: 12px;
  text-align: right;
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffe6a3;
}

.open-imaging-btn {
  margin-top: 8px;
}

.imaging-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.35;
}

.imaging-capture-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.imaging-capture-row .appt-field {
  width: 72px;
  margin: 0;
}

.imaging-cap-btn {
  border: 1px solid var(--line);
  background: rgba(46, 196, 182, 0.12);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.imaging-cap-btn:hover {
  background: rgba(46, 196, 182, 0.22);
  transform: translateY(-1px);
}

.imaging-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.imaging-thumb {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  font: inherit;
}

.imaging-thumb img {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: #02080e;
  filter: contrast(1.05);
}

.imaging-thumb figcaption {
  padding: 6px 8px 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.imaging-thumb strong {
  display: block;
  color: var(--text);
  font-size: 0.8rem;
  margin-bottom: 2px;
}

.card.card-image {
  background: rgba(0, 0, 0, 0.2);
}

@media (max-width: 560px) {
  .appt-when-grid,
  .appt-type-grid {
    grid-template-columns: 1fr 1fr;
  }
  .appt-when-grid .appt-field:last-child {
    grid-column: 1 / -1;
  }
  .appt-patient-search {
    flex-direction: column;
  }
  .tx-add-row {
    grid-template-columns: 1fr;
  }
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .app,
  .app.chart-open,
  .app.imaging-open {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100%;
    padding: 10px;
  }
  .sidebar {
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .chat-shell {
    border-left: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
    min-height: 70vh;
  }
  .app.chart-open .chat-shell {
    border-radius: 0;
  }
}
