/* Shared UI components. Class names are the contract used by module UIs (see web/js/core/README.md). */

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 38px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 600;
  font-size: var(--fs);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font-weight: 600; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-sm { min-height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-lg { min-height: 46px; padding: 0 var(--sp-6); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent;
  animation: spin 0.8s linear infinite;
}
.btn-primary.is-loading::after, .btn-danger.is-loading::after { border-color: #fff transparent #fff transparent; }
.btn-group { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- forms ---------- */
.form { display: grid; gap: var(--sp-4); }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2, .form-grid .field-full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); padding-block-start: var(--sp-2); }
.form-section-title { grid-column: 1 / -1; font-weight: 700; color: var(--ink-2); margin-block-start: var(--sp-2);
  padding-block-end: var(--sp-1); border-block-end: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--danger); margin-inline-start: 2px; }
.field-help { font-size: var(--fs-xs); color: var(--muted); }
.field-error { font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }
.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: auto; padding-inline-end: 8px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--muted); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { flex: 1; border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group .btn { border-start-start-radius: 0; border-end-start-radius: 0; margin-inline-start: -1px; }
.form-error-summary { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm); background: var(--danger-bg);
  color: var(--danger); font-weight: 600; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-block-end: 1px solid var(--line); }
.card-header h2, .card-header h3 { font-size: var(--fs-md); }
.card-body { padding: var(--sp-5); }
.card-footer { padding: var(--sp-3) var(--sp-5); border-block-start: 1px solid var(--line); background: var(--surface-2);
  border-end-start-radius: var(--radius); border-end-end-radius: var(--radius); }
.card-pad { padding: var(--sp-5); }

.stat { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-4) var(--sp-5); }
.stat-label { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.stat-value { font-size: var(--fs-xl); font-weight: 800; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; }
.kv dt { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* department cards: large product-card style tiles */
.dept-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.dept-card {
  --dc: var(--accent);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: 190px;
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, color-mix(in srgb, var(--dc) 9%, #fff) 0%, #fff 60%);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  text-align: start;
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.dept-card::after {
  content: ""; position: absolute; inset-inline-end: -40px; inset-block-start: -40px; width: 140px; height: 140px;
  border-radius: 50%; background: color-mix(in srgb, var(--dc) 12%, transparent);
}
.dept-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--dc) 40%, var(--line)); text-decoration: none; }
.dept-card-icon { width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center;
  background: var(--dc); color: #fff; box-shadow: 0 10px 22px color-mix(in srgb, var(--dc) 35%, transparent); }
.dept-card-icon .icon { width: 30px; height: 30px; }
.dept-card-name { font-size: var(--fs-lg); font-weight: 800; }
.dept-card-sub { color: var(--muted); font-size: var(--fs-sm); }
.dept-card-foot { margin-block-start: auto; display: flex; align-items: center; justify-content: space-between;
  color: var(--dc); font-weight: 700; font-size: var(--fs-sm); }

/* nav tiles (department dashboard quick links) */
.tile-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.tile { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); font-weight: 700; }
.tile:hover { border-color: var(--accent); text-decoration: none; box-shadow: var(--shadow-sm); }
.tile .icon { width: 24px; height: 24px; color: var(--accent); }

/* ---------- badges / pills ---------- */
.badge, .pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700; line-height: 1.6; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-count { min-width: 18px; padding: 0 5px; justify-content: center; background: var(--danger); color: #fff; font-size: 11px; }
.pill--success, .badge--success, .pill--completed, .pill--active, .pill--paid { background: var(--success-bg); color: var(--success); }
.pill--warning, .badge--warning, .pill--in_progress, .pill--trial, .pill--partial { background: var(--warning-bg); color: var(--warning); }
.pill--danger, .badge--danger, .pill--no_show, .pill--expired, .pill--suspended, .pill--unpaid { background: var(--danger-bg); color: var(--danger); }
.pill--info, .badge--info, .pill--scheduled { background: var(--info-bg); color: var(--info); }
.pill--purple, .pill--arrived { background: var(--purple-bg); color: var(--purple); }
.pill--neutral, .pill--cancelled, .pill--archived, .pill--draft { background: var(--neutral-bg); color: var(--neutral); }
.pill--cancelled { text-decoration: line-through; }

/* ---------- alerts / banners ---------- */
.alert { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--info-bg); color: var(--info); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.alert .icon { margin-block-start: 3px; }
.offline-copy-banner { margin-block-end: var(--sp-3); }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs); }
.table th, .table td { padding: 10px var(--sp-4); text-align: start; border-block-end: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted);
  background: var(--surface-2); white-space: nowrap; }
.table tbody tr:hover { background: var(--accent-softer); }
.table tr.is-clickable { cursor: pointer; }
.table td.actions { text-align: end; white-space: nowrap; }
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  border-block-end: 1px solid var(--line); }
.table-toolbar .input { max-width: 320px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4); color: var(--muted); font-size: var(--fs-sm); }
.pagination .btn-group { flex-wrap: nowrap; }

/* phones: tables collapse into stacked cards (cells need data-label) */
@media (max-width: 640px) {
  .table.table-stack thead { display: none; }
  .table.table-stack, .table.table-stack tbody, .table.table-stack tr, .table.table-stack td { display: block; width: 100%; }
  .table.table-stack tr { padding: var(--sp-2) 0; border-block-end: 1px solid var(--line); }
  .table.table-stack td { border: 0; padding: 4px var(--sp-4); display: flex; justify-content: space-between; gap: var(--sp-3); text-align: end; }
  .table.table-stack td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-xs); font-weight: 700; text-align: start; }
  .table.table-stack td.actions { justify-content: flex-end; }
  .table.table-stack td.actions::before { content: none; }
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: var(--sp-1); border-block-end: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tab { padding: 10px var(--sp-4); border: 0; border-block-end: 3px solid transparent; background: none; color: var(--muted);
  font-weight: 700; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-block-end-color: var(--accent); }
.tab-panel { padding-block-start: var(--sp-4); }

/* ---------- states ---------- */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-4); text-align: center; color: var(--muted); }
.state .icon { width: 40px; height: 40px; color: var(--line-strong); }
.state-title { font-weight: 700; color: var(--ink-2); font-size: var(--fs-md); }
.state-error .icon { color: var(--danger); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-block-start-color: var(--accent);
  animation: spin 0.8s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%;
  animation: shimmer 1.2s infinite; border-radius: var(--radius-xs); min-height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- dropdown / popover menus ---------- */
.popover { position: absolute; z-index: var(--z-drawer); min-width: 220px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--sp-2); }
.menu-item { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: 9px var(--sp-3); border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--ink-2); text-align: start; font-weight: 600; }
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: var(--sp-2) 0; }
.menu-head { padding: var(--sp-2) var(--sp-3) var(--sp-3); border-block-end: 1px solid var(--line); margin-block-end: var(--sp-2); }

/* ---------- modal / drawer ---------- */
.overlay { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: var(--sp-4);
  background: rgba(15, 23, 42, 0.45); animation: fadeIn 0.15s ease-out; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: popIn 0.18s ease-out; }
.modal-sm { width: min(420px, 100%); }
.modal-lg { width: min(860px, 100%); }
.modal-xl { width: min(1180px, 100%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5);
  border-block-end: 1px solid var(--line); flex-shrink: 0; }
.modal-header h2 { font-size: var(--fs-md); }
.modal-header .btn { min-width: 38px; min-height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.modal-body { padding: var(--sp-5); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.modal-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5);
  border-block-start: 1px solid var(--line); background: var(--surface-2); border-end-start-radius: var(--radius-lg); border-end-end-radius: var(--radius-lg); flex-shrink: 0; }
.drawer-overlay { place-items: stretch; justify-items: end; padding: 0; }
.drawer { width: min(520px, 100vw); height: 100%; max-height: 100dvh; display: flex; flex-direction: column; background: var(--surface);
  box-shadow: var(--shadow-lg); animation: slideIn 0.2s ease-out; position: relative; }
.drawer-lg { width: min(760px, 100vw); }
.drawer .modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.drawer .modal-footer { border-radius: 0; }
[dir="rtl"] .drawer { animation-name: slideInRtl; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes slideIn { from { transform: translateX(100%); } }
@keyframes slideInRtl { from { transform: translateX(-100%); } }
@media (max-width: 640px) {
  .dept-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .dept-card { min-height: 0; padding: var(--sp-4); gap: var(--sp-2); }
  .dept-card-icon { width: 46px; height: 46px; border-radius: 13px; }
  .dept-card-icon .icon { width: 24px; height: 24px; }
  .dept-card-name { font-size: var(--fs-md); }
  .overlay:not(.drawer-overlay) { place-items: end stretch; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-end-start-radius: 0; border-end-end-radius: 0; }
  .drawer { width: 100vw; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (pointer: coarse) {
  .modal-header .btn { min-width: 44px; min-height: 44px; }
  .modal-footer .btn { min-height: 42px; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: var(--z-toast); inset-block-end: var(--sp-5); inset-inline-end: var(--sp-5); display: flex;
  flex-direction: column; gap: var(--sp-2); width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--radius);
  background: var(--c-navy); color: #fff; box-shadow: var(--shadow-lg); pointer-events: auto; animation: popIn 0.2s ease-out; }
.toast-msg { flex: 1; min-width: 0; }
.toast.toast-success { background: #065f46; }
.toast.toast-error { background: #991b1b; }
.toast.toast-warning { background: #92400e; }
.toast .btn { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.toast .btn:hover { background: rgba(255, 255, 255, 0.24); }
.toast-close { background: none; border: 0; color: rgba(255, 255, 255, 0.75); padding: 2px; }
.toast-countdown { font-variant-numeric: tabular-nums; opacity: 0.75; font-size: var(--fs-xs); }
@media (max-width: 640px) {
  .toasts { inset-inline: var(--sp-4); inset-block-end: var(--sp-4); width: auto; }
}

/* ---------- patient search box ---------- */
.search-box { position: relative; }
.search-box .input { padding-inline-start: 36px; }
.search-box > .icon { position: absolute; inset-inline-start: 11px; inset-block-start: 11px; color: var(--muted); pointer-events: none; }
.search-results { position: absolute; z-index: var(--z-drawer); inset-inline: 0; inset-block-start: calc(100% + 4px); max-height: 340px;
  overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--sp-1); }
.search-result { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 8px var(--sp-3); border: 0; background: none;
  border-radius: var(--radius-sm); text-align: start; }
.search-result:hover, .search-result.is-active { background: var(--accent-soft); }
.search-result-name { font-weight: 700; }
.search-result-meta { font-size: var(--fs-xs); color: var(--muted); }
.search-hint { padding: var(--sp-3); color: var(--muted); font-size: var(--fs-sm); }

/* ---------- avatar ---------- */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: var(--fs-sm); }

/* ---------- coming-soon slot ---------- */
.coming-soon { max-width: 560px; margin: var(--sp-10) auto; }

/* numbers, phones, emails and dates are always entered left-to-right */
[dir="rtl"] .input:is([type="number"], [type="tel"], [type="email"], [type="date"], [type="time"], [type="datetime-local"], [type="url"]) {
  direction: ltr;
  text-align: right;
}

/* ---------- Topbar Quick Search Trigger ---------- */
.topbar-search-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.topbar-search-btn:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.topbar-kbd {
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-2);
}

/* ---------- Omni Search / Command Palette ---------- */
.omni-modal {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: -16px;
}
.omni-search-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.omni-search-bar .icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex-shrink: 0;
}
.omni-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: var(--fs-md);
  color: var(--ink);
  outline: none;
  font-family: inherit;
}
.omni-results {
  max-height: 360px;
  overflow-y: auto;
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.omni-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px 4px;
}
.omni-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: start;
  cursor: pointer;
  transition: all 0.1s ease;
  user-select: none;
}
.omni-item:hover, .omni-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.omni-item-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  flex-shrink: 0;
}
.omni-item:hover .omni-item-icon, .omni-item.is-active .omni-item-icon {
  background: var(--accent);
  color: #fff;
}
.omni-item-content {
  flex: 1;
  min-width: 0;
}
.omni-item-title {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.omni-item-sub {
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.omni-item-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.omni-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-4);
  color: var(--muted);
  font-size: var(--fs-sm);
}
.omni-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-4);
  padding: 8px var(--sp-4);
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--muted);
}
.omni-key-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.omni-key-hint kbd {
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-2);
}

/* ---------- Field Label Row & Snippet Picker ---------- */
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.snippet-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.snippet-trigger-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.snippet-trigger-btn .icon {
  width: 12px;
  height: 12px;
}
.dictate-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.dictate-trigger-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.dictate-trigger-btn .icon {
  width: 12px;
  height: 12px;
}
.dictate-trigger-btn.is-listening {
  background: #fee2e2;
  color: #dc2626;
  border-color: #ef4444;
  animation: pulse-recording 1.2s infinite ease-in-out;
}
@keyframes pulse-recording {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2); }
}
.snippet-popover {
  max-width: 380px;
  width: 90vw;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  z-index: var(--z-modal);
}
.snippet-popover-body {
  display: flex;
  flex-direction: column;
}
.snippet-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.snippet-popover-list {
  max-height: 260px;
  overflow-y: auto;
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.snippet-item {
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-align: start;
  font-size: var(--fs-xs);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s ease;
  line-height: 1.45;
}
.snippet-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(13, 148, 136, 0.25);
}

/* Vitals & Biometrics */
.vitals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--sp-3);
}
.vitals-tile {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.vitals-tile-header {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
}
.vitals-tile-val {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.vitals-tile-val strong {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ink);
}
.vitals-tile-unit {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
}
.vitals-sparkline {
  overflow: visible;
}
.vitals-trends-row {
  margin-bottom: var(--sp-2);
}

/* 80mm POS Thermal Receipt Preview */
.receipt-thermal {
  max-width: 320px;
  margin: 0 auto;
  padding: 16px;
  background: #fff;
  color: #111;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px dashed #ccc;
  border-radius: 4px;
}
.th-header {
  text-align: center;
  margin-bottom: 8px;
}
.th-center-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
.th-title {
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
  text-transform: uppercase;
}
.th-divider {
  border-top: 1px dashed #777;
  margin: 8px 0;
}
.th-divider-dashed {
  border-top: 1px dotted #aaa;
}
.th-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.th-lbl {
  color: #444;
}
.th-items-head {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
  margin-bottom: 6px;
}
.th-item-line {
  margin-bottom: 6px;
}
.th-item-name {
  font-weight: 600;
}
.th-item-calc {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.th-grand-total {
  font-size: 14px;
  font-weight: 700;
  border-top: 1px solid #222;
  border-bottom: 1px solid #222;
  padding: 4px 0;
  margin: 4px 0;
}
.th-paid-now {
  font-weight: 600;
}
.th-balance {
  font-weight: 700;
  color: #b91c1c;
}
.th-barcode-wrap {
  text-align: center;
  margin: 10px 0 6px 0;
}
.th-footer {
  text-align: center;
  font-size: 10px;
  color: #555;
  margin-top: 8px;
}

/* Printable Patient ID Card (CR80 Standard: 85.6mm x 54mm) */
.id-card-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}
.patient-id-card {
  width: 340px;
  height: 215px;
  background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}
.patient-id-card::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--accent, #0d9488), #2563eb);
}
.id-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.id-card-center {
  display: flex;
  align-items: center;
  gap: 8px;
}
.id-card-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent, #0d9488);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.id-card-logo svg {
  width: 18px;
  height: 18px;
}
.id-card-center-name {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  display: block;
}
.id-card-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(13, 148, 136, 0.12);
  color: var(--accent, #0d9488);
}
.id-card-name {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin: 6px 0 8px 0;
}
.id-card-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  font-size: 11px;
}
.id-card-field {
  display: flex;
  flex-direction: column;
}
.id-card-field.span-2 {
  grid-column: span 2;
}
.id-card-lbl {
  font-size: 9px;
  color: #64748b;
  text-transform: uppercase;
}
.id-card-val {
  font-weight: 600;
  color: #1e293b;
}
.id-card-val.highlight {
  color: #b91c1c;
}
.id-card-barcode-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}
.id-card-code-text {
  font-size: 10px;
  font-family: monospace;
  font-weight: 600;
  color: #334155;
  letter-spacing: 1px;
}

/* Orders Panel & Investigation Badges */
.orders-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.order-item-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  background: var(--surface-1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
}
.order-item-main {
  flex: 1;
}
.order-item-title {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink);
}
.order-item-sub {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Referrals / Consultations Timeline */
.referrals-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.referral-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  background: var(--surface-1);
}
.referral-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-2);
}
.referral-route {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: var(--fs-sm);
}
.referral-reason {
  font-size: var(--fs-sm);
  margin-top: var(--sp-1);
}
.referral-notes {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  background: var(--surface-2);
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  margin-top: var(--sp-2);
}

/* Packages & Installments */
.package-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  background: var(--surface-1);
  margin-bottom: var(--sp-3);
}
.pkg-progress-wrap {
  margin: var(--sp-3) 0;
}
.pkg-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.pkg-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.pkg-session-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--sp-2);
}
.pkg-session-pill {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--ink-muted);
}
.pkg-session-pill.used {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}



