:root {
  --ink: #14212f;
  --ink-soft: #5d6f7f;
  --line: #dbe4ec;
  --canvas: #f5f7f9;
  --brand: #0f8b8d;
  --brand-strong: #097273;
  --accent: #ffb703;
  --card: rgba(255, 255, 255, 0.82);
  --shadow: 0 16px 45px rgba(20, 33, 47, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 20px;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 10% 15%, #e6f6f6 0%, transparent 35%),
              radial-gradient(circle at 90% 85%, #ffecc1 0%, transparent 28%),
              var(--canvas);
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  line-height: 1.6;
}

body.lang-alt {
  font-family: "Noto Sans Tibetan", "Plus Jakarta Sans", "Segoe UI", sans-serif;
  font-size: 1.30rem;
  line-height: 1.75;
}

body.lang-alt h1,
body.lang-alt h2,
body.lang-alt h3,
body.lang-alt h4,
body.lang-alt h5,
body.lang-alt .nav-link,
body.lang-alt .btn,
body.lang-alt .nav-user,
body.lang-alt label,
body.lang-alt th,
body.lang-alt td {
  font-family: "Noto Sans Tibetan", "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

body.lang-alt label {
  font-size: 1.5rem;
}

body.lang-alt input[type="text"],
body.lang-alt input[type="email"],
body.lang-alt input[type="password"],
body.lang-alt input[type="tel"],
body.lang-alt input[type="number"],
body.lang-alt input[type="search"],
body.lang-alt input[type="url"],
body.lang-alt input[type="date"],
body.lang-alt textarea {
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

h1, h2, h3, h4, h5 {
  font-family: "Manrope", "Segoe UI", sans-serif;
  letter-spacing: -0.02em;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
  background: rgba(245, 247, 249, 0.75);
  border-bottom: 1px solid rgba(219, 228, 236, 0.7);
}

.brand-mark {
  display: flex;
  align-items: center;
}

.brand-logo {
  height: 72px;
  width: auto;
  display: block;
  margin: -12px -8px;
}

.nav-link {
  color: var(--ink-soft) !important;
  font-weight: 600;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--ink) !important;
}

.nav-user {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
}

.nav-user-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #eef3f8;
}

.profile-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  align-items: start;
}

.profile-photo-block {
  display: flex;
  justify-content: center;
}

.profile-photo {
  width: 160px;
  height: 160px;
  border-radius: 20px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #eef3f8;
}

.profile-detail-row {
  margin-bottom: 0.5rem;
}

.inline-form {
  margin: 0;
}

.nav-search-item {
  min-width: 320px;
}

.nav-search-form {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.nav-search-input {
  min-width: 220px;
}

.btn {
  border-radius: 12px;
  font-weight: 700;
  padding: 0.65rem 1rem;
}

.btn-brand {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  box-shadow: 0 10px 18px rgba(15, 139, 141, 0.22);
}

.btn-brand:hover {
  color: #fff;
  transform: translateY(-1px);
}

.btn-soft {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  white-space: nowrap;
}

.dropdown-item {
  white-space: nowrap;
}

body.lang-alt .site-header .nav-link,
body.lang-alt .site-header .nav-user,
body.lang-alt .site-header .btn,
body.lang-alt .site-header .form-select {
  font-size: 0.9rem;
  line-height: 1.25;
}

.main-shell {
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.shell-card {
  border: 1px solid rgba(219, 228, 236, 0.9);
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 2rem;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(234, 246, 246, 0.72));
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  right: -90px;
  top: -80px;
  background: radial-gradient(circle, rgba(15, 139, 141, 0.28), rgba(15, 139, 141, 0));
  pointer-events: none;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  margin-bottom: 0.9rem;
}

.hero-copy {
  color: var(--ink-soft);
  max-width: 58ch;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  color: var(--brand-strong);
  font-weight: 800;
}

.hero-actions {
  margin-top: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.hero-kpis {
  display: grid;
  gap: 0.8rem;
}

.hero-kpi-link {
  text-decoration: none;
  color: inherit;
  display: block;
  border-radius: 16px;
  transition: filter 0.2s, transform 0.2s;
}

.hero-kpi-link:hover article {
  border-color: var(--brand, #4f6ef7);
  background: var(--brand-soft, #eef1fe);
}

.hero-kpi-link:hover {
  transform: translateY(-4px);
}

.hero-kpis article {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.kpi-panel {
  min-height: 130px;
  display: grid;
  align-content: start;
  gap: 0.15rem;
  box-shadow: 0 12px 24px rgba(14, 37, 53, 0.08);
}

.kpi-panel small {
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 0.2rem;
}

.kpi-patients {
  background: linear-gradient(160deg, #ffffff, #f0fbf8);
}

.kpi-visits {
  background: linear-gradient(160deg, #ffffff, #eef5ff);
}

.kpi-upcoming {
  background: linear-gradient(160deg, #ffffff, #fff6e6);
}

.kpi-panel strong,
.metric-value {
  font-variant-numeric: tabular-nums;
}

.hero-kpis span {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.hero-kpis strong {
  display: block;
  margin-top: 0.2rem;
}

.feature-grid {
  margin-top: 1.1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.feature-grid article {
  padding: 1.2rem;
}

.feature-grid h2 {
  font-size: 1.2rem;
}

.feature-grid p {
  color: var(--ink-soft);
  margin-bottom: 0;
}

.dashboard-grid {
  align-items: stretch;
}

.dashboard-visual-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-visual-card {
  padding: 0.9rem;
  display: grid;
  gap: 0.8rem;
  position: relative;
  overflow: hidden;
}

.dashboard-visual-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(15, 139, 141, 0.12), rgba(255, 183, 3, 0.08));
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.dashboard-visual-card:hover::before {
  opacity: 1;
}

.dashboard-visual-image {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.dashboard-visual-card:hover .dashboard-visual-image {
  transform: scale(1.02);
}

.dashboard-visual-card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.dashboard-visual-card p {
  margin: 0.3rem 0 0;
}

.metric-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 160px;
}

.admin-metric {
  min-height: 130px;
}

.metric-value {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--brand-strong);
}

.auth-shell {
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.2rem;
  padding: 1.2rem;
}

.auth-side {
  padding: 1rem;
}

.auth-side p {
  color: var(--ink-soft);
}

.auth-meta {
  margin: 1rem 0 0;
  padding-left: 1rem;
  color: var(--ink-soft);
}

.auth-side-visual {
  margin-top: 1.1rem;
}

.auth-side-visual img {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 14px 24px rgba(20, 33, 47, 0.12);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.auth-side-visual img:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 30px rgba(20, 33, 47, 0.16);
}

.auth-side-points {
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
}

.auth-side-points li {
  color: var(--ink-soft);
  font-weight: 600;
  position: relative;
  padding-left: 1.05rem;
}

.auth-side-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65rem;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 5px rgba(15, 139, 141, 0.14);
}

.auth-form-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
}

.auth-form {
  display: grid;
  gap: 0.55rem;
}

.auth-form h2 {
  margin-bottom: 0.4rem;
}

.hint {
  margin: 0.4rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.auth-links {
  margin-top: 0.75rem;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.92rem;
}

.auth-links a {
  color: var(--brand-strong);
  font-weight: 700;
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}

.patients-head {
  padding: 1.2rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
}

.patients-head p {
  color: var(--ink-soft);
  margin-bottom: 0;
}

.patients-head-actions {
  flex-shrink: 0;
}

.split-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.patients-search-row {
  display: flex;
  gap: 0.5rem;
  min-width: 320px;
}

.patients-search-row .form-control {
  min-width: 240px;
}

.table-shell {
  margin-top: 0.9rem;
  padding: 0.4rem;
}

.form-shell {
  padding: 1.4rem;
}

.visit-email-shell {
  /* Extra left inset so the send-email page feels less congested. */
  padding-left: clamp(1.8rem, 3.8vw, 3.2rem);
}

.form-shell-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.form-shell-head p {
  color: var(--ink-soft);
  margin-bottom: 0;
}

.patient-form {
  display: grid;
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-span-2 {
  grid-column: span 2;
}

.patient-form label {
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.table-actions {
  display: flex;
  justify-content: end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-inline-form {
  margin: 0;
}

.admin-role-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.lab-thumb-link {
  display: inline-block;
  margin-top: 0.45rem;
}

.lab-thumb {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.detail-grid article {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 1rem;
}

.detail-label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-span-2 {
  grid-column: span 2;
}

.detail-grid p {
  margin: 0;
  white-space: pre-wrap;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.risk {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.risk-low {
  color: #0f5132;
  background: #d1f1dc;
}

.risk-medium {
  color: #664d03;
  background: #fff3cd;
}

.risk-high {
  color: #842029;
  background: #f8d7da;
}

.footer {
  margin: 0 auto 1rem;
  max-width: 1320px;
  padding: 0.95rem 1.2rem;
}

.footer-row {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.app-bg-shape {
  position: fixed;
  pointer-events: none;
  filter: blur(42px);
  opacity: 0.35;
  z-index: -1;
}

.shape-left {
  width: 280px;
  height: 280px;
  background: #0f8b8d;
  top: -80px;
  left: -90px;
}

.shape-right {
  width: 320px;
  height: 320px;
  background: #ffb703;
  bottom: -120px;
  right: -120px;
}

.reveal-up {
  animation: revealUp 650ms ease both;
}

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Visual refresh layer: style-only upgrades, no functional changes. */
:root {
  --line-strong: #cad7e3;
  --surface-solid: #ffffff;
  --focus-ring: rgba(15, 139, 141, 0.26);
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(800px 300px at 3% 0%, rgba(15, 139, 141, 0.16), rgba(15, 139, 141, 0)),
    radial-gradient(700px 280px at 97% 100%, rgba(255, 183, 3, 0.15), rgba(255, 183, 3, 0)),
    linear-gradient(180deg, #f8fbfd 0%, #f2f6fa 100%);
}

.site-header {
  backdrop-filter: blur(14px);
  background: rgba(248, 251, 253, 0.78);
  box-shadow: 0 8px 30px rgba(20, 33, 47, 0.08);
}

.navbar {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.brand-mark {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-link {
  position: relative;
  transition: color 0.2s ease;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0.3rem;
  right: 0.3rem;
  bottom: 0.15rem;
  height: 2px;
  border-radius: 999px;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: transform 0.2s ease;
}

.nav-link:hover::after,
.nav-link:focus-visible::after {
  transform: scaleX(1);
}

.shell-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.82));
  border-color: rgba(202, 215, 227, 0.9);
  box-shadow: 0 18px 42px rgba(20, 33, 47, 0.11);
  backdrop-filter: blur(4px);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.table-shell:hover,
.form-shell:hover,
.hero:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 139, 141, 0.22);
  box-shadow: 0 24px 52px rgba(20, 33, 47, 0.16);
}

.btn {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.btn-brand {
  box-shadow: 0 10px 20px rgba(15, 139, 141, 0.26);
}

.btn-brand:hover,
.btn-brand:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(15, 139, 141, 0.33);
}

.btn-soft {
  background: linear-gradient(180deg, #ffffff, #f5f8fb);
}

.btn-soft:hover,
.btn-soft:focus-visible {
  border-color: rgba(15, 139, 141, 0.35);
  background: linear-gradient(180deg, #ffffff, #edf6f6);
}

.form-control,
.form-select,
textarea.form-control {
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.22rem var(--focus-ring);
}

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
}

.table thead th {
  border-bottom: 1px solid rgba(202, 215, 227, 0.95);
  color: #34495c;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.table tbody tr {
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.table tbody tr:hover {
  background: rgba(15, 139, 141, 0.07);
}

.nav-user {
  border-color: rgba(202, 215, 227, 0.95);
  background: linear-gradient(180deg, #ffffff, #f5f9fd);
}

.nav-user-link:hover,
.nav-user-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.15);
  text-decoration: none;
}

.footer {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(252, 254, 255, 0.82));
  border-color: rgba(202, 215, 227, 0.9);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal-up,
  .btn,
  .shell-card,
  .table tbody tr,
  .dashboard-visual-image {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 992px) {
  body.lang-alt .site-header .nav-link,
  body.lang-alt .site-header .nav-user,
  body.lang-alt .site-header .btn,
  body.lang-alt .site-header .form-select {
    font-size: 1rem;
  }

  .nav-search-item {
    min-width: 100%;
  }

  .nav-search-form {
    width: 100%;
  }

  .nav-search-input {
    min-width: 0;
    width: 100%;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .hero::after {
    width: 180px;
    height: 180px;
    right: -70px;
    top: -60px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-visual-grid {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .form-span-2 {
    grid-column: auto;
  }

  .detail-span-2 {
    grid-column: auto;
  }

  .patients-head,
  .form-shell-head {
    flex-direction: column;
    align-items: stretch;
  }

  .visit-email-shell {
    padding-left: 1.2rem;
  }
}