/* ==========================================================================
   MedTwin AI · global stylesheet (mobile-first, responsive)
   - All breakpoints scale up from 360px
   - Uses CSS variables, fluid clamp() typography, safe-area insets
   - Designed to feel premium on phone, tablet and desktop
   ========================================================================== */

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --primary: #0e6c7a;
  --primary-strong: #08525c;
  --accent: #1b6fa8;
  --warn: #c2410c;
  --danger: #b91c1c;
  --ok: #15803d;
  --text: #122036;
  --text-soft: #5b6c84;
  --line: #d8e1ec;
  --line-strong: #b9c6d6;
  --shadow: 0 12px 32px -16px rgba(13, 42, 79, .25);
  --shadow-lg: 0 24px 56px -28px rgba(13, 42, 79, .35);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  /* Fluid type scale */
  --fs-xs:  clamp(11px, 0.6vw + 10px, 12.5px);
  --fs-sm:  clamp(12.5px, 0.6vw + 11px, 14px);
  --fs-md:  clamp(14px, 0.5vw + 12.5px, 15.5px);
  --fs-lg:  clamp(15.5px, 0.5vw + 14px, 17px);
  --fs-xl:  clamp(18px, 0.8vw + 16px, 21px);
  --fs-2xl: clamp(22px, 1vw + 19px, 26px);
  --fs-3xl: clamp(26px, 2vw + 20px, 38px);

  --header-h: 60px;
  --max-w: 1180px;

  /* Mobile-first chat input bar height (used as bottom padding) */
  --chat-input-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Ensure HTML `hidden` always hides regardless of element-level display rules
   (e.g. `.login-wrap { display: grid }` would otherwise win on specificity). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100dvh; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button { font: inherit; color: inherit; }

/* ----------------------------------------------------------- top bar ------ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  min-height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-logo {
  flex: none;
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: white; font-weight: 800;
  box-shadow: 0 4px 14px -6px rgba(14, 108, 122, .55);
}
.brand-name {
  font-weight: 700; letter-spacing: .25px; color: var(--primary-strong);
  font-size: var(--fs-lg); line-height: 1.2; min-width: 0;
}
.brand-name small {
  display: block; font-weight: 500; color: var(--text-soft);
  font-size: var(--fs-xs); letter-spacing: 1.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-links { display: flex; gap: 4px; flex: none; }
.nav-links a {
  padding: 8px 12px; border-radius: 999px; color: var(--text-soft);
  font-size: var(--fs-sm); transition: background .15s;
}
.nav-links a:hover { background: var(--surface-2); color: var(--primary); text-decoration: none; }

/* Language picker in topbar */
.lang-host { display: flex; align-items: center; gap: 6px; }
.lang-host::before {
  content: "🌐";
  font-size: 14px;
  opacity: .8;
}
.lang-picker {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: var(--fs-xs);
  color: var(--text-soft);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-soft) 50%), linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 26px;
}
.lang-picker:hover { color: var(--primary); }

/* RTL support */
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .nav-links a { margin-left: 0; margin-right: 22px; }
html[dir="rtl"] .lang-picker {
  background-position: 9px 50%, 13px 50%;
  padding-right: 10px;
  padding-left: 26px;
}
html[dir="rtl"] .msg.user { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
html[dir="rtl"] .msg.ai { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
html[dir="rtl"] .materials-table tr.is-child .filename::before { content: "↲"; margin-left: 6px; margin-right: 0; }

/* ----------------------------------------------------------- hero --------- */
.hero {
  padding: 40px 16px 16px;
  max-width: var(--max-w); margin: 0 auto;
}
.hero h1 {
  margin: 0 0 12px; font-size: var(--fs-3xl); line-height: 1.2;
  letter-spacing: -.5px; color: var(--primary-strong);
}
.hero p {
  margin: 0; font-size: var(--fs-lg); color: var(--text-soft); max-width: 720px;
}
.hero .badges {
  margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap;
}
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: var(--fs-sm); color: var(--text-soft);
}
.badge.dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary);
}

/* ----------------------------------------------------------- banner ------- */
.banner {
  max-width: var(--max-w); margin: 18px auto; padding: 12px 16px;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 12px;
  color: #9a3412; font-size: var(--fs-sm); line-height: 1.6;
}
.banner strong { color: var(--warn); }

/* ----------------------------------------------------------- doctor grid ------- */
.grid {
  max-width: var(--max-w); margin: 16px auto 56px; padding: 0 16px;
  display: grid; gap: 16px;
  grid-template-columns: 1fr;            /* mobile: stack */
}
@media (min-width: 640px)  { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px)  { .grid { grid-template-columns: repeat(3, 1fr); gap: 22px; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .25s ease, box-shadow .25s ease;
}
@media (hover: hover) {
  .card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
}

.card .photo {
  position: relative;
  aspect-ratio: 4 / 5;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(27, 111, 168, .18), transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(14, 108, 122, .15), transparent 60%),
    linear-gradient(180deg, #d6e3f0, #e9eff7);
  overflow: hidden;
}
.card .photo img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 18%;
  display: block;
}
.card .photo::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 50%;
  background: linear-gradient(180deg, rgba(8, 26, 49, 0), rgba(8, 26, 49, .68));
  pointer-events: none;
}
.card .photo .overlay {
  position: absolute; left: 16px; right: 16px; bottom: 14px; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.card .photo .overlay h3 { margin: 0 0 4px; font-size: var(--fs-2xl); letter-spacing: .5px; }
.card .photo .overlay .role { font-size: var(--fs-sm); opacity: .95; }
.card .photo .ai-pill {
  position: absolute; top: 12px; right: 12px;
  background: rgba(255,255,255,.9); color: var(--accent);
  padding: 4px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  letter-spacing: .5px;
}

.card .body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.card .subtitle { color: var(--accent); font-weight: 600; font-size: var(--fs-sm); letter-spacing: .25px; }
.card ul { margin: 4px 0 0; padding: 0 0 0 18px; color: var(--text-soft); font-size: var(--fs-sm); }
.card ul li { margin: 4px 0; }

.card .actions { margin-top: auto; display: flex; gap: 8px; padding-top: 12px; }

/* ----------------------------------------------------------- buttons ----- */
.btn {
  flex: 1; padding: 12px 14px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: var(--fs-md); cursor: pointer;
  transition: transform .1s ease, background .15s ease, color .15s ease;
  -webkit-appearance: none;
  min-height: 44px;          /* iOS min touch target */
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-strong); }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 8px 12px; font-size: var(--fs-sm); flex: none; min-height: 36px; }

/* ----------------------------------------------------------- chat layout - */
.chat-wrap {
  max-width: var(--max-w); margin: 0 auto; padding: 0;
  display: flex; flex-direction: column;
  min-height: calc(100dvh - var(--header-h));
}
@media (min-width: 880px) {
  .chat-wrap {
    display: grid; grid-template-columns: 320px 1fr; gap: 22px;
    padding: 22px; align-items: start;
  }
}

/* doctor panel: drawer on mobile, sidebar on desktop */
.doctor-panel {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}
.doctor-panel-header {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.doctor-panel .avatar-mini {
  flex: none; width: 44px; height: 44px; border-radius: 12px; overflow: hidden;
  background: var(--surface-2);
}
.doctor-panel .avatar-mini img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 18%;
}
.doctor-panel .name-row { flex: 1; min-width: 0; }
.doctor-panel .name-row h2 {
  margin: 0; font-size: var(--fs-md); color: var(--primary-strong); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doctor-panel .name-row .role {
  color: var(--text-soft); font-size: var(--fs-xs);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doctor-panel .toggle {
  background: var(--surface-2); border: none; border-radius: 8px;
  padding: 6px 10px; font-size: var(--fs-xs); color: var(--text-soft);
  cursor: pointer;
}
.doctor-panel .full {
  display: none; padding-top: 12px; border-top: 1px solid var(--line); margin-top: 12px;
}
.doctor-panel.open .full { display: block; }
.doctor-panel .full .photo {
  width: 100%; aspect-ratio: 4 / 5; border-radius: 14px; overflow: hidden;
  background: var(--surface-2); margin-bottom: 12px;
}
.doctor-panel .full .photo img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 18%;
}
.doctor-panel .section { margin-top: 14px; }
.doctor-panel .section h4 {
  margin: 0 0 6px; font-size: var(--fs-xs); letter-spacing: 2px; color: var(--text-soft);
  text-transform: uppercase;
}
.doctor-panel .section ul { margin: 0; padding-left: 18px; color: var(--text); font-size: var(--fs-sm); }
.doctor-panel .section ul.forbidden { color: #b54708; }

@media (min-width: 880px) {
  .doctor-panel {
    border-bottom: none; border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 18px; box-shadow: var(--shadow); position: sticky; top: calc(var(--header-h) + 22px);
  }
  .doctor-panel .full { display: block !important; padding-top: 0; border-top: none; margin-top: 16px; }
  .doctor-panel .toggle { display: none; }
  .doctor-panel .name-row h2 { font-size: var(--fs-xl); }
  .doctor-panel .name-row .role { font-size: var(--fs-sm); }
  .doctor-panel .avatar-mini { width: 56px; height: 56px; }
}

/* chat main */
.chat-main {
  background: var(--surface);
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
  overflow: hidden;
  position: relative;
}
@media (min-width: 880px) {
  .chat-main {
    border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
    min-height: calc(100dvh - var(--header-h) - 44px);
  }
}

.chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
  font-size: var(--fs-sm); color: var(--text-soft);
}
.chat-header .ai-pill {
  background: var(--surface-2); color: var(--accent);
  padding: 4px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700;
}

/* ===== Triage strip (above chat stream) ===== */
.triage-strip {
  padding: 8px 14px; font-size: var(--fs-sm); font-weight: 600;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.triage-strip .num {
  background: rgba(255,255,255,.4); padding: 2px 10px; border-radius: 999px;
  font-weight: 800; font-size: var(--fs-xs);
}
.triage-strip.t-ok      { background: #ecfdf5; color: #15803d; }
.triage-strip.t-info    { background: #eff6ff; color: #1d4ed8; }
.triage-strip.t-warn    { background: #fef3c7; color: #92400e; }
.triage-strip.t-danger  { background: #fee2e2; color: #991b1b; }

/* ===== Verifier amendment toast ===== */
.verifier-flag {
  align-self: center; max-width: 92%;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  padding: 8px 14px; border-radius: 999px;
  font-size: var(--fs-xs);
}

/* ===== Profile / intake summary card ===== */
.context-card {
  margin: 8px 0; padding: 12px 14px;
  background: linear-gradient(135deg, #f0f9ff, var(--surface));
  border: 1px solid #bae6fd;
  border-radius: 14px;
  font-size: var(--fs-sm);
}
.context-card h5 {
  margin: 0 0 6px; font-size: var(--fs-xs); letter-spacing: 2px;
  color: var(--accent); text-transform: uppercase;
}
.context-card ul { margin: 4px 0 0; padding-left: 20px; color: var(--text-soft); }

.chat-stream {
  flex: 1; padding: 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, var(--surface), #f7faff);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
@media (min-width: 880px) { .chat-stream { padding: 22px; gap: 14px; } }

.msg {
  max-width: 88%;
  padding: 10px 14px; border-radius: 14px;
  font-size: var(--fs-md); line-height: 1.65;
  word-wrap: break-word; overflow-wrap: anywhere;
}
@media (min-width: 880px) { .msg { max-width: 78%; } }

.msg.user {
  align-self: flex-end; background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px; white-space: pre-wrap;
}
.msg.ai {
  align-self: flex-start; background: var(--surface);
  border: 1px solid var(--line); border-bottom-left-radius: 4px;
}
.msg.ai p { margin: 0 0 8px; }
.msg.ai p:last-child { margin-bottom: 0; }
.msg.ai ul, .msg.ai ol { margin: 6px 0; padding-left: 22px; }
.msg.ai li { margin: 3px 0; }
.msg.ai strong { color: var(--primary-strong); }
.msg.ai code {
  background: var(--surface-2); padding: 1px 6px; border-radius: 4px;
  font-size: .92em; font-family: "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
.msg.ai table {
  border-collapse: collapse; margin: 8px 0; font-size: .92em;
  width: 100%; max-width: 100%; display: block; overflow-x: auto;
}
.msg.ai th, .msg.ai td { padding: 6px 10px; border: 1px solid var(--line); text-align: left; }
.msg.ai th { background: var(--surface-2); font-weight: 600; color: var(--primary-strong); }

.msg.system {
  align-self: center; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  font-size: var(--fs-sm); padding: 8px 14px; border-radius: 999px; max-width: 92%;
  text-align: center;
}
.msg.risk {
  align-self: center; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  font-size: var(--fs-sm); padding: 8px 14px; border-radius: 999px; max-width: 92%;
  text-align: center;
}

.chat-input {
  border-top: 1px solid var(--line); padding: 10px 12px; background: var(--surface);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  display: flex; gap: 8px; align-items: flex-end;
}
.chat-input textarea {
  flex: 1; border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 14px; resize: none; min-height: 44px; max-height: 160px;
  font: inherit; color: inherit; background: var(--surface-2);
  -webkit-appearance: none;
}
.chat-input textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
  background: white;
}
.chat-input .btn { flex: none; padding: 0 16px; min-width: 64px; }

.dot-typing { display: inline-flex; gap: 4px; vertical-align: middle; }
.dot-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-soft); opacity: .35;
  animation: dot 1.2s infinite ease-in-out;
}
.dot-typing span:nth-child(2) { animation-delay: .2s; }
.dot-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .3 } 40% { opacity: 1 } }

/* doctor picker (when no doctor chosen) */
.doctor-picker {
  display: grid; gap: 10px;
  grid-template-columns: 1fr;
  margin: 8px auto; max-width: 520px;
  align-self: stretch;
}
@media (min-width: 480px) { .doctor-picker { grid-template-columns: 1fr 1fr; } }
.doctor-picker button {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; text-align: left;
  transition: transform .1s, border-color .15s, box-shadow .15s;
}
.doctor-picker button:active { transform: scale(.98); }
.doctor-picker button:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.doctor-picker img {
  width: 54px; height: 54px; border-radius: 12px; object-fit: cover; object-position: center 18%;
}
.doctor-picker .name { font-weight: 700; color: var(--primary-strong); font-size: var(--fs-md); }
.doctor-picker .sub { font-size: var(--fs-xs); color: var(--text-soft); margin-top: 2px; }

/* ----------------------------------------------------------- admin ------- */
.admin-wrap {
  max-width: var(--max-w); margin: 0 auto; padding: 18px 16px 60px;
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
@media (min-width: 880px) { .admin-wrap { padding: 24px; gap: 22px; } }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow);
}
@media (min-width: 880px) { .panel { padding: 22px; } }
.panel h2 { margin: 0 0 6px; font-size: var(--fs-xl); color: var(--primary-strong); }
.panel p.hint { margin: 0 0 16px; color: var(--text-soft); font-size: var(--fs-sm); }

.form-row {
  display: grid; grid-template-columns: 1fr; gap: 6px; align-items: start; margin-bottom: 12px;
}
.form-row label { color: var(--text-soft); font-size: var(--fs-sm); }
.form-row input, .form-row select, .form-row textarea {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: var(--surface-2);
  width: 100%; -webkit-appearance: none;
}
.form-row textarea { min-height: 90px; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 25%, transparent); background: white;
}
@media (min-width: 720px) {
  .form-row { grid-template-columns: 180px 1fr; gap: 12px; align-items: center; }
}

.actions-row { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.kpi { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) { .kpi { grid-template-columns: repeat(4, 1fr); } }
.kpi .card-mini {
  background: var(--surface-2); border-radius: 12px; padding: 12px 14px;
  border: 1px solid var(--line);
}
.kpi .card-mini .v { font-size: var(--fs-2xl); font-weight: 700; color: var(--primary-strong); line-height: 1.2; }
.kpi .card-mini .k { font-size: var(--fs-xs); color: var(--text-soft); letter-spacing: 1.5px; text-transform: uppercase; margin-top: 2px; }

/* responsive table → cards on small screens */
table.list { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.list th, table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { color: var(--text-soft); font-weight: 600; font-size: var(--fs-xs); letter-spacing: 1px; text-transform: uppercase; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; }
.tag.low { background: #ecfdf5; color: var(--ok); }
.tag.medium { background: #fef3c7; color: #92400e; }
.tag.high { background: #fee2e2; color: var(--danger); }

@media (max-width: 720px) {
  /* Stack cells under the header label on phones */
  table.list, table.list thead, table.list tbody, table.list tr, table.list th, table.list td { display: block; }
  table.list thead { display: none; }
  table.list tr {
    border: 1px solid var(--line); border-radius: 12px;
    margin-bottom: 10px; padding: 10px 12px; background: var(--surface);
  }
  table.list td {
    padding: 4px 0; border-bottom: none; display: grid;
    grid-template-columns: 90px 1fr; gap: 10px; align-items: baseline;
  }
  table.list td::before {
    content: attr(data-label); color: var(--text-soft);
    font-size: var(--fs-xs); letter-spacing: 1px; text-transform: uppercase;
  }
}

.token-bar {
  position: sticky; top: var(--header-h); z-index: 20;
  background: var(--surface); padding: 10px 16px; border-bottom: 1px solid var(--line);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.token-bar strong { font-size: var(--fs-sm); }
.token-bar input { flex: 1; min-width: 160px; max-width: 360px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.token-bar .status { font-size: var(--fs-sm); color: var(--text-soft); }
.token-bar .status.ok { color: var(--ok); }
.token-bar .status.bad { color: var(--danger); }

.persona-card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  margin-bottom: 12px; background: var(--surface-2);
}
.persona-card .head {
  display: flex; gap: 12px; align-items: center; margin-bottom: 10px;
}
.persona-card .head img {
  width: 56px; height: 56px; border-radius: 12px; object-fit: cover; object-position: center 18%;
}
.persona-card .head h3 {
  margin: 0; color: var(--primary-strong); font-size: var(--fs-lg);
}
.persona-card .head .meta { color: var(--text-soft); font-size: var(--fs-xs); }

footer.global {
  text-align: center; color: var(--text-soft); font-size: var(--fs-xs);
  padding: 24px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}

/* small a11y helper */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================================================================
   Login screen + Materials manager
   ========================================================================== */

.login-wrap {
  min-height: calc(100dvh - var(--header-h));
  display: grid; place-items: center;
  padding: 32px 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
}
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 28px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 380px;
}
.login-card h1 {
  margin: 0 0 6px; font-size: var(--fs-2xl); color: var(--primary-strong); letter-spacing: -.25px;
}
.login-card .sub {
  margin: 0 0 22px; color: var(--text-soft); font-size: var(--fs-sm);
}
.login-card label { display: block; margin: 0 0 6px; color: var(--text-soft); font-size: var(--fs-sm); }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: var(--surface-2); margin-bottom: 14px;
  -webkit-appearance: none;
}
.login-card input:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 25%, transparent); background: white;
}
.login-card .btn { width: 100%; }
.login-error {
  margin: 8px 0 14px; padding: 10px 12px;
  background: #fef2f2; border: 1px solid #fecaca; color: var(--danger);
  border-radius: 10px; font-size: var(--fs-sm); display: none;
}
.login-error.show { display: block; }

.session-bar {
  position: sticky; top: var(--header-h); z-index: 20;
  background: var(--surface); padding: 10px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.session-bar .who { font-size: var(--fs-sm); color: var(--text-soft); }
.session-bar .who strong { color: var(--primary-strong); }

.material-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px; border: 1px dashed var(--line-strong); border-radius: 14px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  margin-bottom: 12px;
}
.material-toolbar.dragover {
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  border-color: var(--primary);
}
.material-toolbar .hint {
  flex: 1 1 240px; font-size: var(--fs-sm); color: var(--text-soft);
}

.materials-table {
  width: 100%; border-collapse: collapse; font-size: var(--fs-sm);
}
.materials-table th, .materials-table td {
  padding: 9px 8px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top;
}
.materials-table th {
  color: var(--text-soft); font-weight: 600; font-size: var(--fs-xs);
  letter-spacing: 1px; text-transform: uppercase;
}
.materials-table .filename {
  font-weight: 600; color: var(--primary-strong); word-break: break-all;
}
.materials-table .meta { color: var(--text-soft); font-size: var(--fs-xs); margin-top: 2px; }
.materials-table .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.materials-table .actions .btn { flex: none; }

.kind-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs);
  font-weight: 700; background: var(--surface-2); color: var(--text-soft);
}
.kind-pill.image { background: #ecfeff; color: #0e7490; }
.kind-pill.pdf   { background: #fef2f2; color: #b91c1c; }
.kind-pill.doc   { background: #eef2ff; color: #4338ca; }
.kind-pill.archive { background: #fef9c3; color: #854d0e; }
.kind-pill.text  { background: #f0fdf4; color: #15803d; }
.kind-pill.audio { background: #fdf4ff; color: #a21caf; }
.kind-pill.video { background: #ecfdf5; color: #0f766e; }

.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 700;
}
.status-pill.pending   { background: #fef3c7; color: #92400e; }
.status-pill.learning  { background: #dbeafe; color: #1d4ed8; }
.status-pill.learned   { background: #ecfdf5; color: var(--ok); }
.status-pill.failed    { background: #fee2e2; color: var(--danger); }
.status-pill.stored    { background: var(--surface-2); color: var(--text-soft); }
.status-pill.extracted { background: #ede9fe; color: #5b21b6; }
.status-pill.active    { background: #ecfdf5; color: var(--ok); }
.status-pill.disabled  { background: #f1f5f9; color: var(--text-soft); }

/* Greyed-out doctor card when disabled */
.doctor-mini.is-disabled {
  opacity: .68;
  background: repeating-linear-gradient(
    -45deg, transparent 0 12px, rgba(148, 163, 184, .08) 12px 24px
  ), var(--surface);
}
.doctor-mini.is-disabled img { filter: grayscale(0.7); }

.materials-table tr.is-child td.filename-cell { padding-left: 22px; }
.materials-table tr.is-child .filename::before {
  content: "↳"; color: var(--text-soft); margin-right: 6px;
}
.materials-table tr.is-child {
  background: linear-gradient(90deg, rgba(91,33,182,.03), transparent 80%);
}
.zip-summary {
  margin-top: 4px; font-size: var(--fs-xs); color: var(--primary);
  background: #ede9fe; display: inline-block;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid #ddd6fe;
}

/* ===== Per-file upload progress queue ===== */

.upload-progress {
  margin: 4px 0 14px;
  display: grid; gap: 6px;
}
.upload-row {
  display: grid;
  grid-template-columns: 1fr 70px 130px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: var(--fs-sm);
}
@media (max-width: 720px) {
  .upload-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name size"
      "bar bar"
      "pct pct";
    row-gap: 4px;
  }
  .upload-row .name { grid-area: name; }
  .upload-row .size { grid-area: size; }
  .upload-row .bar { grid-area: bar; }
  .upload-row .pct { grid-area: pct; }
}
.upload-row .name {
  font-weight: 600; color: var(--primary-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upload-row .size {
  color: var(--text-soft); font-size: var(--fs-xs);
}
.upload-row .bar {
  height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden;
}
.upload-row .bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .15s ease;
}
.upload-row .pct {
  color: var(--text-soft); font-size: var(--fs-xs);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.upload-row.pending   .pct { color: var(--text-soft); }
.upload-row.uploading .pct { color: var(--accent); }
.upload-row.success   { border-color: #bbf7d0; background: #f0fdf4; }
.upload-row.success   .pct { color: var(--ok); }
.upload-row.success   .bar-fill { background: var(--ok); }
.upload-row.fail      { border-color: #fecaca; background: #fef2f2; }
.upload-row.fail      .pct { color: var(--danger); }
.upload-row.fail      .bar-fill { background: var(--danger); width: 100% !important; }

/* ===========================================================================
   Tabbed admin shell
   =========================================================================== */
.tab-nav {
  position: sticky; top: calc(var(--header-h) + 44px); z-index: 10;
  display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.tab-nav .tab {
  flex: none;
  padding: 9px 18px; border-radius: 10px;
  background: transparent; border: 1px solid transparent;
  font-size: var(--fs-sm); color: var(--text-soft); cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.tab-nav .tab:hover { color: var(--primary); background: var(--surface-2); }
.tab-nav .tab.active {
  color: var(--primary-strong); background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 22%, transparent);
  font-weight: 700;
}
.tab-pane { display: block; }
.tab-pane[hidden] { display: none; }

/* ===========================================================================
   Hospitals & Departments two-column tree
   =========================================================================== */
.org-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 880px) { .org-grid { grid-template-columns: 1fr 1.4fr; } }
.org-col {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.org-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.org-head h3 { margin: 0; font-size: var(--fs-lg); color: var(--primary-strong); }
.org-list { display: grid; gap: 8px; }
.org-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.org-item:hover { border-color: var(--primary); }
.org-item.selected {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border-color: var(--primary);
}
.org-item .info .name { font-weight: 600; color: var(--primary-strong); }
.org-item .info .meta { font-size: var(--fs-xs); color: var(--text-soft); margin-top: 2px; }
.org-item .ops { display: flex; gap: 4px; }
.org-item .ops button {
  background: none; border: none; cursor: pointer; padding: 4px 8px;
  font-size: var(--fs-xs); color: var(--text-soft); border-radius: 6px;
}
.org-item .ops button:hover { background: var(--surface-2); color: var(--primary); }
.org-item .ops .danger:hover { color: var(--danger); }

/* ===========================================================================
   Doctors list (compact cards)
   =========================================================================== */
.doctors-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) { .doctors-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .doctors-grid { grid-template-columns: repeat(3, 1fr); } }
.doctor-mini {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: grid; grid-template-columns: 60px 1fr; gap: 12px;
  align-items: start; cursor: pointer; transition: box-shadow .15s, transform .15s;
}
.doctor-mini:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.doctor-mini img {
  width: 60px; height: 60px; border-radius: 12px; object-fit: cover; object-position: center 18%;
  background: var(--surface-2);
}
.doctor-mini .body { min-width: 0; }
.doctor-mini h4 {
  margin: 0; font-size: var(--fs-md); color: var(--primary-strong); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doctor-mini .org {
  font-size: var(--fs-xs); color: var(--accent); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doctor-mini .role {
  font-size: var(--fs-xs); color: var(--text-soft); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doctor-mini .mat-line {
  margin-top: 6px; font-size: var(--fs-xs); color: var(--text-soft);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.doctor-mini .mat-line .pill {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2);
}
.doctor-mini .mat-line .pill.learned { background: #ecfdf5; color: var(--ok); }
.doctor-mini .mat-line .pill.pending { background: #fef3c7; color: #92400e; }
.doctor-mini .mat-line .pill.failed  { background: #fee2e2; color: var(--danger); }

/* ===========================================================================
   Doctor editor (full-screen overlay panel)
   =========================================================================== */
.doctor-editor {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg); overflow-y: auto;
  padding: 0 0 80px;
}
.doctor-editor .editor-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
}
.doctor-editor .editor-head .title { flex: 1; min-width: 0; font-weight: 700; color: var(--primary-strong); }
.doctor-editor .editor-body { max-width: 1080px; margin: 16px auto; padding: 0 16px; display: grid; gap: 16px; }

.editor-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 880px) { .editor-grid { grid-template-columns: 220px 1fr; } }
.editor-avatar {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.editor-avatar img {
  width: 160px; height: 160px; border-radius: 16px; object-fit: cover; object-position: center 18%;
  background: var(--surface-2);
}

/* ===========================================================================
   Materials library
   =========================================================================== */
.library-filter {
  display: grid; gap: 8px; grid-template-columns: 1fr; margin-bottom: 8px;
}
@media (min-width: 720px) {
  .library-filter {
    grid-template-columns: repeat(4, 1fr) 1.5fr auto auto;
    align-items: center;
  }
}
.library-filter select, .library-filter input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font: inherit;
}
.library-filter input:focus, .library-filter select:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
}

.library-bulkbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: 10px; margin-bottom: 10px;
}

.library-table {
  width: 100%; border-collapse: collapse; font-size: var(--fs-sm);
}
.library-table th, .library-table td {
  padding: 9px 10px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top;
}
.library-table th {
  color: var(--text-soft); font-weight: 600; font-size: var(--fs-xs);
  letter-spacing: 1px; text-transform: uppercase;
}
.library-table .doc-cell { color: var(--accent); font-size: var(--fs-xs); margin-top: 2px; }
.library-table tr.is-child .filename::before { content: "↳"; color: var(--text-soft); margin-right: 6px; }

@media (max-width: 720px) {
  .library-table, .library-table thead, .library-table tbody,
  .library-table tr, .library-table th, .library-table td { display: block; }
  .library-table thead { display: none; }
  .library-table tr {
    border: 1px solid var(--line); border-radius: 12px;
    padding: 12px; margin-bottom: 10px; background: var(--surface);
  }
  .library-table td { padding: 4px 0; border-bottom: none; }
}

.library-pager {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 12px 0; font-size: var(--fs-sm); color: var(--text-soft);
}
.library-pager button {
  padding: 6px 12px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; cursor: pointer; font: inherit;
}
.library-pager button:disabled { opacity: .5; cursor: not-allowed; }
.library-pager button.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===========================================================================
   Anonymize toggle
   =========================================================================== */
.anon-panel {
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 6%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--line));
}
.toggle {
  display: inline-flex; align-items: center; cursor: pointer;
  user-select: none;
}
.toggle input { display: none; }
.toggle .slider {
  width: 52px; height: 28px; background: var(--line-strong); border-radius: 999px;
  position: relative; transition: background .2s;
}
.toggle .slider::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: white;
  transition: transform .2s; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::after { transform: translateX(24px); }

/* ===========================================================================
   Avatar slot picker (in doctor editor)
   =========================================================================== */
.avatar-slots {
  display: grid; gap: 12px;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 720px) { .avatar-slots { grid-template-columns: 1fr; } }
.avatar-slot {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative;
  cursor: pointer; transition: border-color .15s;
}
.avatar-slot:hover { border-color: var(--primary); }
.avatar-slot.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
}
.avatar-slot img {
  width: 100%; max-width: 140px; aspect-ratio: 1 / 1;
  border-radius: 12px; object-fit: cover; object-position: center 18%;
  background: var(--surface-2);
}
.avatar-slot .label { font-weight: 700; color: var(--primary-strong); font-size: var(--fs-sm); }
.avatar-slot .desc { font-size: var(--fs-xs); color: var(--text-soft); text-align: center; }
.avatar-slot .active-badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--primary); color: white;
  padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700;
}

/* ===========================================================================
   Modal
   =========================================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8, 26, 49, .45);
  display: grid; place-items: center;
  padding: 16px;
}
.modal-card {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-width: 520px; width: 100%; max-height: 90dvh;
  display: flex; flex-direction: column;
}
.modal-card header {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.modal-card header h3 { margin: 0; flex: 1; color: var(--primary-strong); font-size: var(--fs-lg); }
.modal-close {
  background: none; border: none; font-size: 24px; line-height: 1;
  cursor: pointer; color: var(--text-soft); padding: 2px 8px;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-actions {
  padding: 12px 18px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end;
}

@media (max-width: 720px) {
  .materials-table, .materials-table thead, .materials-table tbody,
  .materials-table tr, .materials-table th, .materials-table td { display: block; }
  .materials-table thead { display: none; }
  .materials-table tr {
    border: 1px solid var(--line); border-radius: 12px;
    padding: 12px; margin-bottom: 10px; background: var(--surface);
  }
  .materials-table td { padding: 4px 0; border-bottom: none; }
  .materials-table td.actions-row { padding-top: 10px; }
}

.summary-box {
  background: #f8fafc; border-left: 3px solid var(--primary); padding: 10px 14px;
  margin: 8px 0 0; border-radius: 0 8px 8px 0; white-space: pre-wrap;
  font-size: var(--fs-sm); line-height: 1.65; color: var(--text);
}
.summary-box.error {
  background: #fef2f2; border-left-color: var(--danger); color: var(--danger);
}

.persona-card .editor-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.persona-card .editor-grid .form-row { margin-bottom: 0; }
.persona-card .learned-list {
  margin-top: 12px; padding: 10px 12px; background: #ffffffaa;
  border: 1px dashed var(--line-strong); border-radius: 10px;
}
.persona-card .learned-list h5 {
  margin: 0 0 6px; font-size: var(--fs-xs); letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-soft);
}
.persona-card .learned-list ul { margin: 0; padding-left: 18px; font-size: var(--fs-sm); }
.persona-card .learned-list li { margin: 4px 0; }
.persona-card .learned-list .remove {
  border: none; background: none; color: var(--danger); cursor: pointer;
  font-size: var(--fs-xs); padding: 0 0 0 8px;
}
.persona-card .learned-list .remove:hover { text-decoration: underline; }


/* ===== v2 — VHI-10 badge / citation chips / SOAP card / inbox =========== */

.vhi-badge-host {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 0 0 10px; border-radius: 10px;
  background: #ecfeff; border: 1px solid #cffafe; color: #155e75;
  font-size: var(--fs-sm);
}
.vhi-badge-host.g-mild     { background: #fef9c3; border-color: #fde68a; color: #854d0e; }
.vhi-badge-host.g-moderate { background: #ffedd5; border-color: #fed7aa; color: #9a3412; }
.vhi-badge-host.g-severe   { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.vhi-badge-host .vhi-num { font-weight: 700; letter-spacing: 1px; font-size: var(--fs-xs); }
.vhi-badge-host .vhi-grade { padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.6); font-weight: 600; }

.vhi10-form .vhi10-row { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.vhi10-form .vhi10-row:last-child { border-bottom: 0; }
.vhi10-form .vhi10-q { font-weight: 600; margin-bottom: 8px; }
.vhi10-form .vhi10-n { color: var(--primary-strong); margin-right: 4px; }
.vhi10-form .vhi10-options { display: flex; gap: 6px; flex-wrap: wrap; }
.vhi10-form .vhi10-options label {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  font-size: var(--fs-sm);
}
.vhi10-form .vhi10-options input { margin: 0; }

sup.cite-ref {
  display: inline-block; min-width: 18px; height: 16px; line-height: 16px;
  text-align: center; padding: 0 4px; margin: 0 1px;
  background: var(--primary); color: white; border-radius: 999px;
  font-size: 10px; cursor: pointer; vertical-align: super; user-select: none;
}
sup.cite-ref:hover { background: var(--primary-strong); }

.cite-chips {
  margin-top: 10px; padding: 8px 10px; background: #f8fafc;
  border: 1px solid var(--line); border-radius: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.cite-chips-head { font-size: var(--fs-xs); color: var(--text-soft); letter-spacing: 1px; text-transform: uppercase; }
.cite-chip { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; background: white; }
.cite-chip summary { cursor: pointer; font-size: var(--fs-sm); }
.cite-chip .cite-n { color: var(--primary); font-weight: 700; margin-right: 4px; }
.cite-chip .cite-snippet { margin-top: 6px; color: var(--text-soft); font-size: var(--fs-sm); white-space: pre-wrap; }

.soap-card {
  margin: 12px 0; padding: 14px 16px; background: linear-gradient(180deg,#f0f9ff,#ffffff);
  border: 1px solid #bae6fd; border-radius: 12px;
}
.soap-card h5 { margin: 0 0 10px; color: #0c4a6e; }
.soap-card .soap-plain { margin: 4px 0 10px; color: #0369a1; font-weight: 500; }
.soap-card .soap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 720px) { .soap-card .soap-grid { grid-template-columns: 1fr; } }
.soap-card .soap-block { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.soap-card .soap-block h6 { margin: 0 0 4px; color: var(--primary-strong); font-size: var(--fs-xs); letter-spacing: 1px; text-transform: uppercase; }
.soap-card .soap-block ul { margin: 0; padding-left: 18px; font-size: var(--fs-sm); }
.soap-card .soap-foot { display: flex; align-items: center; margin-top: 10px; gap: 8px; flex-wrap: wrap; }
.soap-card .conf { padding: 2px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; }
.soap-card .conf-low { background: #fee2e2; color: #991b1b; }
.soap-card .conf-medium { background: #fef9c3; color: #854d0e; }
.soap-card .conf-high { background: #dcfce7; color: #14532d; }

/* Doctor inbox styles */
.inbox-row {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 10px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; margin: 8px 0; background: white;
}
.inbox-row.pri-2 { border-left: 4px solid var(--danger); background: #fef2f2; }
.inbox-row.pri-1 { border-left: 4px solid #f97316; background: #fff7ed; }
.inbox-row.pri-0 { border-left: 4px solid var(--primary); }
.inbox-row .meta { font-size: var(--fs-xs); color: var(--text-soft); }
.inbox-row .trig { font-weight: 600; color: var(--primary-strong); font-size: var(--fs-sm); }
.inbox-row .preview { font-size: var(--fs-sm); color: var(--text); margin-top: 4px; }
.inbox-row .actions { display: flex; gap: 6px; align-items: center; }
.inbox-counts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.inbox-counts .pill { padding: 3px 10px; border-radius: 999px; font-size: var(--fs-xs); }
.inbox-counts .pill.critical { background: #fee2e2; color: #991b1b; }
.inbox-counts .pill.urgent { background: #ffedd5; color: #9a3412; }
.inbox-counts .pill.normal { background: #dbeafe; color: #1e40af; }

.tab-nav .tab-count {
  display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 4px;
  border-radius: 999px; font-size: 11px; color: white; background: var(--primary);
  font-weight: 700;
}

/* SOAP card inside the doctor portal collapses by default for readability */
details.soap-card[open] { background: linear-gradient(180deg,#e0f2fe,#ffffff); }
details.soap-card summary::-webkit-details-marker { display: none; }
details.soap-card summary { list-style: none; padding: 4px 0; }

/* Compact inbox row inside the overview pane */
#doc-overview-inbox-preview .inbox-row { margin: 6px 0; }

/* ===== v3 — Dictionary library admin UI ============================== */

.dict-tabbar { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.dict-tabbar .dict-tab {
  padding: 8px 14px; background: transparent; border: 0; cursor: pointer;
  font: inherit; color: var(--text-soft); border-bottom: 2px solid transparent;
}
.dict-tabbar .dict-tab.active { color: var(--primary-strong); border-bottom-color: var(--primary); font-weight: 600; }
.dict-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dict-toolbar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

.dict-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: var(--fs-sm); }
.dict-table th, .dict-table td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; }
.dict-table th { background: var(--surface-2); color: var(--text-soft); font-weight: 600; text-align: left; }
.dict-table .dict-key {
  font-family: var(--mono); font-size: var(--fs-xs); white-space: nowrap;
  background: #f1f5f9; border-radius: 4px; padding: 2px 6px;
}
.dict-table textarea {
  width: 100%; min-height: 40px; resize: vertical; font: inherit;
  border: 1px solid transparent; border-radius: 6px; padding: 4px 6px;
  background: transparent;
}
.dict-table textarea:focus, .dict-table textarea:hover {
  border-color: var(--line); background: white; outline: none;
}
.dict-table .src-cell textarea { background: #fff7ed; border-color: #fed7aa; }
.dict-table .src-cell textarea:focus { background: white; border-color: var(--primary); }
.dict-table .auto-tag { font-size: 10px; color: var(--text-soft); padding: 1px 6px;
  background: #e0f2fe; border-radius: 999px; margin-left: 4px; }
.dict-table .manual-tag { font-size: 10px; color: #9a3412; padding: 1px 6px;
  background: #ffedd5; border-radius: 999px; margin-left: 4px; }
.dict-table .empty-tag { font-size: 10px; color: var(--danger); padding: 1px 6px;
  background: #fee2e2; border-radius: 999px; margin-left: 4px; }
.dict-table .row-actions { display: flex; gap: 4px; align-items: center; }
.dict-table .row-actions button { padding: 2px 8px; font-size: var(--fs-xs); }

.sys-i18n-summary {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.sys-i18n-summary .card-mini { cursor: pointer; }
.sys-i18n-summary .card-mini.has-missing { border-color: #fed7aa; background: #fff7ed; }
.sys-i18n-summary .missing-n { color: var(--danger); font-weight: 700; }

.sys-i18n-editor { margin-top: 12px; }
.sys-i18n-editor textarea {
  width: 100%; min-height: 360px; font-family: var(--mono); font-size: var(--fs-sm);
}

/* ===== v4 — Soul-setting verification progress + report ============= */
.soul-progress {
  background: white; border: 1px solid #fed7aa; border-radius: 10px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
}
.soul-step { font-size: var(--fs-sm); display: flex; align-items: center; gap: 6px; }
.soul-step.pending { color: var(--text-soft); }
.soul-step.doing { color: #d97706; font-weight: 600; }
.soul-step.done { color: #16a34a; }
.soul-step.fail { color: var(--danger); font-weight: 600; }

.soul-signals-list { list-style: none; padding: 8px 0 0; margin: 0; }
.soul-signals-list li {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 8px;
  padding: 6px 8px; border-bottom: 1px dashed var(--line); align-items: center;
}
.soul-signals-list li.hit { background: #f0fdf4; }
.soul-signals-list li.miss { background: #f9fafb; opacity: .75; }
.soul-signals-list li .phrase { font-size: var(--fs-sm); color: var(--text); }
.soul-signals-list li.miss .phrase { color: var(--text-soft); text-decoration: line-through dotted; }
.soul-signals-list li .status {
  font-size: 10px; padding: 2px 8px; border-radius: 999px;
  background: #dcfce7; color: #14532d;
}
.soul-signals-list li.miss .status { background: #f3f4f6; color: var(--text-soft); }
