:root {
  --tblr-primary: #08766d;
  --tblr-primary-rgb: 8, 118, 109;
  --med-sidebar: #123b3a;
}

body { background: #f3f6f5; }

.med-page { min-height: 100vh; }
.med-sidebar { background: var(--med-sidebar); }
.med-sidebar .container-fluid { min-height: 100%; }
.med-sidebar .navbar-collapse { min-height: calc(100vh - 72px); }
.med-brand { display: inline-flex; gap: .75rem; align-items: center; color: #fff; font-size: .9rem; font-weight: 700; letter-spacing: .12em; text-decoration: none; }
.med-brand:hover { color: #fff; }
.med-brand-mark { display: grid; width: 2rem; height: 2rem; place-items: center; border-radius: .6rem; color: var(--med-sidebar); font-size: 1.45rem; line-height: 1; background: #8dd3c0; }
.med-sidebar .nav-link { border-radius: .5rem; }
.med-sidebar .nav-link.active { background: rgba(141, 211, 192, .14); }
.med-nav-icon { color: #8dd3c0; font-size: 1rem; text-align: center; }
.med-sidebar-account { border-top: 1px solid rgba(255, 255, 255, .1); }
.med-btn-icon { margin-right: .25rem; font-size: 1.2rem; line-height: 0; }

.med-welcome-card { overflow: hidden; border: 0; color: #fff; background: radial-gradient(circle at 80% 20%, rgba(141, 211, 192, .26), transparent 30%), linear-gradient(125deg, #123b3a, #08766d); box-shadow: 0 1rem 3rem rgba(18, 59, 58, .15); }
.med-welcome-title { max-width: 720px; margin: 0; color: #fff; font-size: clamp(1.8rem, 3.5vw, 3.2rem); line-height: 1.08; }
.med-welcome-copy { max-width: 650px; margin: 1rem 0 1.5rem; color: rgba(255, 255, 255, .75); font-size: 1rem; line-height: 1.65; }
.med-health-mark { position: relative; width: 10rem; height: 10rem; border: 1px solid rgba(255, 255, 255, .22); border-radius: 50%; box-shadow: 0 0 0 2rem rgba(255, 255, 255, .025), 0 0 0 4rem rgba(255, 255, 255, .018); }
.med-health-mark span { position: absolute; inset: 2.5rem 4.25rem; border-radius: .5rem; background: #9ee0ce; }
.med-health-mark span:last-child { transform: rotate(90deg); }
.med-empty-icon { display: grid; width: 4rem; height: 4rem; place-items: center; margin: auto; border-radius: 1rem; color: var(--tblr-primary); font-size: 2rem; background: rgba(var(--tblr-primary-rgb), .1); }
.med-profile-list { display: grid; gap: 1rem; margin: 0; }
.med-profile-list div { padding-bottom: 1rem; border-bottom: 1px solid var(--tblr-border-color); }
.med-profile-list div:last-child { padding-bottom: 0; border-bottom: 0; }
.med-profile-list dt { margin-bottom: .25rem; color: var(--tblr-secondary-color); font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.med-profile-list dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }
.med-booking-message:empty { display: none; }
.med-booking-message .message-card {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .85rem 1rem;
  border: 1px solid var(--tblr-border-color);
  border-left-width: 4px;
  border-radius: var(--tblr-border-radius);
}
.med-booking-message .message-card strong { display: block; margin-bottom: .15rem; font-size: .9rem; }
.med-booking-message .message-card span { display: block; font-size: .85rem; opacity: .92; }
.med-booking-message .message-card::before {
  content: "!";
  flex: 0 0 auto;
  display: grid;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: .05rem;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
  background: var(--tblr-secondary-color);
}
.med-booking-message .message-card.notice {
  color: var(--tblr-success-text-emphasis);
  background: var(--tblr-success-lt);
  border-color: rgba(var(--tblr-success-rgb), .4);
  border-left-color: var(--tblr-success);
}
.med-booking-message .message-card.notice::before { content: "\2713"; background: var(--tblr-success); }
.med-booking-message .message-card.error {
  color: var(--tblr-danger-text-emphasis);
  background: var(--tblr-danger-lt);
  border-color: rgba(var(--tblr-danger-rgb), .4);
  border-left-color: var(--tblr-danger);
}
.med-booking-message .message-card.error::before { content: "!"; background: var(--tblr-danger); }

/* Toast popup for htmx 4xx/5xx responses */
.app-toast {
  position: fixed;
  z-index: 2000;
  right: 1.25rem;
  bottom: 1.25rem;
  max-width: 24rem;
  padding: .8rem 1rem .8rem 2.7rem;
  color: var(--tblr-danger-text-emphasis);
  background: var(--tblr-danger-lt);
  border: 1px solid rgba(var(--tblr-danger-rgb), .45);
  border-left: 4px solid var(--tblr-danger);
  border-radius: var(--tblr-border-radius);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
  font-size: .88rem;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(.4rem);
  transition: opacity .2s ease, transform .2s ease;
}
.app-toast::before {
  content: "!";
  position: absolute;
  left: .9rem;
  top: .8rem;
  display: grid;
  width: 1.2rem;
  height: 1.2rem;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  background: var(--tblr-danger);
}
.app-toast.show { opacity: 1; transform: translateY(0); }

/* Red outline on invalid form fields after a failed request */
.form-control.is-invalid {
  border-color: var(--tblr-danger);
  box-shadow: 0 0 0 .15rem rgba(var(--tblr-danger-rgb), .15);
}

@media (min-width: 992px) {
  .med-sidebar { width: 16rem; }
}

@media (max-width: 991.98px) {
  .med-sidebar .container-fluid { min-height: auto; }
  .med-sidebar .navbar-collapse { display: none !important; min-height: 0; }
}

@media (max-width: 575.98px) {
  .page-header .col-auto { width: 100%; margin-top: .75rem; }
  .page-header .col-auto .btn { width: 100%; }
  .med-welcome-card .card-body { padding: 1.5rem !important; }
  .med-welcome-title { font-size: 1.8rem; }
  .table-responsive .table { min-width: 650px; }
}

/* --- Schedule day cards --- */
.med-day-card { position: relative; display: flex; flex-direction: column; min-width: 7rem; border: 2px solid transparent; border-radius: .75rem; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.med-day-card.is-workday { background: #d1f5e3; border-color: #6cd9a8; }
.med-day-card.is-off { background: #fde8e8; border-color: #f0a0a0; }
.med-day-card.is-open { border-color: var(--tblr-primary); box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.med-day-toggle { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .75rem 1rem; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: .85rem; }
.med-day-card.is-workday .med-day-toggle { color: #0a6640; }
.med-day-card.is-off .med-day-toggle { color: #6b2020; }
.med-day-status { font-size: .75rem; font-weight: 400; opacity: .8; }
.med-day-editor { padding: .75rem; border-top: 1px solid rgba(0,0,0,.08); background: #fff; }
.med-day-time-input { margin-top: .5rem; width: 100%; }

/* --- Queue patient buttons --- */
.med-queue-grid { display: flex; flex-wrap: wrap; gap: .75rem; padding: 1.25rem; }
.med-patient-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem; min-width: 6.5rem; padding: .7rem .9rem; border: 2px solid transparent; border-radius: .75rem; cursor: pointer; font-size: .82rem; font-weight: 600; transition: background .15s, border-color .15s; }
.med-patient-btn.waiting   { color: #1a3a6b; background: #dbeafe; border-color: #93c5fd; }
.med-patient-btn.present   { color: #0a6640; background: #d1f5e3; border-color: #6cd9a8; }
.med-patient-btn.done      { color: #4b5563; background: #f3f4f6; border-color: #d1d5db; }
.med-patient-btn.absent    { color: #6b2020; background: #fde8e8; border-color: #f0a0a0; }
.med-patient-serial { font-size: 1.05rem; font-weight: 700; }
.med-patient-name   { font-size: .72rem; font-weight: 400; max-width: 6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Appointment timeline --- */
.med-timeline { padding: .25rem 0 1rem; }
.med-timeline-track { position: relative; height: 3.4rem; margin: 0 .25rem; border-bottom: 2px solid var(--tblr-border-color); }
.med-timeline-slot { position: absolute; top: .25rem; bottom: .25rem; width: 2.6rem; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; border-radius: .5rem; font-size: .68rem; font-weight: 600; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.med-timeline-slot.waiting { color: #1a3a6b; background: #dbeafe; border: 1px solid #93c5fd; }
.med-timeline-slot.present { color: #0a6640; background: #d1f5e3; border: 1px solid #6cd9a8; }
.med-timeline-slot.done    { color: #4b5563; background: #f3f4f6; border: 1px solid #d1d5db; }
.med-timeline-slot.absent  { color: #6b2020; background: #fde8e8; border: 1px solid #f0a0a0; }
.med-timeline-serial { font-size: .78rem; font-weight: 700; line-height: 1; }
.med-timeline-time { font-size: .62rem; font-weight: 400; opacity: .8; line-height: 1; }
.med-timeline-now { position: absolute; top: -.35rem; bottom: -.35rem; width: 2px; background: var(--tblr-primary); z-index: 5; }
.med-timeline-now::before { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid var(--tblr-primary); }
.med-timeline-scale { display: flex; justify-content: space-between; margin: .35rem .25rem 0; font-size: .62rem; color: var(--tblr-secondary-color); }

/* Action popover (pure CSS <details> based) */
.med-action-popover { position: absolute; top: calc(100% + .4rem); left: 50%; transform: translateX(-50%); z-index: 100; min-width: 9rem; padding: .4rem 0; background: #fff; border: 1px solid var(--tblr-border-color); border-radius: .6rem; box-shadow: 0 4px 16px rgba(0,0,0,.12); white-space: nowrap; }
.med-action-popover button { display: block; width: 100%; padding: .45rem 1rem; border: 0; background: none; text-align: left; font-size: .82rem; cursor: pointer; }
.med-action-popover button:hover { background: var(--tblr-light); }
.med-patient-wrap { position: relative; }
.med-patient-wrap details[open] .med-patient-btn { border-color: var(--tblr-primary); }
.med-patient-wrap details summary { list-style: none; }
.med-patient-wrap details summary::-webkit-details-marker { display: none; }
 .phone-input { display: grid; grid-template-columns: auto 1fr; align-items: center; border: 1px solid var(--tblr-border-color, #d9e1e7); border-radius: 4px; background: var(--tblr-bg-forms, #fff); overflow: hidden; }
 .phone-input:focus-within { border-color: var(--tblr-primary, #206bc4); box-shadow: 0 0 0 2px rgba(32,107,196,.12); }
 .phone-input select { min-height: 2.25rem; padding: 0 .65rem; border: 0; border-right: 1px solid var(--tblr-border-color, #d9e1e7); border-radius: 0; background: transparent; }
 .phone-input input[data-phone-local] { border: 0; box-shadow: none; }
