/* Genetidoc Doctor Portal. Same look as the other Genetidoc tools (brand palette), plus a phone layout for doctors. */
:root {
  --blue: #3E3E7E; --blue-d: #2e2e63; --blue-l: #eceefc; --blue-m: #c9cdf6; --accent: #5E6CE6;
  --pink: #E84E85; --pink-l: #fdeaf1; --cream: #FFF3E8; --mist: #F7F9FC;
  --ink: #232a3d; --ink-2: #35405B; --ink-3: #6b7684; --line: #e3e8ee; --bg: #f5f7fb; --card: #fff;
  --green: #1b8a5a; --green-l: #e5f5ed; --red: #c62828; --red-l: #fdecec; --amber: #9a5b00; --amber-l: #fff4e0;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
h2 { font-size: 15px; margin: 0; color: var(--blue); }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: #f0f2f8; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef1f7; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.big { padding: 12px 18px; font-size: 16px; border-radius: 10px; }
.btn.block { width: 100%; }
.input, select.input, textarea.input { width: 100%; border: 1px solid #d3d9e4; border-radius: 8px; padding: 8px 10px; background: #fff; outline: none; }
textarea.input { resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--blue-l); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; color: var(--ink-2); }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; cursor: pointer; }
.check input { margin-top: 3px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--blue-l) 0%, var(--cream) 100%); padding: 16px; }
.login-card { width: 400px; max-width: 100%; background: #fff; border-radius: 14px; padding: 30px; box-shadow: 0 10px 40px rgba(62,62,126,.14); }
.login-card img { height: 44px; max-width: 100%; }
.code-input { font-size: 26px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }

/* top bar */
.topbar { min-height: 58px; padding-top: var(--safe-t); background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; padding-left: 18px; padding-right: 18px; position: sticky; top: 0; z-index: 20; }
.topbar .logo { height: 30px; margin-right: 10px; }
.topbar .spacer { flex: 1; }
.nav a { padding: 7px 11px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 500; position: relative; }
.nav:empty { display: none; }
.nav a:hover { background: #f0f2f8; }
.nav a.active { background: var(--blue-l); color: var(--blue); }
.page { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }
.page h1 { font-size: 22px; margin: 0; color: var(--blue); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.empty { text-align: center; padding: 50px 20px; color: var(--ink-3); background: #fff; border: 1px dashed #cfd6e3; border-radius: 12px; margin-top: 14px; }
.brand-name { color: var(--blue); margin-right: 14px; font-size: 15px; white-space: nowrap; }
.badge { display: inline-block; min-width: 19px; height: 19px; line-height: 19px; padding: 0 5px; border-radius: 10px; background: var(--pink); color: #fff; font-size: 11.5px; font-weight: 700; text-align: center; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: #eef1f6; color: var(--ink-2); white-space: nowrap; }
.pill.blue { background: var(--blue-l); color: var(--blue); }
.pill.green { background: var(--green-l); color: var(--green); }
.pill.amber { background: var(--amber-l); color: var(--amber); }
.pill.pink { background: var(--pink-l); color: #b8285c; }
.pill.red { background: var(--red-l); color: var(--red); }
.pill.grey { background: #eceff3; color: #5b6573; }

/* tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
th { background: #f9fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody.click tr { cursor: pointer; }
tbody.click tr:hover { background: #f7f8ff; }
tr.off td { opacity: .5; }
tr.unread td { font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(20,22,45,.45); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 540px; max-width: 100%; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { width: 860px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; align-items: center; position: sticky; bottom: 0; background: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }

.toast { position: fixed; bottom: calc(20px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; }
.toast.err { background: var(--red); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--blue-m); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { background: var(--amber-l); color: #6b4300; border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hint.blue { background: var(--blue-l); color: var(--ink-2); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--blue); color: #fff; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 9px 12px; text-decoration: none; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tabs a.on { color: var(--blue); border-bottom-color: var(--blue); }

/* stage progress */
.steps { display: flex; gap: 4px; margin: 4px 0 2px; }
.steps span { flex: 1; height: 5px; border-radius: 3px; background: #e2e6ef; }
.steps span.done { background: var(--blue); }
.steps-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); }

/* case page */
.case-layout { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.chat-card { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 160px); min-height: 520px; }
.chat { flex: 1; overflow-y: auto; padding: 16px; background: #eef1f6; border-radius: var(--radius) var(--radius) 0 0; display: flex; flex-direction: column; gap: 10px; }
.composer { padding: 10px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 var(--radius) var(--radius); }
.composer textarea { min-height: 42px; max-height: 160px; }
.composer .tools { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.bubble { max-width: 78%; padding: 9px 12px; border-radius: 12px; box-shadow: var(--shadow); line-height: 1.5; word-wrap: break-word; overflow-wrap: anywhere; background: #fff; align-self: flex-start; border-top-left-radius: 4px; }
.bubble.mine { background: #e3e7ff; align-self: flex-end; border-top-left-radius: 12px; border-top-right-radius: 4px; }
.bubble.internal { background: var(--amber-l); border: 1px dashed #e8b765; }
.bubble.system { align-self: center; background: transparent; box-shadow: none; color: var(--ink-3); font-size: 12.5px; text-align: center; padding: 2px 8px; max-width: 90%; }
.bubble.system.report { background: var(--green-l); color: var(--green); border-radius: 10px; padding: 8px 12px; font-weight: 500; }
.bubble .who { font-size: 11.5px; color: var(--ink-3); margin-bottom: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bubble .text { font-size: 14px; white-space: pre-wrap; }
.bubble .acts { opacity: 0; transition: opacity .15s; }
.bubble:hover .acts { opacity: 1; }
.att { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.att img.thumb { max-width: 240px; max-height: 240px; border-radius: 8px; cursor: zoom-in; border: 1px solid var(--line); display: block; }
.att a.doc { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.7); border: 1px solid var(--line); text-decoration: none; color: var(--ink); max-width: 300px; }
.att a.doc.report { background: #fff; border-color: var(--green); }
.att audio { width: 260px; max-width: 100%; height: 40px; }
.transcript { font-size: 12.5px; background: rgba(255,255,255,.65); border-left: 3px solid var(--blue-m); padding: 5px 8px; border-radius: 4px; white-space: pre-wrap; }
.transcript .en { color: var(--ink-3); margin-top: 3px; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pending-files .pill button { border: 0; background: none; cursor: pointer; padding: 0 0 0 2px; color: inherit; }
.rec { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.rec .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.side .card h2 { margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.reports .rep { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px; }
.activity { font-size: 12.5px; max-height: 260px; overflow-y: auto; }
.activity div { padding: 4px 0; border-bottom: 1px solid #f0f2f5; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 150; display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 6px; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin: 14px 0; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); cursor: pointer; text-decoration: none; color: inherit; display: block; }
.kpi .v { font-size: 24px; font-weight: 700; color: var(--blue); }
.kpi .l { font-size: 12px; color: var(--ink-3); }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.list-item:hover { background: #f7f8ff; }
.list-item:last-child { border-bottom: 0; }

/* ---------- doctor app (phone first) ---------- */
.doc .topbar { padding-left: 14px; padding-right: 10px; }
.doc .page { max-width: 760px; padding: 14px 12px calc(90px + var(--safe-b)); }
.case-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.case-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; box-shadow: var(--shadow); cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.case-card:active { background: #f7f8ff; }
.case-card .t { font-weight: 600; font-size: 15px; }
.case-card .s { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.fab { position: fixed; right: 16px; bottom: calc(18px + var(--safe-b)); z-index: 30; box-shadow: 0 6px 18px rgba(62,62,126,.35); border-radius: 30px; padding: 13px 20px; font-size: 16px; }
.pick2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed #c4cbe6; border-radius: 14px; padding: 22px 14px; background: #fafbff; cursor: pointer; text-align: center; color: var(--blue); font-weight: 600; width: 100%; }
.big-pick .ico { font-size: 34px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.thumbs .th { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; font-size: 11px; text-align: center; padding: 4px; }
.thumbs .th img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.thumbs .th button { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 50%; width: 22px; height: 22px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; z-index: 2; }
.banner { background: var(--blue-l); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.doc .case-layout { display: block; }
.doc .chat-card { height: auto; min-height: 0; border-radius: 12px; }
.doc .chat { border-radius: 12px 12px 0 0; min-height: 280px; max-height: none; overflow: visible; }
.doc .composer { position: sticky; bottom: 0; padding-bottom: calc(10px + var(--safe-b)); border-radius: 0 0 12px 12px; box-shadow: 0 -4px 12px rgba(0,0,0,.04); }

/* tablet & phone */
@media (max-width: 1100px) {
  .case-layout { grid-template-columns: 1fr; }
  .chat-card { height: 70vh; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .nav a { padding: 7px 7px; }
  .brand-name { display: none; }
}
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; padding-top: calc(6px + var(--safe-t)); padding-bottom: 6px; }
  .topbar .logo { height: 24px; }
  .nav { order: 5; width: 100%; overflow-x: auto; }
  .page { padding: 14px 12px 60px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .bubble { max-width: 90%; }
  .att img.thumb { max-width: 200px; }
  .modal { border-radius: 14px 14px 0 0; max-height: 96vh; }
  .overlay { padding: 0; align-items: end; }
  .hide-phone { display: none !important; }
  input.input, select.input, textarea.input { font-size: 16px; } /* stops iPhone zooming in */
}
