/* =====================================================================
   Documentação Fotográfica — identidade visual do Centro Radiológico de Castro
   Cores e tipografia do site radiologiacastro.com.br: verde CRC #017D3F, preto,
   texto #1E1E1E, cinza #F6F6F6 / #E4E4E4 e títulos em Yantramanav.
   O editor usa uma "mesa de luz" escura com marcas de corte de gráfica.
   ===================================================================== */

@font-face { font-family: "Inter Local"; src: url("../fonts/Inter-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter Local"; src: url("../fonts/Inter-SemiBold.otf") format("opentype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter Local"; src: url("../fonts/Inter-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Yantramanav Local"; src: url("../fonts/Yantramanav-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Yantramanav Local"; src: url("../fonts/Yantramanav-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Yantramanav Local"; src: url("../fonts/Yantramanav-700.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }

:root {
  --enamel: #f6f6f6;          /* cinza das seções do site */
  --surface: #ffffff;
  --ink: #1e1e1e;             /* texto do site */
  --ink-2: #333333;
  --muted: #69727d;
  --line: #e4e4e4;
  --line-soft: #eeeeee;
  --brand: #017d3f;           /* verde CRC */
  --brand-strong: #01622f;
  --brand-tint: #e6f2ec;
  --brand-on-dark: #45c486;   /* verde CRC legível sobre fundo escuro */
  --amber: #b97b12;
  --amber-tint: #fbf1dc;
  --danger: #b4332c;
  --danger-tint: #f9e6e4;
  --graphite: #000000;        /* preto do site */
  --graphite-2: #161616;
  --table: #222222;
  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 5px;
  --sidebar-w: 248px;
  --font: "Inter Local", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-head: "Yantramanav Local", "Yantramanav", "Inter Local", "Segoe UI", sans-serif;

  --bs-body-font-family: var(--font);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--enamel);
  --bs-border-color: var(--line);
  --bs-primary: var(--brand);
  --bs-primary-rgb: 1, 125, 63;
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: 1, 125, 63;
  --bs-link-hover-color: var(--brand-strong);
  --bs-focus-ring-color: rgba(1, 125, 63, .28);
  --bs-border-radius: var(--radius-sm);
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--enamel);
  color: var(--ink);
  font-size: 0.9375rem;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
.num, .tabular { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4, h5, .h3, .h4, .h5, .modal-title, .stat .value { font-family: var(--font-head); font-weight: 700; letter-spacing: 0; color: var(--ink); }
.page-title { font-size: 1.85rem; margin: 0; line-height: 1.1; }
.page-sub { color: var(--muted); margin: .2rem 0 0; }
a { text-decoration: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Botões ---------- */
.btn { font-weight: 600; border-radius: var(--radius-sm); letter-spacing: .005em; --bs-btn-padding-y: .5rem; --bs-btn-padding-x: .95rem; --bs-btn-font-size: .9rem; display: inline-flex; align-items: center; gap: .45rem; justify-content: center; }
.btn-sm { --bs-btn-padding-y: .3rem; --bs-btn-padding-x: .65rem; --bs-btn-font-size: .82rem; }
.btn-lg { --bs-btn-padding-y: .7rem; --bs-btn-padding-x: 1.25rem; --bs-btn-font-size: 1rem; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-strong); --bs-btn-hover-border-color: var(--brand-strong); --bs-btn-active-bg: var(--brand-strong); --bs-btn-active-border-color: var(--brand-strong); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-strong); }
.btn-light { --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line); --bs-btn-hover-bg: var(--line-soft); --bs-btn-hover-border-color: var(--line); --bs-btn-color: var(--ink); }
.btn-ghost { --bs-btn-color: var(--ink-2); --bs-btn-hover-bg: var(--line-soft); --bs-btn-border-color: transparent; --bs-btn-hover-border-color: transparent; }
.btn-produce { --bs-btn-bg: #000; --bs-btn-border-color: #000; --bs-btn-color: #fff; --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--brand-strong); font-family: var(--font-head); text-transform: uppercase; letter-spacing: .04em; }
.btn-danger { --bs-btn-bg: var(--danger); --bs-btn-border-color: var(--danger); }
.btn-outline-danger { --bs-btn-color: var(--danger); --bs-btn-border-color: #e3b5b1; --bs-btn-hover-bg: var(--danger); --bs-btn-hover-border-color: var(--danger); }

.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--line); padding: .55rem .75rem; font-size: .93rem; background-color: #fff; }
.form-control:disabled, .form-select:disabled { background-color: var(--line-soft); color: var(--muted); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(1,125,63,.16); }
.form-label { font-weight: 600; font-size: .84rem; color: var(--ink-2); margin-bottom: .3rem; }
.form-text { color: var(--muted); font-size: .8rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.input-group-text { background: var(--line-soft); border-color: var(--line); color: var(--muted); }

/* ---------- Estrutura ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); color: var(--ink-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  z-index: 1030;
}
.sidebar-brand { display: flex; flex-direction: column; align-items: stretch; gap: .55rem; padding: 1.2rem 1.1rem 1rem; color: var(--ink); border-bottom: 1px solid var(--line-soft); }
.brand-logo { display: block; width: 100%; height: 54px; object-fit: contain; object-position: left center; }
.brand-emblem { display: none; width: 40px; height: 40px; object-fit: contain; margin: 0 auto; }
.brand-text { line-height: 1.15; min-width: 0; }
.brand-text strong { display: block; font-size: .92rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-family: var(--font-head); font-size: .74rem; font-weight: 600; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: .06em; }
.nav-group { padding: .6rem .6rem .35rem; }
.nav-heading { font-family: var(--font-head); font-size: .74rem; color: var(--muted); padding: .95rem .6rem .35rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.nav-link-item {
  display: flex; align-items: center; gap: .7rem;
  color: var(--ink-2); padding: .55rem .65rem; border-radius: var(--radius-sm); font-weight: 500; font-size: .9rem;
  position: relative; white-space: nowrap;
}
.nav-link-item i { font-size: 1.05rem; width: 1.2rem; text-align: center; color: var(--muted); }
.nav-link-item:hover { background: var(--enamel); color: var(--ink); }
.nav-link-item.active { background: var(--brand-tint); color: var(--brand-strong); font-weight: 600; }
.nav-link-item.active i { color: var(--brand); }
.nav-link-item.active::before { content: ""; position: absolute; left: -.6rem; top: .4rem; bottom: .4rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav-link-item.cta { background: var(--brand); color: #fff; margin: .1rem 0 .5rem; font-family: var(--font-head); font-weight: 600; font-size: .95rem; text-transform: uppercase; letter-spacing: .03em; }
.nav-link-item.cta i { color: #fff; }
.nav-link-item.cta:hover { background: var(--brand-strong); color: #fff; }
.sidebar-footer { margin-top: auto; padding: .6rem; border-top: 1px solid var(--line-soft); }
.sidebar-footer form { margin: 0; }
.sidebar-footer button.nav-link-item { width: 100%; background: none; border: 0; text-align: left; }
.sidebar-footer button.nav-link-item:hover { background: var(--enamel); }

/* Sidebar compacta (editor) */
.sidebar-compact .sidebar { --sidebar-w: 68px; }
.sidebar-compact .brand-text, .sidebar-compact .brand-logo, .sidebar-compact .nav-link-item span, .sidebar-compact .nav-heading { display: none; }
.sidebar-compact .brand-emblem { display: block; }
.sidebar-compact .sidebar-brand { justify-content: center; padding: .9rem .5rem; }
.sidebar-compact .nav-link-item { justify-content: center; padding: .6rem; }
.sidebar-compact .nav-link-item.active::before { left: -.6rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 1rem;
  padding: 0 1.75rem; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: inset 0 3px 0 var(--brand);
  position: sticky; top: 0; z-index: 1020;
}
.content { padding: 1.75rem; flex: 1; width: 100%; max-width: 1320px; }
.app-footer { padding: 1rem 1.75rem 1.5rem; color: var(--muted); font-size: .8rem; }
.menu-toggle { display: none; }

.user-chip { display: flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .25rem; border-radius: 999px; color: var(--ink); border: 1px solid transparent; }
.user-chip:hover { border-color: var(--line); color: var(--ink); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-strong); display: grid; place-items: center; font-weight: 700; font-size: .78rem; }
.user-chip small { color: var(--muted); display: block; font-size: .72rem; line-height: 1; }
.user-chip strong { font-size: .85rem; display: block; line-height: 1.2; }

/* ---------- Busca de paciente ---------- */
.patient-search { position: relative; flex: 1; max-width: 520px; }
.patient-search .bi-search { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.patient-search input { padding-left: 2.4rem; background: var(--enamel); border-color: transparent; height: 40px; }
.patient-search input:focus { background: #fff; }
/* Resultados da busca: ancorados ao campo (mesma largura), por cima do conteúdo da página e com rolagem
   interna. z-index acima de todo o conteúdo, mas abaixo da barra superior fixa (1020) e do menu lateral
   no tablet (1025/1030), para não cobrir a navegação. */
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 1015; display: none;
  background: #fff; color: var(--ink); text-align: left; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 14px 40px rgba(0,0,0,.14);
  max-height: min(420px, 60vh); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
}
.search-results.show { display: block; }
.search-item { display: flex; align-items: center; gap: .8rem; padding: .65rem .9rem; color: var(--ink); border-bottom: 1px solid var(--line-soft); }
.search-item:last-child { border-bottom: 0; }
.search-item:hover, .search-item.active { background: var(--brand-tint); color: var(--ink); }
.search-item .pid { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand-strong); min-width: 5.5rem; }
.search-item .meta { color: var(--muted); font-size: .8rem; }
.search-empty { padding: .9rem; color: var(--muted); font-size: .88rem; }
.search-big input { height: 52px; font-size: 1.05rem; background: #fff; border-color: var(--line); }

/* ---------- Painéis ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-body { padding: 1.35rem 1.5rem; }
.panel-head { padding: 1rem 1.5rem; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-head h2, .panel-head h3 { font-size: 1.02rem; margin: 0; text-transform: uppercase; letter-spacing: .03em; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

/* Faixa de números do dashboard */
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.stat { padding: 1.15rem 1.4rem; border-left: 1px solid var(--line-soft); }
.stat:first-child { border-left: 0; }
.stat .value { font-size: 2.1rem; font-weight: 700; letter-spacing: 0; color: var(--brand); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .84rem; }
.stat.attention .value { color: var(--amber); }
.stat:first-child .value, .stat .value.neutral { color: var(--ink); }

.hero-search { background: var(--brand); color: #fff; border-radius: var(--radius-lg); padding: 1.6rem 1.6rem 1.4rem; position: relative; overflow: visible; } /* visible: não cortar os resultados da busca */
.hero-search h1 { color: #fff; font-size: 1.7rem; margin-bottom: .2rem; text-transform: uppercase; letter-spacing: .02em; }
.hero-search p { color: rgba(255,255,255,.82); margin-bottom: 1rem; }
.hero-search .patient-search { max-width: none; }
.hero-search .patient-search input { background: #fff; height: 52px; font-size: 1.02rem; }
.crop-marks { position: absolute; inset: 14px; pointer-events: none; }
.crop-marks::before, .crop-marks::after { content: ""; position: absolute; width: 16px; height: 16px; border: 1px solid rgba(255,255,255,.45); }
.crop-marks::before { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.crop-marks::after { bottom: 0; left: 0; border-right: 0; border-top: 0; }

/* ---------- Tabelas ---------- */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .75rem 1rem; border-color: var(--line-soft); }
.table thead th { font-family: var(--font-head); font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: #fafafa; border-bottom: 1px solid var(--line); }
.table-hover tbody tr:hover > * { background: #f3f8f5; }
.table .pid { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand-strong); }
.row-link { cursor: pointer; }

.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--line-soft); color: var(--ink-2); white-space: nowrap; }
.chip-brand { background: var(--brand-tint); color: var(--brand-strong); }
.chip-amber { background: var(--amber-tint); color: #8a5b0b; }
.chip-danger { background: var(--danger-tint); color: var(--danger); }
.chip-dark { background: var(--ink); color: #fff; }

/* ---------- Estado vazio ---------- */
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--muted); }
.empty .empty-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--brand-tint); color: var(--brand); display: inline-grid; place-items: center; font-size: 1.7rem; margin-bottom: 1rem; }
.empty h3 { font-size: 1.05rem; color: var(--ink); }

/* ---------- Paciente / histórico ---------- */
.patient-header { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.patient-id-badge { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; background: var(--brand); color: #fff; border-radius: 8px; padding: .35rem .7rem; letter-spacing: .02em; }
.patient-facts { display: flex; gap: 1.6rem; color: var(--muted); font-size: .9rem; flex-wrap: wrap; }
.patient-facts strong { color: var(--ink); font-weight: 600; }

.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 104px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.tl-item { display: grid; grid-template-columns: 92px 1fr; gap: 26px; position: relative; padding-bottom: 1.1rem; }
.tl-date { text-align: right; padding-top: .9rem; }
.tl-date .d { font-weight: 700; font-size: 1.02rem; font-variant-numeric: tabular-nums; display: block; }
.tl-date .y { color: var(--muted); font-size: .8rem; }
.tl-item::after { content: ""; position: absolute; left: 99px; top: 1.2rem; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--brand); }
.tl-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem 1.15rem; display: grid; grid-template-columns: 1fr auto; gap: .9rem 1.2rem; align-items: center; transition: border-color .15s; }
.tl-card:hover { border-color: #9fcdb4; }
.tl-card h3 { font-size: 1rem; margin: 0 0 .25rem; }
.tl-card h3 a { color: var(--ink); }
.tl-card h3 a:hover { color: var(--brand); }
.tl-meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .84rem; }
.tl-actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.thumb-strip { grid-column: 1 / -1; display: flex; gap: 4px; }
.thumb-strip span { width: 54px; height: 40px; border-radius: 4px; background: #ececec center/cover no-repeat; flex: 0 0 auto; }
.thumb-strip span.missing { background: repeating-linear-gradient(135deg, #f2f2f2 0 6px, #e8e8e8 6px 12px); }

/* ---------- Progresso de fotos ---------- */
.photo-progress { display: inline-flex; align-items: center; gap: .45rem; font-size: .84rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.photo-progress .bar { width: 52px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.photo-progress .bar span { display: block; height: 100%; background: var(--brand); }
.photo-progress.incomplete .bar span { background: var(--amber); }

/* ---------- Toasts / modais ---------- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; width: min(380px, calc(100vw - 40px)); pointer-events: none; }
.toast-stack > * { pointer-events: auto; }
.editor-body .toast-stack { right: auto; left: 88px; }
.app-toast { background: var(--ink); color: #fff; border-radius: var(--radius); padding: .8rem 1rem; display: flex; gap: .7rem; align-items: flex-start; box-shadow: 0 12px 32px rgba(0,0,0,.22); font-size: .9rem; animation: toast-in .22s ease-out; }
.app-toast i { font-size: 1.1rem; line-height: 1.2; }
.app-toast.success i { color: var(--brand-on-dark); }
.app-toast.danger { background: #5a1a16; }
.app-toast.danger i, .app-toast.warning i { color: #ffc56b; }
.app-toast .close { margin-left: auto; background: none; border: 0; color: #fff; opacity: .6; padding: 0 0 0 .5rem; }
.app-toast.hide { opacity: 0; transform: translateY(-6px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-content { border-radius: var(--radius-lg); border: 0; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.modal-header { border-bottom-color: var(--line-soft); padding: 1.1rem 1.4rem; }
.modal-body { padding: 1.3rem 1.4rem; }
.modal-footer { border-top-color: var(--line-soft); padding: .9rem 1.4rem; }
.modal-title { font-weight: 700; font-size: 1.08rem; }

/* ---------- Login / setup ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-visual { background: var(--graphite); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 3rem; }
.auth-sheet { width: min(460px, 90%); aspect-ratio: 3 / 2; background: #000; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 1.44fr 1fr .91fr; gap: 3.5%; padding: 4% 13%; position: relative; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.auth-sheet span { background: #3a3a3a; border-radius: 1px; }
.auth-sheet span.center { background: #fff; display: grid; place-items: center; border-radius: 1px; }
.auth-sheet span.center img { width: 46%; height: auto; }
.auth-sheet::before, .auth-sheet::after { content: ""; position: absolute; width: 22px; height: 22px; border-color: rgba(255,255,255,.4); border-style: solid; }
.auth-sheet::before { top: -16px; left: -16px; border-width: 0 1px 1px 0; }
.auth-sheet::after { bottom: -16px; right: -16px; border-width: 1px 0 0 1px; }
.auth-caption { position: absolute; left: 3rem; bottom: 2.5rem; right: 3rem; color: #a7a7a7; font-size: .88rem; border-left: 3px solid var(--brand); padding-left: .9rem; }
.auth-caption strong { color: #fff; display: block; font-size: 1.05rem; margin-bottom: .2rem; }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 2.5rem; }
.auth-form { width: 100%; max-width: 380px; }
.auth-logo { height: 64px; max-width: 280px; object-fit: contain; object-position: left center; margin-bottom: 1.5rem; display: block; }

/* ---------- Nova documentação ---------- */
.step-block { display: grid; grid-template-columns: 34px 1fr; gap: 1rem; }
.step-num { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.step-block.disabled { opacity: .45; pointer-events: none; }
.found-patient { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--brand-tint); border: 1px solid #bfe0cd; }
.found-patient .pid { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.mini-register { border: 1px dashed #c9b27f; background: #fffaf0; border-radius: var(--radius); padding: 1.1rem 1.15rem; }
.id-input { font-size: 1.35rem !important; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .04em; height: 56px; }

/* =====================================================================
   EDITOR DA DOCUMENTAÇÃO — mesa de luz
   ===================================================================== */
.editor-body .main { height: 100vh; overflow: hidden; }
.editor-body .content { max-width: none; padding: 0; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.editor-body .app-footer { display: none; }
.editor-bar { background: var(--surface); border-bottom: 1px solid var(--line); padding: .75rem 1.25rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.editor-bar .who { min-width: 0; }
.editor-bar .who h1 { font-size: 1.12rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-bar .who .tl-meta { font-size: .8rem; }
.editor-actions { margin-left: auto; display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
/* largura fixa: trocar "Tudo salvo" ↔ "Alterações…" ↔ "Salvo às …" não pode mudar a barra (senão o editor redesenha a página toda) */
.save-state { font-size: .8rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; width: 8.75rem; flex: 0 0 8.75rem; white-space: nowrap; overflow: hidden; }
.save-state span { overflow: hidden; text-overflow: ellipsis; }
.save-state.saving { color: var(--amber); }
.save-state.saved i { color: var(--brand); }
.save-state.error { color: var(--danger); }

.editor-layout { display: flex; flex: 1; min-height: 0; }
.light-table {
  flex: 1; min-width: 0; position: relative;
  background-color: var(--table);
  background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 18px 18px;
  display: flex; align-items: center; justify-content: center; padding: 34px; overflow: hidden; min-height: 0;
}
.sheet { position: relative; box-shadow: 0 22px 60px rgba(0,0,0,.45); user-select: none; }
.sheet .crop { position: absolute; width: 18px; height: 18px; border-color: rgba(255,255,255,.35); border-style: solid; pointer-events: none; }
.sheet .crop.tl { top: -24px; left: -24px; border-width: 0 1px 1px 0; }
.sheet .crop.tr { top: -24px; right: -24px; border-width: 0 0 1px 1px; }
.sheet .crop.bl { bottom: -24px; left: -24px; border-width: 1px 1px 0 0; }
.sheet .crop.br { bottom: -24px; right: -24px; border-width: 1px 0 0 1px; }
.sheet-size { position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,.45); font-size: .72rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.zone { position: absolute; overflow: hidden; cursor: pointer; }
.zone.photo-zone.is-empty { outline: 1px dashed rgba(255,255,255,.35); outline-offset: -1px; background: rgba(255,255,255,.035); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: rgba(255,255,255,.75); }
.zone.photo-zone.is-empty:hover, .zone.drop-target { background: rgba(69,196,134,.12); outline-color: var(--brand-on-dark); color: #fff; }
.zone.compact .add-label, .zone.compact .zone-name, .zone.compact .zone-tag { display: none; }
.zone.compact .add-icon { width: 24px; height: 24px; font-size: .9rem; margin: 0; }
.zone .add-icon { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.45); display: grid; place-items: center; font-size: 1.15rem; margin-bottom: .35rem; }
.zone .add-label { font-size: .74rem; opacity: .8; }
.zone .zone-name { font-size: .72rem; font-weight: 700; letter-spacing: .06em; margin-top: .15rem; padding: 0 .4rem; }
.zone img.photo { position: absolute; max-width: none; pointer-events: none; transform-origin: center center; }
.zone.has-photo { cursor: grab; }
.zone.has-photo.panning { cursor: grabbing; }
.zone.selected::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--brand-on-dark); pointer-events: none; }
.zone .zone-tag { position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: .66rem; padding: 1px 6px; border-radius: 4px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.zone:hover .zone-tag, .zone.selected .zone-tag { opacity: 1; }
.zone .upload-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.15); }
.zone .upload-progress span { display: block; height: 100%; background: var(--brand-on-dark); width: 0; transition: width .15s; }
.zone .uploading-label { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.55); color: #fff; font-size: .8rem; }
.info-zone { cursor: default; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow: hidden; }
.info-zone img.logo { display: block; object-fit: contain; }
.info-zone .line { white-space: nowrap; }

.side-panel { width: 330px; flex: 0 0 330px; background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.side-section { padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.side-section h3 { font-size: .95rem; margin: 0 0 .8rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.side-label { font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: .4rem; display: block; }
.selected-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.ctrl-row { display: flex; align-items: center; gap: .5rem; }
.ctrl-row .form-range { flex: 1; }
.form-range::-webkit-slider-thumb { background: var(--brand); }
.form-range::-moz-range-thumb { background: var(--brand); }
.icon-btn { width: 36px; height: 36px; padding: 0 !important; display: inline-grid; place-items: center; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--line-soft); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 6px; padding: .4rem; font-size: .84rem; font-weight: 600; color: var(--muted); }
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.calib { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem; }
.calib summary { cursor: pointer; font-size: .88rem; }
.auto-box { background: var(--brand-tint); border-radius: 10px; padding: .7rem; }
.auto-status { list-style: none; padding: 0; margin: 0 0 .55rem; font-size: .8rem; color: var(--brand-strong); }
.auto-status li { display: flex; gap: .35rem; align-items: baseline; }
.auto-status li::before { content: "✓"; font-weight: 700; }
.auto-status li.warn { color: #8a5b0b; }
.position-check { border: 1px solid #e6c98a; background: var(--amber-tint); color: #6b4708; border-radius: var(--radius-sm); padding: .65rem .7rem; margin-bottom: .6rem; font-size: .84rem; }
.position-check i { color: var(--amber); }
.auto-status li.warn::before { content: "!"; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); padding: 0; box-shadow: inset 0 0 0 2px #fff; }
.swatch.active { outline: 2px solid var(--brand); outline-offset: 2px; }
.swatch-input { width: 30px; height: 30px; padding: 0; border: 0; background: none; }
.zone-list .zbadge { font-size: .68rem; color: var(--brand-strong); background: #fff; border-radius: 999px; padding: 0 .4rem; margin-left: .3rem; }
.zone-list { list-style: none; margin: 0; padding: 0; }
.zone-list li { display: flex; align-items: center; gap: .65rem; padding: .4rem .45rem; border-radius: 8px; cursor: pointer; font-size: .86rem; }
.zone-list li:hover { background: var(--line-soft); }
.zone-list li.active { background: var(--brand-tint); }
.zone-list .zthumb { width: 40px; height: 30px; border-radius: 4px; background: #ececec center/cover no-repeat; flex: 0 0 40px; display: grid; place-items: center; color: #9aa5ab; font-size: .9rem; }
.zone-list .zstate { margin-left: auto; font-size: .95rem; }
.zone-list .zstate.ok { color: var(--brand); }
.zone-list .zstate.miss { color: #c3cbcf; }
.hint { font-size: .78rem; color: var(--muted); }
.kbd { font-size: .72rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .3rem; background: #fff; color: var(--ink-2); }

/* ---------- Visualizar resultado ---------- */
.preview-body { background: #111111; color: #fff; min-height: 100vh; display: flex; flex-direction: column; }
.preview-bar { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.2rem; background: rgba(0,0,0,.35); flex-wrap: wrap; }
.preview-bar .title { font-weight: 600; }
.preview-bar .title small { color: #9a9a9a; font-weight: 400; margin-left: .5rem; }
.preview-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; min-height: 0; }
.preview-stage img { max-width: 100%; max-height: calc(100vh - 130px); box-shadow: 0 30px 90px rgba(0,0,0,.6); background: #000; }
.preview-stage.actual { overflow: auto; align-items: flex-start; justify-content: flex-start; }
.preview-stage.actual img { max-width: none; max-height: none; }
.preview-loading { color: #9a9a9a; display: flex; align-items: center; gap: .6rem; }
.btn-on-dark { --bs-btn-color: #e6ecee; --bs-btn-border-color: rgba(255,255,255,.22); --bs-btn-hover-bg: rgba(255,255,255,.1); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: rgba(255,255,255,.35); }

/* ---------- Editor de template ---------- */
.tpl-zone { position: absolute; border: 1px solid rgba(255,255,255,.55); background: rgba(255,255,255,.08); color: rgba(255,255,255,.85); font-size: .72rem; display: flex; align-items: center; justify-content: center; text-align: center; cursor: move; overflow: hidden; }
.tpl-zone.info { border-style: dashed; background: rgba(69,196,134,.06); }
.tpl-zone.logo { border-style: dotted; background: rgba(255,255,255,.04); }
.logo-zone { overflow: hidden; }
.logo-zone .logo-ph { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.6); font-size: .7rem; text-align: center; }
.logo-file-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem; background: var(--enamel); }
.logo-file-preview { height: 64px; background: #000 center/contain no-repeat; border-radius: 4px; margin-bottom: .4rem; }
.logo-file-preview:empty::after { content: "Nenhum arquivo"; display: grid; place-items: center; height: 100%; color: #aaa; font-size: .75rem; }
.tpl-zone.selected { border-color: var(--brand-on-dark); box-shadow: 0 0 0 1px var(--brand-on-dark); background: rgba(69,196,134,.16); z-index: 50 !important; }
.tpl-zone .tz-label { pointer-events: none; padding: 2px 4px; line-height: 1.25; }
.tpl-zone .tz-dims { position: absolute; bottom: 2px; right: 4px; font-size: .62rem; opacity: .65; font-variant-numeric: tabular-nums; pointer-events: none; }
.tpl-zone .handle { position: absolute; width: 11px; height: 11px; background: var(--brand-on-dark); border: 2px solid var(--table); border-radius: 2px; display: none; }
.tpl-zone.selected .handle { display: block; }
.handle.nw { left: -1px; top: -1px; cursor: nwse-resize; }
.handle.ne { right: -1px; top: -1px; cursor: nesw-resize; }
.handle.sw { left: -1px; bottom: -1px; cursor: nesw-resize; }
.handle.se { right: -1px; bottom: -1px; cursor: nwse-resize; }
.margin-guide { position: absolute; border: 1px dashed rgba(255,193,90,.45); pointer-events: none; }
.drag-readout { position: absolute; background: #000; color: #fff; font-size: .72rem; padding: 2px 7px; border-radius: 4px; pointer-events: none; font-variant-numeric: tabular-nums; z-index: 100; white-space: nowrap; }
.cm-input { font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .6rem; }
.color-field { display: flex; gap: .4rem; align-items: center; }
.color-field input[type=color] { width: 42px; height: 38px; padding: 3px; border-radius: 7px; border: 1px solid var(--line); background: #fff; }
.nav-tabs-slim { display: flex; border-bottom: 1px solid var(--line); padding: 0 1.25rem; gap: 1.2rem; }
.nav-tabs-slim button { border: 0; background: none; padding: .8rem 0; font-weight: 600; font-size: .88rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.nav-tabs-slim button.active { color: var(--ink); border-bottom-color: var(--brand); }

/* ---------- Erros ---------- */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.error-code { font-size: 4.5rem; font-weight: 700; letter-spacing: -0.04em; color: var(--line); line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- Logos (configurações) ---------- */
.logo-preview { height: 110px; border-radius: var(--radius); display: grid; place-items: center; border: 1px solid var(--line); overflow: hidden; }
.logo-preview img { max-height: 84%; max-width: 86%; object-fit: contain; }
.logo-preview.dark { background: #000; }
.logo-preview.light { background: var(--enamel); }

/* ---------- Responsivo ---------- */
@media (max-width: 1680px) {
  .editor-actions .lbl { display: none; }
  .editor-actions .btn:has(.lbl) { width: 40px; padding-left: 0; padding-right: 0; }
}
@media (max-width: 1100px) {
  .side-panel { width: 290px; flex-basis: 290px; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
}
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; --sidebar-w: 260px; }
  .sidebar-compact .sidebar { --sidebar-w: 260px; }
  .sidebar-compact .brand-text, .sidebar-compact .brand-logo, .sidebar-compact .nav-link-item span, .sidebar-compact .nav-heading { display: block; }
  .sidebar-compact .brand-emblem { display: none; }
  .sidebar-compact .nav-link-item { justify-content: flex-start; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.4); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1025; }
  .topbar { padding: 0 1rem; }
  .content { padding: 1.1rem; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .editor-body .main { height: auto; overflow: visible; }
  .editor-layout { flex-direction: column; }
  .light-table { height: calc(100vw * 0.72); flex: 0 0 auto; padding: 22px; }
  .editor-body .toast-stack { left: 20px; }
  .side-panel { width: 100%; flex-basis: auto; border-left: 0; border-top: 1px solid var(--line); }
  .timeline::before, .tl-item::after { display: none; }
  .tl-item { grid-template-columns: 1fr; gap: .4rem; }
  .tl-date { text-align: left; padding: 0; }
  .tl-date .d, .tl-date .y { display: inline; margin-right: .4rem; }
  .tl-card { grid-template-columns: 1fr; }
  .tl-actions { justify-content: flex-start; }
  .user-chip .who-text, .topbar .new-doc-label { display: none; }
}
@media (max-width: 560px) {
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 1.5rem; }
  .hide-sm { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Dados complementares do paciente / documentos clínicos ---------- */
.complement-box summary { cursor: pointer; list-style: none; }
.complement-box summary::-webkit-details-marker { display: none; }
.complement-box summary::after { content: "\F282"; font-family: bootstrap-icons; float: right; transition: transform .15s; }
.complement-box[open] summary::after { transform: rotate(180deg); }
.complement-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); border-bottom: 1px solid var(--line-soft); padding-bottom: .25rem; margin-top: .25rem; }
.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.doc-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.doc-card-head { display: flex; align-items: center; gap: .55rem; }
.doc-card-head i { color: var(--brand); font-size: 1.35rem; }
.doc-card h2 { font-size: .98rem; margin: 0; letter-spacing: .03em; }
.doc-card .doc-status { align-self: flex-start; }
.doc-meta { font-size: .78rem; color: var(--muted); margin: 0; }
.doc-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: auto; }
.doc-photo-preview { width: 96px; height: 120px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; place-items: center; overflow: hidden; flex: 0 0 auto; background: #fff; }
.doc-photo-preview img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.doc-form-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.doc-toolbar { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.doc-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.doc-tabs a { padding: .5rem .85rem; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 600; font-size: .9rem; }
.doc-tabs a.active { color: var(--brand-strong); border-bottom-color: var(--brand); }
.doc-header-card .doc-head-grid { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; font-size: .9rem; }
.doc-head-grid em { font-style: normal; color: var(--muted); font-size: .78rem; margin-right: .25rem; }
.doc-diff { max-width: 420px; background: var(--amber-tint); border-radius: var(--radius); padding: .6rem .8rem; }
.doc-label { font-size: .8rem; margin-bottom: .2rem; }
.doc-checklist { display: grid; gap: .25rem 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 768px) {
  .doc-checklist.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-checklist.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.doc-checklist-col { display: flex; flex-direction: column; min-width: 0; }
.doc-cl-head { font-size: .74rem; font-weight: 700; letter-spacing: .02em; color: var(--brand, #017d3f); margin: .55rem 0 .1rem; }
.doc-cl-head:first-child { margin-top: 0; }
.doc-cl-opt { display: flex; align-items: center; gap: .4rem; min-height: 1.9rem; }
.doc-cl-opt .form-check-input { margin: 0; flex: none; }
.doc-cl-opt label { font-size: .88rem; white-space: nowrap; cursor: pointer; }
.doc-cl-text { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.doc-cl-fill { min-width: 2.5rem; flex-basis: 0; height: 1.65rem; padding: .1rem .4rem; }
.doc-table th, .doc-grid th { font-size: .78rem; color: var(--muted); font-weight: 600; }
.doc-table td { padding: .2rem .25rem; }
.doc-auto { font-weight: 600; }
.doc-page-break { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; margin: 1.2rem 0 .8rem; }
.doc-page-break::before, .doc-page-break::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.doc-viewer { height: calc(100vh - 230px); min-height: 520px; overflow: hidden; }
.doc-viewer iframe { width: 100%; height: 100%; border: 0; display: block; }
.doc-form .form-check-input { border-color: #8a8a8a; }
