/* GK Imagem — tinta sobre papel; cor reservada para o estado de cada exame. */

@font-face { font-family: "Carlito"; src: url("../fonts/web/Carlito-Regular.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("../fonts/web/Carlito-Bold.woff") format("woff"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("../fonts/web/Carlito-Italic.woff") format("woff"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Caladea"; src: url("../fonts/web/Caladea-Regular.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Caladea"; src: url("../fonts/web/Caladea-Bold.woff") format("woff"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --paper: #eef1f0;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --ink: #17201d;
  --ink-2: #34403b;
  --muted: #5b6863;
  --line: #d3dbd8;
  --line-2: #e4e9e7;
  --link: #1d5c52;
  --focus: #2a6f97;
  --danger: #b42318;
  --danger-bg: #fdf0ee;
  --warn: #9a5208;
  --warn-bg: #fdf4e7;
  --ok: #1b7343;
  --ok-bg: #edf7f1;
  --st-agendado: #74807b;
  --st-aguardando: #c06a0a;
  --st-imagens: #2459b8;
  --st-laudando: #6b3fb0;
  --st-laudado: #1b7343;
  --st-entregue: #17201d;
  --st-cancelado: #a7b0ad;
  --radius: 6px;
  --sans: "Carlito", "Calibri", "Segoe UI", system-ui, sans-serif;
  --serif: "Caladea", "Cambria", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 var(--sans);
  font-variant-numeric: tabular-nums lining-nums;
}
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.2; }
h1 { font-family: var(--serif); font-size: 28px; letter-spacing: -0.01em; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- barra superior */
.topbar {
  background: var(--ink);
  color: #e8eeeb;
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 22px; min-height: 56px;
}
.brand { display: flex; align-items: baseline; gap: 8px; color: #fff; text-decoration: none; white-space: nowrap; }
.brand b { font: 700 19px/1 var(--serif); letter-spacing: 0.01em; }
.brand span { font-size: 13px; color: #a9b7b2; }
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: #cdd8d4; text-decoration: none; padding: 17px 11px 15px; font-size: 15px;
  border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 6px;
}
.nav a:hover { color: #fff; }
.nav a.active { color: #fff; border-bottom-color: #fff; }
.badge {
  display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px;
  background: #c06a0a; color: #fff; font-size: 12px; font-weight: 700; text-align: center; line-height: 18px;
}
.top-search { display: flex; }
.top-search input {
  width: 230px; height: 34px; border-radius: var(--radius); border: 1px solid #44524d;
  background: #222d29; color: #fff; padding: 0 10px; font: inherit; font-size: 14px;
}
.top-search input::placeholder { color: #93a39d; }
.user-menu { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #cdd8d4; white-space: nowrap; }
.user-menu a { color: #cdd8d4; }
.user-menu form { margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

/* ---------------------------------------------------------------- página */
.page { max-width: 1320px; margin: 0 auto; padding: 26px 20px 60px; }
.page-narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 10px; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px;
}
.panel + .panel { margin-top: 14px; }
.panel > h2 { margin-bottom: 10px; }
.grid-2 > .panel, .grid-side > .panel { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
@media (max-width: 960px) { .grid-2, .grid-side { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- identidade do paciente */
.identity {
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--ink);
  border-radius: 0 8px 8px 0; padding: 14px 20px; margin-bottom: 20px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center;
}
.identity-name { font: 700 26px/1.15 var(--serif); letter-spacing: -0.005em; }
.identity-name a { color: inherit; text-decoration: none; }
.identity-social { font-size: 14px; color: var(--muted); margin-top: 2px; }
.identity-meta { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 6px; font-size: 15px; }
.identity-meta span b { font-weight: 700; }
.identity-meta .k { color: var(--muted); margin-right: 4px; }

/* ---------------------------------------------------------------- trilha do exame */
.track { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; }
.track i { width: 16px; height: 5px; border-radius: 2px; background: var(--line); display: block; }
.track.st-agendado i.on { background: var(--st-agendado); }
.track.st-aguardando i.on { background: var(--st-aguardando); }
.track.st-imagens i.on { background: var(--st-imagens); }
.track.st-laudando i.on { background: var(--st-laudando); }
.track.st-laudado i.on { background: var(--st-laudado); }
.track.st-entregue i.on { background: var(--st-entregue); }
.track.st-cancelado i { background: transparent; border: 1px dashed var(--st-cancelado); }
.status { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 14px; }
.status-label { font-weight: 700; }
.st-agendado .status-label, .status-label.st-agendado { color: var(--st-agendado); }
.st-aguardando .status-label, .status-label.st-aguardando { color: var(--st-aguardando); }
.st-imagens .status-label, .status-label.st-imagens { color: var(--st-imagens); }
.st-laudando .status-label, .status-label.st-laudando { color: var(--st-laudando); }
.st-laudado .status-label, .status-label.st-laudado { color: var(--st-laudado); }
.st-entregue .status-label, .status-label.st-entregue { color: var(--st-entregue); }
.st-cancelado .status-label, .status-label.st-cancelado { color: var(--st-cancelado); text-decoration: line-through; }

/* trilha grande, na página do exame */
.journey { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 4px 0 2px; }
.journey div { border-top: 5px solid var(--line); padding-top: 7px; font-size: 14px; color: var(--muted); }
.journey div.done { color: var(--ink); }
.journey div.now b { color: var(--ink); }
.journey small { display: block; font-size: 13px; }
.journey.st-agendado div.done { border-top-color: var(--st-agendado); }
.journey.st-aguardando div.done { border-top-color: var(--st-aguardando); }
.journey.st-imagens div.done, .journey.st-laudando div.done { border-top-color: var(--st-imagens); }
.journey.st-laudando div.now { border-top-color: var(--st-laudando); }
.journey.st-laudado div.done { border-top-color: var(--st-laudado); }
.journey.st-entregue div.done { border-top-color: var(--st-entregue); }

/* ---------------------------------------------------------------- tabelas */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th {
  text-align: left; font-weight: 400; color: var(--muted); font-size: 13px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.row-link { cursor: pointer; }
table.list tr.row-link:hover td { background: #f7faf9; }
table.list td.time { font-size: 17px; font-weight: 700; white-space: nowrap; width: 70px; }
table.list td.right, table.list th.right { text-align: right; }
table.list tr.cancelado td { color: var(--muted); }
.pname { font-weight: 700; color: var(--ink); text-decoration: none; }
.pname:hover { text-decoration: underline; }
.sub { display: block; font-size: 13px; color: var(--muted); }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; font-size: 16px; }

/* ---------------------------------------------------------------- formulários */
form.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field label, .label { font-size: 14px; color: var(--ink-2); font-weight: 700; }
.field .hint { font-size: 13px; color: var(--muted); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=time],
input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff;
  border: 1px solid #bfc9c5; border-radius: var(--radius); padding: 8px 10px; min-height: 40px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input[readonly] { background: var(--surface-2); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; }
.check input { margin-top: 3px; width: 17px; height: 17px; }
.code-input { font-size: 28px !important; letter-spacing: 0.3em; text-align: center; max-width: 220px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 700 15px/1 var(--sans); padding: 10px 16px; min-height: 40px; border-radius: var(--radius);
  border: 1px solid var(--ink); background: var(--ink); color: #fff; text-decoration: none; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #2b3833; color: #fff; }
.btn-2 { background: #fff; color: var(--ink); border-color: #b9c4c0; }
.btn-2:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-2); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e3b5b0; }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { padding: 6px 10px; min-height: 32px; font-size: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-sign { background: var(--st-laudado); border-color: var(--st-laudado); }
.btn-sign:hover { background: #155c35; }

/* ---------------------------------------------------------------- mensagens */
.flash { border-radius: var(--radius); padding: 11px 14px; margin-bottom: 14px; font-size: 15px; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: #b8dcc6; color: #10502d; }
.flash.erro { background: var(--danger-bg); border-color: #efc4be; color: #7a1a11; }
.flash.atencao { background: var(--warn-bg); border-color: #efd3a8; color: #6b3a05; }
.errors { margin: 0 0 6px; padding: 11px 14px 11px 32px; background: var(--danger-bg); border: 1px solid #efc4be; border-radius: var(--radius); color: #7a1a11; }
.alerts { display: grid; gap: 8px; margin-bottom: 18px; }
.alert { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-bg); border: 1px solid #efd3a8; }
.alert.erro { background: var(--danger-bg); border-color: #efc4be; }
.session-warning {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 8px; display: flex; gap: 14px; align-items: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.session-warning .btn { background: #fff; color: var(--ink); }

/* ---------------------------------------------------------------- números e chips */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  display: inline-flex; gap: 6px; align-items: baseline; padding: 6px 12px; border-radius: 16px;
  border: 1px solid var(--line); background: #fff; text-decoration: none; color: var(--ink); font-size: 14px;
}
.chip b { font-size: 16px; }
.chip.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line); color: var(--ink-2); background: var(--surface-2); }
.tag.danger { color: var(--danger); border-color: #efc4be; background: var(--danger-bg); }
.tag.warn { color: var(--warn); border-color: #efd3a8; background: var(--warn-bg); }
.tag.ok { color: var(--ok); border-color: #b8dcc6; background: var(--ok-bg); }

/* ---------------------------------------------------------------- agenda */
.daynav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week { position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; }
.week a {
  display: block; padding: 8px 10px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 14px;
}
.week a b { display: block; font-size: 18px; }
.week a.sel { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.week a.today b { text-decoration: underline; text-underline-offset: 4px; }
.week a small { display: block; }
@media (max-width: 700px) {
  .week { grid-template-columns: repeat(7, 74px); overflow-x: auto; padding-bottom: 4px; }
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
  table.list tr:last-child { border-bottom: 0; }
  table.list td { padding: 2px 0; border: 0; }
  table.list td.time { width: auto; font-size: 16px; }
  table.list td.right { text-align: left; padding-top: 8px; }
  table.list td:empty { display: none; }
}

/* ---------------------------------------------------------------- definição (dados) */
dl.data { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 0; font-size: 15px; }
dl.data dt { color: var(--muted); }
dl.data dd { margin: 0; }
aside dl.data, .editor-side dl.data { grid-template-columns: 96px minmax(0, 1fr); }
dl.data dd { min-width: 0; overflow-wrap: anywhere; }
dl.data dd .status { white-space: normal; flex-wrap: wrap; }
@media (max-width: 600px) { dl.data { grid-template-columns: 1fr; } dl.data dd { margin-bottom: 6px; } }
.timeline form { display: block; margin: 2px 0 0; }

/* ---------------------------------------------------------------- imagens */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.thumb {
  position: relative; background: #0b0f0e; border-radius: 4px; overflow: hidden; aspect-ratio: 4 / 3;
  border: 2px solid transparent; cursor: pointer; padding: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb .n { position: absolute; left: 6px; bottom: 3px; color: #fff; font-size: 12px; text-shadow: 0 1px 2px #000; }
.thumb .pick {
  position: absolute; right: 5px; top: 5px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.45); border: 2px solid #fff; color: #fff; font: 700 13px/18px var(--sans); text-align: center;
}
.thumb.selected { border-color: #f0b429; }
.thumb.selected .pick { background: #f0b429; border-color: #f0b429; color: #17201d; }
.thumb .clip { position: absolute; left: 6px; top: 5px; color: #fff; font-size: 11px; background: rgba(0,0,0,.55); padding: 0 5px; border-radius: 3px; }

/* ---------------------------------------------------------------- editor de laudo */
.editor-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1080px) { .editor-layout { grid-template-columns: 1fr; } }
.editor-side { position: sticky; top: 76px; display: grid; gap: 14px; max-height: calc(100vh - 96px); overflow: auto; }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface-2); }
.toolbar button { font: 700 14px/1 var(--sans); min-width: 34px; height: 32px; border: 1px solid transparent; background: none; border-radius: 4px; cursor: pointer; color: var(--ink); }
.toolbar button:hover { border-color: var(--line); background: #fff; }
.toolbar .sep { width: 1px; background: var(--line); margin: 4px 4px; }
.toolbar select { min-height: 32px; height: 32px; padding: 2px 8px; width: auto; font-size: 14px; }
.doc {
  background: #fff; border: 1px solid var(--line); border-radius: 0 0 8px 8px; min-height: 560px;
  padding: 34px 44px; font: 400 17px/1.6 var(--serif); color: #111;
}
.doc:focus { outline: 2px solid var(--focus); outline-offset: -2px; }
.doc p { margin: 0 0 10px; }
.doc h3 { font: 700 16px/1.3 var(--sans); margin: 16px 0 6px; }
.doc h4 { font: 700 15px/1.3 var(--sans); color: var(--muted); margin: 12px 0 4px; }
.doc ul, .doc ol { margin: 0 0 10px; padding-left: 24px; }
.title-input { font: 700 18px/1.3 var(--sans) !important; border-radius: 8px 8px 0 0 !important; border-bottom: 0 !important; }
.savebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.save-state { font-size: 14px; color: var(--muted); }
.save-state.erro { color: var(--danger); }
.indication { background: var(--warn-bg); border: 1px solid #efd3a8; border-radius: var(--radius); padding: 10px 12px; font-size: 15px; }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 22px 24px; max-width: 520px; width: calc(100% - 32px); color: var(--ink); }
dialog::backdrop { background: rgba(10, 16, 14, 0.5); }
dialog h2 { margin-bottom: 10px; }

/* ---------------------------------------------------------------- telas de entrada */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card .brand-big { text-align: left; margin-bottom: 22px; }
.auth-card .brand-big b { font: 700 30px/1 var(--serif); display: block; }
.auth-card .brand-big span { color: var(--muted); font-size: 15px; }
.auth-card .panel { padding: 24px; }
.auth-foot { margin-top: 16px; font-size: 13px; color: var(--muted); }
.qr { background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 8px; width: 236px; height: 236px; }
.secret { font: 700 17px/1.4 var(--sans); letter-spacing: 0.08em; word-break: break-all; }
.terms { max-height: 52vh; overflow: auto; font-size: 15px; padding-right: 8px; }
.terms li { margin-bottom: 6px; }

/* ---------------------------------------------------------------- linha do tempo */
.timeline { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.timeline li { padding: 6px 0; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 120px 1fr; gap: 10px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); }

.verify-ok { border-left: 5px solid var(--ok); }
.verify-bad { border-left: 5px solid var(--danger); }
.verify-old { border-left: 5px solid var(--warn); }

@media (max-width: 860px) {
  .topbar { position: static; }
  .topbar-inner { flex-wrap: wrap; gap: 6px 14px; padding: 10px 16px; }
  .brand { order: 1; flex: 1 1 auto; }
  .user-menu { order: 2; }
  .nav { order: 3; flex: 0 0 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .nav a { padding: 8px 10px 8px 0; margin-right: 6px; white-space: nowrap; }
  .top-search { order: 4; flex: 0 0 100%; padding-bottom: 4px; }
  .top-search input { width: 100%; }
  .page { padding: 18px 16px 50px; }
  .doc { padding: 22px 18px; }
  h1 { font-size: 24px; }
  .identity-name { font-size: 22px; }
}

@media print {
  .topbar, .actions, .no-print { display: none !important; }
  body { background: #fff; }
}

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

.sig-img { max-width: 280px; height: auto; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.auth-card.page-narrow { max-width: 600px; }
.auth-card dl.data { grid-template-columns: 130px minmax(0, 1fr); }
