/* PoseAlign — shared styles (PC web app)
   ─────────────────────────────────────────
   Visual direction: clinical confidence.
   Single confident indigo for UI; gradient reserved for the printed
   letterhead. Cool slate neutrals. Disciplined typography with
   tabular numerics on every measurement. */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  font-family: var(--font);
  font-feature-settings: "ss01", "cv01";
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--p1); outline-offset: 2px; border-radius: 6px; }

:root {
  /* type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --font-num: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* surface */
  --bg: #F4F5F9;
  --card: #FFFFFF;
  --line: #E6E8EF;
  --divide: #EEF0F4;
  --hover: #F6F7FB;

  /* ink */
  --ink: #0F172A;
  --body: #1F2937;
  --mute: #64748B;
  --faint: #9AA3B2;

  /* brand */
  --p1: #3D4ED6;      /* primary indigo */
  --p2: #6B43C9;      /* secondary plum (gradient partner) */
  --p-dark: #2E3DBF;
  --p-tint: #EEF0FF;
  --p-tint-2: #E4E8FF;
  --grad: linear-gradient(135deg, #3D4ED6 0%, #6B43C9 100%);

  /* semantic */
  --ok: #0E9F6E;
  --okd: #058256;
  --okbg: #E8F6EF;
  --warn: #D93B3B;
  --warnd: #B82A2A;
  --warnbg: #FCEDED;
  --approx: #B45309;
  --approxbg: #FEF3C7;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.05);
  --shadow-2: 0 4px 16px rgba(15,23,42,.08);

  /* radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;
}

/* ───────────── App shell ───────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; background: #fff;
  border-right: 1px solid var(--line);
  position: fixed; inset: 0 auto 0 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 18px 0; z-index: 5;
}
.sb-brand {
  font-size: 18px; font-weight: 700; letter-spacing: -.02em;
  padding: 4px 22px 22px;
  display: flex; align-items: center; gap: 9px;
  color: var(--ink);
}
.sb-brand .logo {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 2px 8px rgba(61,78,214,.28);
  flex-shrink: 0;
}
.sb-brand .logo svg { width: 14px; height: 14px; display: block; }
.sb-brand .sb-accent { color: var(--p1); }
.sb-nav { flex: 1; padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }
.sb-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; font-size: 13.5px; font-weight: 500;
  color: var(--mute); cursor: pointer;
  border-radius: 8px;
  transition: background .12s, color .12s;
}
.sb-item:hover { background: var(--hover); color: var(--ink); }
.sb-item.active { color: var(--p1); font-weight: 600; background: var(--p-tint); }
.sb-item.active .ico svg { stroke: var(--p1); }
.sb-item .ico { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sb-item .ico svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.sb-foot {
  margin: 12px 14px 0; padding: 12px 8px 0;
  border-top: 1px solid var(--divide);
}
.sb-user { display: flex; align-items: center; gap: 10px; }
.sb-ava {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.sb-uname { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.sb-urole { font-size: 11px; color: var(--mute); margin-top: 2px; }

.main { margin-left: 232px; flex: 1; min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 14px 32px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 4;
  min-height: 60px;
}
.tb-title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.tb-spacer { flex: 1; }
.content { padding: 26px 32px 48px; }

.crumb {
  color: var(--mute); font-size: 13px; font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; margin-left: -8px; border-radius: 6px;
}
.crumb:hover { color: var(--p1); background: var(--p-tint); }

/* ───────────── Buttons ───────────── */
.btn {
  border: none; border-radius: var(--r-md);
  padding: 9px 16px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .12s, transform .04s, box-shadow .12s;
  line-height: 1;
}
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--p1); color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.btn-primary:hover { background: var(--p-dark); }
.btn-primary:disabled { opacity: .45; pointer-events: none; }
.btn-ghost {
  background: #fff; color: var(--body);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn-ghost:hover { background: var(--hover); color: var(--ink); box-shadow: inset 0 0 0 1px #D7DBE3; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ───────────── Cards ───────────── */
.card {
  background: var(--card); border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--line);
}
.card-pad { padding: 22px; }
.card-h {
  padding: 14px 20px; border-bottom: 1px solid var(--divide);
  font-size: 13px; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
  letter-spacing: -.005em;
}

/* ───────────── Stat cards ───────────── */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 22px;
}
.stat-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 16px 18px;
  box-shadow: var(--shadow-1);
  position: relative; overflow: hidden;
}
.stat-card .lbl {
  font-size: 11px; color: var(--mute);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  margin-bottom: 6px;
}
.stat-card .num {
  font-size: 28px; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink); line-height: 1;
}
.stat-card .delta { font-size: 11px; color: var(--mute); margin-top: 6px; font-weight: 500; }
.stat-card.p .num { color: var(--p1); }
.stat-card.g .num { color: var(--okd); }
.stat-card.w .num { color: var(--warn); }
.stat-card .rule {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--line);
}
.stat-card.p .rule { background: var(--p1); }
.stat-card.g .rule { background: var(--ok); }
.stat-card.w .rule { background: var(--warn); }

/* ───────────── Tables ───────────── */
.table-wrap {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-1);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--mute); text-transform: uppercase; letter-spacing: .06em;
  padding: 11px 18px; background: #FBFBFE;
  border-bottom: 1px solid var(--divide);
}
th.center, td.center { text-align: center; }
th.right, td.right { text-align: right; }
tbody tr { border-bottom: 1px solid var(--divide); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--hover); }
tbody td { padding: 12px 18px; font-size: 13.5px; vertical-align: middle; color: var(--body); }
tbody td.num { font-variant-numeric: tabular-nums; }

.cell-client { display: flex; align-items: center; gap: 12px; }
.av {
  width: 36px; height: 36px; border-radius: 50%;
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
  background: var(--grad);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.c-name { font-weight: 600; color: var(--ink); }
.c-sub { font-size: 12px; color: var(--mute); margin-top: 1px; }
.muted { color: var(--mute); font-size: 13px; }

.num-pill {
  font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums;
  background: var(--hover); border-radius: 999px;
  padding: 2px 10px; font-size: 12.5px;
  display: inline-block;
}

/* ───────────── Status & badges ───────────── */
.status {
  font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
}
.status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: .9;
}
.status.warn { background: var(--warnbg); color: var(--warnd); }
.status.ok   { background: var(--okbg);   color: var(--okd); }
.status.pend { background: #FEF3C7; color: var(--approx); }

.badge-ok   { background: var(--okbg);   color: var(--okd);   font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: var(--r-sm); font-variant-numeric: tabular-nums; }
.badge-warn { background: var(--warnbg); color: var(--warnd); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: var(--r-sm); font-variant-numeric: tabular-nums; }

.delta { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-sm); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 3px; }
.d-imp  { background: var(--okbg);   color: var(--okd); }
.d-reg  { background: var(--warnbg); color: var(--warnd); }
.d-same { background: #F1F3F7;       color: var(--mute); }

/* ───────────── Empty / loading ───────────── */
.empty {
  text-align: center; color: var(--mute);
  padding: 64px 24px; font-size: 13.5px;
}
.empty .empty-ico {
  width: 44px; height: 44px; margin: 0 auto 12px;
  border-radius: 12px; background: var(--p-tint);
  display: flex; align-items: center; justify-content: center;
  color: var(--p1);
}
.empty .empty-ico svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.6; fill: none; }
.empty .empty-title { font-size: 14.5px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.empty .empty-body { max-width: 320px; margin: 0 auto 14px; line-height: 1.5; }

.spin {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--divide); border-top-color: var(--p1);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: -3px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────── Modal ───────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px;
  padding: 22px 22px 18px; width: 400px; max-width: 100%;
  box-shadow: 0 20px 60px rgba(15,23,42,.25);
  border: 1px solid var(--line);
}
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; letter-spacing: -.01em; }
.modal .sub { font-size: 12.5px; color: var(--mute); margin-bottom: 18px; }
.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 11.5px; color: var(--mute);
  margin-bottom: 5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: #fff;
  border-radius: var(--r-md); padding: 9px 11px; font-size: 13.5px;
  font-family: inherit; outline: none; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--p1); box-shadow: 0 0 0 3px rgba(61,78,214,.12);
}
.field input::placeholder { color: var(--faint); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* ───────────── Tag chips (assessment) ───────────── */
.tag {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; letter-spacing: .01em;
  display: inline-flex; align-items: center; gap: 4px;
}
.tag.empty { background: #F1F3F7; color: var(--mute); }
.tag.ready { background: var(--okbg); color: var(--okd); }
.tag.ready::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }

/* ───────────── Responsive ─────────────
   PC is the core — but we still want graceful narrowing on smaller
   monitors, tablets and clinic laptops. Three breakpoints:
     ≤1180 : stats grid drops to 2 cols
     ≤980  : sidebar collapses to icon-only rail; stat & report layouts compact
     ≤700  : sidebar becomes a top icon strip; content goes single-column
*/

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 22px 24px 40px; }
}

@media (max-width: 980px) {
  /* Sidebar — icon-only rail */
  .sidebar { width: 64px; padding: 16px 0; }
  .sb-brand { padding: 4px 0 18px; justify-content: center; gap: 0; }
  .sb-brand .sb-wordmark { display: none; }
  .sb-nav { padding: 0 8px; }
  .sb-item { padding: 11px 0; justify-content: center; gap: 0; font-size: 0; line-height: 1; }
  .sb-item .ico { margin: 0; }
  .sb-foot { padding: 12px 0 0; margin: 12px 8px 0; }
  .sb-user > div:last-child { display: none; }
  .sb-user { justify-content: center; }
  .main { margin-left: 64px; }

  /* Topbar can wrap actions if needed */
  .topbar { padding: 12px 20px; flex-wrap: wrap; min-height: 56px; }

  .content { padding: 20px 20px 36px; }
}

@media (max-width: 700px) {
  /* Sidebar — top icon strip */
  .sidebar {
    position: sticky; top: 0; left: 0; right: 0;
    width: 100%; height: auto;
    flex-direction: row; padding: 8px 14px; gap: 6px;
    border-right: none; border-bottom: 1px solid var(--line);
    align-items: center;
  }
  .sb-brand { padding: 0 8px 0 0; flex-shrink: 0; }
  .sb-brand .sb-wordmark { display: inline; font-size: 16px; }
  .sb-nav { flex-direction: row; flex: 1; justify-content: flex-end; gap: 2px; padding: 0; }
  .sb-item { padding: 8px 10px; border-radius: 8px; }
  .sb-foot { margin: 0 0 0 8px; padding: 0; border: 0; }

  .main { margin-left: 0; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .tb-title { font-size: 17px; }
  .content { padding: 18px 14px 36px; }

  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 14px 14px 16px; }
  .stat-card .num { font-size: 24px; }
}

/* Table overflow on narrow — let the row scroll horizontally inside its card */
@media (max-width: 980px) {
  .table-wrap { overflow-x: auto; }
  .table-wrap > table { min-width: 720px; }
  .card > table { min-width: 100%; }
}

/* ───────────── Print / PDF ───────────── */
.print-only { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: #fff; }
  .sidebar, .topbar, .btn, .crumb, .overlay { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { max-width: none !important; padding: 0 !important; }
  .print-only { display: block !important; }
  .card { box-shadow: none !important; border: 1px solid #D8DCE6; }
  .card, tr, .issue-banner, .stat-row, .print-head, .view-section { page-break-inside: avoid; }
  thead { display: table-header-group; }
}

/* legacy print-head (kept; not used directly anymore) */
.print-head { padding: 0 0 14px; border-bottom: 2px solid var(--p1); margin-bottom: 18px; }
.print-head .ph-top { display: flex; justify-content: space-between; align-items: baseline; }
.print-head .ph-clinic { font-size: 20px; font-weight: 800; }
.print-head .ph-brand { font-size: 14px; font-weight: 800; color: var(--p1); }
.print-head .ph-title { font-size: 12px; color: #666; margin-top: 2px; }
.print-head .ph-meta { font-size: 12px; color: #444; margin-top: 8px; display: flex; gap: 22px; flex-wrap: wrap; }
.print-head .ph-meta b { color: #111; }
