:root{
  --bg: #0b1020;
  --panel: #0f172a;
  --panel2: #111c36;
  --border: rgba(255,255,255,.08);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #3b82f6;
  --primary2: #1d4ed8;
  --danger: #ef4444;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(900px 600px at 20% -10%, rgba(59,130,246,.25), transparent 55%),
              radial-gradient(900px 600px at 80% 0%, rgba(16,185,129,.12), transparent 60%),
              var(--bg);
  color:var(--text);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  background: rgba(15,23,42,.75);
  backdrop-filter: blur(10px);
  position: sticky;
  top:0;
  z-index:10;
}

.brand{ display:flex; gap:12px; align-items:center; }
.logo{
  width:36px; height:36px; border-radius:10px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(59,130,246,.9), rgba(16,185,129,.7));
  font-weight:800;
}
.title{ font-size:14px; font-weight:700; line-height:1.1; }
.subtitle{ font-size:12px; color:var(--muted); }

.top-actions{ display:flex; align-items:center; gap:10px; }
.pill{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  color:var(--muted);
  font-size:12px;
}

.layout{
  display:grid;
  grid-template-columns: 320px 1fr 520px;
  gap:12px;
  padding:12px;
  height: calc(100vh - 64px);
}

.panel{
  border:1px solid var(--border);
  border-radius:14px;
  background: rgba(15,23,42,.72);
  backdrop-filter: blur(8px);
  position:relative;
  overflow:hidden;
  min-height: 200px;
}

.panel-head{
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  background: rgba(17,28,54,.6);
}
.panel-title{ font-weight:700; font-size:13px; }
.panel-sub{ margin-top:4px; font-size:12px; color:var(--muted); }

.left{ padding-bottom:12px; }
.middle{ }
.right{ }

.mode-toggle{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:8px;
  padding:12px 12px 0 12px;
}
.seg{
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius:12px;
  padding:10px 10px;
  font-size:12px;
  cursor:pointer;
}
.seg.active{
  background: rgba(59,130,246,.18);
  border-color: rgba(59,130,246,.35);
}

.card{
  margin:12px;
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
  background: rgba(255,255,255,.03);
}
.card-title{
  font-weight:700;
  font-size:12px;
  margin-bottom:10px;
  color:#f3f4f6;
}

.form-row{ display:flex; flex-direction:column; gap:6px; margin-bottom:10px; }
.form-row label{ font-size:12px; color:var(--muted); }
input, select{
  border:1px solid var(--border);
  background: rgba(2,6,23,.35);
  color: var(--text);
  padding:10px 10px;
  border-radius:12px;
  outline:none;
}
input:focus, select:focus{
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 4px rgba(59,130,246,.15);
}

.form-actions{ display:flex; gap:8px; }
.btn{
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-size:12px;
}
.btn.primary{
  background: rgba(59,130,246,.22);
  border-color: rgba(59,130,246,.45);
}
.btn.primary:hover{ background: rgba(59,130,246,.28); }
.btn:hover{ background: rgba(255,255,255,.06); }

.hint{
  margin-top:8px;
  font-size:11px;
  color: var(--muted);
}
.hint code{
  color:#c7d2fe;
  background: rgba(99,102,241,.12);
  padding:2px 6px;
  border-radius:8px;
  border:1px solid rgba(99,102,241,.2);
}

.kv{
  display:flex;
  justify-content:space-between;
  padding:6px 0;
  font-size:12px;
}
.k{ color:var(--muted); }
.v{ color:var(--text); font-weight:600; }

.form-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap:8px;
}

.list{
  padding:12px;
  overflow:auto;
  height: calc(100% - 58px);
}
.patient-card{
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
  background: rgba(255,255,255,.03);
  cursor:pointer;
  margin-bottom:10px;
  transition: transform .08s ease, background .08s ease;
}
.patient-card:hover{ transform: translateY(-1px); background: rgba(255,255,255,.05); }
.patient-card.active{
  border-color: rgba(59,130,246,.6);
  box-shadow: 0 0 0 4px rgba(59,130,246,.12);
}

.pc-top{ display:flex; justify-content:space-between; align-items:center; gap:10px; }
.pc-pt{ font-weight:800; letter-spacing:.2px; }
.pc-meta{ font-size:12px; color:var(--muted); }

.pc-dx{ margin-top:8px; font-size:13px; font-weight:700; }
.pc-sub{ margin-top:6px; font-size:12px; color:var(--muted); line-height:1.35; }
.badges{ margin-top:10px; display:flex; gap:6px; flex-wrap:wrap; }
.badge{
  font-size:11px;
  padding:5px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--muted);
}
.badge.good{ border-color: rgba(16,185,129,.35); color: #bbf7d0; background: rgba(16,185,129,.08); }
.badge.warn{ border-color: rgba(245,158,11,.35); color: #fde68a; background: rgba(245,158,11,.08); }
.badge.bad{ border-color: rgba(239,68,68,.35); color: #fecaca; background: rgba(239,68,68,.08); }

.empty{
  position:absolute;
  inset: 58px 0 0 0;
  display:grid;
  place-items:center;
  text-align:center;
  padding:16px;
}
.empty-title{ font-weight:800; }
.empty-desc{ margin-top:6px; color:var(--muted); font-size:12px; }

.tabs{
  display:flex;
  gap:6px;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  background: rgba(17,28,54,.55);
  flex-wrap:wrap;
}
.tab{
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  padding:8px 10px;
  border-radius:12px;
  cursor:pointer;
  font-size:12px;
}
.tab.active{
  border-color: rgba(59,130,246,.55);
  background: rgba(59,130,246,.14);
}

.tab-body{
  position:relative;
  height: calc(100% - 110px);
  overflow:auto;
  padding:12px;
}

.tab-panel{ }
.hidden{ display:none !important; }

.ov-card{
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
  background: rgba(255,255,255,.03);
  margin-bottom:10px;
}
.ov-title{ font-weight:800; }
.ov-line{ margin-top:6px; color:var(--muted); font-size:12px; }
.ov-grid{
  margin-top:12px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
.ov-item{
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px;
  background: rgba(255,255,255,.02);
}
.ov-item .k{ font-size:11px; }
.ov-item .v{ margin-top:6px; font-size:13px; }

.ov-list{
  margin-top:10px;
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
}
.ov-row{
  padding:10px 12px;
  border-top:1px solid var(--border);
}
.ov-row:first-child{ border-top:0; }
.ov-row .t{ font-weight:700; font-size:12px; }
.ov-row .s{ margin-top:4px; color:var(--muted); font-size:12px; }

.raw-head{ display:flex; gap:10px; align-items:center; margin-bottom:10px; }
.raw-meta{ color:var(--muted); font-size:12px; }
.json{
  border:1px solid var(--border);
  border-radius:14px;
  background: rgba(2,6,23,.35);
  padding:12px;
  overflow:auto;
  max-height: calc(100vh - 260px);
  font-size:11px;
  color:#d1d5db;
  line-height:1.45;
}

.overlay{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  background: rgba(2,6,23,.55);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.overlay-text{ margin-top:10px; color:var(--muted); font-size:12px; }
.spinner{
  width:30px; height:30px;
  border-radius:999px;
  border:3px solid rgba(255,255,255,.15);
  border-top-color: rgba(59,130,246,.9);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1200px){
  .layout{ grid-template-columns: 320px 1fr; grid-template-rows: auto auto; height:auto; }
  .right{ grid-column: 1 / -1; height: 560px; }
  .middle{ height: 560px; }
}
