/* VIKI :: makeover — Apple-style craft on top of app.css + viki.css.
   Principles (WWDC "Designing Fluid Interfaces", "Details of UI Typography"):
   respond on press, materials for chrome, size-specific tracking, critically
   damped motion, and gentler equivalents for reduced motion / transparency / contrast. */

/* ---------------------------------------------------------------- tokens */
:root {
  --viz-1: #00819c;                 /* chart blue-teal (toward the Vital360Rx mark), validated on the light surface */
  --viz-grid: rgba(11, 11, 11, .07);
  --viz-base: rgba(11, 11, 11, .22);
  --r: 12px; --r-sm: 9px; --r-lg: 18px;
  --sh-1: 0 1px 1px rgba(11,11,11,.03), 0 2px 6px rgba(11,11,11,.04), 0 0 0 1px rgba(11,11,11,.055);
  --sh-2: 0 6px 24px rgba(11,11,11,.10), 0 1px 3px rgba(11,11,11,.06), 0 0 0 1px rgba(11,11,11,.06);
  --spring: cubic-bezier(.2, .8, .2, 1);       /* critically damped feel, no overshoot */
  --material: color-mix(in srgb, var(--surface) 72%, transparent);
  --material-heavy: color-mix(in srgb, var(--plane) 80%, transparent);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --viz-1: #1a9bb8; --viz-grid: rgba(255,255,255,.07); --viz-base: rgba(255,255,255,.24);
    --sh-1: 0 1px 2px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.06);
    --sh-2: 0 10px 30px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.07); }
}
:root[data-theme="dark"] { --viz-1: #1a9bb8; --viz-grid: rgba(255,255,255,.07); --viz-base: rgba(255,255,255,.24);
  --sh-1: 0 1px 2px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.06);
  --sh-2: 0 10px 30px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.07); }

/* ---------------------------------------------------------------- type: tracking by size, weight for hierarchy */
body { font-family: var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-optical-sizing: auto; }
h1 { font-size: 26px; line-height: 1.12; letter-spacing: -.024em; font-weight: 700; }
h2 { font-size: 16px; line-height: 1.25; letter-spacing: -.012em; font-weight: 650; }
h3 { letter-spacing: -.006em; }
.pagehead { margin-bottom: 18px; }
.pagehead p { font-size: 14px; letter-spacing: -.003em; }
@media (min-width: 900px) { h1 { font-size: 30px; } }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- surfaces */
.card { border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-h { border-bottom-color: color-mix(in srgb, var(--line) 70%, transparent); }

/* KPI tiles: label first, big number, optional sparkline */
.kpis { gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi { border: 0; box-shadow: var(--sh-1); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column-reverse; gap: 4px;
  transition: transform .12s var(--spring), box-shadow .2s var(--spring); }
.kpi-v { font-size: 22px; letter-spacing: -.025em; font-weight: 700; line-height: 1.1; }
.kpi-k { font-size: 12px; margin: 0; letter-spacing: 0; color: var(--ink-3); font-weight: 550; }
a.kpi:hover { box-shadow: var(--sh-2); }
.kpis-hero { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 10px; }
.kpi-hero { flex-direction: column; padding: 16px 18px; gap: 8px; }
.kpi-hero .kpi-v { font-size: 30px; letter-spacing: -.03em; }
.kpi-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.spark { flex: none; overflow: visible; }

/* ---------------------------------------------------------------- respond on press (pointer-down), not release */
.btn, .kpi[href], .mtile, .or-tab, .or-st, .seg-b, .nav a, .tabbar a, .tabbar .tab-menu, .hbar[href], .mlist a, .mlist button {
  -webkit-tap-highlight-color: transparent; }
.btn { transition: background .12s, border-color .12s, transform .1s var(--spring), box-shadow .12s; border-radius: var(--r-sm); }
.btn:active:not(:disabled) { transform: scale(.97); }
a.kpi:active, .mtile:active, .or-tab:active, .or-st:active, .hbar[href]:active { transform: scale(.98); transition-duration: .08s; }
.tbl tbody tr.click:active { background: var(--surface-3); }
.btn-pri { box-shadow: 0 1px 2px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.12); }

/* focus that's visible and calm */
:where(a, button, input, select, textarea, [tabindex]):focus-visible { outline: 2.5px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }

/* ---------------------------------------------------------------- materials: chrome floats, content scrolls under */
@media (min-width: 761px) {
  .side { background: var(--material-heavy); backdrop-filter: saturate(170%) blur(24px); -webkit-backdrop-filter: saturate(170%) blur(24px);
    border-right: 1px solid color-mix(in srgb, var(--line) 80%, transparent); }
}
.topbar { background: var(--material); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0; box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 70%, transparent); }
.tabbar { background: var(--material) !important; backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -1px 0 color-mix(in srgb, var(--line) 70%, transparent); border-top: 0 !important; }
.tabbar a span, .tabbar .tab-menu span { font-weight: 600; letter-spacing: .005em; }

/* sidebar rows: softer pill, accent rail kept */
.nav a { border-radius: 10px; }
.nav a.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* ---------------------------------------------------------------- modals & sheets: materialize, don't just fade */
.scrim { animation: v-fade .2s ease both; backdrop-filter: blur(2px); }
.modal { border-radius: 20px; box-shadow: var(--sh-2); animation: v-materialize .28s var(--spring) both; }
@keyframes v-fade { from { opacity: 0; } }
@keyframes v-materialize { from { opacity: 0; transform: translateY(8px) scale(.97); filter: blur(4px); } }
.msheet { background: var(--material); backdrop-filter: saturate(180%) blur(28px); -webkit-backdrop-filter: saturate(180%) blur(28px);
  touch-action: none; will-change: transform; }
.msheet-body { touch-action: pan-y; }
.mtile { box-shadow: var(--sh-1); border: 0; background: var(--surface); }

/* ---------------------------------------------------------------- charts */
.viz-card { overflow: visible; }
.viz-h { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 6px; flex-wrap: wrap; }
.viz-h p { margin: 3px 0 0; font-size: 13px; color: var(--ink-3); }
.viz-body { padding: 6px 14px 14px; }
.viz-body > .tbl-wrap, .viz-body > .empty { margin: 0 -14px -14px; }
.vz { position: relative; width: 100%; min-height: 40px; }
.vz svg { display: block; max-width: 100%; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-base { stroke: var(--viz-base); stroke-width: 1; }
.viz-ax { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-line { fill: none; stroke: var(--viz-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-end { fill: var(--viz-1); stroke: var(--surface); stroke-width: 1.5; }
.viz-cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.viz-dot { fill: var(--viz-1); stroke: var(--surface); stroke-width: 2; }
.viz-col { fill: var(--viz-1); opacity: .9; transition: opacity .12s; }
.viz-col.on { opacity: 1; }
.vz svg:hover .viz-col:not(.on) { opacity: .55; }
.viz-tip { position: absolute; z-index: 5; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .16s var(--spring); background: var(--material); backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%); box-shadow: var(--sh-2); border-radius: 10px; padding: 7px 10px; white-space: nowrap; }
.viz-tip.on { opacity: 1; transform: none; }
.viz-tip-t { font-size: 11.5px; color: var(--ink-3); font-weight: 550; }
.viz-tip-v { font-size: 15px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.viz-empty { padding: 26px 8px; text-align: center; color: var(--ink-3); font-size: 13px; }
.viz-tog { margin-left: auto; }
.seg-sm .seg-b { padding: 5px 10px; font-size: 12.5px; }

.hbars { display: flex; flex-direction: column; gap: 2px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(60px, 1.4fr) auto; gap: 12px; align-items: center;
  padding: 7px 6px; border-radius: 10px; color: inherit; text-decoration: none; }
a.hbar:hover { background: var(--surface-2); }
.hbar-l { min-width: 0; display: flex; flex-direction: column; }
.hbar-n { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-s { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-t { height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--viz-1) 9%, transparent); overflow: hidden; }
.hbar-t > i { display: block; height: 100%; background: var(--viz-1); border-radius: 0 5px 5px 0; transform-origin: left;
  animation: v-grow .5s var(--spring) both; }
.hbar-v { font-size: 13.5px; font-weight: 650; min-width: 64px; text-align: right; }
@keyframes v-grow { from { transform: scaleX(0); } }
@media (max-width: 560px) { .hbar { grid-template-columns: minmax(0, 1fr) auto; } .hbar-t { grid-column: 1 / -1; grid-row: 2; } }

/* ---------------------------------------------------------------- accessibility preferences */
@media (prefers-reduced-motion: reduce) {
  .modal, .scrim, .hbar-t > i, .viz-tip { animation: none !important; transition: opacity .15s ease !important; }
  .btn:active, a.kpi:active, .mtile:active, .or-tab:active, .or-st:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .side, .topbar, .tabbar, .msheet, .viz-tip { background: var(--surface) !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
}
@media (prefers-contrast: more) {
  .card, .kpi, .mtile { box-shadow: 0 0 0 1.5px var(--ink-3); }
  .viz-grid { stroke: var(--ink-3); }
}
@media print {
  .side, .topbar, .tabbar, .viz-tog { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
.wrap .grid-2 { align-items: start; }
@media (max-width: 560px) {
  .kpis-hero { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-hero { padding: 13px 14px; }
  .kpi-hero .kpi-v { font-size: 22px; }
  .kpi-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .kpis { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .kpi { padding: 11px 12px; }
  .kpi-v { font-size: 18px; }
}
