/* =========================================================
   Portal de Exames · Visum Oftalmologia
   Cores do logo: azul #053782 e vinho #572029
   Fonte: Inter (hospedada no próprio portal, licença OFL)
   ========================================================= */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --azul: #053782;
  --azul-escuro: #032a66;
  --azul-claro: #f0f4fa;
  --vinho: #572029;
  --vinho-claro: #f8f0f1;

  --bg: #fafbfc;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7486;
  --line: #eceff3;
  --line-strong: #dde2e9;

  --ok-bg: #eef7f1; --ok: #1d6640;
  --err-bg: var(--vinho-claro); --err: var(--vinho);
  --warn-bg: #fdf7e8; --warn: #7a5600;

  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.6; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 1.6rem; margin: 0 0 .3em; color: var(--text); font-weight: 600; letter-spacing: -.02em; line-height: 1.25; }
h2 { font-size: 1rem; margin: 0 0 1.1em; color: var(--text); font-weight: 600; letter-spacing: -.01em; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 40px; padding-bottom: 56px; min-height: 70vh; }

/* ---------- Cabeçalho ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; padding-top: 16px; padding-bottom: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand:hover { text-decoration: none; }
.brand img { height: 34px; width: auto; display: block; }
.brand-label { font-size: .78rem; font-weight: 500; color: var(--muted); padding-left: 14px; border-left: 1px solid var(--line-strong); }
body.equipe .brand-label { color: var(--vinho); }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav .link { color: var(--muted); font-size: .9rem; font-weight: 500; padding: 6px 12px; border-radius: 8px; text-decoration: none; }
.nav a:hover, .nav .link:hover { color: var(--azul); background: var(--azul-claro); text-decoration: none; }
.nav .muted { font-size: .85rem; padding: 0 8px; }
.nav form { margin: 0; }

/* ---------- Cartões e layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; margin-bottom: 20px; }
.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row form { margin: 0; }
.between { justify-content: space-between; align-items: flex-start; }
.grid2, .grid3 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: 1fr 1fr 1.4fr; } }

/* ---------- Telas de login ---------- */
.auth { padding-top: 32px; }
.auth .card { border: 0; background: transparent; padding: 0; }
.auth-logo { display: block; width: 160px; max-width: 60%; height: auto; margin: 0 auto 36px; }
.auth h1 { text-align: center; font-size: 1.45rem; }
.auth .lead { text-align: center; margin: 0 0 28px; }
.help { margin-top: 24px; color: var(--muted); font-size: .85rem; text-align: center; }

/* ---------- Formulários ---------- */
label { display: block; margin-bottom: 18px; font-weight: 500; font-size: .85rem; color: var(--text); }
label small { display: block; font-weight: 400; color: var(--muted); margin-top: 6px; font-size: .8rem; }
input[type=text], input:not([type]), input[type=password], input[type=email], input[type=date], input[type=file] {
  display: block; width: 100%; margin-top: 6px; padding: 11px 14px; font: inherit; font-size: .95rem; font-weight: 400;
  border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #a3aab7; }
input:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(5, 55, 130, .1); }
input[type=file] { padding: 8px; font-size: .85rem; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .88rem; color: var(--muted); }
.check input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--azul); }

/* ---------- Botões ---------- */
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--azul);
  background: var(--azul); color: #fff; font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer;
  text-align: center; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--azul-escuro); border-color: var(--azul-escuro); color: #fff; text-decoration: none; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--azul-claro); color: var(--azul); border-color: var(--azul-claro); }
.btn.block { width: 100%; padding: 12px; font-size: .95rem; margin-top: 4px; }
.btn:focus-visible, .link:focus-visible, .nav a:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--azul); cursor: pointer; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: var(--vinho); font-size: .85rem; }

/* ---------- Textos e avisos ---------- */
.muted { color: var(--muted); }
.small { font-size: .83rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.big { font-size: 1.4rem; letter-spacing: .1em; color: var(--azul); }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: .9rem; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.note { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 8px; font-size: .88rem; }
.tag { display: inline-block; font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--vinho-claro); color: var(--vinho); letter-spacing: .02em; }
.tag.off { background: #f1f3f6; color: var(--muted); }

/* ---------- Busca e tabelas (equipe) ---------- */
.search { display: flex; gap: 8px; margin: 8px 0 20px; }
.search input { margin: 0; }
.table-wrap { overflow-x: auto; padding: 8px 20px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 14px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .75rem; font-weight: 500; color: var(--muted); }
td form { margin: 0; }

/* ---------- Exames (paciente) ---------- */
.page-head { margin-bottom: 28px; }
.page-head p { margin: 0; }
.exam-list { list-style: none; padding: 0; margin: 0 0 24px; }
.exam-head { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; font-weight: 600; }
.exam-head strong { font-weight: 600; }
.exam-list .muted { font-size: .88rem; }
.exam-list p.small { margin: 8px 0 0; color: var(--muted); }
.empty { text-align: center; padding: 48px 24px; }
.empty-icon { width: 48px; height: 48px; margin: 0 auto 16px; border-radius: 50%; background: var(--azul-claro); position: relative; }
.empty-icon::before { content: ""; position: absolute; inset: 15px 9px; border: 2px solid var(--azul); border-radius: 50% / 60%; }
.empty-icon::after { content: ""; position: absolute; width: 8px; height: 8px; left: 20px; top: 20px; border-radius: 50%; background: var(--vinho); }

/* ---------- Arquivos (imagens e PDFs) ---------- */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; margin-top: 18px; }
.file { display: flex; flex-direction: column; gap: 8px; color: var(--text); min-width: 0; }
a.file:hover { text-decoration: none; }
.file img, .file .pdf { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: #0b1626; display: block; transition: opacity .15s; }
.file a:hover img, a.file:hover img, .file a:hover .pdf, a.file:hover .pdf { opacity: .88; }
.file .pdf { display: grid; place-items: center; background: var(--azul-claro); color: var(--azul); font-size: .8rem; font-weight: 600; letter-spacing: .08em; }
.file .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.file-preview { display: block; }
.file-preview:hover { text-decoration: none; }
.file-actions { display: flex; gap: 16px; font-size: .85rem; font-weight: 500; }
.staff-exam { padding: 20px 0; border-top: 1px solid var(--line); }
.staff-exam:first-of-type { border-top: 0; padding-top: 0; }

/* ---------- Credencial impressa ---------- */
.credential { border: 1px dashed var(--azul); background: var(--azul-claro); }
.credential-logo { height: 30px; width: auto; display: none; margin-bottom: 12px; }
.credential dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; }
.credential dt { color: var(--muted); font-size: .9rem; }
.credential dd { margin: 0; font-weight: 500; word-break: break-all; }

/* ---------- Diversos ---------- */
.prose { line-height: 1.7; }
.prose h2 { margin-top: 1.6em; margin-bottom: .4em; }
.footer { color: var(--muted); font-size: .8rem; padding-top: 24px; padding-bottom: 32px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.footer img { height: 18px; width: auto; opacity: .6; }
.footer a { margin-left: auto; color: var(--muted); }

@media (max-width: 560px) {
  body { font-size: 15px; }
  main.wrap { padding-top: 28px; }
  .brand img { height: 28px; }
  .brand-label { font-size: .72rem; padding-left: 10px; }
  .topbar-inner { padding-top: 12px; padding-bottom: 8px; }
  .nav { margin-left: -12px; }
  h1 { font-size: 1.35rem; }
  .card { padding: 20px; }
}

@media print {
  body * { visibility: hidden; }
  #credencial, #credencial * { visibility: visible; }
  #credencial { position: absolute; top: 0; left: 0; width: 100%; border: 1px solid #000; background: #fff; }
  .credential-logo { display: block; }
  .no-print { display: none; }
}

/* ---------- Usuários da equipe ---------- */
select { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font: inherit; font-size: .9rem; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--text); }
select:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(5, 55, 130, .1); }
details.actions summary { list-style: none; font-size: .85rem; }
details.actions summary::-webkit-details-marker { display: none; }
details.actions[open] { min-width: 260px; }
details.actions form { margin-top: 10px; }
.inline-form { display: flex; gap: 6px; }
.inline-form input { margin: 0; padding: 8px 10px; font-size: .85rem; }
.inline-form .btn { padding: 8px 12px; font-size: .8rem; white-space: nowrap; }
