:root {
  --ink: #17312e; --muted: #69817d; --primary: #0c6b61; --primary-dark: #075149;
  --mint: #e8f5f1; --line: #dce9e6; --paper: #ffffff; --canvas: #f2f8f6;
  --danger: #b84242; --danger-soft: #fff0ef; --shadow: 0 24px 70px rgba(16, 77, 69, .12);
  font-family: Tahoma, Arial, sans-serif; color: var(--ink); background: var(--canvas);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
input, select { width: 100%; min-height: 46px; border: 1px solid #cbdeda; border-radius: 10px; background: #fff; color: var(--ink); padding: 0 13px; outline: none; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(12, 107, 97, .1); }
label { display: block; font-size: .9rem; font-weight: 700; margin: 16px 0 7px; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: .76rem; font-weight: 800; letter-spacing: .04em; }
.brand-mark { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 24px 8px 24px 8px; color: #fff; background: var(--primary); font-size: 1.5rem; font-weight: 800; box-shadow: 0 14px 30px rgba(12, 107, 97, .25); overflow: hidden; }
.brand-mark img { width: 88%; height: 88%; object-fit: contain; display: block; }
.brand-mark.small { width: 46px; height: 46px; border-radius: 14px 5px 14px 5px; font-size: 1rem; box-shadow: none; flex: 0 0 auto; }
.booking-page { background: radial-gradient(circle at 8% 5%, #d8efe8 0, transparent 31%), var(--canvas); }
.booking-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, .85fr) minmax(420px, 1.15fr); max-width: 1180px; margin: auto; padding: 48px; align-items: center; gap: clamp(44px, 8vw, 110px); }
.brand-panel { align-self: stretch; min-height: 590px; border-radius: 32px; padding: 54px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: linear-gradient(155deg, #0f766b, #084b45); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.brand-panel::after { content: "+"; position: absolute; left: -18px; bottom: -50px; font-size: 20rem; line-height: 1; color: rgba(255,255,255,.06); font-weight: 300; }
.brand-panel .brand-mark { background: rgba(255,255,255,.14); box-shadow: none; backdrop-filter: blur(8px); }
.brand-panel .eyebrow { color: #aee2d8; margin-top: auto; padding-top: 38px; }
.brand-panel h1 { margin: 0; font-size: clamp(2.1rem, 4vw, 3.5rem); line-height: 1.25; letter-spacing: -.04em; }
.brand-note { max-width: 380px; color: #d9efeb; line-height: 1.9; font-size: 1rem; }
.clinic-promise { position: relative; z-index: 1; border-top: 1px solid rgba(255,255,255,.16); padding-top: 24px; font-size: .92rem; }
.clinic-promise span { color: #8ee2b8; font-size: .8rem; margin-left: 7px; }
.clinic-promise.closed span { color: #ffb5ad; }
.booking-card { background: var(--paper); border: 1px solid rgba(12,107,97,.09); padding: clamp(28px, 5vw, 54px); border-radius: 28px; box-shadow: var(--shadow); }
.card-heading h2, .success-view h2 { margin: 0 0 10px; font-size: 1.75rem; }
.card-heading > p:last-child { margin: 0; color: var(--muted); line-height: 1.7; }
.primary-button, .secondary-button { width: 100%; min-height: 50px; border: 0; border-radius: 11px; font-weight: 800; margin-top: 22px; }
.primary-button { background: var(--primary); color: #fff; display: flex; justify-content: center; align-items: center; gap: 10px; box-shadow: 0 9px 22px rgba(12,107,97,.22); }
.primary-button:hover { background: var(--primary-dark); }
.button-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.17); }
.secondary-button { background: var(--mint); color: var(--primary); }
.privacy-note { text-align: center; font-size: .75rem; color: var(--muted); margin: 17px 0 0; }
.chat-booking-link { display: flex; min-height: 46px; align-items: center; justify-content: center; margin-top: 12px; border: 1px solid #88cdb4; border-radius: 11px; background: #effbf6; color: #08724f; text-decoration: none; font-weight: 800; }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 9px; padding: 11px 13px; margin: 14px 0 0; font-size: .86rem; }
.patients-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.patients-heading label { margin: 0; }
.patients-heading span { color: var(--muted); font-size: .74rem; }
.patients-list { display: grid; gap: 10px; margin-top: 9px; }
.patient-row { border: 1px solid var(--line); border-radius: 12px; background: #fbfdfc; padding: 11px; }
.patient-row-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; color: var(--muted); font-size: .77rem; font-weight: 700; }
.patient-row input { background: #fff; }
.remove-patient { border: 0; background: transparent; color: var(--danger); font-size: .75rem; font-weight: 700; padding: 2px 6px; }
.add-patient-button { width: 100%; min-height: 42px; margin-top: 10px; border: 1px dashed #9fc9c1; border-radius: 10px; background: #f4faf8; color: var(--primary); font-weight: 800; }
.add-patient-button:hover { background: var(--mint); }
.add-patient-button:disabled { cursor: default; opacity: .55; }
.success-view { text-align: center; padding: 28px 0 10px; }
.success-icon { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 20px; background: var(--mint); border-radius: 50%; color: var(--primary); font-size: 1.8rem; }
.tickets-list { display: grid; gap: 10px; margin: 20px 0; }
.ticket-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 14px; text-align: right; padding: 13px 15px; border-radius: 13px; background: #f4faf8; border: 1px solid var(--line); }
.ticket-item span { font-weight: 800; }
.ticket-item strong { grid-row: span 2; min-width: 54px; text-align: center; font-size: 2.15rem; color: var(--primary); }
.ticket-item small { color: var(--muted); }
.success-message { color: var(--muted); line-height: 1.8; max-width: 430px; margin: 0 auto; }
.healing-note { margin-top: 24px; padding: 15px; border-radius: 12px; background: #f4faf8; font-weight: 800; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0, #d4ece6, transparent 38%); }
.login-card { width: min(100%, 410px); background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 38px; box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 25px; }
.login-card h1 { margin: 0 0 25px; font-size: 1.7rem; }
.admin-page { background: #f6faf9; }
.dashboard { min-height: 100vh; }
.admin-header { height: 72px; padding: 0 clamp(18px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); }
.header-identity { display: flex; align-items: center; gap: 13px; }
.header-identity h1 { margin: 0; font-size: 1.12rem; }
.header-identity .eyebrow { margin-bottom: 2px; }
.ghost-button, .compact-button, .load-more { min-height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 0 14px; font-weight: 700; }
.toolbar { min-height: 62px; padding: 8px clamp(18px, 4vw, 56px); background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.today-label { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--mint); }
.limit-form { display: flex; align-items: center; gap: 8px; }
.toolbar-actions { display: flex; align-items: center; gap: 9px; }
.limit-form label { margin: 0; font-size: .82rem; white-space: nowrap; color: var(--muted); }
.limit-form input { width: 78px; min-height: 36px; }
.compact-button { background: var(--primary); color: #fff; border-color: var(--primary); }
.close-day-button { min-height: 36px; border: 1px solid #e6b9b4; border-radius: 8px; padding: 0 14px; background: var(--danger-soft); color: var(--danger); font-weight: 800; }
.close-day-button:disabled { border-color: var(--line); background: #f3f6f5; color: var(--muted); cursor: default; }
.stats { padding: 22px clamp(18px, 4vw, 56px); display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stats article { min-height: 94px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; justify-content: space-between; align-items: center; }
.stats span { color: var(--muted); font-size: .86rem; }
.stats strong { font-size: 1.85rem; color: var(--primary); }
.tabs { padding: 0 clamp(18px, 4vw, 56px); display: flex; gap: 5px; border-bottom: 1px solid var(--line); overflow-x: auto; background: #fff; }
.tabs button { min-height: 50px; border: 0; background: none; color: var(--muted); padding: 0 18px; font-weight: 800; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tabs span { display: inline-grid; place-items: center; min-width: 23px; height: 23px; border-radius: 999px; background: #edf4f2; font-size: .72rem; margin-right: 5px; }
.records-panel { margin: 20px clamp(18px, 4vw, 56px) 50px; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.archives-panel { margin: 20px clamp(18px, 4vw, 56px) 50px; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.whatsapp-panel { margin: 20px clamp(18px, 4vw, 56px) 50px; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.whatsapp-content { display: grid; grid-template-columns: minmax(250px,360px) minmax(300px,1fr); gap: 28px; padding: 28px; align-items: center; }
.whatsapp-qr-box { min-height: 300px; border: 1px dashed #9fc9c1; border-radius: 16px; background: #f7fbfa; display: grid; place-items: center; padding: 18px; color: var(--muted); text-align: center; }
.whatsapp-qr-box img { width: min(100%,320px); height: auto; display: block; }
.whatsapp-details h3 { margin: 13px 0 8px; }
.whatsapp-details p { color: var(--muted); line-height: 1.8; }
.status-chip { display: inline-flex; min-height: 28px; align-items: center; padding: 0 10px; border-radius: 999px; background: #fff2dc; color: #8a5a0b; font-size: .76rem; font-weight: 800; }
.status-chip.connected { background: #e5f8ee; color: #08724f; }
.message-template { margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfc; }
.message-template strong { display: block; margin-bottom: 8px; }
.message-template code { display: block; direction: rtl; white-space: normal; line-height: 1.9; color: var(--ink); font-family: Tahoma,Arial,sans-serif; }
.warning-note { font-size: .77rem; }
.whatsapp-inbox { border-top: 1px solid var(--line); }
.chat-feed { display: grid; gap: 12px; padding: 18px; background: #f5faf8; min-height: 220px; }
.chat-message { width: min(720px,92%); margin-right: auto; padding: 13px 15px; border-radius: 15px 15px 4px 15px; background: #fff; border: 1px solid var(--line); box-shadow: 0 5px 18px rgba(16,77,69,.05); }
.chat-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .72rem; }
.chat-message p { margin: 10px 0; white-space: pre-wrap; line-height: 1.7; }
.chat-result { border-top: 1px solid var(--line); padding-top: 8px; color: var(--danger); font-size: .78rem; font-weight: 800; }
.chat-result.ok { color: var(--primary); }
.chat-booking-page { background: linear-gradient(160deg,#dcefe9,#f6faf9 42%,#edf7f4); padding: 18px; }
.patient-chat-shell { width: min(100%,720px); min-height: calc(100vh - 36px); margin: auto; display: grid; grid-template-rows: auto 1fr auto; background: #eef6f3; border: 1px solid #cfe2dd; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.patient-chat-header { min-height: 72px; padding: 10px 16px; display: flex; align-items: center; gap: 12px; color: #fff; background: var(--primary); }
.patient-chat-header > div:nth-child(2) { display: grid; gap: 4px; flex: 1; }
.patient-chat-header strong { font-size: .94rem; }
.patient-chat-header span { font-size: .72rem; color: #d5eee8; }
.patient-chat-header i { display: inline-block; width: 7px; height: 7px; margin-left: 5px; border-radius: 50%; background: #8ee2b8; }
.patient-chat-header a { color: #fff; text-decoration: none; font-size: .78rem; font-weight: 800; }
.patient-chat-feed { display: flex; flex-direction: column; gap: 12px; padding: 22px; background-color: #eef6f3; background-image: radial-gradient(rgba(12,107,97,.06) 1px,transparent 1px); background-size: 18px 18px; }
.system-bubble,.patient-bubble,.chat-form-bubble { max-width: 86%; padding: 13px 15px; border: 1px solid var(--line); box-shadow: 0 5px 18px rgba(16,77,69,.06); }
.system-bubble { align-self: flex-start; background: #fff; border-radius: 16px 16px 16px 4px; }
.system-bubble span { color: var(--primary); font-size: .7rem; font-weight: 800; }
.system-bubble p,.patient-bubble p { margin: 6px 0 0; line-height: 1.8; }
.patient-bubble { align-self: flex-end; background: #d9f5e9; border-radius: 16px 16px 4px 16px; }
.chat-form-bubble { width: min(92%,480px); align-self: flex-end; background: #fff; border-radius: 16px 16px 4px 16px; }
.chat-form-bubble label { margin-top: 11px; }
.chat-form-bubble label:first-child { margin-top: 0; }
.chat-send-button { width: 100%; min-height: 46px; margin-top: 16px; border: 0; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 800; }
.chat-send-button span { margin-right: 8px; }
.success-reply strong { color: var(--primary); font-size: 1.08rem; }
.patient-chat-footer { padding: 11px; text-align: center; background: #fff; color: var(--muted); font-size: .7rem; border-top: 1px solid var(--line); }
.records-heading { min-height: 58px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.records-heading h2 { margin: 0; font-size: 1rem; }
.records-heading span { color: var(--muted); font-size: .8rem; }
.back-button { min-height: 32px; border: 1px solid var(--line); background: #fff; color: var(--primary); border-radius: 8px; padding: 0 11px; font-weight: 800; }
.archive-list { display: grid; gap: 10px; padding: 15px; }
.archive-day { display: grid; grid-template-columns: minmax(150px,1.2fr) repeat(4,minmax(70px,.65fr)) auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; }
.archive-day strong { color: var(--ink); }
.archive-day span { color: var(--muted); font-size: .78rem; }
.archive-day button { min-height: 34px; border: 0; border-radius: 8px; background: var(--mint); color: var(--primary); padding: 0 12px; font-weight: 800; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 850px; }
th, td { text-align: right; padding: 13px 16px; border-bottom: 1px solid #edf3f1; font-size: .84rem; vertical-align: middle; }
th { color: var(--muted); font-size: .75rem; background: #fbfdfc; }
tbody tr:hover { background: #fbfdfc; }
td a { color: var(--ink); text-decoration: none; }
.number-pill { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px; background: var(--mint); color: var(--primary); }
.row-actions { display: flex; gap: 6px; align-items: center; }
.row-actions select { width: 108px; min-height: 34px; font-size: .78rem; padding: 0 8px; }
.row-actions button, .promote-button { min-height: 34px; border: 0; border-radius: 7px; padding: 0 11px; font-weight: 800; font-size: .78rem; }
.done-button, .promote-button { color: #fff; background: var(--primary); }
.cancel-button { color: var(--danger); background: var(--danger-soft); }
.muted { color: var(--muted); }
.empty-state { min-height: 240px; display: flex; flex-direction: column; justify-content: center; align-items: center; color: var(--muted); gap: 7px; }
.empty-state strong { color: var(--ink); }
.load-more { display: block; margin: 15px auto; }
.toast { position: fixed; left: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 48px)); padding: 13px 18px; border-radius: 10px; color: #fff; background: #17312e; box-shadow: var(--shadow); z-index: 20; }

@media (max-width: 850px) {
  .booking-shell { grid-template-columns: 1fr; padding: 22px; gap: 18px; }
  .brand-panel { min-height: auto; padding: 28px; border-radius: 24px; gap: 24px; }
  .brand-panel .eyebrow { padding-top: 0; }
  .brand-panel h1 { font-size: 2.1rem; }
  .clinic-promise, .brand-note { margin: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .chat-booking-page { padding: 0; }
  .patient-chat-shell { min-height: 100vh; border: 0; border-radius: 0; }
  .patient-chat-feed { padding: 16px 12px; }
  .system-bubble,.patient-bubble,.chat-form-bubble { max-width: 94%; }
  .booking-shell { padding: 0; display: block; }
  .brand-panel { border-radius: 0 0 28px 28px; padding: 24px 22px 34px; box-shadow: none; }
  .brand-panel .brand-mark { width: 54px; height: 54px; border-radius: 16px 6px 16px 6px; }
  .brand-panel h1 { font-size: 1.85rem; }
  .brand-note { font-size: .9rem; }
  .clinic-promise { display: none; }
  .booking-card { margin: -14px 14px 24px; position: relative; border-radius: 20px; padding: 26px 20px; box-shadow: 0 14px 44px rgba(16,77,69,.12); }
  .admin-header { height: 64px; padding: 0 14px; }
  .header-identity h1 { font-size: .93rem; }
  .header-identity .eyebrow, .admin-header .brand-mark { display: none; }
  .ghost-button { padding: 0 10px; font-size: .76rem; }
  .toolbar { align-items: flex-start; flex-direction: column; padding: 12px 14px; }
  .limit-form { width: 100%; }
  .toolbar-actions { width: 100%; display: grid; grid-template-columns: 1fr auto; }
  .limit-form label { flex: 1; }
  .stats { padding: 14px; gap: 8px; }
  .stats article { min-height: 72px; padding: 13px; }
  .stats strong { font-size: 1.45rem; }
  .tabs { padding: 0 8px; }
  .tabs { overflow-x: auto; }
  .tabs button { padding: 0 3px; font-size: .76rem; }
  .tabs span { min-width: 20px; height: 20px; margin-right: 2px; }
  .records-panel { margin: 14px 10px 40px; }
  .archives-panel { margin: 14px 10px 40px; }
  .whatsapp-panel { margin: 14px 10px 40px; }
  .whatsapp-content { grid-template-columns: 1fr; padding: 16px; gap: 18px; }
  .whatsapp-qr-box { min-height: 250px; }
  .archive-day { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .archive-day strong, .archive-day button { grid-column: 1 / -1; }
  .table-wrap { overflow: visible; }
  table, tbody { display: block; min-width: 0; }
  thead { display: none; }
  tr { display: block; border-bottom: 8px solid var(--canvas); padding: 10px 14px; }
  td { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 8px 0; border: 0; text-align: left; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .75rem; }
  .row-actions { flex-wrap: wrap; justify-content: flex-end; }
  .row-actions select { width: 116px; }
  .toast { left: 14px; bottom: 14px; }
}
