/* ==========================================================================
   SANJARMedi — Hospital / Clinic Provider Panel
   Design System: Modern Healthcare (Premium Slate & Blue)
   Shares tokens, typography and elevation with the public website stylesheet
   so patients and clinic staff see one coherent product.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Typography */
  --sm-font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sm-font-display: var(--sm-font-body);

  /* Brand */
  --sm-primary: hsl(215, 90%, 52%);
  --sm-primary-hover: hsl(215, 90%, 45%);
  --sm-primary-dark: hsl(215, 90%, 38%);
  --sm-primary-light: hsl(215, 90%, 96%);

  --sm-secondary: hsl(150, 75%, 38%);
  --sm-secondary-light: hsl(150, 75%, 96%);
  --sm-accent: hsl(187, 85%, 42%);
  --sm-accent-light: hsl(187, 85%, 96%);
  --sm-warning: hsl(35, 92%, 45%);
  --sm-warning-light: hsl(35, 92%, 95%);
  --sm-danger: hsl(354, 76%, 53%);
  --sm-danger-light: hsl(354, 76%, 96%);

  /* Neutrals */
  --sm-ink: hsl(220, 25%, 15%);
  --sm-ink-soft: hsl(220, 15%, 32%);
  --sm-bg: hsl(220, 20%, 98%);
  --sm-panel: hsl(0, 0%, 100%);
  --sm-panel-strong: hsl(220, 20%, 97%);
  --sm-border: hsl(220, 15%, 90%);
  --sm-border-light: hsl(220, 15%, 95%);
  --sm-text: hsl(220, 25%, 15%);
  --sm-muted: hsl(220, 15%, 45%);
  --sm-soft: hsl(215, 90%, 96%);
  --sm-amber-soft: hsl(35, 92%, 95%);

  /* Radii */
  --sm-radius-xs: 6px;
  --sm-radius-sm: 10px;
  --sm-radius-md: 16px;
  --sm-radius-lg: 24px;
  --sm-radius-pill: 9999px;

  /* Elevation */
  --shadow-sm: 0 2px 8px rgba(26, 115, 232, 0.04);
  --shadow-md: 0 8px 24px rgba(26, 115, 232, 0.06);
  --shadow-lg: 0 16px 48px rgba(26, 115, 232, 0.1);
  --panel-shadow: var(--shadow-sm);
  --hairline-shadow: inset 3px 0 0 var(--sm-primary);

  /* Motion */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* Bootstrap bridge */
  --bs-body-font-family: var(--sm-font-body);
  --bs-border-radius: var(--sm-radius-sm);
  --bs-focus-ring-color: rgba(26, 115, 232, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sm-font-body);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--sm-text);
  background: var(--sm-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  letter-spacing: -0.02em;
}

/* Consistent keyboard affordance across every interactive element */
:where(a, button, input, select, textarea, summary, .nav-link, .quick-filter-chip):focus-visible {
  outline: 2px solid var(--sm-primary);
  outline-offset: 2px;
  box-shadow: none;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: hsl(220, 15%, 85%);
  border: 3px solid var(--sm-bg);
  border-radius: var(--sm-radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: hsl(220, 15%, 75%);
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

/* ==========================================================================
   Login
   ========================================================================== */

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px circle at 50% -10%, hsl(215, 90%, 94%), transparent 70%),
    var(--sm-bg);
}

.login-panel {
  width: min(430px, 100%);
  background: var(--sm-panel);
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-md);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.login-panel h1 {
  font-family: var(--sm-font-display);
  font-size: 1.6rem;
  font-weight: 800;
  margin: 16px 0 4px;
}

.login-panel p {
  margin-bottom: 26px;
  color: var(--sm-muted);
  font-size: 0.9rem;
}

.login-panel .btn-primary {
  min-height: 46px;
  margin-top: 4px;
}

.brand-mark,
.brand-icon {
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, hsl(215, 90%, 52%) 0%, hsl(200, 95%, 48%) 100%);
  border-radius: var(--sm-radius-sm);
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-md);
}

.brand-mark {
  width: 52px;
  height: 52px;
  font-size: 1.15rem;
  border-radius: var(--sm-radius-md);
}

.brand-icon {
  width: 36px;
  height: 36px;
  font-size: 0.78rem;
  box-shadow: none;
}

/* ==========================================================================
   Application shell
   ========================================================================== */

.provider-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  color: var(--sm-text);
  background: var(--sm-panel);
  border-right: 1px solid var(--sm-border-light);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
  padding: 0 6px;
  font-family: var(--sm-font-display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  align-content: start;
}

.sidebar-nav .nav-link {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  color: var(--sm-muted);
  background: transparent;
  border: 0;
  border-radius: var(--sm-radius-sm);
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.sidebar-nav .nav-link i {
  font-size: 1.05rem;
  line-height: 1;
  color: var(--sm-text-muted, var(--sm-muted));
  transition: color var(--transition-fast);
}

.sidebar-nav .nav-link:hover {
  color: var(--sm-text);
  background: var(--sm-panel-strong);
}

.sidebar-nav .nav-link.active {
  color: var(--sm-primary);
  background: var(--sm-primary-light);
  font-weight: 700;
}

.sidebar-nav .nav-link.active i {
  color: var(--sm-primary);
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: hsla(0, 0%, 100%, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--sm-border-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h2 {
  font-family: var(--sm-font-display);
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
}

.topbar span {
  color: var(--sm-muted);
  font-size: 0.84rem;
}

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

.operator-pill {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sm-ink-soft);
  background: var(--sm-panel-strong);
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-pill);
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
}

.content-view {
  padding: 24px 28px 40px;
}

/* ==========================================================================
   Command strip
   ========================================================================== */

.provider-command-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
  padding: 22px 24px;
  color: #fff;
  background:
    radial-gradient(600px circle at 100% 0%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(135deg, hsl(215, 90%, 52%) 0%, hsl(200, 95%, 44%) 100%);
  border-radius: var(--sm-radius-md);
  box-shadow: var(--shadow-md);
}

.command-copy {
  display: grid;
  gap: 4px;
}

.command-copy .eyebrow {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.command-copy strong {
  font-family: var(--sm-font-display);
  font-size: clamp(1.28rem, 2vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.command-copy span:last-child {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.88rem;
}

.command-actions,
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* Buttons sitting on the gradient need their own treatment.
   The primary action inverts to a solid white chip; the rest stay ghosted. */
.provider-command-strip .btn-primary {
  --bs-btn-color: hsl(215, 90%, 40%);
  --bs-btn-bg: #fff;
  --bs-btn-border-color: #fff;
  --bs-btn-hover-color: hsl(215, 90%, 34%);
  --bs-btn-hover-bg: hsl(215, 90%, 97%);
  --bs-btn-hover-border-color: hsl(215, 90%, 97%);
  --bs-btn-active-color: hsl(215, 90%, 34%);
  --bs-btn-active-bg: hsl(215, 90%, 94%);
  --bs-btn-active-border-color: hsl(215, 90%, 94%);
}

.provider-command-strip .btn-outline-primary,
.provider-command-strip .btn-outline-secondary {
  --bs-btn-color: #fff;
  --bs-btn-bg: rgba(255, 255, 255, 0.12);
  --bs-btn-border-color: rgba(255, 255, 255, 0.45);
  --bs-btn-hover-color: hsl(215, 90%, 40%);
  --bs-btn-hover-bg: #fff;
  --bs-btn-hover-border-color: #fff;
  --bs-btn-active-color: hsl(215, 90%, 34%);
  --bs-btn-active-bg: #fff;
  --bs-btn-active-border-color: #fff;
  backdrop-filter: blur(4px);
}

/* ==========================================================================
   Stat cards
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card,
.panel {
  background: var(--sm-panel);
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-md);
  box-shadow: var(--shadow-sm);
}

.stat-card {
  min-height: 128px;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--sm-primary);
  opacity: 0.85;
}

.stat-icon {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  font-size: 1.05rem;
  color: var(--sm-primary);
  background: var(--sm-primary-light);
  border-radius: var(--sm-radius-sm);
  margin-bottom: 6px;
}

.stat-blue::before { background: var(--sm-primary); }
.stat-blue .stat-icon {
  color: var(--sm-primary);
  background: var(--sm-primary-light);
}

.stat-green::before { background: var(--sm-secondary); }
.stat-green .stat-icon {
  color: var(--sm-secondary);
  background: var(--sm-secondary-light);
}

.stat-teal::before { background: var(--sm-accent); }
.stat-teal .stat-icon {
  color: var(--sm-accent);
  background: var(--sm-accent-light);
}

.stat-amber::before { background: var(--sm-warning); }
.stat-amber .stat-icon {
  color: var(--sm-warning);
  background: var(--sm-amber-soft);
}

.stat-ink::before { background: var(--sm-ink); }
.stat-ink .stat-icon {
  color: #fff;
  background: var(--sm-ink);
}

.stat-label {
  color: var(--sm-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  font-family: var(--sm-font-display);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-hint {
  color: var(--sm-muted);
  font-size: 0.78rem;
}

/* ==========================================================================
   Panels
   ========================================================================== */

.panel {
  padding: 20px;
}

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

.panel-header h3 {
  margin: 0;
  font-family: var(--sm-font-display);
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   Filters & toolbars
   ========================================================================== */

.quick-filter-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.quick-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 14px;
  color: var(--sm-ink-soft);
  background: var(--sm-panel-strong);
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-pill);
  font-weight: 700;
  font-size: 0.82rem;
  transition: color var(--transition-fast), background var(--transition-fast),
    border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.quick-filter-chip:hover {
  color: var(--sm-primary);
  background: var(--sm-primary-light);
  border-color: hsl(215, 90%, 88%);
}

.quick-filter-chip.active {
  color: #fff;
  background: var(--sm-primary);
  border-color: var(--sm-primary);
  box-shadow: var(--shadow-sm);
}

/* Filter bars wrap on their own rather than depending on a single breakpoint,
   so the trailing Filter button is never clipped at awkward widths. */
.toolbar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.toolbar-grid > * {
  flex: 1 1 180px;
  min-width: 0;
}

.toolbar-grid > .btn {
  flex: 0 0 auto;
}

.appointment-filters > [type='search'] {
  flex: 2 1 220px;
}

.appointment-filters > [type='date'] {
  flex: 1 1 150px;
}

.prescription-filters > [type='search'] {
  flex: 1 1 240px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

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

.compact-form {
  gap: 12px;
}

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

.field span {
  color: var(--sm-ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.field.full,
.form-grid button {
  grid-column: 1 / -1;
}

.form-label {
  color: var(--sm-ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.form-control,
.form-select {
  min-height: 42px;
  padding: 9px 12px;
  color: var(--sm-text);
  background: var(--sm-panel);
  border: 1px solid var(--sm-border);
  border-radius: var(--sm-radius-sm);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control::placeholder {
  color: var(--sm-muted);
  opacity: 0.75;
}

.form-control:hover:not(:focus),
.form-select:hover:not(:focus) {
  border-color: hsl(220, 15%, 82%);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--sm-primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
  outline: none;
}

.form-select-sm {
  min-height: 34px;
  padding: 4px 28px 4px 10px;
  font-size: 0.82rem;
}

.form-check-input:checked {
  background-color: var(--sm-primary);
  border-color: var(--sm-primary);
}

.form-check-input:focus {
  border-color: var(--sm-primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
}

.form-check-label {
  font-size: 0.85rem;
  color: var(--sm-ink-soft);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  border-radius: var(--sm-radius-sm);
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--sm-radius-xs);
}

.btn-primary {
  --bs-btn-bg: var(--sm-primary);
  --bs-btn-border-color: var(--sm-primary);
  --bs-btn-hover-bg: var(--sm-primary-hover);
  --bs-btn-hover-border-color: var(--sm-primary-hover);
  --bs-btn-active-bg: var(--sm-primary-dark);
  --bs-btn-active-border-color: var(--sm-primary-dark);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  box-shadow: var(--shadow-md);
}

.btn-outline-primary {
  --bs-btn-color: var(--sm-primary);
  --bs-btn-border-color: hsl(215, 90%, 86%);
  --bs-btn-bg: var(--sm-panel);
  --bs-btn-hover-bg: var(--sm-primary);
  --bs-btn-hover-border-color: var(--sm-primary);
  --bs-btn-active-bg: var(--sm-primary-hover);
  --bs-btn-active-border-color: var(--sm-primary-hover);
}

.btn-outline-secondary {
  --bs-btn-color: var(--sm-ink-soft);
  --bs-btn-border-color: var(--sm-border);
  --bs-btn-bg: var(--sm-panel);
  --bs-btn-hover-bg: var(--sm-panel-strong);
  --bs-btn-hover-border-color: hsl(220, 15%, 82%);
  --bs-btn-hover-color: var(--sm-ink);
  --bs-btn-active-bg: var(--sm-panel-strong);
  --bs-btn-active-border-color: hsl(220, 15%, 78%);
  --bs-btn-active-color: var(--sm-ink);
}

.btn-outline-danger {
  --bs-btn-color: var(--sm-danger);
  --bs-btn-border-color: hsl(354, 76%, 88%);
  --bs-btn-bg: var(--sm-panel);
  --bs-btn-hover-bg: var(--sm-danger);
  --bs-btn-hover-border-color: var(--sm-danger);
}

.btn:active {
  transform: translateY(1px);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table {
  --bs-table-color: var(--sm-text);
  --bs-table-border-color: var(--sm-border-light);
  margin-bottom: 0;
  vertical-align: middle;
  font-size: 0.88rem;
}

.table > :not(caption) > * > * {
  padding: 12px 14px;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--sm-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--sm-panel-strong);
  border-bottom: 1px solid var(--sm-border);
  white-space: nowrap;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--sm-panel-strong);
}

.table-responsive {
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
  overflow: auto;
  max-height: 620px;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 220px;
}

/* ==========================================================================
   Appointment & prescription boards
   ========================================================================== */

.appointment-board,
.prescription-board {
  display: grid;
  gap: 12px;
}

.appointment-board-compact {
  gap: 10px;
}

.appointment-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  overflow: hidden;
  background: var(--sm-panel);
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.appointment-card:hover {
  border-color: hsl(215, 90%, 88%);
  box-shadow: var(--shadow-md);
}

.appointment-time-ribbon {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 14px 10px;
  color: #fff;
  background: var(--sm-ink);
  text-align: center;
}

.appointment-confirmed .appointment-time-ribbon,
.appointment-checkedin .appointment-time-ribbon,
.appointment-checked-in .appointment-time-ribbon {
  background: var(--sm-primary);
}

.appointment-in-consultation .appointment-time-ribbon {
  background: var(--sm-warning);
}

.appointment-completed .appointment-time-ribbon {
  background: var(--sm-secondary);
}

.appointment-cancelled .appointment-time-ribbon,
.appointment-failed-payment .appointment-time-ribbon {
  background: var(--sm-danger);
}

.appointment-time-ribbon span {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

.appointment-time-ribbon strong {
  font-family: var(--sm-font-display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.appointment-card-main {
  display: grid;
  gap: 12px;
  padding: 16px;
  min-width: 0;
}

.patient-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.patient-avatar,
.scope-avatar {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 42px;
  color: #fff;
  background: linear-gradient(135deg, hsl(215, 90%, 52%) 0%, hsl(200, 95%, 48%) 100%);
  border-radius: var(--sm-radius-sm);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.patient-cluster h4,
.prescription-card h4 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.patient-cluster p {
  margin: 1px 0 0;
  color: var(--sm-muted);
  font-size: 0.82rem;
}

.appointment-meta-grid,
.prescription-meta-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr auto;
  gap: 8px;
}

.appointment-meta-grid > div,
.prescription-meta-grid > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--sm-panel-strong);
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
}

.appointment-meta-grid span,
.prescription-meta-grid span {
  color: var(--sm-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.appointment-meta-grid strong,
.prescription-meta-grid strong {
  overflow: hidden;
  color: var(--sm-ink);
  font-size: 0.88rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appointment-card-footer,
.prescription-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-stack {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.appointment-actions {
  display: grid;
  justify-items: end;
  gap: 7px;
  min-width: min(100%, 300px);
}

.appointment-action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.quick-status-actions,
.detail-status-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.detail-status-actions {
  justify-content: flex-start;
  margin: 12px 0 18px;
}

.status-menu {
  width: 100%;
  color: var(--sm-primary);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-menu summary {
  cursor: pointer;
  list-style: none;
  text-align: right;
  border-radius: var(--sm-radius-xs);
}

.status-menu summary:hover {
  color: var(--sm-primary-hover);
  text-decoration: underline;
}

.status-menu summary::-webkit-details-marker {
  display: none;
}

.status-menu-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

/* Without a floor the status select collapses to a few characters
   inside the narrow action column. */
.status-menu-body .form-select-sm {
  flex: 1 1 160px;
  min-width: 150px;
  max-width: 220px;
}

.prescription-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  background: var(--sm-panel);
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.prescription-card:hover {
  border-color: hsl(215, 90%, 88%);
  box-shadow: var(--shadow-md);
}

.rx-ledger-mark {
  width: 48px;
  height: 58px;
  display: grid;
  place-items: center;
  color: var(--sm-primary);
  background: var(--sm-primary-light);
  border: 1px solid hsl(215, 90%, 90%);
  border-radius: var(--sm-radius-sm);
  font-family: var(--sm-font-display);
  font-size: 1.15rem;
  font-weight: 800;
}

.prescription-card-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

/* ==========================================================================
   Provider scope
   ========================================================================== */

.scope-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--sm-panel-strong);
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
}

.scope-card div:last-child {
  display: grid;
}

.scope-card span,
.scope-row {
  color: var(--sm-muted);
  font-size: 0.84rem;
}

.scope-list {
  display: grid;
  gap: 8px;
}

.scope-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scope-row i {
  color: var(--sm-primary);
}

/* ==========================================================================
   Status badges
   ========================================================================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--sm-radius-pill);
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.status-active,
.status-completed,
.status-paid,
.status-credit {
  color: hsl(150, 75%, 26%);
  background: var(--sm-secondary-light);
}

.status-confirmed,
.status-in_consultation {
  color: var(--sm-primary-dark);
  background: var(--sm-primary-light);
}

.status-unpaid,
.status-pending,
.status-pending_payment,
.status-checked_in {
  color: hsl(35, 92%, 30%);
  background: var(--sm-amber-soft);
}

.status-cancelled,
.status-failed_payment {
  color: hsl(354, 76%, 38%);
  background: var(--sm-danger-light);
}

.resource-meta {
  color: var(--sm-muted);
  font-size: 0.8rem;
}

/* ==========================================================================
   Detail panels
   ========================================================================== */

.detail-panel {
  margin-top: 18px;
}

.appointment-summary-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
  background: var(--sm-panel-strong);
}

.appointment-summary-card h3 {
  margin: 2px 0;
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.appointment-summary-card p {
  margin: 0;
  color: var(--sm-muted);
  font-size: 0.84rem;
}

.appointment-summary-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.detail-block {
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
  background: var(--sm-panel);
  padding: 14px;
}

.inline-prescription-panel,
.inline-report-panel,
.appointment-notes {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--sm-border-light);
}

.detail-subhead {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.prescription-summary,
.report-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
  padding: 14px;
  background: var(--sm-panel-strong);
}

.note-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
  background: var(--sm-panel-strong);
  padding: 11px 13px;
}

.note-row + .note-row {
  margin-top: 8px;
}

.note-row span {
  color: var(--sm-muted);
  font-size: 0.76rem;
}

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

.vital-item {
  display: grid;
  gap: 3px;
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
  padding: 11px;
  background: var(--sm-panel-strong);
}

.vital-item span {
  color: var(--sm-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.vital-item strong {
  font-size: 0.96rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

.report-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

/* ==========================================================================
   Prescription composer
   ========================================================================== */

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

.medicine-row {
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
  padding: 14px;
  background: var(--sm-panel);
}

.prescription-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.rx-section {
  display: grid;
  gap: 14px;
  border: 1px solid var(--sm-border-light);
  border-radius: var(--sm-radius-sm);
  padding: 16px;
  background: var(--sm-panel-strong);
}

.rx-section > .btn {
  justify-self: start;
}

.rx-section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.rx-section-head i {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  color: var(--sm-primary);
  background: var(--sm-primary-light);
  border-radius: var(--sm-radius-sm);
  flex: 0 0 36px;
}

.rx-section-head h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.rx-section-head span {
  color: var(--sm-muted);
  font-size: 0.8rem;
}

.medicine-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.medicine-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--sm-border-light);
}

.medicine-row-head span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--sm-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.prescription-submit-row {
  display: flex;
  justify-content: flex-end;
}

.medicine-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
}

/* ==========================================================================
   Toasts & empty states
   ========================================================================== */

.toast-region {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1080;
  display: grid;
  gap: 8px;
}

.app-toast {
  min-width: 260px;
  max-width: min(420px, calc(100vw - 32px));
  color: #fff;
  background: var(--sm-ink);
  border-radius: var(--sm-radius-sm);
  padding: 12px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: sm-toast-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-toast.danger {
  background: var(--sm-danger);
}

@keyframes sm-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.empty-state {
  color: var(--sm-muted);
  padding: 32px 20px;
  text-align: center;
  font-size: 0.88rem;
  background: var(--sm-panel-strong);
  border: 1px dashed var(--sm-border);
  border-radius: var(--sm-radius-sm);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
  .stat-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .appointment-meta-grid,
  .prescription-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 991px) {
  .provider-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 264px;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
    z-index: 1040;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .toolbar-grid > *,
  .toolbar-grid > .btn {
    flex-basis: 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .provider-command-strip {
    grid-template-columns: 1fr;
  }

  .command-actions,
  .panel-actions {
    justify-content: flex-start;
  }

  .content-view {
    padding: 20px;
  }

  .topbar {
    padding: 14px 20px;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .content-view {
    padding: 16px;
  }

  .panel {
    padding: 16px;
  }

  .form-grid,
  .medicine-row-grid,
  .medicine-checks,
  .vital-grid,
  .appointment-meta-grid,
  .prescription-meta-grid {
    grid-template-columns: 1fr;
  }

  /* Two-up keeps the KPI row scannable instead of five full-width blocks. */
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-card {
    min-height: 116px;
    padding: 14px;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .provider-command-strip {
    padding: 18px;
  }

  .command-actions .btn,
  .panel-actions .btn {
    width: 100%;
  }

  .appointment-card,
  .prescription-card {
    grid-template-columns: 1fr;
  }

  .appointment-time-ribbon {
    grid-template-columns: auto 1fr;
    justify-items: start;
    text-align: left;
  }

  .appointment-summary-card,
  .medicine-row-head {
    align-items: stretch;
    flex-direction: column;
  }

  .appointment-summary-status,
  .appointment-actions,
  .appointment-action-row,
  .quick-status-actions,
  .status-menu-body,
  .prescription-submit-row {
    justify-content: stretch;
    justify-items: stretch;
  }

  .appointment-actions .btn,
  .appointment-action-row .btn,
  .detail-status-actions .btn,
  .status-menu-body .btn,
  .prescription-submit-row .btn {
    width: 100%;
  }

  .prescription-card > .btn {
    width: 100%;
  }

  .toast-region {
    left: 16px;
    right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

/* ==========================================================================
   Sidebar identity, sections and live counts
   ========================================================================== */

.sidebar-brand .brand-word {
  display: grid;
  line-height: 1.15;
}

.sidebar-brand .brand-word em {
  color: var(--sm-muted);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.nav-section {
  margin: 14px 0 4px;
  padding: 0 12px;
  color: var(--sm-muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-section:first-child {
  margin-top: 0;
}

.sidebar-nav .nav-link .nav-count {
  margin-left: auto;
  min-width: 24px;
  padding: 1px 7px;
  color: var(--sm-muted);
  background: var(--sm-panel-strong);
  border-radius: var(--sm-radius-pill);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.sidebar-nav .nav-link .nav-count:empty {
  display: none;
}

.sidebar-nav .nav-link.active .nav-count {
  color: #fff;
  background: var(--sm-primary);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--sm-border-light);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--sm-panel-strong);
  border-radius: var(--sm-radius-sm);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, hsl(215, 90%, 52%) 0%, hsl(200, 95%, 48%) 100%);
  border-radius: var(--sm-radius-sm);
  font-size: 0.78rem;
  font-weight: 800;
}

.sidebar-user-text {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.sidebar-user-text strong {
  overflow: hidden;
  font-size: 0.86rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-text em {
  color: var(--sm-muted);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 600;
}

/* ==========================================================================
   Stat card secondary metric
   ========================================================================== */

.stat-meta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--sm-border-light);
  color: var(--sm-ink-soft);
  font-size: 0.74rem;
  font-weight: 600;
}

.stat-meta i {
  font-size: 0.8rem;
  line-height: 1;
  color: var(--sm-primary);
}

/* ==========================================================================
   Appointment pipeline — horizontal stacked bar (part-to-whole)
   Segments carry a 2px surface gap; identity is never colour alone, so the
   legend repeats every state with its icon, count and share.
   ========================================================================== */

.pipeline-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.pipeline-total strong {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pipeline-total span {
  color: var(--sm-muted);
  font-size: 0.84rem;
}

.pipeline-bar {
  display: flex;
  gap: 2px;
  height: 14px;
  margin-bottom: 16px;
  border-radius: var(--sm-radius-pill);
  overflow: hidden;
  background: var(--sm-panel-strong);
}

.pipeline-seg {
  min-width: 4px;
  background: var(--sm-muted);
  transition: filter var(--transition-fast);
}

.pipeline-seg:first-child { border-radius: 999px 0 0 999px; }
.pipeline-seg:last-child { border-radius: 0 999px 999px 0; }
.pipeline-seg:hover { filter: brightness(1.08); }

.pipeline-legend {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pipeline-legend li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--sm-radius-xs);
  font-size: 0.85rem;
  transition: background var(--transition-fast);
}

.pipeline-legend li:hover {
  background: var(--sm-panel-strong);
}

.pipeline-legend i {
  color: var(--sm-muted);
  font-size: 0.92rem;
  line-height: 1;
}

.pipeline-legend-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--sm-ink-soft);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-legend b {
  color: var(--sm-ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.pipeline-legend em {
  min-width: 42px;
  color: var(--sm-muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pipeline-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  background: var(--sm-muted);
}

/* Reserved status hues for the pipeline. Held as literals rather than UI
   tokens so re-theming the panel can never silently break the chart, and
   validated for colourblind separation: the worst adjacent pair is 8.9 dE
   under protanopia, 11.5 under tritanopia. Completed/cancelled sit next to
   each other in the bar, so the red is stepped well darker than the green
   rather than relying on hue alone.
   statusClass() hyphenates, so these selectors are hyphenated too. */
.pipeline-pending-payment { background: #e0921f; }
.pipeline-confirmed { background: #1672f3; }
.pipeline-checked-in { background: #10b1c6; }
.pipeline-in-consultation { background: #e9730c; }
.pipeline-completed { background: #18aa61; }
.pipeline-cancelled { background: #a3182a; }

/* ==========================================================================
   Clinic at a glance
   ========================================================================== */

.glance-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.glance-list li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 10px;
  border-radius: var(--sm-radius-xs);
  font-size: 0.88rem;
  transition: background var(--transition-fast);
}

.glance-list li + li {
  border-top: 1px solid var(--sm-border-light);
}

.glance-list li:hover {
  background: var(--sm-panel-strong);
}

.glance-list i {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: inline-grid;
  place-items: center;
  color: var(--sm-primary);
  background: var(--sm-primary-light);
  border-radius: var(--sm-radius-xs);
  font-size: 0.92rem;
}

.glance-list span {
  flex: 1;
  color: var(--sm-ink-soft);
  font-weight: 600;
}

.glance-list b {
  font-size: 1.02rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Skeleton loaders
   ========================================================================== */

.skeleton-set {
  display: grid;
  gap: 14px;
}

.skeleton-set.skeleton-stat {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.skeleton-block {
  border-radius: var(--sm-radius-md);
  background:
    linear-gradient(90deg, var(--sm-panel-strong) 0%, hsl(220, 20%, 93%) 40%, var(--sm-panel-strong) 80%)
    0 0 / 300% 100%;
  animation: skeleton-sweep 1.35s ease-in-out infinite;
}

.skeleton-stat .skeleton-block { height: 128px; }
.skeleton-bar .skeleton-block { height: 190px; }
.skeleton-card .skeleton-block { height: 132px; }
.skeleton-row .skeleton-block { height: 46px; border-radius: var(--sm-radius-sm); }

@keyframes skeleton-sweep {
  from { background-position: 150% 0; }
  to { background-position: -150% 0; }
}

/* ==========================================================================
   Empty states & toasts
   ========================================================================== */

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.empty-state p {
  margin: 0;
}

.empty-icon {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  color: var(--sm-primary);
  background: var(--sm-primary-light);
  border-radius: 50%;
  font-size: 1.15rem;
}

.app-toast {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-toast i {
  font-size: 1.05rem;
  line-height: 1;
}

.app-toast.success {
  background: var(--sm-ink);
}

.app-toast.leaving {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 200ms ease, transform 200ms ease;
}

@media (max-width: 991px) {
  .pipeline-legend em { min-width: 38px; }
}

/* ==========================================================================
   MOTION LAYER
   Shared by every provider panel (pathology and ultrasound import this file).
   Entry animations run on render, so replacing innerHTML replays them — which
   is what makes a refreshed list feel alive rather than snapping into place.
   ========================================================================== */

@keyframes sm-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes sm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sm-slide-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}

@keyframes sm-pop {
  0% { opacity: 0; transform: scale(0.94); }
  60% { transform: scale(1.015); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes sm-grow-x {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes sm-pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(26, 115, 232, 0.32); }
  70% { box-shadow: 0 0 0 10px rgba(26, 115, 232, 0); }
  100% { box-shadow: 0 0 0 0 rgba(26, 115, 232, 0); }
}

/* --- View transitions -------------------------------------------------- */
.content-view:not(.d-none) {
  animation: sm-fade-up 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* --- Command strip ------------------------------------------------------ */
.provider-command-strip {
  animation: sm-pop 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* --- Stat cards arrive in sequence -------------------------------------- */
.stat-grid .stat-card {
  animation: sm-fade-up 460ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stat-grid .stat-card:nth-child(1) { animation-delay: 40ms; }
.stat-grid .stat-card:nth-child(2) { animation-delay: 90ms; }
.stat-grid .stat-card:nth-child(3) { animation-delay: 140ms; }
.stat-grid .stat-card:nth-child(4) { animation-delay: 190ms; }
.stat-grid .stat-card:nth-child(5) { animation-delay: 240ms; }

.stat-icon {
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(-5deg);
}

/* The live-queue card breathes while patients are actually in the clinic. */
.stat-card.is-live .stat-icon {
  animation: sm-pulse-ring 2.2s ease-out infinite;
}

/* --- Panels ------------------------------------------------------------- */
.panel {
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

/* --- Boards and tables stagger their rows ------------------------------- */
.appointment-board > *,
.prescription-board > *,
.booking-board > * {
  animation: sm-fade-up 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.appointment-board > *:nth-child(1),
.prescription-board > *:nth-child(1),
.booking-board > *:nth-child(1) { animation-delay: 30ms; }
.appointment-board > *:nth-child(2),
.prescription-board > *:nth-child(2),
.booking-board > *:nth-child(2) { animation-delay: 70ms; }
.appointment-board > *:nth-child(3),
.prescription-board > *:nth-child(3),
.booking-board > *:nth-child(3) { animation-delay: 110ms; }
.appointment-board > *:nth-child(4),
.prescription-board > *:nth-child(4),
.booking-board > *:nth-child(4) { animation-delay: 150ms; }
.appointment-board > *:nth-child(5),
.prescription-board > *:nth-child(5),
.booking-board > *:nth-child(5) { animation-delay: 190ms; }
.appointment-board > *:nth-child(n+6),
.prescription-board > *:nth-child(n+6),
.booking-board > *:nth-child(n+6) { animation-delay: 220ms; }

.table tbody tr {
  animation: sm-fade-in 340ms ease both;
}

.appointment-card:hover,
.prescription-card:hover {
  transform: translateY(-2px);
}

.appointment-card,
.prescription-card {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    border-color var(--transition-fast);
}

/* --- Sidebar ------------------------------------------------------------ */
.sidebar-nav .nav-link {
  animation: sm-slide-in 340ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.sidebar-nav .nav-link:nth-of-type(1) { animation-delay: 30ms; }
.sidebar-nav .nav-link:nth-of-type(2) { animation-delay: 65ms; }
.sidebar-nav .nav-link:nth-of-type(3) { animation-delay: 100ms; }
.sidebar-nav .nav-link:nth-of-type(4) { animation-delay: 135ms; }
.sidebar-nav .nav-link:nth-of-type(5) { animation-delay: 170ms; }
.sidebar-nav .nav-link:nth-of-type(6) { animation-delay: 205ms; }

/* A rail slides in beside the active item instead of appearing instantly. */
.sidebar-nav .nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 0 3px 3px 0;
  background: var(--sm-primary);
  transform: translateY(-50%);
  transition: height 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-nav .nav-link.active::before {
  height: 20px;
}

.sidebar-nav .nav-link i {
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.sidebar-nav .nav-link:hover i {
  transform: translateX(2px) scale(1.08);
}

.sidebar-user {
  animation: sm-fade-up 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 240ms;
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: var(--sm-primary-light);
}

/* --- Pipeline / funnel bars grow from their origin ---------------------- */
.pipeline-bar .pipeline-seg {
  transform-origin: left;
  animation: sm-grow-x 640ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.pipeline-bar .pipeline-seg:nth-child(1) { animation-delay: 80ms; }
.pipeline-bar .pipeline-seg:nth-child(2) { animation-delay: 140ms; }
.pipeline-bar .pipeline-seg:nth-child(3) { animation-delay: 200ms; }
.pipeline-bar .pipeline-seg:nth-child(4) { animation-delay: 260ms; }
.pipeline-bar .pipeline-seg:nth-child(5) { animation-delay: 320ms; }
.pipeline-bar .pipeline-seg:nth-child(6) { animation-delay: 380ms; }

.pipeline-legend li,
.glance-list li {
  animation: sm-fade-up 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.pipeline-legend li:nth-child(1), .glance-list li:nth-child(1) { animation-delay: 120ms; }
.pipeline-legend li:nth-child(2), .glance-list li:nth-child(2) { animation-delay: 165ms; }
.pipeline-legend li:nth-child(3), .glance-list li:nth-child(3) { animation-delay: 210ms; }
.pipeline-legend li:nth-child(4), .glance-list li:nth-child(4) { animation-delay: 255ms; }
.pipeline-legend li:nth-child(5), .glance-list li:nth-child(5) { animation-delay: 300ms; }
.pipeline-legend li:nth-child(6), .glance-list li:nth-child(6) { animation-delay: 345ms; }

.glance-list i {
  transition: transform var(--transition-fast);
}

.glance-list li:hover i {
  transform: scale(1.12) rotate(-6deg);
}

/* --- Buttons, chips and inputs ------------------------------------------ */
.quick-filter-chip {
  animation: sm-fade-in 300ms ease both;
}

.quick-filter-chip:active {
  transform: scale(0.96);
}

.btn i {
  transition: transform var(--transition-fast);
}

.btn:hover i {
  transform: scale(1.1);
}

/* The refresh control spins while its view is loading. */
[data-refresh].is-busy i {
  animation: sm-spin 720ms linear infinite;
}

@keyframes sm-spin {
  to { transform: rotate(360deg); }
}

/* --- Detail panel ------------------------------------------------------- */
.detail-panel:not(.d-none) {
  animation: sm-fade-up 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.empty-state {
  animation: sm-pop 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.empty-icon {
  transition: transform var(--transition-normal);
}

.empty-state:hover .empty-icon {
  transform: scale(1.08) rotate(6deg);
}

/* --- Numbers counting up ------------------------------------------------ */
.stat-value,
.pipeline-total strong {
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .content-view:not(.d-none),
  .provider-command-strip,
  .stat-grid .stat-card,
  .appointment-board > *,
  .prescription-board > *,
  .booking-board > *,
  .table tbody tr,
  .sidebar-nav .nav-link,
  .sidebar-user,
  .pipeline-bar .pipeline-seg,
  .pipeline-legend li,
  .glance-list li,
  .quick-filter-chip,
  .detail-panel:not(.d-none),
  .empty-state {
    animation: none !important;
  }

  .stat-card.is-live .stat-icon,
  [data-refresh].is-busy i {
    animation: none !important;
  }
}
