.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: grid;
  place-items: center;

  background: var(--canvas, #f7f2e8);
}

.online-login-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  /* Premium gradient background */
  background: linear-gradient(135deg, #0b2942 0%, #0c3a58 35%, #0369a1 75%, #0284c7 100%);
  overflow: hidden;
}

/* Decorative orbs for depth */
.online-login-screen::before,
.online-login-screen::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  pointer-events: none;
}

.online-login-screen::before {
  width: 500px;
  height: 500px;
  background: #38bdf8;
  top: -120px;
  right: -80px;
}

.online-login-screen::after {
  width: 400px;
  height: 400px;
  background: #6366f1;
  bottom: -100px;
  left: -80px;
}

.online-login-screen.hidden {
  display: none;
}

.online-login-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: 40px 36px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255,255,255,0.15);
  backdrop-filter: blur(20px);
  animation: loginCardIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.online-login-card .brand-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 6px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.35);
}

.online-login-card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: #0f172a;
  text-align: center;
}

.online-login-card > .muted {
  text-align: center;
  color: #5b6b80;
  font-size: 13px;
  margin: 0;
}

.online-login-card .eyebrow {
  text-align: center;
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #0369a1;
  background: #e0f2fe;
  padding: 4px 12px;
  border-radius: 99px;
  width: fit-content;
  margin: 0 auto;
}

.online-login-card .field {
  display: grid;
  gap: 7px;
}

.online-login-card .field > span,
.online-login-card .field > label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.online-login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.online-login-card input:focus {
  border-color: #0369a1;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
  outline: none;
}

.online-login-card .button-primary {
  margin-top: 4px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 10px;
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

.online-login-card .button-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
}

.online-login-card .button-primary:active {
  transform: translateY(0);
}

.online-login-card button.is-loading {
  opacity: 0.65;
  cursor: wait;
}

/* Password field wrapper with toggle */
.password-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field-wrap input {
  padding-inline-end: 44px;
}

.toggle-password-btn {
  position: absolute;
  inset-inline-end: 12px;
  background: transparent;
  border: 0;
  color: #5b6b80;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.toggle-password-btn:hover {
  color: #0369a1;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.online-auth-hidden {
  visibility: hidden;
}

.online-unauthenticated .context-drawer,
.online-unauthenticated .modal {
  display: none;
}

.patient-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

.patient-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.online-logout-button {
  display: none;
  width: calc(100% - 24px);
  margin: 12px;
}

.online-authenticated .online-logout-button {
  display: block;
}

.lock-screen.hidden {
  display: none;
}

.lock-card {
  width: min(380px, calc(100% - 32px));
  padding: 32px;

  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);

  text-align: center;
}

.lock-card .brand-mark {
  margin: 0 auto 16px;
}

.lock-card h1 {
  margin: 0 0 6px;
}

.lock-card p {
  color: var(--muted);
}

.lock-card input {
  width: 100%;
  margin: 20px 0 12px;

  padding: 12px;
  text-align: center;

  letter-spacing: 6px;
  font-size: 22px;

  border: 1px solid var(--line);
  border-radius: 8px;
}

.pin-error {
  color: var(--danger) !important;
  min-height: 20px;
}
.app-locked {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}
.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 18px;
}
.calendar-day {
  display: grid;
  gap: 8px;
  min-height: 62px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.calendar-day span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calendar-day b {
  font-size: 16px;
  color: var(--ink);
}
.calendar-day:hover {
  border-color: #7dd3fc;
  background: #f0f9ff;
}
.calendar-day.active {
  background: #0369a1;
  border-color: #0369a1;
  color: #e0f2fe;
  box-shadow: 0 5px 12px rgba(2, 132, 199, 0.2);
}
.calendar-day.active b {
  color: #fff;
}
.calendar-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 11px 13px;
  margin-bottom: 14px;
  border-inline-start: 3px solid var(--primary);
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}
.calendar-summary strong {
  font-size: 22px;
  color: var(--primary);
}
.calendar-card .agenda {
  margin-top: 0;
}
.odontogram-patient-picker {
  margin-top: 10px;
  max-width: 320px;
}
.odontogram-patient-picker label {
  display: block;
  margin-bottom: 5px;
}
.odontogram-patient-picker select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
}
.patient-context-picker {
  margin: 12px 0 18px;
  max-width: 420px;
}
.patient-context-picker label {
  display: block;
  margin-bottom: 5px;
}
.patient-context-picker select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}
.patient-timeline {
  position: relative;

  display: grid;
  gap: 0;

  margin-top: 16px;
  padding-inline-start: 8px;
}

.timeline-event {
  position: relative;

  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);

  gap: 12px;

  padding-bottom: 20px;
}

.timeline-event:not(:last-child)::before {
  content: "";

  position: absolute;

  top: 42px;

  bottom: 0;

  left: 20px;

  width: 1px;

  background: var(--line);
}

.timeline-marker {
  position: relative;
  z-index: 1;

  width: 40px;
  height: 40px;

  display: grid;
  place-items: center;

  border: 1px solid var(--line);
  border-radius: 50%;

  background: var(--surface);

  font-size: 17px;
}

.timeline-content {
  min-width: 0;

  padding: 12px 14px;

  border: 1px solid var(--line);
  border-radius: 10px;

  background: var(--surface);
}

.timeline-event-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 12px;
}

.timeline-event-header strong {
  display: block;
}

.timeline-event-header small {
  display: block;

  margin-top: 4px;

  color: var(--muted);
}

.timeline-content p {
  margin: 8px 0 0;

  color: var(--muted);

  font-size: 13px;
}

.timeline-empty {
  padding: 20px 0;

  color: var(--muted);

  text-align: center;
}
@media (max-width: 700px) {
  .calendar-week {
    gap: 4px;
  }
  .calendar-day {
    min-height: 56px;
    padding: 8px 2px;
    font-size: 9px;
  }
  .calendar-day b {
    font-size: 14px;
  }
  .calendar-summary {
    margin-bottom: 10px;
  }
}
.delete-patient-button {
  color: var(--danger);
  border: 1px solid #fecaca;
  background: #fff;
}
.delete-patient-button:hover {
  background: var(--danger-bg);
  color: #991b1b;
}
/* Clinical workspace refinement */
.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  box-shadow: 0 1px 0 rgba(148, 163, 184, 0.18);
}
.main {
  max-width: 1600px;
  margin-inline: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.page-heading {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.page-heading h1 {
  font-weight: 750;
}
.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.card {
  min-width: 0;
}
.content-grid {
  align-items: start;
}
.card-heading {
  gap: 14px;
  flex-wrap: wrap;
}
.card-heading > .button {
  margin-inline-start: auto;
}
.data-table th,
.data-table td {
  vertical-align: middle;
}
.button,
.icon-button,
.nav-item,
.surface-btn,
.action-btn {
  min-height: 38px;
}
.agenda-date-controls {
  flex-wrap: wrap;
}
@media (max-width: 900px) {
  .main {
    padding: 24px 20px;
  }
  .page-heading {
    align-items: flex-start;
  }
  .page-heading h1 {
    font-size: 24px;
  }
  .content-grid {
    gap: 14px;
  }
  .card {
    padding: 18px;
  }
  .top-actions {
    width: 100%;
  }
  .top-actions .search {
    flex: 1;
    min-width: 190px;
  }
}
@media (max-width: 560px) {
  .topbar {
    padding: 12px 14px;
  }
  .brand {
    flex: 1;
  }
  .top-actions {
    justify-content: stretch;
  }
  .top-actions .button-ghost:not(#langBtn) {
    display: none;
  }
  .top-actions #langBtn {
    padding: 8px 10px;
  }
  .top-actions .icon-button {
    display: grid;
    place-items: center;
  }
  .main {
    padding: 18px 12px;
  }
  .page-heading {
    margin-bottom: 18px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .card-heading > .button {
    margin-inline-start: 0;
  }
  .form-actions {
    flex-wrap: wrap;
  }
  .form-actions .button {
    flex: 1;
  }
  .agenda-date-controls b {
    min-width: 78px;
  }
  .prescription-actions {
    width: 100%;
  }
  .prescription-actions .button {
    flex: 1;
  }
}
.agenda-date-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.agenda-date-controls b {
  font-size: 12px;
  color: var(--ink);
  min-width: 92px;
  text-align: center;
}
.agenda-date-controls .icon-button {
  color: var(--muted);
  font-size: 18px;
  padding: 3px 7px;
}
.treatment-patient-picker {
  margin-bottom: 18px;
  max-width: 420px;
}
.treatment-status-select {
  min-width: 130px;

  padding: 6px 8px;

  border: 1px solid var(--line);

  border-radius: 7px;

  background: #fff;

  color: var(--ink);

  font-size: 12px;
}
.treatment-plan-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.treatment-plan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 14px;

  border: 1px solid var(--line);
  border-radius: 10px;

  background: #fff;
}

.treatment-plan-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.treatment-plan-main strong {
  display: block;
}

.treatment-plan-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.treatment-plan-tooth {
  width: 40px;
  height: 40px;

  display: grid;
  place-items: center;

  flex-shrink: 0;

  border-radius: 8px;

  background: #f0f9ff;
  color: var(--primary);

  font-weight: 700;
}

.treatment-plan-details {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 700px) {
  .treatment-plan-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .treatment-plan-details {
    width: 100%;
    flex-wrap: wrap;
  }
}
.treatment-plan-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.treatment-plan-delete {
  min-width: 36px;
  padding-inline: 10px;

  color: var(--danger);

  border: 1px solid #fecaca;

  background: #fff;
}

.treatment-plan-delete:hover {
  background: var(--danger-bg);
}

@media (max-width: 700px) {
  .treatment-plan-actions {
    width: 100%;
  }

  .treatment-plan-actions .button {
    flex: 1;
  }
}
:root {
  --surface: #fff;
  --decay: #ef4444;
  --filling: #3b82f6;
  --crown: #f59e0b;
  --rct: #8b5cf6;
  --extract: #475569;
  --implant: #10b981;
}

.legend i {
  border: 1px solid #94a3b8;
}

.prescription-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #f1f5f9;
}

.prescription-row small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.prescription-actions {
  display: flex;
  gap: 6px;
}

.prescription-print {
  display: none;
}

/* ============================================================
   PREMIUM MEDICATION BOX UI
   ============================================================ */
.prescription-medications-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  grid-column: 1 / -1;
  width: 100%;
}

.prescription-edit-medication {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--primary);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  position: relative;
}

.prescription-edit-medication:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
}

.medication-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}

.medication-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.med-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(2, 132, 199, 0.08);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(2, 132, 199, 0.15);
}

.medication-delete-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.medication-delete-button:hover {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(220, 38, 38, 0.2);
  transform: scale(1.02);
}

.medication-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.med-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.required-star {
  color: var(--danger);
  font-weight: bold;
}

.medication-grid-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 600px) {
  .medication-grid-row {
    grid-template-columns: 1fr;
  }
}

.add-medication-bar {
  grid-column: 1 / -1;
  margin-top: 4px;
  margin-bottom: 12px;
}

.add-medication-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: 2px dashed rgba(2, 132, 199, 0.35) !important;
  border-radius: 12px;
  background: rgba(2, 132, 199, 0.04) !important;
  color: var(--primary) !important;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-medication-btn:hover {
  border-color: var(--primary) !important;
  background: rgba(2, 132, 199, 0.1) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.12);
}

.add-medication-btn .add-icon {
  font-size: 16px;
  font-weight: 700;
}

.quick-med-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.quick-med-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.quick-med-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(2, 132, 199, 0.06);
  transform: translateY(-1px);
}

@media print {
  body.printing-prescription * {
    visibility: hidden !important;
  }

  body.printing-prescription .prescription-print.active,
  body.printing-prescription .prescription-print.active * {
    visibility: visible !important;
  }

  body.printing-prescription .prescription-print.active {
    display: block !important;
    position: absolute;
    inset: 0;
    padding: 24mm 20mm;
    background: #fff;
    color: #000;
    font-family: Arial, sans-serif;
  }

  .prescription-print header {
    text-align: center;
    border-bottom: 2px solid #0369a1;
    padding-bottom: 12px;
  }

  .prescription-print h1 {
    font-size: 22px;
    margin: 0;
  }

  .prescription-print h2 {
    font-size: 20px;
    text-align: center;
    margin: 20px 0;
  }

  .prescription-medication {
    padding: 12px 0;
    border-bottom: 1px solid #cbd5e1;
  }

  .prescription-medication h3 {
    margin: 0 0 7px;
    font-size: 16px;
  }

  .prescription-medication p {
    margin: 4px 0;
    font-size: 13px;
  }

  .prescription-print footer {
    margin-top: 55mm;
    border-top: 1px solid #94a3b8;
    padding-top: 8px;
  }
}

.primary-odontogram .teeth-row {
  gap: 8px;
}

/* .primary-odontogram .tooth {
  width: 36px;
  height: 46px;
  border-radius: 12px 12px 8px 8px;
}

.primary-odontogram .tooth-mark {
  inset: 7px 6px 14px;
  border-radius: 6px;
}

.primary-odontogram .tooth-label {
  font-size: 12px;
  bottom: 2px;
} */

.primary-odontogram .tooth {
  width: 40px;
  height: 60px;
}

.primary-odontogram .tooth-visual {
  width: 40px;
  height: 60px;
}

.primary-odontogram .tooth-label {
  font-size: 16px;
}
.teeth-row {
  direction: ltr;
}

.odontogram-direction-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;

  width: 50%;
  margin: 0 auto 12px;

  direction: ltr;

  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

.odontogram-direction-labels .right,
.odontogram-direction-labels .left {
  width: 60px;
  text-align: center;
}

input[name="phone"] {
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}

.action-btn.active {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0369a1;
  font-weight: 700;
}

.appointment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.appointment-delete {
  flex: 0 0 auto;
  color: #b91c1c;
  background: transparent;
  border: 1px solid #fecaca;
  border-radius: 5px;
  width: 25px;
  height: 25px;
  font-size: 17px;
  line-height: 1;
}

.appointment-delete:hover {
  background: #fef2f2;
}

@media (max-width: 900px) {
  body:not(.sidebar-collapsed) .sidebar {
    width: 248px !important;
    padding: 25px 14px !important;
  }

  body:not(.sidebar-collapsed) .profile {
    padding-inline: 10px !important;
    justify-content: flex-start !important;
  }

  body:not(.sidebar-collapsed) .profile > div:last-child,
  body:not(.sidebar-collapsed) .sidebar-foot span:last-child,
  body:not(.sidebar-collapsed) .nav-item span:last-child {
    display: block !important;
  }

  body:not(.sidebar-collapsed) .nav-item {
    justify-content: flex-start !important;
    padding: 11px 12px !important;
  }
}

/* Collapse/expand toggle: its own row at the top of the sidebar, so it never covers the
   avatar or the doctor/clinic names. */
.sidebar-toggle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -8px 0 6px;
  margin-inline-start: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

/* The glyph is "‹". Open: it points toward the sidebar's outer edge (collapse). Collapsed: it
   points into the page (expand). RTL mirrors both. */
html[dir="rtl"] .sidebar-toggle,
.sidebar-collapsed .sidebar-toggle {
  transform: scaleX(-1);
}
html[dir="rtl"] .sidebar-collapsed .sidebar-toggle {
  transform: none;
}

.sidebar-toggle:hover {
  background: #e0f2fe;
  color: var(--primary);
}

.sidebar {
  position: relative;
}

.sidebar-collapsed .sidebar {
  width: 72px;
  padding: 18px 8px;
}

.sidebar-collapsed .profile {
  padding-inline: 0;
  justify-content: center;
}

.sidebar-collapsed .profile > div:last-child,
.sidebar-collapsed .sidebar-foot span:last-child,
.sidebar-collapsed .nav-item span:last-child {
  display: none;
}

.sidebar-collapsed .nav-item {
  justify-content: center;
  padding-inline: 5px;
}

.sidebar-collapsed .sidebar-toggle {
  margin-inline: auto;
}

/* Collapsed: Sign out becomes an icon button that fits the rail (same as on phones). */
.sidebar-collapsed.online-authenticated .online-logout-button {
  width: 44px;
  margin: 10px auto;
  padding: 8px 0;
  display: grid;
  place-items: center;
}
.sidebar-collapsed .online-logout-button span { display: none; }
.sidebar-collapsed .online-logout-button::before { content: "⏻"; font-size: 16px; }

html[dir="rtl"] .context-drawer {
  transform: translateX(-105%) !important;
  box-shadow: 12px 0 30px rgba(15, 23, 42, 0.14);
}

html[dir="rtl"] body.drawer-open .context-drawer {
  transform: translateX(0) !important;
}

:root {
  --canvas: #f7f2e8;
  --surface: #fff;
  --ink: #0f172a;
  --muted: #5b6b80;
  --line: #e2e8f0;
  --primary: #0369a1;
  --sky: #0ea5e9;
  --navy: #0b2942;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --purple: #8b5cf6;
  --teal: #10b981;
  --radius: 12px;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  font-family: Cairo, "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid #bae6fd;
  outline-offset: 1px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  height: 76px;
  background: linear-gradient(180deg, #0b2942 0%, #0c3354 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 24px;
  position: relative;
  z-index: 50;
}

.brand,
.profile,
.top-actions,
.heading-date,
.stat,
.card-heading,
.timeline-item,
.patient-summary,
.form-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  background: var(--sky);
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-size: 22px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35);
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.brand strong,
.brand span,
.profile small {
  display: block;
}

.brand strong {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.profile small {
  color: #5b6b80;
  font-size: 11px;
  margin-top: 2px;
}

.top-actions {
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #a9b8cc;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  width: min(320px, 32vw);
  padding: 0 12px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.search:focus-within {
  background: rgba(255, 255, 255, 0.13);
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.search input {
  border: 0;
  background: transparent;
  color: #fff;
  min-width: 0;
  width: 100%;
  height: 38px;
}

.search input::placeholder {
  color: #a9b8cc;
}

.button {
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  /* Never fall back to the browser's grey button: variants below override these. */
  background: #ffffff;
  color: var(--ink);
  border: 1px solid #cbd5e1;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.35);
}

.button-primary:hover {
  background: linear-gradient(135deg, #075985 0%, #0369a1 100%);
  box-shadow: 0 5px 14px rgba(2, 132, 199, 0.45);
}

.button-ghost {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.button-ghost:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.brand span {
  display: block;
  color: #a9b8cc;
  font-size: 11px;
  margin-top: 2px;
}

.search > span {
  color: #a9b8cc;
}

/* The top bar is dark navy, so its ghost buttons use the translucent light-on-dark style. */
.topbar .button-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.topbar .button-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.icon-button {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 16px;
  transition: all 0.15s ease;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.clock {
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.workspace {
  display: flex;
  min-height: calc(100vh - 76px);
}

.sidebar {
  width: 248px;
  background: #fff;
  border-inline-end: 1px solid var(--line);
  padding: 25px 14px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.profile {
  gap: 12px;
  padding: 0 10px 22px;
  border-bottom: 1px solid var(--line);
}

.avatar {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  color: #fff;
  font-weight: 700;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 13px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
  flex-shrink: 0;
}

.profile b {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.user-role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  margin-top: 4px;
  width: fit-content;
  line-height: 1.4;
}

.badge-role-admin {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #d8b4fe;
}

.badge-role-head {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-role-doctor {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.badge-role-secretary {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.sidebar nav {
  padding-top: 18px;
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  gap: 12px;
  align-items: center;
  color: #475569;
  background: transparent;
  text-align: start;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.nav-item:hover {
  background: #f1f5f9;
  color: var(--ink);
  transform: translateX(2px);
}

html[dir="rtl"] .nav-item:hover {
  transform: translateX(-2px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.12) 0%, rgba(14, 165, 233, 0.05) 100%);
  color: var(--primary);
  font-weight: 700;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 6px;
  bottom: 6px;
  width: 3.5px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

html[dir="rtl"] .nav-item.active::before {
  border-radius: 4px 0 0 4px;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.sidebar-foot {
  margin-top: auto;
  color: #5b6b80;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: var(--teal);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 31px 38px;
  overflow: auto;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 27px;
}

.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #5b6b80;
  margin: 0 0 7px;
  text-transform: uppercase;
}

.page-heading h1 {
  font-size: 26px;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.3px;
}

.heading-date {
  text-align: end;
  align-items: flex-end;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.heading-date b {
  color: var(--ink);
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s;
  position: relative;
  overflow: hidden;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -4px rgba(15, 23, 42, 0.08);
  border-color: #cbd5e1;
}

.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.stat:hover .stat-icon-wrap {
  transform: scale(1.06);
}

.stat-icon-blue {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
}
.stat-icon-green {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}
.stat-icon-amber {
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.stat-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.pill-blue { background: #e0f2fe; color: #0369a1; }
.pill-green { background: #dcfce7; color: #15803d; }
.pill-amber { background: #fef3c7; color: #b45309; }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
  line-height: 1.15;
  margin-top: 4px;
}

.stat-sub {
  font-size: 11px;
  margin-top: 3px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 20px;
}

@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.content-grid.treatments-billing-layout,
.treatments-billing-layout {
  grid-template-columns: 1fr;
  gap: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-heading-icon {
  font-size: 18px;
}

.card-heading h2,
.card-heading h3 {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}

.dashboard-appointments-list {
  display: grid;
  gap: 10px;
}

.dashboard-appointment {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #f1f5f9;
  background: #f8fafc;
  transition: all 0.18s ease;
}

.dashboard-appointment:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.appointment-time-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  flex-shrink: 0;
}

.time-clock {
  font-size: 11px;
  color: var(--primary);
}

.appointment-body {
  flex: 1;
  min-width: 0;
}

.appointment-patient-name {
  font-size: 14px;
  color: #0f172a;
  display: block;
}

.appointment-meta {
  font-size: 12px;
  color: #5b6b80;
  margin-top: 2px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.appointment-status {
  flex-shrink: 0;
}

.appointment-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
}

.button-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.dashboard-empty-state {
  text-align: center;
  padding: 36px 16px;
  background: #fafafa;
  border: 1.5px dashed #e2e8f0;
  border-radius: 12px;
}

.empty-state-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.7;
}

.dashboard-patients-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.patient-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border-bottom: 1px solid #f1f5f9;
  transition: all 0.15s ease;
  cursor: pointer;
}

.patient-row:hover {
  background: #f8fafc;
  color: var(--primary);
}

.patient-row-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 700;
  font-size: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.patient-row-info {
  flex: 1;
  min-width: 0;
}

.patient-row-info b {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
  color: #0f172a;
}

.patient-row-info small {
  color: #5b6b80;
  font-size: 12px;
}

.patient-row-status {
  margin-inline-start: auto;
  flex-shrink: 0;
}

.dashboard-side-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Keyboard Shortcuts Box */
.dashboard-shortcuts-card {
  padding: 18px 20px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.shortcuts-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.shortcuts-card-header h3 {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.shortcuts-icon {
  font-size: 16px;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

@media (max-width: 480px) {
  .shortcuts-grid {
    grid-template-columns: 1fr;
  }
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 9px;
  transition: all 0.15s ease;
}

.shortcut-item:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.shortcut-keys {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #5b6b80;
  flex-shrink: 0;
}

.shortcut-keys kbd {
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  line-height: 1.3;
}

.shortcut-label {
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  min-width: 0;
  text-align: end;
  line-height: 1.35;
}

.muted {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 99px;
  padding: 4px 10px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.badge-danger {
  background: var(--danger-bg);
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.badge-blue {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-green,
.badge-success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-amber,
.badge-warning {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-gray {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.badge-purple {
  background: #f3e8ff;
  color: #7c3aed;
  border: 1px solid #d8b4fe;
}

.timeline {
  display: grid;
  gap: 0;
}

.timeline-item {
  align-items: flex-start;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid #f1f5f9;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--sky);
  margin-top: 5px;
  flex-shrink: 0;
}

.timeline-item b {
  font-size: 12px;
}

.timeline-item small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.workspace-card {
  padding: 0;
  overflow: hidden;
}

.workspace-toolbar {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.segmented {
  display: flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  padding: 7px 11px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.segmented button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px #cbd5e1;
}

.odontogram-wrap {
  padding: 22px;
  overflow: auto;
}

.arch-title {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  margin: 4px 0 9px;
}

.teeth-row {
  display: flex;
  gap: 6px;
  min-width: 630px;
  justify-content: center;
}
/*
.tooth {
  width: 38px;
  height: 50px;
  border: 1px solid #cbd5e1;
  border-radius: 14px 14px 10px 10px;
  background: #fff;
  position: relative;
  padding: 0;
  color: #475569;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}

.tooth:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 10px #cbd5e1;
}

.tooth-label {
  font-size: 9px;
  position: absolute;
  bottom: 3px;
  inset-inline: 0;
}

.tooth-mark {
  position: absolute;
  inset: 9px 8px 16px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #94a3b8;
}

.tooth.decay .tooth-mark {
  background: #ef4444;
  border-color: #ef4444;
}

.tooth.filling .tooth-mark {
  background: #3b82f6;
  border-color: #3b82f6;
}

.tooth.crown .tooth-mark {
  background: #f59e0b;
  border-color: #f59e0b;
}

.tooth.rct .tooth-mark {
  background: #8b5cf6;
  border-color: #8b5cf6;
}

.tooth.implant .tooth-mark {
  background: #10b981;
  border-color: #10b981;
}

.tooth.extract .tooth-mark {
  background: #475569;
  border-color: #475569;
}

.tooth.extract .tooth-mark:after {
  content: "×";
  color: #fff;
  font-size: 25px;
  position: absolute;
  inset: -7px 0 0;
  text-align: center;
}
*/

.tooth {
  width: 38px;
  height: 64px;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0;
  color: #5b6b80;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}

.tooth:hover {
  transform: translateY(-3px);
  filter: drop-shadow(0 5px 6px rgba(148, 163, 184, 0.5));
}

.tooth-visual {
  position: relative;
  width: 40px;
  height: 60px;
}

.tooth-shape {
  width: 100%;
  height: 100%;
  display: block;
}

.tooth-shape path {
  fill: #ffffff;
  stroke: #94a3b8;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  transition: fill 0.15s, stroke 0.15s;
}

.tooth-label {
  font-size: 16px;
  line-height: 1;
}

.tooth-mark {
  display: none;
}

.tooth.decay .tooth-shape path {
  fill: #ef4444;
  stroke: #ef4444;
}
.tooth.filling .tooth-shape path {
  fill: #3b82f6;
  stroke: #3b82f6;
}
.tooth.crown .tooth-shape path {
  fill: #f59e0b;
  stroke: #f59e0b;
}
.tooth.rct .tooth-shape path {
  fill: #8b5cf6;
  stroke: #8b5cf6;
}
.tooth.implant .tooth-shape path {
  fill: #10b981;
  stroke: #10b981;
}

.tooth.extract .tooth-shape path {
  fill: #cbd5e1;
  stroke: #94a3b8;
  opacity: 0.6;
}

.tooth.extract .tooth-mark {
  display: flex;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
}

.tooth.extract .tooth-mark::after {
  content: "×";
  color: #dc2626;
  font-size: 26px;
  font-weight: 700;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-inline-end: 4px;
  vertical-align: -1px;
  border: 1px solid #94a3b8;
}

.patient-summary {
  justify-content: space-between;
  gap: 15px;
  padding: 14px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 20px;
}

.patient-summary h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.patient-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.alert-banner {
  background: var(--danger-bg);
  border: 1px solid #fca5a5;
  color: #991b1b;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  margin-bottom: 18px;
}

.table-wrap {
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  text-align: start;
  padding: 12px 9px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

.data-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #5b6b80;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 13px;
}

.field {
  display: grid;
  gap: 5px;
}

.field.full-span {
  grid-column: 1/-1;
}

.field label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.field input,
.field textarea,
.field select,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  min-width: 0;
}

.field textarea,
textarea {
  resize: vertical;
}

.form-actions {
  justify-content: flex-end;
  gap: 9px;
  margin-top: 19px;
}

.agenda {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.agenda-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  min-height: 55px;
  border-bottom: 1px solid #f1f5f9;
}

.agenda-row:last-child {
  border: 0;
}

.agenda-time {
  padding: 12px;
  color: var(--muted);
  font-size: 11px;
  border-inline-end: 1px solid var(--line);
}

.appointment {
  margin: 6px 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-inline-start: 4px solid #0369a1;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  user-select: none;
  cursor: grab;
  position: relative;
}

.appointment:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.appointment:active,
.appointment.is-dragging {
  cursor: grabbing;
  opacity: 0.5;
  transform: scale(0.98);
}

.appointment > div:first-child {
  flex: 1 1 auto;
}

.appointment b {
  display: block;
  font-size: 12px;
}

/* Color-coded Statuses */
.appointment.status-booked {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-inline-start: 4px solid #0369a1;
  color: #0c4a6e;
}

.appointment.status-arrived {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-inline-start: 4px solid #f59e0b;
  color: #78350f;
}

.appointment.status-in_chair {
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-inline-start: 4px solid #9333ea;
  color: #581c87;
}

.appointment.status-completed {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-inline-start: 4px solid #16a34a;
  color: #14532d;
}

.appointment.status-cancelled,
.appointment.is-cancelled {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-inline-start: 4px solid #94a3b8;
  color: #5b6b80;
  opacity: 0.75;
}

.appointment.status-cancelled b,
.appointment.is-cancelled b {
  text-decoration: line-through;
  color: #5b6b80;
}

/* Drag-and-drop Drop Target Highlights */
.agenda-slot-target {
  min-height: 48px;
  transition: all 0.2s ease;
  border-radius: 6px;
  position: relative;
}

.agenda-slot-target.is-slot-dragover {
  background: #e0f2fe !important;
  outline: 2px dashed #0369a1 !important;
  outline-offset: -2px;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.25) inset;
}

.calendar-day.is-day-dragover {
  background: #0369a1 !important;
  color: #ffffff !important;
  transform: scale(1.05);
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.4);
}

/* Wait-list Panel & Cards */
.waitlist-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.waitlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.waitlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.waitlist-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: grab;
  transition: all 0.15s ease;
  position: relative;
}

.waitlist-card:hover {
  border-color: var(--primary);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.waitlist-card:active,
.waitlist-card.is-dragging {
  cursor: grabbing;
  opacity: 0.55;
}

.waitlist-card.priority-urgent {
  border-inline-start: 4px solid #ef4444;
}

.waitlist-card.priority-high {
  border-inline-start: 4px solid #f59e0b;
}

.waitlist-card.priority-normal {
  border-inline-start: 4px solid #3b82f6;
}

.badge-urgent {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.badge-high {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-normal {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  z-index: 8;
}

.context-drawer {
  position: fixed;
  z-index: 9;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(360px, 100vw);
  background: #fff;
  box-shadow: -12px 0 30px rgba(15, 23, 42, 0.14);
  padding: 25px;
  transform: translateX(105%);
  transition: transform 0.22s ease;
  overflow: auto;
}

.drawer-open .context-drawer {
  transform: translateX(0);
}

.drawer-open .drawer-backdrop {
  display: block;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  font-size: 27px;
  margin: 0;
}

.drawer-head p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.drawer-head .icon-button,
.modal-close {
  color: var(--muted);
}

.surface-list {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding: 18px 0;
}

.surface-btn {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 11px;
}

.surface-btn.active {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #7dd3fc;
}

.drawer-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-top: 10px;
}

.action-btn {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-align: start;
  font-size: 11px;
}

.action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.full {
  width: 100%;
  margin-top: 9px;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 20;
  place-items: center;
  padding: 20px;
}

.modal.show {
  display: grid;
}

.modal-card {
  position: relative;
  background: #fff;
  border-radius: 14px;
  width: min(700px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 28px;
  box-shadow: 0 20px 60px #0f172a33;
}

.modal-close {
  position: absolute;
  inset-inline-end: 15px;
  top: 13px;
}

.modal-card h2 {
  margin: 0 0 20px;
  font-size: 20px;
}

.modal-card .card {
  box-shadow: none;
  padding: 0;
  border: 0;
}
.modal-card:has(.xray-viewer) {
  width: min(1200px, calc(100vw - 32px));

  max-width: 1200px;
}
.xray-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.xray-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.xray-item img {
  width: 100%;
  aspect-ratio: 1.3;
  object-fit: cover;
  background: #0f172a;
}

.xray-item > .xray-info {
  padding: 10px 12px;
  font-size: 12px;
}
.xray-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.xray-info > div {
  min-width: 0;
}
.xray-info b {
  display: block;
  overflow-wrap: anywhere;
}

.xray-delete-button {
  flex: 0 0 auto;

  width: 30px;
  height: 30px;

  display: grid;
  place-items: center;

  border: 1px solid #fecaca;
  border-radius: 7px;

  background: #fff;
  color: var(--danger);

  font-size: 18px;
  line-height: 1;
}

.xray-delete-button:hover {
  background: var(--danger-bg);
}

.xray-upload-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;

  margin: 18px 0 24px;

  padding: 18px;

  background: #f8fafc;

  border: 1px solid var(--line);

  border-radius: 10px;
}

.xray-upload-form .full-span {
  grid-column: 1 / -1;
}

.xray-upload-form > .button {
  width: fit-content;
}

.xray-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;

  margin-top: 6px;
}

.xray-meta span {
  padding: 3px 7px;

  border-radius: 5px;

  background: #f1f5f9;

  color: var(--muted);

  font-size: 11px;
}

.xray-notes {
  margin: 8px 0 0;

  color: var(--muted);

  font-size: 12px;

  line-height: 1.5;
}
.xray-viewer {
  width: min(1100px, 90vw);
}

.xray-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 14px;

  margin-bottom: 14px;

  flex-wrap: wrap;
}

.xray-viewer-info {
  display: flex;
  align-items: center;

  gap: 6px;

  flex-wrap: wrap;
}

.xray-viewer-actions {
  display: flex;
  align-items: center;

  gap: 6px;

  flex-wrap: wrap;
}

.xray-zoom-label {
  min-width: 52px;

  text-align: center;

  font-size: 12px;

  color: var(--muted);
}

.xray-viewer-stage {
  position: relative;

  width: 100%;
  min-height: 55vh;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;

  padding: 20px;

  background: #0f172a;

  border-radius: 10px;
}

.xray-viewer-stage img {
  display: block;

  max-width: 100%;
  max-height: 65vh;

  object-fit: contain;

  transform-origin: center center;

  transition: transform 0.2s ease;

  user-select: none;
}

.xray-viewer-stage.is-pannable {
  cursor: grab;
  touch-action: none;
}

.xray-viewer-stage.is-panning {
  cursor: grabbing;
}

.xray-viewer-stage.is-panning img {
  transition: none;
}

.xray-viewer-notes {
  margin-top: 14px;

  padding: 12px 14px;

  border: 1px solid var(--line);

  border-radius: 8px;

  background: var(--surface);
}

.xray-viewer-notes p {
  margin: 6px 0 0;

  color: var(--muted);

  line-height: 1.6;
}

.timeline-event-clickable,
.xray-item-clickable {
  cursor: pointer;
}

.timeline-event-clickable:hover .timeline-content,
.xray-item-clickable:hover {
  border-color: var(--primary);
}

@media (max-width: 700px) {
  .xray-viewer {
    width: 100%;
  }

  .xray-viewer-stage {
    min-height: 45vh;

    padding: 10px;
  }

  .xray-viewer-actions {
    width: 100%;
  }

  .xray-viewer-actions .button {
    flex: 1;
  }
}
@media (max-width: 700px) {
  .xray-upload-form {
    grid-template-columns: 1fr;
  }

  .xray-upload-form .full-span {
    grid-column: auto;
  }
}

.toast {
  position: fixed;
  bottom: 22px;
  inset-inline-end: 22px;
  background: var(--navy);
  color: #fff;
  padding: 11px 15px;
  border-radius: 8px;
  z-index: 40;
  font-size: 12px;
  animation: rise 0.2s ease;
}

/* Professional Footer */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  margin-top: auto;
  padding: 22px 4px 6px;

  border-top: 1px solid var(--line);

  color: var(--muted);
  font-size: 14px;
}

.footer-left,
.footer-center,
.footer-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.footer-center {
  text-align: center;
}

.footer-right a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.footer-right a:hover {
  color: var(--primary);
}

/* Mobile */
@media (max-width: 700px) {
  .app-footer {
    flex-direction: column;
    justify-content: center;
    gap: 9px;

    padding-top: 18px;

    text-align: center;
  }

  .footer-left,
  .footer-center,
  .footer-right {
    justify-content: center;
    flex-wrap: wrap;
  }
}

.undo-toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.undo-toast button {
  padding: 5px 10px;

  background: transparent;

  border: 1px solid currentColor;
  border-radius: 6px;

  color: inherit;

  font-weight: 700;

  cursor: pointer;
}

.undo-toast button:hover {
  background: rgba(255, 255, 255, 0.12);
}

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

  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 900px) {
  .topbar {
    height: auto;
    min-height: 76px;
    flex-wrap: wrap;
    padding: 15px 18px;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .search {
    width: 100%;
    order: 5;
  }

  .sidebar {
    width: 72px;
    padding: 18px 8px;
  }

  .profile {
    padding: 0 0 18px;
    justify-content: center;
  }

  .profile > div:last-child,
  .sidebar-foot span:last-child,
  .nav-item span:last-child {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 11px 5px;
  }

  .main {
    padding: 24px 18px;
  }

  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: flex-start;
    gap: 10px;
  }

  .heading-date {
    display: none;
  }
}

@media (max-width: 560px) {
  .brand {
    min-width: auto;
  }

  .brand span,
  .clock {
    display: none;
  }

  .top-actions {
    gap: 5px;
  }

  .top-actions .button-primary span {
    display: none;
  }

  .main {
    padding: 20px 13px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-heading h1 {
    font-size: 22px;
  }

  .card {
    padding: 16px;
  }

  .workspace-toolbar {
    padding: 14px 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid {
    gap: 9px;
  }

  .stat {
    padding: 13px;
  }

  .stat-value {
    font-size: 20px;
  }
}

@media print {
  .topbar,
  .sidebar,
  .page-heading,
  .button,
  .workspace-toolbar,
  .drawer-backdrop,
  .context-drawer {
    display: none !important;
  }

  .main {
    padding: 0;
  }

  .app-shell,
  .card {
    box-shadow: none;
  }

  .print-only {
    display: block !important;
  }

  .invoice-print {
    border: 0 !important;
  }
}
.hidden {
  display: none !important;
}

.demo-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;

  display: flex;
  align-items: center;
  gap: 8px;

  padding: 7px 12px;

  border: 1px solid var(--line);
  border-radius: 999px;

  background: var(--surface);
  color: var(--muted);

  font-size: 11px;

  box-shadow: var(--shadow);
}

.demo-banner span {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.4px;
}

.demo-banner small {
  font-size: 10px;
}

@media (max-width: 560px) {
  .demo-banner {
    top: 8px;
    padding: 6px 10px;
  }

  .demo-banner small {
    display: none;
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--surface, #f1f5f9);
  color: var(--text, #334155);
  border: 1px solid var(--line, #e2e8f0);
}
.badge-blue {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}
.badge-green {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}
.badge-amber {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}
.badge-gray {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}
.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}
.badge-red {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}
.badge-purple {
  background: #f3e8ff;
  color: #7e22ce;
  border-color: #e9d5ff;
}
.button-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

body.is-super-admin #newPatientBtn,
body.is-super-admin .search,
body.is-super-admin #backupBtn {
  display: none !important;
}

body.is-super-admin .main {
  max-width: 100%;
  padding: 24px 32px;
  overflow-x: hidden;
}

/* ==========================================
   Super Admin Dashboard & Control Center
   ========================================== */
.admin-container {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  width: 100%;
}

.admin-stat-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.03);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.admin-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.admin-stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--stat-accent, #0369a1);
}

.admin-stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
  background: var(--stat-bg, #f0f9ff);
  color: var(--stat-accent, #0369a1);
}

.admin-stat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-stat-title {
  font-size: 12px;
  color: #5b6b80;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
  margin: 2px 0;
}

.admin-stat-sub {
  font-size: 11px;
  color: #5b6b80;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card & Table Section */
.admin-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 100%;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 16px;
}

.admin-card-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: #0f172a;
}

.admin-card-header p {
  margin: 3px 0 0;
  font-size: 12px;
  color: #5b6b80;
}

/* Filter Controls Bar */
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

.admin-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-search-box {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 0 12px;
  min-width: 240px;
  height: 38px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.admin-search-box:focus-within {
  border-color: #0369a1;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.admin-search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 13px;
  color: #0f172a;
}

.admin-filter-chip {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-filter-chip:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.admin-filter-chip.active {
  background: #0369a1;
  color: #ffffff;
  border-color: #0369a1;
}

.admin-filter-chip .chip-count {
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
}

.admin-filter-chip.active .chip-count {
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
}

/* Data Table Styling */
.admin-table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: start;
  font-size: 13px;
}

.admin-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: #f8fafc;
}

/* Modern Status Badges */
.admin-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.admin-status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-active {
  background: #dcfce7;
  color: #15803d;
}
.status-active .dot {
  background: #22c55e;
}

.status-warning {
  background: #fef3c7;
  color: #b45309;
}
.status-warning .dot {
  background: #f59e0b;
}

.status-danger {
  background: #fee2e2;
  color: #b91c1c;
}
.status-danger .dot {
  background: #ef4444;
}

.status-neutral {
  background: #f1f5f9;
  color: #475569;
}
.status-neutral .dot {
  background: #94a3b8;
}

.status-trial {
  background: #e0f2fe;
  color: #0369a1;
}
.status-trial .dot {
  background: #0369a1;
}

/* Compact Table Action Buttons */
.admin-action-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.btn-admin-action {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-admin-action:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-admin-primary {
  background: #0369a1;
  border-color: #0369a1;
  color: #ffffff;
}

.btn-admin-primary:hover {
  background: #0369a1;
  border-color: #0369a1;
  color: #ffffff;
}

.btn-admin-danger {
  background: #ffffff;
  border-color: #fecaca;
  color: #dc2626;
}

.btn-admin-danger:hover {
  background: #fef2f2;
  border-color: #f87171;
  color: #b91c1c;
}

.btn-admin-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  font-size: 13px;
}

/* Keyboard shortcut hint badge */
.kbd-shortcut {
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #cbd5e1;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.4;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.search:hover .kbd-shortcut {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Calendar appointment status dropdown */
.appointment-status-select {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.appointment-status-select:hover {
  border-color: var(--primary);
  background: #f8fafc;
}

.appointment-status-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

/* ==========================================================================
   Prescription & Invoice Print Styles
   ========================================================================== */
.prescription-print {
  display: none;
}

@media print {
  /* Hide application shell, sidebars, headers, floating modals, and buttons */
  .sidebar,
  .top-bar,
  header.top-bar,
  .treatment-patient-picker,
  .quick-med-list,
  .pagination,
  .btn-admin-action,
  .appointment-actions,
  .keyboard-shortcuts-card,
  .dashboard-welcome-banner,
  .admin-card-header button,
  .card-heading button,
  button,
  .button,
  input,
  select,
  textarea,
  .modal-backdrop,
  #modal,
  .toast,
  .command-palette-modal {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 11pt !important;
    line-height: 1.4 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .app-shell,
  .main-content,
  .content-grid {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Specific Prescription Print Mode */
  body.printing-prescription .card,
  body.printing-prescription .content-grid > * {
    display: none !important;
  }

  body.printing-prescription .prescription-print.active {
    display: block !important;
    background: #ffffff !important;
    border: 2px solid #334155 !important;
    border-radius: 8px !important;
    padding: 16mm 18mm !important;
    margin: 10mm auto !important;
    max-width: 180mm !important;
    box-shadow: none !important;
  }

  .prescription-print header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 12px;
    margin-bottom: 16px;
  }

  .prescription-print header h1 {
    font-size: 18pt !important;
    margin: 0 0 4px 0 !important;
    color: #0f172a !important;
  }

  .prescription-print header p {
    font-size: 11pt !important;
    margin: 0 !important;
    color: #475569 !important;
  }

  .prescription-print h2 {
    font-size: 14pt !important;
    margin: 12px 0 !important;
    color: #0369a1 !important;
  }

  .prescription-medication {
    border-bottom: 1px dashed #cbd5e1;
    padding: 8px 0;
  }

  .prescription-medication:last-of-type {
    border-bottom: none;
  }

  .prescription-medication h3 {
    font-size: 12pt !important;
    margin: 0 0 2px 0 !important;
    color: #0f172a !important;
  }

  .prescription-print footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 10pt;
    color: #5b6b80;
  }

  /* Specific Invoice Print Mode */
  body.printing-invoice .card:not(.invoice-print) {
    display: none !important;
  }

  body.printing-invoice .invoice-print {
    display: block !important;
    border: none !important;
    box-shadow: none !important;
    padding: 12mm 15mm !important;
    margin: 0 auto !important;
    max-width: 190mm !important;
  }

  .invoice-print .data-table {
    border-collapse: collapse !important;
    width: 100% !important;
    margin-top: 12px !important;
  }

  .invoice-print .data-table th,
  .invoice-print .data-table td {
    border: 1px solid #94a3b8 !important;
    padding: 6px 10px !important;
    color: #0f172a !important;
  }

  .invoice-print .data-table th {
    background: #f1f5f9 !important;
    font-weight: 700 !important;
  }
}


/* ================================================================
   HR-lite Module Styles
   ================================================================ */

.hr-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 4px 0;
}

/* Alert Banner */
.hr-alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--danger-bg), #fff7ed);
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 14px;
  flex-wrap: wrap;
}
.hr-alert-link {
  background: #fff;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  margin-left: auto;
  transition: background 0.15s;
}
.hr-alert-link:hover { background: var(--danger-bg); }

/* Tabs */
.hr-tabs {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.hr-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.hr-tab:hover { background: #fff; color: var(--ink); }
.hr-tab--active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35);
}

/* Time Clock */
.hr-timeclock-wrap {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .hr-timeclock-wrap { grid-template-columns: 1fr; }
}

.punch-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.punch-card__icon { font-size: 48px; line-height: 1; }
.punch-card__status {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.punch-card__timer {
  font-size: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--teal);
  letter-spacing: 0.04em;
  line-height: 1;
}
.punch-card__since {
  font-size: 12px;
  color: var(--muted);
}
.punch-notes-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: start;
  font-size: 12px;
  color: var(--muted);
}
.punch-notes-input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
  font-size: 13px;
}
.hr-punch-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  border-radius: 10px;
  font-weight: 600;
}
.hr-attendance-log { flex: 1; }

/* Table */
.hr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hr-table th {
  text-align: start;
  padding: 10px 12px;
  color: #5b6b80;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
}
.hr-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--ink);
  vertical-align: middle;
}
.hr-table tr:last-child td { border-bottom: none; }
.hr-table tr:hover td { background: #f8fafc; }
.tc-empty { text-align: center; padding: 32px !important; color: var(--muted); }

/* Badges */
.tc-badge { border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 600; }
.tc-badge--in  { background: #dcfce7; color: #15803d; }
.tc-badge--out { background: #f1f5f9; color: #475569; }

.cred-badge { border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 600; }
.cred-badge--active   { background: #dcfce7; color: #15803d; }
.cred-badge--expiring { background: #fef3c7; color: #b45309; }
.cred-badge--expired  { background: var(--danger-bg); color: var(--danger); }

.shift-badge { border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 600; }
.badge-scheduled { background: #e0f2fe; color: #0369a1; }
.badge-completed  { background: #dcfce7; color: #15803d; }
.badge-absent     { background: var(--danger-bg); color: var(--danger); }
.badge-leave      { background: #f3e8ff; color: #7c3aed; }

/* Filter Row */
.hr-filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.hr-filter-row label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.hr-date-input {
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  font-size: 13px;
}

/* Credential KPI Row */
.hr-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.hr-kpi-card {
  border-radius: 14px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
}
.hr-kpi--total   { background: var(--surface); }
.hr-kpi--active  { background: #f0fdf4; border-color: #bbf7d0; }
.hr-kpi--expiring { background: #fffbeb; border-color: #fde68a; }
.hr-kpi--expired  { background: var(--danger-bg); border-color: #fca5a5; }
.hr-kpi-number { font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1; }
.hr-kpi-label  { font-size: 12px; color: var(--muted); font-weight: 500; }

/* Shifts wrap */
.hr-shifts-wrap { display: flex; flex-direction: column; gap: 0; }
.hr-creds-wrap  { display: flex; flex-direction: column; }

/* Action cell small buttons */
.btn-xs { padding: 3px 8px !important; font-size: 12px !important; }
.btn-danger-ghost {
  background: transparent !important;
  border: 1px solid var(--danger) !important;
  color: var(--danger) !important;
}
.btn-danger-ghost:hover { background: var(--danger-bg) !important; }

/* RTL support */
[dir="rtl"] .hr-alert-link { margin-left: 0; margin-right: auto; }
[dir="rtl"] .hr-table th,
[dir="rtl"] .hr-table td   { text-align: right; }
[dir="rtl"] .hr-filter-row { flex-direction: row-reverse; }


/* ================================================================
   Inventory Module Styles
   ================================================================ */

.inv-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 4px 0;
}

.inv-tabs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.inv-tabs {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 6px;
  flex: 1;
  overflow-x: auto;
}
.inv-tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
}
.inv-tab:hover { background: #fff; color: var(--ink); }
.inv-tab--active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35);
}
.inv-tab--active:hover { background: var(--primary); color: #fff; }
.inv-quick { display: flex; gap: 8px; flex-wrap: wrap; }
.inv-content { display: flex; flex-direction: column; gap: 18px; }

/* KPI grid */
.inv-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.inv-kpi {
  border-radius: 14px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.inv-kpi--link { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.inv-kpi--link:hover,
.inv-kpi--link:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); outline: none; }
.inv-kpi--ok  { background: #f0fdf4; border-color: #bbf7d0; }
.inv-kpi--low { background: #fffbeb; border-color: #fde68a; }
.inv-kpi--out { background: var(--danger-bg); border-color: #fca5a5; }
.inv-kpi-number { font-size: 28px; font-weight: 700; line-height: 1; }
.inv-kpi-label  { font-size: 12px; color: var(--muted); font-weight: 500; }

.inv-money-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.inv-money-card { display: flex; flex-direction: column; gap: 6px; }

.inv-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 900px) {
  .inv-two-col { grid-template-columns: 1fr; }
}

.inv-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
.inv-list-row:last-child { border-bottom: none; }
.inv-empty { padding: 14px 0; text-align: center; }

.inv-alert-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #fffbeb, #fff7ed);
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  margin-bottom: 16px;
}
.inv-alert-banner .hr-alert-link { border-color: #d97706; color: #b45309; }
[dir="rtl"] .inv-alert-banner .hr-alert-link { margin-left: 0; margin-right: auto; }

/* Toolbar */
.inv-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.inv-toolbar select,
.inv-search {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}
.inv-search { flex: 1 1 240px; }
.inv-toolbar > .button-primary { margin-inline-start: auto; }

/* Tables */
.inv-table td { vertical-align: top; }
.inv-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-nowrap { white-space: nowrap; }
.inv-in  { color: #15803d; }
.inv-out { color: var(--danger); }
.inv-danger-text { display: block; color: var(--danger); font-size: 11px; }
.inv-codes { display: block; font-size: 11px; margin-top: 2px; }
.inv-details { min-width: 180px; font-size: 12px; line-height: 1.5; }
.inv-actions { white-space: nowrap; text-align: end; }
.inv-actions .button + .button { margin-inline-start: 4px; }
.inv-row-inactive td { opacity: 0.6; }
.inv-table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  flex-wrap: wrap;
}
.inv-link {
  background: none;
  padding: 0;
  color: var(--primary);
  font-weight: 600;
  text-align: start;
}
.inv-link:hover { text-decoration: underline; }
[dir="rtl"] .inv-table th,
[dir="rtl"] .inv-table td { text-align: right; }

/* Item detail modal */
.modal-card:has(.inv-detail) { width: min(960px, calc(100vw - 32px)); }
.inv-detail { display: flex; flex-direction: column; gap: 16px; }
.inv-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.inv-detail-head .badge + .badge { margin-inline-start: 6px; }
.inv-detail-stock { display: flex; gap: 24px; flex-wrap: wrap; }
.inv-detail-stock .stat-value small { font-size: 13px; color: var(--muted); font-weight: 500; }
.inv-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inv-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
}
.inv-description { margin: 0; color: var(--muted); white-space: pre-wrap; }
.inv-section-title { margin: 6px 0 0; font-size: 15px; }

/* Forms */
.inv-checkbox {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  color: var(--ink) !important;
  font-weight: 600;
}
.inv-checkbox input { width: auto !important; }
.inv-hint { margin: 0; font-size: 12px; }
.form-grid .hidden { display: none; }

/* Item picker */
.inv-picker-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  max-height: 50vh;
  overflow: auto;
}
.inv-picker-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: start;
}
.inv-picker-row:hover { border-color: var(--primary); background: #f0f9ff; }

@media (max-width: 700px) {
  .inv-list-row { grid-template-columns: 1fr auto; }
  .inv-tab { flex: 0 0 auto; }
}

@media print {
  .inv-quick,
  .inv-toolbar,
  .inv-actions { display: none !important; }
}

#invItemForm > .full-span,
#invItemForm > .inv-form-actions,
#invMovementForm > .full-span,
#invMovementForm > .inv-form-actions,
#invSupplierForm > .inv-form-actions,
#invCategoryForm > .inv-form-actions {
  grid-column: 1 / -1;
}
.inv-form-actions { margin-top: 6px; }

.delete-patient-button,
.form-actions .button {
  white-space: nowrap;
}

/* Phones: always use the compact icon rail. The ≤900px "expanded unless collapsed" rule
   above made the 248px sidebar consume most of a phone screen and squeeze every page. */
@media (max-width: 700px) {
  body .sidebar,
  body:not(.sidebar-collapsed) .sidebar {
    width: 60px !important;
    padding: 14px 6px !important;
  }
  body .profile,
  body:not(.sidebar-collapsed) .profile {
    padding: 0 0 14px !important;
    justify-content: center !important;
  }
  body .profile > div:last-child,
  body .sidebar-foot span:last-child,
  body .nav-item span:last-child,
  body:not(.sidebar-collapsed) .profile > div:last-child,
  body:not(.sidebar-collapsed) .sidebar-foot span:last-child,
  body:not(.sidebar-collapsed) .nav-item span:last-child {
    display: none !important;
  }
  body .nav-item,
  body:not(.sidebar-collapsed) .nav-item {
    justify-content: center !important;
    padding: 11px 4px !important;
  }
  .sidebar-toggle { display: none; }
  .avatar { width: 40px; height: 40px; font-size: 13px; }
  .online-authenticated .online-logout-button {
    width: 44px;
    margin: 10px auto;
    padding: 8px 0;
    display: grid;
    place-items: center;
  }
  .online-logout-button span { display: none; }
  .online-logout-button::before { content: "⏻"; font-size: 16px; }
  .main { padding: 18px 12px; min-width: 0; }
  .workspace { min-width: 0; }
}

/* HR tables use .table-wrapper; give it the same horizontal scroll as .table-wrap */
.table-wrapper {
  overflow-x: auto;
  max-width: 100%;
}

@media (max-width: 700px) {
  .dashboard-appointment {
    flex-wrap: wrap;
  }
  .dashboard-appointment .appointment-body {
    flex: 1 1 60%;
    min-width: 0;
  }
  .dashboard-appointment .appointment-actions {
    margin-inline-start: auto;
  }
}

/* Primary buttons have no visible border; on the navy top bar a faint sky outline keeps them defined. */
.button-primary {
  border-color: transparent;
}
.topbar .button-primary {
  border-color: rgba(125, 211, 252, 0.45);
}

/* ================================================================
   Sign-in & request-trial screens
   ================================================================ */

/* The card must stay reachable on short screens (phones in landscape): scroll the screen
   instead of clipping, and center with auto margins so nothing is cut off at the top. */
.online-login-screen {
  display: flex;
  overflow-x: hidden;
  overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.online-login-screen > .online-login-card,
.online-login-screen > .trial-card {
  margin: auto;
}

.login-lang-btn {
  justify-self: end;
  padding: 6px 12px;
  font-size: 12px;
  margin-bottom: -8px;
}

.trial-page {
  background: #0b2942;
}
.trial-screen {
  position: fixed;
}
.trial-card {
  width: min(520px, 100%);
}
.trial-card h1 {
  margin: 0;
  font-size: 22px;
  text-align: center;
}
.trial-card > .muted,
.trial-card > .eyebrow {
  text-align: center;
  margin: 0;
}
.trial-card .brand-mark {
  margin: 0 auto;
}
.trial-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.trial-back {
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}
.trial-back:hover { text-decoration: underline; }
.trial-lang {
  padding: 6px 12px;
  font-size: 12px;
}
.trial-form {
  display: grid;
  gap: 14px;
}
.trial-form .field input,
.trial-form .field textarea {
  font-size: 16px; /* prevents iOS zoom-on-focus */
}
.trial-form .field input[aria-invalid="true"],
.trial-form .field textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.field-error {
  margin: 0;
  min-height: 0;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
}
.field-error:empty { display: none; }
.field-hint {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-align: end;
}
.trial-honeypot {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.trial-success {
  display: grid;
  gap: 12px;
  text-align: center;
}
.trial-success.hidden,
.trial-form.hidden { display: none; }
.trial-success h2 { margin: 0; }
.trial-success-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #dcfce7;
  color: #15803d;
  font-size: 28px;
  font-weight: 700;
}
@media (max-width: 480px) {
  .online-login-card { padding: 28px 20px; }
}
.trial-form .login-error:empty { display: none; }
.trial-card > .eyebrow { justify-self: center; }

/* ================================================================
   Odontogram quadrants (responsive)
   ================================================================ */
.teeth-row {
  gap: 18px;
  align-items: flex-end;
}
.teeth-quadrant {
  display: flex;
  gap: 6px;
  justify-content: center;
}
/* Midline between the patient's right and left quadrants. */
.teeth-quadrant + .teeth-quadrant {
  border-inline-start: 2px dashed #cbd5e1;
  padding-inline-start: 18px;
}
.teeth-row { direction: ltr; }

@media (max-width: 1100px) {
  .odontogram-wrap {
    padding: 14px 4px;
    overflow: visible;
  }
  .teeth-row {
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .teeth-quadrant {
    position: relative;
    gap: 2px;
    padding-top: 18px;
  }
  .teeth-quadrant + .teeth-quadrant {
    border-inline-start: 0;
    border-top: 2px dashed #cbd5e1;
    padding-inline-start: 0;
    padding-top: 26px;
  }
  .teeth-quadrant::before {
    content: attr(data-side);
    position: absolute;
    top: 0;
    inset-inline-start: 2px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
  }
  .teeth-quadrant + .teeth-quadrant::before { top: 8px; }
  .odontogram-direction-labels { display: none; }
  .tooth,
  .primary-odontogram .tooth {
    flex: 1 1 0;
    min-width: 0;
    max-width: 44px;
    width: auto;
    height: auto;
    min-height: 44px;
  }
  .tooth-visual,
  .primary-odontogram .tooth-visual {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
  }
  .tooth-label,
  .primary-odontogram .tooth-label { font-size: 13px; }
  .tooth:hover { transform: none; }
}

/* ================================================================
   Responsive & touch layer
   ================================================================ */

/* Overlays must stack above the sticky top bar (z-index 50). */
.drawer-backdrop { z-index: 150; }
.context-drawer { z-index: 160; }
.modal { z-index: 200; }
.toast { z-index: 300; }

/* Safe areas (notches / home indicator) for installed apps and mobile browsers. */
.topbar {
  padding-top: max(0px, env(safe-area-inset-top));
  padding-inline-start: max(28px, env(safe-area-inset-left));
  padding-inline-end: max(28px, env(safe-area-inset-right));
}
.main { padding-bottom: max(24px, env(safe-area-inset-bottom)); }

/* Wide tables scroll horizontally inside their card; edge shadows show there is more. */
.table-wrap,
.table-wrapper,
.admin-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left center / 24px 100% no-repeat local,
    linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right center / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, 0.14), transparent) left center / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, 0.14), transparent) right center / 10px 100% no-repeat scroll;
}

/* Touch devices: comfortable hit areas for icon-sized controls. */
@media (pointer: coarse) {
  .modal-close,
  .icon-button,
  .appointment-delete,
  .xray-delete-button,
  .btn-xs,
  .btn-admin-action,
  .medication-delete-button,
  .button-sm,
  .sidebar-toggle,
  .toggle-password-btn {
    min-width: 40px;
    min-height: 40px;
  }
  .tooth:hover,
  .button:hover { transform: none; }
}

/* Phones: 16px form text prevents iOS zoom-on-focus; dialogs become bottom sheets. */
@media (max-width: 700px), (max-height: 500px) and (orientation: landscape) {
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  .field input,
  .field select,
  .field textarea,
  .hr-date-input,
  .inv-search,
  .inv-toolbar select,
  #auditSearchInput,
  #adminClinicSearch,
  #adminUserSearch,
  .treatment-status-select,
  .appointment-status-select {
    font-size: 16px;
  }
  .modal {
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    align-items: end;
  }
  .modal-card {
    width: 100%;
    max-height: calc(100dvh - 16px - env(safe-area-inset-top));
    padding: 22px 16px 18px;
    border-radius: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .modal-card .form-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .modal-card h2 { font-size: 18px; padding-inline-end: 40px; }
  .context-drawer {
    width: 100% !important;
    max-width: 100%;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .page-heading h1 { font-size: 22px; }
}

/* Phones in landscape have little height: use the compact rail, not the full sidebar. */
@media (max-height: 500px) and (orientation: landscape) {
  body .sidebar,
  body:not(.sidebar-collapsed) .sidebar {
    width: 60px !important;
    padding: 10px 6px !important;
  }
  body .profile > div:last-child,
  body .sidebar-foot span:last-child,
  body .nav-item span:last-child,
  body:not(.sidebar-collapsed) .profile > div:last-child,
  body:not(.sidebar-collapsed) .sidebar-foot span:last-child,
  body:not(.sidebar-collapsed) .nav-item span:last-child {
    display: none !important;
  }
  body .nav-item,
  body:not(.sidebar-collapsed) .nav-item {
    justify-content: center !important;
    padding: 9px 4px !important;
  }
  body .profile,
  body:not(.sidebar-collapsed) .profile { padding: 0 0 10px !important; justify-content: center !important; }
  .sidebar-toggle { display: none; }
  .online-authenticated .online-logout-button { width: 44px; margin: 8px auto; padding: 8px 0; display: grid; place-items: center; }
  .online-logout-button span { display: none; }
  .online-logout-button::before { content: "⏻"; font-size: 16px; }
  .topbar { min-height: 56px; padding-block: 8px; }
  .brand span, .clock { display: none; }
  .heading-date { display: none; }
}

/* Inventory: tabs get their own scrollable row on narrow screens. */
@media (max-width: 900px) {
  .inv-tabs-row { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .inv-tabs { flex: none; }
  .inv-tab { flex: 0 0 auto; }
  .inv-quick { justify-content: stretch; }
  .inv-quick .button { flex: 1 1 0; }
}

/* Agenda: appointment cards wrap (based on the agenda's own width, whatever the sidebar
   state) so status, edit and delete stay reachable. */
.agenda { container-type: inline-size; }
@container (max-width: 620px) {
  .agenda .appointment {
    flex-wrap: wrap;
    gap: 8px;
  }
  .agenda .appointment > div:first-child { flex: 1 1 100%; min-width: 0; }
  .agenda .appointment > [data-stop-propagation] { flex: 1 1 100%; justify-content: flex-end; flex-wrap: wrap; }
  .agenda .appointment-status-select { flex: 1 1 140px; }
}
@media (max-width: 700px) {
  .agenda-row { grid-template-columns: 52px 1fr; }
  .agenda-time { padding: 10px 6px; }
  .audit-search-box, #auditSearchInput { max-width: 100%; min-width: 0; width: 100%; }
}

.audit-search-box {
  position: relative;
  flex: 1 1 240px;
  min-width: 0;
  max-width: 360px;
}
.audit-search-input {
  width: 100%;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 13px;
  background: #fff;
}
.audit-search-input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

@media (max-width: 700px) {
  .card { padding: 16px 12px; border-radius: 14px; }
  .audit-search-box { max-width: none; flex-basis: 100%; }
  .audit-search-input { font-size: 16px; }
}

/* HR: tabs keep their natural width and scroll on narrow screens. */
@media (max-width: 700px) {
  .hr-tab { flex: 0 0 auto; }
}

/* Connectivity banner (online mode): shown while the device is offline. */
.connection-banner {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 250;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #7c2d12;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
}
@media print {
  .connection-banner { display: none !important; }
}

/* Screen-reader-only text. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* WhatsApp reminder buttons (links styled as buttons). */
.whatsapp-button {
  color: #15803d;
  border-color: #bbf7d0;
  text-decoration: none;
  white-space: nowrap;
}
.whatsapp-button:hover { background: #f0fdf4; }
.whatsapp-button:disabled { color: var(--muted); border-color: #e2e8f0; cursor: not-allowed; }

/* Recall list (dashboard). */
.recall-hint, .sessions-hint { margin: -4px 0 12px; font-size: 13px; }
.recall-interval select { min-width: 0; max-width: 100%; }
.recall-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.recall-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border-bottom: 1px solid #f1f5f9;
}
.recall-patient {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 0;
  background: none;
  border: 0;
  text-align: start;
  color: inherit;
  cursor: pointer;
}
.recall-patient b { color: #0f172a; font-size: 14px; overflow-wrap: anywhere; }
.recall-patient small { font-size: 12px; }
.recall-patient:hover b, .recall-patient:focus-visible b { color: var(--primary); }
.recall-more { margin: 6px 0 0; font-size: 12px; }

/* Active sessions (settings). */
.session-list { display: grid; gap: 8px; }
.session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.session-row.is-current { border-color: #bbf7d0; background: #f0fdf4; }
.session-info { flex: 1; min-width: 0; display: grid; gap: 4px; }
.session-info small { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.sessions-more { margin: 4px 0 0; font-size: 12px; }
.recall-card .card-heading { flex-wrap: wrap; }
.recall-interval { flex: 1 1 180px; display: flex; justify-content: flex-end; min-width: 0; }
.recall-interval select { width: auto; max-width: 100%; }
@media (max-width: 700px) {
  .recall-interval, .recall-interval select { width: 100%; }
}

/* Clinic backup (settings). */
.backup-divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0 14px; }
.backup-subtitle { margin: 0 0 8px; font-size: 16px; }
.backup-warning {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.5;
}
.backup-confirm { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.backup-confirm input { margin-top: 3px; min-height: 0; width: auto; }
.backup-result {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  font-size: 13px;
  overflow-wrap: anywhere;
}
