/* Vitalis — hand-written CSS (no build step). Tokens ported 1:1 from the
   original Next.js build's globals.css so the site looks identical. */

:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.511 0.096 186.391);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.953 0.03 186.391);
  --accent-foreground: oklch(0.32 0.06 186.391);
  --destructive: oklch(0.577 0.245 27.325);
  --warning: oklch(0.76 0.146 74.5);
  --warning-foreground: oklch(0.26 0.05 74.5);
  --success: oklch(0.62 0.13 155);
  --success-foreground: oklch(0.32 0.09 155);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.511 0.096 186.391);
  --chart-1: oklch(0.6 0.118 184.704);
  --radius: 0.625rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --scheme-auto-dark: 1; }
}

:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --background: oklch(0.145 0 0);
    --foreground: oklch(0.985 0 0);
    --card: oklch(0.205 0 0);
    --card-foreground: oklch(0.985 0 0);
    --popover: oklch(0.205 0 0);
    --popover-foreground: oklch(0.985 0 0);
    --primary: oklch(0.704 0.14 182.503);
    --primary-foreground: oklch(0.145 0 0);
    --secondary: oklch(0.269 0 0);
    --secondary-foreground: oklch(0.985 0 0);
    --muted: oklch(0.269 0 0);
    --muted-foreground: oklch(0.708 0 0);
    --accent: oklch(0.28 0.05 186.391);
    --accent-foreground: oklch(0.9 0.05 186.391);
    --destructive: oklch(0.704 0.191 22.216);
    --warning: oklch(0.769 0.146 74.5);
    --warning-foreground: oklch(0.88 0.11 74.5);
    --success: oklch(0.7 0.14 155);
    --success-foreground: oklch(0.85 0.12 155);
    --border: oklch(1 0 0 / 10%);
    --input: oklch(1 0 0 / 15%);
    --ring: oklch(0.704 0.14 182.503);
  }
}

[data-theme="dark"] {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.704 0.14 182.503);
  --primary-foreground: oklch(0.145 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.28 0.05 186.391);
  --accent-foreground: oklch(0.9 0.05 186.391);
  --destructive: oklch(0.704 0.191 22.216);
  --warning: oklch(0.769 0.146 74.5);
  --warning-foreground: oklch(0.88 0.11 74.5);
  --success: oklch(0.7 0.14 155);
  --success-foreground: oklch(0.85 0.12 155);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.704 0.14 182.503);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
img { max-width: 100%; }

/* --- App shell --- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0; padding: 1rem; display: flex; flex-direction: column; gap: 1.5rem;
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; font-weight: 600; font-size: 1.05rem; color: var(--primary); }
.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; border-radius: calc(var(--radius) * 0.8);
  color: var(--muted-foreground); font-weight: 500;
}
.nav-link:hover { background: var(--muted); color: var(--foreground); }
.nav-link.active { background: var(--accent); color: var(--accent-foreground); }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.avatar { width: 36px; height: 36px; border-radius: 999px; background: var(--accent); color: var(--accent-foreground); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.8rem; flex-shrink: 0; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--border); background: color-mix(in oklch, var(--background) 95%, transparent); backdrop-filter: blur(6px); }
.content { padding: 1.5rem; flex: 1; }
.mobile-menu-btn { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; background: var(--background); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .mobile-menu-btn { display: inline-flex; }
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; justify-content: center;
  border: 1px solid transparent; border-radius: calc(var(--radius) * 0.8); font-weight: 500; font-size: 0.85rem;
  padding: 0.5rem 0.9rem; cursor: pointer; background: var(--secondary); color: var(--secondary-foreground);
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--muted); }
.btn-destructive { background: var(--destructive); color: white; }
.btn-icon { padding: 0.5rem; }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Cards / stats --- */
.card { background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.2); padding: 1.25rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { display: flex; align-items: center; gap: 0.9rem; }
.stat-icon { width: 40px; height: 40px; border-radius: calc(var(--radius) * 0.9); background: var(--accent); color: var(--accent-foreground); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-value { font-size: 1.4rem; font-weight: 700; }
.stat-label { color: var(--muted-foreground); font-size: 0.82rem; }

.patient-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.patient-card { display: flex; flex-direction: column; gap: 0.75rem; }
.patient-card-head { display: flex; align-items: center; gap: 0.7rem; }
.patient-metrics { display: flex; gap: 0.6rem; flex-wrap: wrap; font-size: 0.85rem; }
.patient-metric { display: flex; align-items: center; gap: 0.3rem; background: var(--muted); border-radius: calc(var(--radius) * 0.7); padding: 0.3rem 0.55rem; }

/* --- Forms --- */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field label { font-weight: 500; font-size: 0.85rem; }
.field .hint { color: var(--muted-foreground); font-size: 0.78rem; }
input, select, textarea {
  font: inherit; padding: 0.5rem 0.65rem; border-radius: calc(var(--radius) * 0.7); border: 1px solid var(--input);
  background: var(--background); color: var(--foreground); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ring); outline-offset: 1px; }
.form-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.form-section h3 { font-size: 0.95rem; margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.form-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-row input { width: auto; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; white-space: nowrap; }
th, td { padding: 0.65rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted-foreground); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--muted); }

/* --- Badges --- */
.badge { display: inline-flex; align-items: center; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: color-mix(in oklch, var(--success) 18%, transparent); color: var(--success-foreground); }
.badge-warning { background: color-mix(in oklch, var(--warning) 20%, transparent); color: var(--warning-foreground); }
.badge-destructive { background: color-mix(in oklch, var(--destructive) 16%, transparent); color: var(--destructive); }
.badge-muted { background: var(--muted); color: var(--muted-foreground); }

/* --- Empty states --- */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--muted-foreground); }
.empty-state h3 { color: var(--foreground); margin-bottom: 0.4rem; }
.empty-state .btn { margin-top: 1rem; }

/* --- Flash / toasts --- */
.flash-stack { position: fixed; top: 1rem; right: 1rem; z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; max-width: 320px; }
.flash { padding: 0.75rem 1rem; border-radius: calc(var(--radius) * 0.8); border: 1px solid var(--border); background: var(--popover); color: var(--popover-foreground); box-shadow: 0 4px 16px rgba(0,0,0,.12); font-size: 0.85rem; }
.flash-success { border-color: var(--success); }
.flash-error { border-color: var(--destructive); }

/* --- Modal / confirm dialog --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--popover); color: var(--popover-foreground); border-radius: var(--radius); padding: 1.5rem; max-width: 360px; width: 90%; }
.modal h3 { margin-bottom: 0.5rem; }
.modal p { color: var(--muted-foreground); font-size: 0.85rem; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }
[hidden] { display: none !important; }

/* --- Gallery / lightbox --- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.gallery-item { border: 1px solid var(--border); border-radius: calc(var(--radius) * 0.8); overflow: hidden; cursor: zoom-in; aspect-ratio: 1; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 60; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 1rem; }
.lightbox img { max-height: 80vh; max-width: 90vw; border-radius: 6px; }
.lightbox-actions { display: flex; gap: 0.6rem; }

/* --- Login page --- */
.login-shell { min-height: 100vh; display: grid; }
@media (min-width: 1024px) { .login-shell { grid-template-columns: 1fr 1fr; } }
.login-hero { display: none; flex-direction: column; justify-content: space-between; background: var(--primary); color: var(--primary-foreground); padding: 3rem; }
@media (min-width: 1024px) { .login-hero { display: flex; } }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 2rem; position: relative; }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 1.75rem; }

/* --- Utility --- */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; }
.text-muted { color: var(--muted-foreground); } .text-sm { font-size: .82rem; } .text-xs { font-size: .75rem; }
.mb-1 { margin-bottom: .25rem; } .mb-2 { margin-bottom: .5rem; } .mb-3 { margin-bottom: .75rem; } .mb-4 { margin-bottom: 1rem; }
.mt-auto { margin-top: auto; }
.w-full { width: 100%; }
.chart-wrap { height: 220px; margin-bottom: 1.25rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.breadcrumb { font-size: 0.82rem; color: var(--muted-foreground); margin-bottom: 0.35rem; }

/* --- Print --- */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  html, body { background: white !important; }
  .no-print { display: none !important; }
}
