/* ===== Portal CSS — Base Styles ===== */
/* Mobile-first, RTL-first */

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body.portal-body {
  font-family: var(--portal-font-ar);
  background: var(--portal-bg);
  color: var(--portal-text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

html[dir="ltr"] body.portal-body {
  font-family: var(--portal-font-en);
}

/* ===== Loading Screen ===== */
.portal-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--portal-surface);
  z-index: 9999;
  transition: opacity 0.3s ease;
  padding-top: env(safe-area-inset-top, 0px);
}

.portal-loading.fade-out {
  opacity: 0;
  pointer-events: none;
}

.portal-loading-inner {
  text-align: center;
}

.portal-loading-logo {
  position: relative;
  width: 90px;
  height: 90px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  background: linear-gradient(
    145deg,
    rgba(var(--portal-primary-rgb), 0.16),
    rgba(var(--portal-primary-rgb), 0.04)
  );
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9), 0 10px 24px rgba(var(--portal-primary-rgb), 0.18);
}

.portal-loading-logo::after {
  content: '';
  position: absolute;
  inset: -10px;
  z-index: -1;
  border-radius: 34px;
  background: radial-gradient(
    circle,
    rgba(var(--portal-primary-rgb), 0.2) 0%,
    rgba(var(--portal-primary-rgb), 0.02) 72%
  );
}

.portal-brand-logo {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 8px 14px rgba(0, 42, 84, 0.16));
}

.portal-brand-logo-loading {
  animation: portal-logo-float 2.8s ease-in-out infinite;
}

.portal-brand-pulse {
  transform-origin: 58.5px 33px;
  animation: portal-brand-pulse 1.8s ease-in-out infinite;
}

.portal-loading-logo-img,
.portal-login-logo-img {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 8px 16px rgba(0, 56, 109, 0.14);
}

.portal-loading-logo.has-custom-logo,
.portal-login-logo.has-custom-logo {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.94),
    rgba(255, 255, 255, 0.76)
  );
}

.portal-loading-logo.has-custom-logo .portal-brand-logo,
.portal-login-logo.has-custom-logo .portal-brand-logo {
  display: none;
}

@keyframes portal-logo-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes portal-brand-pulse {
  0%, 100% {
    transform: scale(0.92);
    opacity: 0.88;
  }
  45% {
    transform: scale(1.08);
    opacity: 1;
  }
}

.portal-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--portal-border);
  border-top-color: var(--portal-primary);
  border-radius: 50%;
  animation: portal-spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes portal-spin {
  to { transform: rotate(360deg); }
}

.portal-loading-text {
  font-size: 0.875rem;
  color: var(--portal-text-secondary);
}

/* ===== Screens ===== */
.portal-screen {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ===== Login Screen ===== */
#portal-login {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding-top: env(safe-area-inset-top, 0px);
  background:
    radial-gradient(120% 65% at 8% 10%, rgba(var(--portal-primary-rgb), 0.14) 0%, rgba(var(--portal-primary-rgb), 0) 60%),
    radial-gradient(110% 72% at 94% 92%, rgba(var(--portal-accent-rgb), 0.20) 0%, rgba(var(--portal-accent-rgb), 0) 66%),
    linear-gradient(160deg, #f8fbff 0%, #eff5fc 48%, #f7fbff 100%);
}

/* Overlay mode: login as a popup modal inside the guest page */
#portal-login.portal-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  /* transparent dark scrim — guest page stays visible behind */
  background: rgba(0, 15, 40, 0.52) !important;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  animation: portal-login-overlay-in 0.25s ease both;
}
#portal-login.portal-login-overlay::before { display: none !important; }
/* Card floats in center, not full-height */
#portal-login.portal-login-overlay .portal-login-container {
  min-height: auto;
  padding: 60px 16px 32px;
  justify-content: flex-start;
}
#portal-login.portal-login-overlay .portal-login-card {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28), 0 8px 20px rgba(0, 0, 0, 0.12);
  animation: portal-login-modal-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* In overlay: keep subtitle but hide big logo/title — header already shows them */
#portal-login.portal-login-overlay .portal-login-logo { display: none; }
#portal-login.portal-login-overlay .portal-login-title { display: none; }
#portal-login.portal-login-overlay .portal-login-tagline { display: none; }
/* Hide footer lang toggle — header toggle is accessible */
#portal-login.portal-login-overlay .portal-login-lang { display: none; }
#portal-login.portal-login-overlay .portal-login-footer { display: none; }
/* Back-to-guest as a close-like action */
#portal-login.portal-login-overlay .portal-login-guest-back {
  margin-top: 12px;
}
#portal-login.portal-login-overlay .portal-login-guest-back .portal-link-btn {
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  font-size: 0.95rem;
}

@keyframes portal-login-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes portal-login-modal-in {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#portal-login::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.2) 0 12px,
    rgba(255, 255, 255, 0.02) 12px 24px
  );
  opacity: 0.4;
  pointer-events: none;
}
#portal-login.no-overlay::before {
  display: none;
}

.portal-login-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
}

.portal-login-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  padding: 26px 22px 22px;
  box-shadow: 0 20px 42px rgba(0, 56, 109, 0.16), 0 6px 16px rgba(0, 56, 109, 0.08);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: portal-login-card-in 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes portal-login-card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.portal-login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 92px;
  height: 92px;
  border-radius: 24px;
  margin: 0 auto 18px;
  background: linear-gradient(
    145deg,
    rgba(var(--portal-primary-rgb), 0.14),
    rgba(var(--portal-primary-rgb), 0.04)
  );
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.88), 0 10px 24px rgba(var(--portal-primary-rgb), 0.2);
}

.portal-login-logo .portal-brand-logo,
.portal-login-logo .portal-login-logo-img {
  width: 80px;
  height: 80px;
}

.portal-login-title {
  font-size: clamp(1.75rem, 4.6vw, 2.05rem);
  font-weight: 700;
  color: var(--portal-text);
  margin-bottom: 10px;
  text-align: center;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.portal-login-tagline {
  font-size: 0.88rem;
  color: var(--portal-text-secondary);
  text-align: center;
  margin-bottom: 6px;
  line-height: 1.5;
  opacity: 0.85;
}

.portal-login-subtitle {
  font-size: 0.95rem;
  color: var(--portal-text-secondary);
  margin-bottom: 26px;
  text-align: center;
  line-height: 1.6;
}

.portal-login-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  width: 100%;
}

.portal-login-footer {
  font-size: 0.8rem;
  color: var(--portal-text-secondary);
  text-align: center;
  opacity: 0.7;
}

.portal-login-step {
  width: 100%;
  animation: portal-fade-in-up 220ms ease both;
}

@keyframes portal-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Phone Input Group */
.portal-phone-input-group {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid rgba(113, 133, 161, 0.28);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  margin-bottom: 10px;
  direction: ltr;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.portal-phone-input-group:focus-within {
  border-color: rgba(var(--portal-primary-rgb), 0.72);
  box-shadow: 0 0 0 4px rgba(var(--portal-primary-rgb), 0.13);
  transform: translateY(-1px);
}

.portal-country-code {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 10px 12px 12px;
  border-right: 1px solid rgba(113, 133, 161, 0.2);
  background: rgba(var(--portal-primary-rgb), 0.05);
  flex-shrink: 0;
}

.portal-country-select {
  border: none;
  background: transparent;
  font-size: 0.93rem;
  font-weight: 500;
  color: var(--portal-text);
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
}

.portal-phone-input {
  flex: 1;
  border: none;
  padding: 14px 12px;
  font-size: 1.125rem;
  font-family: var(--portal-font-en);
  letter-spacing: 1px;
  outline: none;
  background: transparent;
  color: var(--portal-text);
}

.portal-phone-input::placeholder {
  color: var(--portal-text-muted);
}

.portal-security-hint {
  margin-top: 8px;
  margin-bottom: 4px;
  min-height: 1.25rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
}

.portal-security-hint.is-info {
  color: var(--portal-text-secondary);
}

.portal-security-hint.is-error {
  color: var(--portal-danger);
}

#recaptcha-container {
  display: none;
  margin: 10px auto 6px;
}

#recaptcha-container > div {
  margin-inline: auto;
}

/* OTP Inputs */
.portal-otp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 18px 0 16px;
  direction: ltr;
}

.portal-otp-digit {
  width: 48px;
  height: 56px;
  border: 1.5px solid rgba(113, 133, 161, 0.32);
  border-radius: 12px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  font-family: var(--portal-font-en);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  background: rgba(255, 255, 255, 0.96);
  color: var(--portal-text);
}

.portal-otp-digit:focus {
  border-color: rgba(var(--portal-primary-rgb), 0.72);
  box-shadow: 0 0 0 3px rgba(var(--portal-primary-rgb), 0.13);
  transform: translateY(-1px);
}

.portal-otp-info {
  text-align: center;
  font-size: 0.9rem;
  color: var(--portal-text-secondary);
}

.portal-otp-phone {
  text-align: center;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--portal-text);
  margin: 6px 0 8px;
  font-family: var(--portal-font-en);
}

.portal-resend-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.portal-timer {
  font-size: 0.84rem;
  color: var(--portal-text-muted);
  font-family: var(--portal-font-en);
}

.portal-step-title {
  font-size: 1.125rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 16px;
}

/* Company selector */
.portal-company-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.portal-company-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--portal-surface);
  border: 2px solid var(--portal-border);
  border-radius: var(--portal-radius-md);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.portal-company-card:hover,
.portal-company-card:active {
  border-color: var(--portal-primary);
  box-shadow: var(--portal-shadow-sm);
}

.portal-company-card-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--portal-radius-sm);
  object-fit: contain;
  background: var(--portal-bg);
}

.portal-company-card-name {
  font-weight: 600;
  font-size: 1rem;
}

/* Clinic selector polished UI */
#portal-clinic-selector {
  position: relative;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  background:
    radial-gradient(120% 68% at 6% 4%, rgba(var(--portal-primary-rgb), 0.14) 0%, rgba(var(--portal-primary-rgb), 0) 62%),
    radial-gradient(120% 70% at 96% 96%, rgba(var(--portal-accent-rgb), 0.2) 0%, rgba(var(--portal-accent-rgb), 0) 64%),
    linear-gradient(160deg, #f8fbff 0%, #eff5fc 52%, #f7fbff 100%);
}

#portal-clinic-selector::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.17) 0 12px,
    rgba(255, 255, 255, 0.03) 12px 24px
  );
  pointer-events: none;
  opacity: 0.36;
}

#portal-clinic-selector .portal-login-container {
  position: relative;
  z-index: 1;
}

.portal-clinic-selector-head {
  margin-bottom: 12px;
}

.portal-clinic-selector-head .portal-login-title {
  margin-bottom: 6px;
}

.portal-clinic-selector-head .portal-login-subtitle {
  margin-bottom: 0;
}

.portal-clinic-search-shell {
  position: relative;
  margin-bottom: 8px;
}

.portal-clinic-search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 14px;
  width: 18px;
  height: 18px;
  color: rgba(var(--portal-primary-rgb), 0.88);
  transform: translateY(-50%);
  pointer-events: none;
}

.portal-clinic-search-input {
  text-align: start;
  direction: rtl;
  letter-spacing: 0;
  font-size: 0.98rem;
  font-family: inherit;
  padding-inline-start: 44px;
}

html[dir="ltr"] .portal-clinic-search-input {
  direction: ltr;
}

.portal-clinic-search-helper {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin-bottom: 10px;
}

.portal-clinic-results {
  max-height: min(52vh, 440px);
  overflow-y: auto;
  padding-inline-end: 2px;
}

.portal-clinic-item {
  width: 100%;
  border: 1px solid rgba(113, 133, 161, 0.24);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 12px rgba(12, 50, 92, 0.06);
}

.portal-clinic-item:hover,
.portal-clinic-item:active {
  border-color: rgba(var(--portal-primary-rgb), 0.52);
  box-shadow: 0 10px 20px rgba(var(--portal-primary-rgb), 0.16);
  transform: translateY(-1px);
}

.portal-clinic-item-logo,
.portal-clinic-item-logo-fallback {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
}

.portal-clinic-item-logo {
  object-fit: cover;
  border: 1px solid rgba(113, 133, 161, 0.2);
  background: #fff;
}

.portal-clinic-item-logo-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(var(--portal-primary-rgb), 0.9), rgba(var(--portal-primary-rgb), 0.72));
  color: #fff;
  font-size: 1.12rem;
}

.portal-clinic-item-main {
  min-width: 0;
  flex: 1;
}

.portal-clinic-item-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--portal-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-clinic-item-city {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-clinic-item-arrow {
  width: 17px;
  height: 17px;
  color: rgba(var(--portal-primary-rgb), 0.8);
  flex-shrink: 0;
}

.portal-clinic-skeleton {
  height: 70px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(226, 234, 246, 0.88) 25%, rgba(245, 249, 255, 0.98) 50%, rgba(226, 234, 246, 0.88) 75%);
  background-size: 200% 100%;
  animation: portal-shimmer 1.15s infinite;
}

.portal-clinic-empty {
  padding: 18px 10px;
  text-align: center;
  border: 1px dashed rgba(113, 133, 161, 0.34);
  border-radius: 14px;
  color: var(--portal-text-secondary);
  font-size: 0.89rem;
  background: rgba(255, 255, 255, 0.86);
}

/* ===== Buttons ===== */
.portal-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 24px;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  font-family: inherit;
  gap: 8px;
  overflow: hidden;
}

.portal-btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.portal-btn-primary {
  background: var(--portal-gradient);
  color: #fff;
  box-shadow: 0 8px 20px rgba(var(--portal-primary-rgb), 0.24);
}

.portal-btn-primary:hover:not(:disabled) {
  box-shadow: 0 12px 22px rgba(var(--portal-primary-rgb), 0.3);
  transform: translateY(-2px);
}

.portal-btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.portal-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(var(--portal-primary-rgb), 0.2);
}

.portal-btn-outline {
  background: transparent;
  color: var(--portal-primary);
  border: 2px solid var(--portal-primary);
}

.portal-link-btn {
  background: none;
  border: none;
  color: var(--portal-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px;
  font-family: inherit;
  transition: opacity 0.2s;
}

.portal-link-btn:disabled {
  color: var(--portal-text-muted);
  cursor: not-allowed;
}

.portal-btn.is-loading,
.portal-link-btn.is-loading {
  cursor: wait;
  pointer-events: none;
}

.portal-btn.is-loading {
  opacity: 1;
}

.portal-loading-spinner-sm {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: portal-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.portal-btn-loading-text {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  font-size: 0.95rem;
}

.portal-link-btn.is-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.portal-link-btn.is-loading .portal-loading-spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
  border-color: rgba(var(--portal-primary-rgb), 0.3);
  border-top-color: var(--portal-primary);
}

.portal-link-btn.is-loading .portal-btn-loading-text {
  font-size: 0.875rem;
  color: var(--portal-primary);
}

/* ===== Error Text ===== */
.portal-error-text {
  color: var(--portal-danger);
  font-size: 0.8125rem;
  margin: 4px 0 8px;
  text-align: center;
}

/* ===== Language Toggle ===== */
.portal-login-lang {
  margin-top: 26px;
  display: flex;
  justify-content: center;
}

.portal-lang-toggle {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(113, 133, 161, 0.3);
  border-radius: var(--portal-radius-sm);
  padding: 7px 16px;
  font-size: 0.84rem;
  color: var(--portal-text-secondary);
  cursor: pointer;
  font-family: var(--portal-font-en);
  transition: all 0.2s;
}

.portal-lang-toggle:hover {
  color: var(--portal-text);
  border-color: rgba(var(--portal-primary-rgb), 0.4);
}

/* ===== App Header ===== */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--portal-surface);
  border-bottom: 1px solid var(--portal-divider);
  height: var(--portal-header-total-height);
  padding: 0 16px;
  padding-top: var(--portal-safe-top);
  overflow: hidden;
}

.portal-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 100%;
  max-width: 768px;
  margin: 0 auto;
}

.portal-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.portal-clinic-logo {
  height: 36px;
  width: auto;
  border-radius: 6px;
}

.portal-clinic-name {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  color: var(--portal-text);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.portal-header-guest-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.portal-lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--portal-divider);
  border-radius: 999px;
  background: #eef2f7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  flex-shrink: 0;
}

.portal-lang-pill-btn {
  min-width: 44px;
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--portal-text-secondary);
  font-family: var(--portal-font-en);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.portal-lang-pill-btn.active {
  background: #fff;
  color: var(--portal-text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

.portal-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  padding: 8px;
  cursor: pointer;
  color: var(--portal-text);
  border-radius: 50%;
  transition: background 0.2s;
}

.portal-icon-btn svg {
  width: 18px;
  height: 18px;
}

.portal-icon-btn:hover {
  background: var(--portal-bg);
}

.portal-guest-settings-btn {
  border: 1px solid var(--portal-divider);
  background: #eef2f7;
}

.portal-guest-settings-btn:hover {
  background: #e4ebf5;
}

body:not(.portal-guest) .portal-guest-settings-btn {
  display: none !important;
}

.portal-notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  background: var(--portal-danger);
  color: #fff;
  border-radius: 9px;
  font-size: 0.6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-family: var(--portal-font-en);
}

html[dir="rtl"] .portal-notif-badge {
  right: auto;
  left: 2px;
}

/* ===== Notification Page ===== */
.portal-notif-card {
  transition: background 0.2s;
}
.portal-notif-unread {
  background: rgba(var(--portal-primary-rgb, 59, 130, 246), 0.06);
  border-right: 3px solid var(--portal-primary);
}
html[dir="ltr"] .portal-notif-unread {
  border-right: none;
  border-left: 3px solid var(--portal-primary);
}
.portal-notif-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--portal-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--portal-text-muted);
}
.portal-notif-icon-unread {
  background: rgba(var(--portal-primary-rgb, 59, 130, 246), 0.12);
  color: var(--portal-primary);
}
.portal-notif-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--portal-primary);
  flex-shrink: 0;
  align-self: center;
}

/* ===== Support Page ===== */
.portal-btn-success {
  background: #25d366;
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.portal-btn-success:hover:not(:disabled) {
  opacity: 0.9;
}
.portal-btn-link {
  background: none;
  border: none;
  color: var(--portal-primary);
  font-size: inherit;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
}
.portal-btn-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Main Content ===== */
.portal-main {
  padding: 16px;
  padding-bottom: calc(var(--portal-tabs-height) + var(--portal-safe-bottom) + 16px);
  max-width: 768px;
  margin: 0 auto;
  min-height: calc(100vh - var(--portal-header-total-height) - var(--portal-tabs-height));
}

/* ===== Bottom Tab Bar ===== */
.portal-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: calc(var(--portal-tabs-height) + var(--portal-safe-bottom));
  padding-bottom: var(--portal-safe-bottom);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--portal-divider);
}

.portal-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--portal-text-muted);
  transition: color 0.2s;
  font-family: inherit;
  position: relative;
  min-width: 64px;
}

.portal-tab svg {
  width: 22px;
  height: 22px;
}

.portal-tab span {
  font-size: 0.6875rem;
  font-weight: 500;
}

.portal-tab.active {
  color: var(--portal-primary);
}

.portal-tab-lang {
  display: none;
}

.portal-tab-lang-value {
  display: none;
}



/* ===== Cards ===== */
.portal-card {
  background: var(--portal-surface);
  border-radius: var(--portal-radius-lg);
  box-shadow: var(--portal-shadow-sm);
  padding: 16px;
  margin-bottom: 12px;
}

/* ===== Badges ===== */
.portal-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.portal-badge-success {
  background: rgba(56, 161, 105, 0.12);
  color: var(--portal-success);
}

.portal-badge-warning {
  background: rgba(221, 107, 32, 0.12);
  color: var(--portal-warning);
}

.portal-badge-danger {
  background: rgba(229, 62, 62, 0.12);
  color: var(--portal-danger);
}

.portal-badge-info {
  background: rgba(49, 130, 206, 0.12);
  color: var(--portal-info);
}

.portal-badge-pending {
  background: rgba(214, 158, 46, 0.12);
  color: var(--portal-pending);
}

/* ===== Page Header ===== */
.portal-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.portal-back-btn {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--portal-text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

html[dir="ltr"] .portal-back-btn svg {
  transform: scaleX(-1);
}

html[dir="ltr"] .pm-legal-back svg {
  transform: scaleX(-1);
}

.portal-page-title {
  font-size: 1.25rem;
  font-weight: 700;
}

/* ===== Empty State ===== */
.portal-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

.portal-empty-state svg {
  width: 80px;
  height: 80px;
  color: var(--portal-text-muted);
  margin-bottom: 16px;
}

.portal-empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--portal-text);
  margin-bottom: 4px;
}

.portal-empty-subtitle {
  font-size: 0.875rem;
  color: var(--portal-text-secondary);
}

/* ===== Skeleton Loading ===== */
.portal-skeleton {
  background: linear-gradient(90deg, var(--portal-divider) 25%, var(--portal-bg) 50%, var(--portal-divider) 75%);
  background-size: 200% 100%;
  animation: portal-shimmer 1.5s infinite;
  border-radius: var(--portal-radius-sm);
}

@keyframes portal-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.portal-skeleton-card {
  height: 100px;
  margin-bottom: 12px;
  border-radius: var(--portal-radius-lg);
}

.portal-skeleton-line {
  height: 14px;
  margin-bottom: 8px;
}

.portal-skeleton-line-short {
  height: 14px;
  width: 60%;
  margin-bottom: 8px;
}

/* ===== Toast ===== */
.portal-toast-container {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.portal-toast {
  padding: 12px 16px;
  border-radius: var(--portal-radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--portal-shadow-lg);
  animation: portal-toast-in 0.3s ease;
  pointer-events: auto;
  text-align: center;
}

@keyframes portal-toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.portal-toast-success {
  background: var(--portal-success);
  color: #fff;
}

.portal-toast-error {
  background: var(--portal-danger);
  color: #fff;
}

.portal-toast-info {
  background: var(--portal-info);
  color: #fff;
}

/* ===== Service Grid ===== */
.portal-service-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.portal-service-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 8px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-divider);
  border-radius: var(--portal-radius-md);
  box-shadow: var(--portal-shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.portal-service-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
  border-color: rgba(var(--portal-primary-rgb), 0.3);
}

.portal-service-item:active {
  transform: scale(0.96) translateY(0);
  box-shadow: var(--portal-shadow-sm);
}

.portal-service-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.portal-service-icon {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  border-radius: 14px;
  color: var(--portal-primary);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.portal-service-item:hover .portal-service-icon {
  transform: scale(1.12);
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
}

.portal-service-icon svg {
  width: 22px;
  height: 22px;
}

.portal-service-item span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--portal-text);
  line-height: 1.3;
}

.portal-service-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--portal-text);
  line-height: 1.3;
}

/* ===== Vitals Strip ===== */
.portal-vitals-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 0;
  margin: 12px 0;
}

.portal-vitals-strip::-webkit-scrollbar {
  display: none;
}

.portal-vital-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  padding: 12px 14px;
  background: var(--portal-surface);
  border-radius: var(--portal-radius-md);
  box-shadow: var(--portal-shadow-sm);
  min-width: 80px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: default;
}

.portal-vital-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

.portal-vital-icon {
  width: 20px;
  height: 20px;
  color: var(--portal-primary);
  margin-bottom: 4px;
  transition: transform 0.25s ease;
}

.portal-vital-chip:hover .portal-vital-icon {
  transform: scale(1.18);
}

/* Individual vital chip icon colors */
.portal-vital-chip.vital-temp       .portal-vital-icon { color: #ef4444; }
.portal-vital-chip.vital-temp       .portal-vital-value { color: #dc2626; }
.portal-vital-chip.vital-bp         .portal-vital-icon { color: #ec4899; }
.portal-vital-chip.vital-bp         .portal-vital-value { color: #db2777; }
.portal-vital-chip.vital-spo2       .portal-vital-icon { color: #0ea5e9; }
.portal-vital-chip.vital-spo2       .portal-vital-value { color: #0284c7; }
.portal-vital-chip.vital-hr         .portal-vital-icon { color: #8b5cf6; }
.portal-vital-chip.vital-hr         .portal-vital-value { color: #7c3aed; }
.portal-vital-chip.vital-weight     .portal-vital-icon { color: #10b981; }
.portal-vital-chip.vital-weight     .portal-vital-value { color: #059669; }
.portal-vital-chip.vital-height     .portal-vital-icon { color: #6366f1; }
.portal-vital-chip.vital-height     .portal-vital-value { color: #4f46e5; }

.portal-vital-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--portal-text);
  font-family: var(--portal-font-en);
}

.portal-vital-label {
  font-size: 0.6875rem;
  color: var(--portal-text-secondary);
  margin-top: 2px;
}

.portal-vital-unit {
  font-size: 0.625rem;
  color: var(--portal-text-muted);
}

/* ===== Stats Chips ===== */
.portal-stats-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 12px 0;
}

.portal-stats-row::-webkit-scrollbar {
  display: none;
}

.portal-stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  padding: 12px 16px;
  border-radius: var(--portal-radius-md);
  background: var(--portal-primary-light);
  min-width: 80px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: default;
}

.portal-stat-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

/* Individual stat chip colors */
.portal-stat-chip.stat-visits   { background: #dbeafe; }
.portal-stat-chip.stat-visits .portal-stat-value { color: #2563eb; }
.portal-stat-chip.stat-visits .portal-stat-icon  { color: #2563eb; }
.portal-stat-chip.stat-visits .portal-stat-label  { color: #1e40af; }

.portal-stat-chip.stat-bookings { background: #ccfbf1; }
.portal-stat-chip.stat-bookings .portal-stat-value { color: #0d9488; }
.portal-stat-chip.stat-bookings .portal-stat-icon  { color: #0d9488; }
.portal-stat-chip.stat-bookings .portal-stat-label  { color: #115e59; }

.portal-stat-chip.stat-lab      { background: #dcfce7; }
.portal-stat-chip.stat-lab .portal-stat-value { color: #16a34a; }
.portal-stat-chip.stat-lab .portal-stat-icon  { color: #16a34a; }
.portal-stat-chip.stat-lab .portal-stat-label  { color: #166534; }

.portal-stat-chip.stat-radiology { background: #fef3c7; }
.portal-stat-chip.stat-radiology .portal-stat-value { color: #d97706; }
.portal-stat-chip.stat-radiology .portal-stat-icon  { color: #d97706; }
.portal-stat-chip.stat-radiology .portal-stat-label  { color: #92400e; }

.portal-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--portal-primary);
  font-family: var(--portal-font-en);
}

.portal-stat-label {
  font-size: 0.6875rem;
  color: var(--portal-primary-dark);
  margin-top: 2px;
}

/* ===== Bottom Sheet ===== */
.portal-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 500;
  animation: portal-fade-in 0.2s ease;
}

@keyframes portal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.portal-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 501;
  background: var(--portal-surface);
  border-radius: var(--portal-radius-xl) var(--portal-radius-xl) 0 0;
  max-height: 85vh;
  overflow-y: auto;
  animation: portal-slide-up 0.3s ease;
  padding-bottom: var(--portal-safe-bottom);
}

@keyframes portal-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.portal-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--portal-border);
  border-radius: 2px;
  margin: 12px auto;
}

.portal-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--portal-divider);
}

.portal-sheet-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.portal-sheet-body {
  padding: 16px 20px;
}

/* ===== List Items ===== */
.portal-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--portal-divider);
  cursor: pointer;
}

.portal-list-item:last-child {
  border-bottom: none;
}

.portal-list-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--portal-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--portal-primary-light);
  color: var(--portal-primary);
}

.portal-list-content {
  flex: 1;
  min-width: 0;
}

.portal-list-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--portal-text);
}

.portal-list-subtitle {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin-top: 2px;
}

.portal-list-arrow {
  margin-inline-start: auto;
  color: var(--portal-text-muted);
  flex-shrink: 0;
}

html[dir="ltr"] svg.portal-list-arrow {
  transform: scaleX(-1);
}

.portal-list-locale-value {
  margin-inline-start: auto;
  color: var(--portal-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

/* ===== Confirm Dialog ===== */
.portal-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.portal-dialog {
  background: var(--portal-surface);
  border-radius: var(--portal-radius-lg);
  padding: 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: var(--portal-shadow-lg);
}

.portal-dialog-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.portal-dialog-message {
  font-size: 0.875rem;
  color: var(--portal-text-secondary);
  margin-bottom: 20px;
}

.portal-dialog-actions {
  display: flex;
  gap: 8px;
}

.portal-dialog-actions .portal-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 0.875rem;
}

.portal-dialog-prompt {
  text-align: start;
}

.portal-dialog-prompt .portal-dialog-title,
.portal-dialog-prompt .portal-dialog-message {
  text-align: start;
}

.portal-dialog-input-wrap {
  margin-bottom: 10px;
}

.portal-dialog-prompt-error {
  margin: 0 0 12px;
  font-size: 0.75rem;
  color: var(--portal-danger, #dc2626);
  text-align: start;
}

/* ===== Tab Bar (Filter tabs) ===== */
.portal-filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.portal-filter-tabs::-webkit-scrollbar {
  display: none;
}

.portal-filter-tab {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--portal-border);
  background: var(--portal-surface);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--portal-text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.portal-filter-tab.active {
  border-color: var(--portal-primary);
  background: var(--portal-primary);
  color: #fff;
}

/* ===== Page Transitions ===== */
.portal-page-enter {
  animation: portal-page-in 0.25s ease;
}

@keyframes portal-page-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

html[dir="rtl"] .portal-page-enter {
  animation-name: portal-page-in-rtl;
}

@keyframes portal-page-in-rtl {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===== Spinner (inline) ===== */
.portal-spinner-inline {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: portal-spin 0.6s linear infinite;
  display: inline-block;
}

/* ===== Home Page ===== */
.portal-home {
  padding: 4px 0;
}

.portal-welcome-card {
  background: linear-gradient(135deg, var(--portal-primary), var(--portal-primary-dark));
  color: #fff;
  border-radius: var(--portal-radius-lg);
  padding: 20px;
  margin-bottom: 8px;
}

.portal-welcome-text h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.portal-welcome-sub {
  font-size: 0.875rem;
  opacity: 0.85;
  margin-top: 4px;
}

/* ===== Section ===== */
.portal-section {
  margin: 16px 0;
}

.portal-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--portal-text);
  margin-bottom: 8px;
}

/* ===== Stat Icon (feather inside stat chip) ===== */
.portal-stat-icon {
  width: 22px;
  height: 22px;
  color: var(--portal-primary);
  margin-bottom: 4px;
  transition: transform 0.25s ease;
}

.portal-stat-chip:hover .portal-stat-icon {
  transform: scale(1.18);
}

/* ===== Page Container ===== */
.portal-page {
  padding: 4px 0;
}

/* ===== Profile Card ===== */
.portal-profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px;
  background: var(--portal-surface);
  border-radius: var(--portal-radius-lg);
  box-shadow: var(--portal-shadow-sm);
  margin-bottom: 16px;
}

.portal-profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--portal-primary-light);
  color: var(--portal-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.portal-profile-avatar svg {
  width: 28px;
  height: 28px;
}

.portal-profile-avatar.has-image {
  background: #fff;
  border: 2px solid var(--portal-primary-light);
}

.portal-profile-photo-btn {
  width: auto;
  min-width: 190px;
  margin-bottom: 12px;
}

.portal-profile-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--portal-text);
}

/* ===== Profile Actions ===== */
.portal-profile-actions {
  background: var(--portal-surface);
  border-radius: var(--portal-radius-lg);
  box-shadow: var(--portal-shadow-sm);
  padding: 0 16px;
  overflow: hidden;
}

.portal-profile-actions .portal-list-item {
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.9375rem;
  text-align: start;
  color: var(--portal-text);
}

.portal-profile-actions .portal-list-item svg:first-child {
  width: 20px;
  height: 20px;
  color: var(--portal-primary);
  flex-shrink: 0;
}

.portal-list-item-danger {
  color: var(--portal-danger) !important;
}

.portal-list-item-danger svg:first-child {
  color: var(--portal-danger) !important;
}

/* ===== Data Cards & Forms ===== */
.portal-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.portal-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--portal-text);
}

.portal-card-subtitle {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin-top: 2px;
}

.portal-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.portal-chip-muted {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--portal-text-secondary);
  background: var(--portal-bg);
  border: 1px solid var(--portal-border);
  border-radius: 999px;
  padding: 5px 10px;
}

.portal-chip-muted i {
  width: 14px;
  height: 14px;
}

.portal-card-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.portal-inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.portal-action-btn {
  width: auto;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 0.8125rem;
}

.portal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.portal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--portal-text-secondary);
}

.portal-select,
.portal-input,
.portal-textarea {
  width: 100%;
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  background: var(--portal-surface);
  color: var(--portal-text);
  font-size: 0.9375rem;
  font-family: inherit;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.portal-select:focus,
.portal-input:focus,
.portal-textarea:focus {
  border-color: var(--portal-primary);
  box-shadow: 0 0 0 3px rgba(var(--portal-primary-rgb), 0.13);
}

.portal-select:disabled,
.portal-input:disabled,
.portal-textarea:disabled {
  background: var(--portal-bg);
  color: var(--portal-text-muted);
}

.portal-textarea {
  min-height: 82px;
  resize: vertical;
}

.portal-field-hint {
  font-size: 0.75rem;
  color: var(--portal-text-muted);
}

.portal-slot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.portal-slot-btn {
  border: 1px solid var(--portal-border);
  background: var(--portal-surface);
  color: var(--portal-text);
  border-radius: 10px;
  min-height: 42px;
  padding: 8px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.portal-slot-btn:hover:not(:disabled) {
  border-color: var(--portal-primary);
}

.portal-slot-btn.active {
  border-color: var(--portal-primary);
  background: var(--portal-primary-light);
  color: var(--portal-primary-dark);
}

.portal-slot-btn:disabled {
  opacity: 0.5;
  text-decoration: line-through;
  cursor: not-allowed;
}

.portal-kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px dashed var(--portal-divider);
  padding: 10px 0;
}

.portal-kv-row:last-child {
  border-bottom: none;
}

.portal-kv-key {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
}

.portal-kv-value {
  font-size: 0.875rem;
  color: var(--portal-text);
  font-weight: 600;
  text-align: end;
}

.portal-result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portal-detail-block {
  background: var(--portal-bg);
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 10px;
}

.portal-detail-block h4 {
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.portal-detail-block p {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  line-height: 1.7;
}

.portal-images-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.portal-link-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  background: var(--portal-primary-light);
  color: var(--portal-primary-dark);
  padding: 8px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
}

.portal-link-chip i {
  width: 14px;
  height: 14px;
}

.portal-next-appointment {
  margin: 14px 0 8px;
}

.portal-next-appointment .portal-card {
  border: 1px solid rgba(var(--portal-primary-rgb), 0.22);
}

.portal-next-appointment-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--portal-primary-dark);
  margin-bottom: 8px;
}

.portal-profile-details {
  background: var(--portal-surface);
  border-radius: var(--portal-radius-lg);
  box-shadow: var(--portal-shadow-sm);
  padding: 4px 16px;
  margin-bottom: 12px;
}

.portal-service-item[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.portal-empty-action {
  width: auto;
  margin-top: 12px;
}

@media (max-width: 420px) {
  .portal-slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .portal-header {
    padding: 0 12px;
  }

  .portal-header-content {
    gap: 8px;
  }

  .portal-header-actions {
    gap: 6px;
  }

  .portal-clinic-name {
    font-size: 0.92rem;
  }

  .portal-tab span {
    font-size: 0.75rem;
  }

  .portal-lang-pill-btn {
    min-width: 38px;
    height: 28px;
    padding: 0 10px;
    font-size: 0.8rem;
  }
}

@media (max-width: 380px) {
  .portal-login-card {
    padding: 22px 16px 18px;
    border-radius: 22px;
  }

  .portal-otp-digit {
    width: 44px;
    height: 52px;
    font-size: 1.3rem;
  }
}

/* ===== Print ===== */
@media print {
  body { display: none !important; }
}

/* ===== Responsive (tablet+) ===== */
@media (min-width: 768px) {
  .portal-login-container {
    max-width: 500px;
  }

  .portal-login-card {
    padding: 32px 30px 24px;
  }

  .portal-main {
    max-width: 960px;
    padding: 28px 24px;
    padding-bottom: calc(var(--portal-tabs-height) + var(--portal-safe-bottom) + 20px);
  }

  .portal-tabs {
    max-width: 560px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--portal-radius-lg) var(--portal-radius-lg) 0 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  }

  .portal-tab {
    flex-direction: row;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--portal-radius-sm);
    transition: color 0.2s, background 0.2s;
  }

  .portal-tab:hover {
    background: var(--portal-bg);
  }

  .portal-tab span {
    font-size: 0.8125rem;
  }

  .portal-tab svg {
    width: 18px;
    height: 18px;
  }

  /* Service grid — wider on desktop */
  .portal-service-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .portal-service-item {
    padding: 20px 12px;
    border-radius: var(--portal-radius-lg);
    border: 1px solid var(--portal-divider);
    box-shadow: none;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  }

  .portal-service-item:hover {
    border-color: var(--portal-primary);
    box-shadow: var(--portal-shadow-md);
    transform: translateY(-2px);
  }

  .portal-service-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--portal-radius-md);
  }
}

/* ===== Responsive (desktop sidebar) ===== */
@media (min-width: 1024px) {
  .portal-header {
    position: sticky;
    top: 0;
  }

  .portal-header-content {
    max-width: none;
    padding-inline-start: 252px;
    padding-inline-end: 20px;
    position: relative;
  }

  .portal-header-logo {
    max-width: min(65vw, 880px);
  }

  /* Guest tools inside header, aligned above sidebar column */
  #portal-header-guest-tools {
    position: absolute;
    inset-inline-start: 16px;
    top: 50%;
    transform: translateY(-50%);
  }

  #portal-header-lang-toggle {
    position: static;
    inset-inline-start: auto;
    top: auto;
    transform: none;
  }

  .portal-tabs {
    position: fixed;
    top: calc(var(--portal-header-total-height) + 16px);
    bottom: auto;
    left: auto;
    right: auto;
    inset-inline-start: 16px;
    inset-inline-end: auto;
    width: 220px;
    max-width: 220px;
    height: auto;
    padding: 10px;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    border-radius: var(--portal-radius-lg);
    border: 1px solid var(--portal-divider);
    background: var(--portal-surface);
    box-shadow: var(--portal-shadow-md);
    transform: none;
  }

  .portal-tab {
    width: 100%;
    justify-content: flex-start;
    min-width: 0;
  }

  .portal-tab-lang {
    display: none !important;
  }

  .portal-tab-lang-value {
    display: none !important;
  }

  .portal-main {
    max-width: none;
    margin: 0;
    margin-inline-start: 252px;
    margin-inline-end: 0;
    padding: 28px 24px;
    padding-bottom: 28px;
    min-height: calc(100vh - var(--portal-header-total-height) - 24px);
  }

  .portal-tab.active {
    background: rgba(var(--portal-primary-rgb), 0.1);
    border-radius: 10px;
    font-weight: 700;
  }

  /* Hide sidebar for guest (non-logged-in) on desktop */
  body.portal-guest .portal-tabs { display: none; }
  body.portal-guest .portal-main { margin-inline-start: 0; }
  body.portal-guest .portal-header-content { padding-inline-start: 20px; }
  body.portal-guest #portal-header-guest-tools {
    position: static;
    transform: none;
  }
}
