/* sungax.org — Monze Mission Hospital PACS
   Public site and remote viewer. */

:root {
  --bg: #0b1220;
  --bg-2: #111a2e;
  --bg-3: #16223c;
  --line: #22304f;
  --line-soft: #1b2740;
  --text: #e8edf7;
  --muted: #93a3c0;
  --dim: #6f7f9e;
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 14px 40px rgba(0, 0, 0, .45);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 1080px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

a { color: var(--accent-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

.wrap { width: min(var(--wrap), 100%); margin: 0 auto; padding: 0 20px; }

/* ----------------------------------------------------------------- header */
.site-head {
  position: sticky; top: 0; z-index: 30;
  background: rgba(11, 18, 32, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap {
  display: flex; align-items: center; gap: 14px;
  height: 62px;
}
.logo { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); }
.logo img { width: 32px; height: 32px; border-radius: 7px; display: block; }
.logo b { font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; }
.logo span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.site-nav a {
  padding: 8px 12px; border-radius: 8px; font-size: 14px;
  color: var(--muted); text-decoration: none;
}
.site-nav a:hover { background: var(--bg-3); color: var(--text); }
@media (max-width: 720px) {
  .site-nav a.hide-sm { display: none; }
}

/* ------------------------------------------------------------------- hero */
.hero {
  padding: 60px 0 46px;
  background:
    radial-gradient(760px 380px at 18% -8%, rgba(59,130,246,.18) 0%, transparent 62%),
    radial-gradient(620px 340px at 88% 4%, rgba(34,197,94,.10) 0%, transparent 60%);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent-2); font-weight: 650;
  background: rgba(59,130,246,.10); border: 1px solid rgba(59,130,246,.28);
  padding: 5px 12px; border-radius: 99px; margin-bottom: 18px;
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 5.2vw, 46px);
  line-height: 1.12; letter-spacing: -.022em; font-weight: 700;
  max-width: 21ch;
}
.hero p.lead {
  margin: 0 0 26px; font-size: clamp(16px, 2.1vw, 18.5px);
  color: var(--muted); max-width: 62ch;
}
.hero-actions { display: flex; gap: 11px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 19px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 550;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover { background: #1c2b4d; border-color: #33456e; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2f74e8; border-color: #2f74e8; }
.btn.small { padding: 7px 13px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --------------------------------------------------------------- sections */
section { padding: 52px 0; border-top: 1px solid var(--line-soft); }
section > .wrap > h2 {
  margin: 0 0 8px; font-size: clamp(22px, 3.2vw, 28px);
  letter-spacing: -.018em; font-weight: 670;
}
section > .wrap > p.sub { margin: 0 0 30px; color: var(--muted); max-width: 64ch; }

.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(258px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); }

.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
}
.card h3 { margin: 0 0 7px; font-size: 16.5px; font-weight: 620; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.card .ico {
  width: 38px; height: 38px; border-radius: 9px;
  display: grid; place-items: center; margin-bottom: 14px;
  background: rgba(59,130,246,.13); color: var(--accent-2);
}
.card .ico.green { background: rgba(34,197,94,.13); color: #4ade80; }
.card .ico.amber { background: rgba(245,158,11,.13); color: #fbbf24; }

/* ------------------------------------------------------------- department */
.dept-list { display: flex; flex-wrap: wrap; gap: 8px; }
.dept-chip {
  padding: 7px 14px; border-radius: 99px; font-size: 14px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
}

/* --------------------------------------------------------------- launcher */
.launcher {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 24px; box-shadow: var(--shadow);
}
.launcher h3 { margin: 0 0 6px; font-size: 18px; }
.launcher p.note { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.launcher .row { display: flex; gap: 10px; flex-wrap: wrap; }
.launcher input {
  flex: 1; min-width: 220px; padding: 11px 13px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  font: inherit; font-size: 15px; font-family: var(--mono);
}
.launcher input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
.launcher .saved {
  margin-top: 14px; font-size: 13.5px; color: var(--muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* ------------------------------------------------------------------ steps */
.steps { counter-reset: step; list-style: none; margin: 0; padding: 0; }
.steps li {
  counter-increment: step; position: relative;
  padding: 0 0 22px 46px; border-left: 2px solid var(--line);
  margin-left: 14px;
}
.steps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps li::before {
  content: counter(step);
  position: absolute; left: -15px; top: -2px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--accent-2); font-size: 13px; font-weight: 650;
  display: grid; place-items: center;
}
.steps li h4 { margin: 2px 0 5px; font-size: 15.5px; font-weight: 600; }
.steps li p { margin: 0; color: var(--muted); font-size: 14.5px; }

/* ------------------------------------------------------------------ callout */
.callout {
  border: 1px solid rgba(245,158,11,.36);
  background: rgba(245,158,11,.07);
  border-radius: var(--radius); padding: 18px 20px;
}
.callout.blue { border-color: rgba(59,130,246,.36); background: rgba(59,130,246,.07); }
.callout h3 { margin: 0 0 6px; font-size: 15.5px; }
.callout p { margin: 0 0 8px; color: var(--muted); font-size: 14.5px; }
.callout p:last-child { margin-bottom: 0; }

code.k {
  font-family: var(--mono); font-size: .9em;
  background: var(--bg-3); border: 1px solid var(--line);
  padding: 1.5px 6px; border-radius: 5px; color: #cbd5e1;
}

/* ------------------------------------------------------------------ footer */
.site-foot {
  border-top: 1px solid var(--line); padding: 30px 0 40px;
  color: var(--dim); font-size: 13.5px;
}
.site-foot .wrap { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--text); }
.site-foot .spacer { flex: 1; }

/* ======================================================= remote viewer app */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.setup-card {
  width: min(680px, 100%); margin: 40px auto;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
}
.setup-card h2 { margin: 0 0 8px; font-size: 20px; }
.setup-card ol { color: var(--muted); font-size: 14.5px; padding-left: 20px; }
.setup-card li { margin-bottom: 8px; }
.setup-card pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 14px; overflow-x: auto; font-family: var(--mono);
  font-size: 12.5px; color: #cbd5e1; line-height: 1.6;
}

.signin-wrap { display: grid; place-items: center; padding: 40px 20px; flex: 1; }
.signin {
  width: min(400px, 100%); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 30px 26px; box-shadow: var(--shadow);
}
.signin h2 { margin: 0 0 4px; font-size: 20px; text-align: center; }
.signin p.sub { margin: 0 0 22px; font-size: 13px; color: var(--muted); text-align: center; }
.signin label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.signin input {
  width: 100%; margin-top: 5px; padding: 10px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 15px;
}
.signin input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.18); }
.form-error {
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4);
  color: #fecaca; padding: 9px 11px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}
.fineprint { font-size: 11.5px; color: var(--dim); text-align: center; margin: 16px 0 0; line-height: 1.55; }

.viewer-top {
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px; height: 56px; flex: 0 0 56px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.viewer-top .spacer { flex: 1; }
.viewer-body { flex: 1; display: flex; min-height: 0; }
.study-pane {
  width: 330px; flex: 0 0 330px; overflow-y: auto;
  background: var(--bg-2); border-right: 1px solid var(--line); padding: 12px;
}
.detail-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 18px; }
@media (max-width: 900px) {
  .viewer-body { flex-direction: column; }
  .study-pane { width: auto; flex: 0 0 auto; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .detail-pane { padding: 14px; }
}

.study-item {
  display: block; width: 100%; text-align: left;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 11px 13px; margin-bottom: 8px;
  color: inherit; font: inherit; cursor: pointer;
}
.study-item:hover { border-color: #33456e; }
.study-item.active { border-color: var(--accent); background: rgba(59,130,246,.10); }
.study-item strong { display: block; font-size: 14.5px; }
.study-item small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: var(--bg-3); color: var(--muted); border: 1px solid var(--line);
}
.badge.ok { background: rgba(34,197,94,.14); color: #86efac; border-color: rgba(34,197,94,.35); }
.badge.warn { background: rgba(245,158,11,.14); color: #fcd34d; border-color: rgba(245,158,11,.35); }
.badge.danger { background: rgba(239,68,68,.15); color: #fca5a5; border-color: rgba(239,68,68,.4); }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.report-body { white-space: pre-wrap; font-size: 14.5px; line-height: 1.65; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }

/* viewer canvas — shared with the hospital app */
.viewer-shell { background: #000; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.viewer-bar {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.viewer-bar .spacer { flex: 1; }
.viewer-bar .btn { padding: 5px 10px; font-size: 12.5px; }
.viewer-bar .btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.viewer-bar select {
  width: auto; padding: 5px 9px; font-size: 12.5px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; font-family: inherit;
}
.viewer-host { position: relative; height: min(60vh, 620px); min-height: 320px; }
.viewer-stage {
  position: absolute; inset: 0; overflow: hidden;
  display: grid; place-items: center; background: #000;
  touch-action: none; cursor: grab;
}
.viewer-stage:active { cursor: grabbing; }
.viewer-canvas, .viewer-overlay { position: absolute; image-rendering: -webkit-optimize-contrast; will-change: transform; }
.viewer-overlay { pointer-events: none; }
.viewer-message {
  position: absolute; z-index: 5; max-width: 74%;
  padding: 14px 18px; border-radius: 10px; text-align: center;
  background: rgba(17,26,46,.95); border: 1px solid var(--line);
  color: var(--muted); font-size: 13.5px; display: none; line-height: 1.55;
}
.viewer-message.visible { display: block; }
.viewer-message.error { border-color: rgba(239,68,68,.45); color: #fecaca; }
.viewer-corner {
  position: absolute; z-index: 4; font: 11.5px/1.45 var(--mono);
  color: rgba(226,235,255,.72); text-shadow: 0 1px 3px #000; pointer-events: none;
}
.viewer-corner.tl { top: 8px; left: 10px; }
.viewer-corner.tr { top: 8px; right: 10px; text-align: right; }
.viewer-corner.bl { bottom: 8px; left: 10px; }
.viewer-corner.br { bottom: 8px; right: 10px; text-align: right; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 9px 10px; background: var(--bg-2); border-top: 1px solid var(--line); }
.thumb {
  flex: 0 0 auto; width: 84px; border-radius: 7px; overflow: hidden;
  border: 2px solid transparent; background: var(--bg-3); cursor: pointer;
  padding: 0; color: inherit; font: inherit;
}
.thumb.active { border-color: var(--accent); }
.thumb .box { height: 60px; display: grid; place-items: center; background: #000; color: var(--dim); font-size: 10.5px; }
.thumb .box img, .thumb .box canvas { max-width: 100%; max-height: 100%; display: block; }
.thumb .cap { font-size: 10.5px; padding: 3px 5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
