/* ─────────────────────────────────────────────────────────────────
   EDURE Maintenance Manuals — app.css  (tema navy, padrão EDURE)
   ───────────────────────────────────────────────────────────────── */

:root {
  --primary:       #1a2e4a;
  --primary-light: #243d60;
  --primary-dark:  #111e30;
  --accent:        #2f6fd6;
  --accent-hover:  #285fb8;
  --bg:            #f0f3f7;
  --surface:       #ffffff;
  --border:        #dbe2ea;
  --text:          #1d2733;
  --muted:         #6b7785;
  --ok:            #1f9d57;
  --warn:          #c77f11;
  --danger:        #c0392b;
  --aviao:         #2f6fd6;
  --heli:          #7a4fd6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
a { color: var(--accent); }

/* ── Login ───────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 24px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
}
.login-card {
  background: var(--surface); border-radius: 18px; padding: 36px 32px;
  width: 100%; max-width: 380px; box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: fit-content; margin: 0 auto; padding: 12px 28px;
  background: #f5f5f5; border-radius: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.ll-edure { font-weight: 800; font-size: 24px; color: #1a2e4a; letter-spacing: -0.5px; }
.ll-fd    { font-weight: 400; font-size: 12px; color: #1a2e4a; letter-spacing: .3px; margin-top: 2px; }
.ll-app   { font-size: 11px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; margin-top: 4px; }
.login-version { text-align: center; margin-top: 20px; font-size: 12px; color: var(--muted); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .pw-wrap input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; font-size: 15px; background: #f7f9fc; color: var(--text);
}
.field input:focus, .pw-wrap input:focus { outline: none; border-color: var(--accent); background: #fff; }
.pw-wrap { position: relative; }
.pw-toggle { position: absolute; right: 4px; top: 0; bottom: 0; border: none; background: none; color: var(--muted); padding: 0 12px; cursor: pointer; }

.login-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 18px 0; font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.link-btn { display: block; margin: 14px auto 0; background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 10px; padding: 11px 16px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover:not(:disabled) { background: var(--accent); color: #fff; }
.btn-passkey { background: var(--primary); color: #fff; }
.btn-passkey:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 11px; font-size: 13px; }

/* ── App shell: sidebar (desktop) + topbar/bottom-nav (mobile) ────── */
#screen-app { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 232px; flex-shrink: 0; position: fixed; inset: 0 auto 0 0; height: 100vh;
  background: var(--primary); color: #fff; display: flex; flex-direction: column; z-index: 40;
}
.sidebar-header { padding: 18px 16px 10px; }
.sidebar-logo-card {
  background: #f5f5f5; border-radius: 14px; padding: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.28);
  display: flex; flex-direction: column; align-items: center;
}
.sidebar-nav { flex: 1; list-style: none; padding: 8px 10px; overflow-y: auto; }
.sidebar-nav li { margin: 2px 0; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px;
  color: rgba(255,255,255,.78); text-decoration: none; font-size: 14.5px; font-weight: 500; cursor: pointer;
}
.sidebar-link i { width: 20px; text-align: center; font-size: 15px; }
.sidebar-link:hover { background: rgba(255,255,255,.09); color: #fff; }
.sidebar-link.active { background: rgba(255,255,255,.1); color: #fff; }   /* padrão EDURE (= accounting) */
.sidebar-version { padding: 8px 18px; font-size: 11.5px; color: rgba(255,255,255,.45); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.1); font-size: 13.5px;
}
.sidebar-user .fa-circle-user { font-size: 22px; color: rgba(255,255,255,.7); }
.sidebar-user .u-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .u-logout {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; flex-shrink: 0;
}
.sidebar-user .u-logout:hover { background: rgba(255,255,255,.22); }

#main-content { flex: 1; min-width: 0; margin-left: 232px; }
#mobile-topbar { display: none; }
#mobile-nav { display: none; }
#mobile-sheet-overlay, #mobile-bottom-sheet { display: none; }
main#view { max-width: 1080px; margin: 0 auto; padding: 26px 26px 64px; }
/* CIV do tripulante usa largura total (tabela larga, sem scroll lateral). */
main#view.view-wide { max-width: 100%; }

/* Cabeçalho de página (título + voltar) */
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-header h2 { flex: 1; font-size: 22px; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.page-header h2 i { color: var(--accent); font-size: 19px; }
.ph-back {
  background: var(--border); border: none; color: var(--text);
  width: 36px; height: 36px; border-radius: 9px; cursor: pointer; font-size: 14px; flex-shrink: 0;
}
.ph-back:hover { background: #cdd6e0; }

@media (max-width: 860px) {
  .app-sidebar { display: none; }
  #main-content { margin-left: 0; }
  #mobile-topbar {
    display: flex; align-items: center; position: sticky; top: 0; z-index: 30;
    height: calc(48px + env(safe-area-inset-top, 0px));
    background: var(--primary); color: #fff;
    padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  #mobile-topbar .m-title { font-size: 16px; font-weight: 600; line-height: 1; display: flex; align-items: center; gap: 9px; }
  #mobile-topbar .m-title i { color: #8fb6f2; }
  main#view { max-width: 100%; padding: 16px 14px calc(98px + env(safe-area-inset-bottom, 0px)); }
  .page-header h2 { font-size: 19px; }
  /* Pílula flutuante translúcida (estilo iOS/IG) — mesma posição do Accounting.
     viewport-fit=cover aqui, então NÃO somar safe-area no bottom (subiria ~34px) */
  #mobile-nav {
    display: flex; position: fixed; z-index: 40;
    left: 12px; right: 12px; bottom: 20px;
    height: 58px; border-radius: 26px;
    background: rgba(26, 46, 74, 0.82);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,0.10);
    justify-content: space-around; align-items: center;
    padding-left: max(env(safe-area-inset-left, 0px), 6px);
    padding-right: max(env(safe-area-inset-right, 0px), 6px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.28);
  }
  .mobile-nav-item {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 6px 4px; background: none; border: none;
    color: rgba(255,255,255,0.55); font-size: 10px; font-weight: 600; letter-spacing: 0.01em; cursor: pointer;
  }
  .mobile-nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-nav-item i { font-size: 20px; }
  .mobile-nav-item.active { color: #fff; }

  /* Folha "Mais" */
  #mobile-sheet-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 300; opacity: 0; pointer-events: none; transition: opacity .2s; cursor: pointer; touch-action: none; }
  #mobile-sheet-overlay.open { opacity: 1; pointer-events: auto; }
  #mobile-bottom-sheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 301;
    background: var(--surface, #fff); border-radius: 20px 20px 0 0;
    padding: 8px 0 calc(16px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 24px rgba(0,0,0,.18);
    transform: translateY(100%); transition: transform .28s ease;
  }
  #mobile-bottom-sheet.open { transform: translateY(0); }
  #mobile-bottom-sheet { touch-action: none; }
  .sheet-handle { width: 40px; height: 4px; background: var(--border, #dde3ea); border-radius: 2px; margin: 10px auto 8px; }
  .sheet-item {
    display: flex; align-items: center; gap: 14px; width: 100%;
    padding: 14px 24px; background: none; border: none; text-align: left;
    font-size: 16px; color: var(--text, #1c2b3a); cursor: pointer; min-height: 44px; font-family: inherit;
  }
  .sheet-item i { width: 20px; color: var(--accent, #2e7dcf); font-size: 16px; }
  .sheet-item:active { background: var(--bg, #f5f8fc); }
  .sheet-divider { height: 1px; background: var(--border, #dde3ea); margin: 8px 24px; }
  .sheet-user { display: flex; align-items: center; gap: 12px; padding: 10px 24px; font-size: 14px; color: var(--muted, #6b7c93); }
  .sheet-logout, .sheet-logout i { color: var(--danger, #d9534f) !important; }
  .sheet-version { text-align: center; font-size: 12px; color: var(--muted, #6b7c93); padding: 6px 24px 2px; }
}

/* ── Painel (aeronaves) ──────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.search { flex: 1; position: relative; }
.search input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 10px 36px; font-size: 14px; background: #fff; }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.card { background: var(--surface); border-radius: 14px; box-shadow: 0 3px 14px rgba(0,0,0,.06); overflow: hidden; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th { text-align: left; background: #f4f7fb; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.tbl td { padding: 11px 12px; border-bottom: 1px solid #eef2f6; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr.clickable:hover { background: #f5f9ff; }
.pdf-yes { color: var(--ok); } .pdf-no { color: var(--border); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-warn { background: #fdf2dc; color: var(--warn); }

/* ── Abas Folhas | Voos (segmented) ──────────────────────────────── */
.seg-tabs { display: inline-flex; gap: 4px; background: var(--border); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.seg-tab { border: none; background: transparent; color: var(--muted); font-weight: 600; font-size: 13.5px; padding: 8px 16px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; font-family: inherit; }
.seg-tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.overlay { position: fixed; inset: 0; background: rgba(15,25,40,.55); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-sm { max-width: 380px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--muted); cursor: pointer; }
.modal-body { padding: 18px; }
.acct-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #eef2f6; }
.acct-row:last-child { border-bottom: none; }
.passkey-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: #f5f8fc; border-radius: 10px; margin-bottom: 8px; }
.passkey-name { font-weight: 600; } .passkey-date { font-size: 11.5px; color: var(--muted); }

/* ── Misc ────────────────────────────────────────────────────────── */
.page-title { font-size: 19px; font-weight: 700; color: var(--primary); margin-bottom: 14px; }
.alert { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.alert-erro { background: #fdecea; color: var(--danger); }
.alert-ok { background: #e7f6ee; color: var(--ok); }
.alert-warn { background: #fdf2dc; color: var(--warn); }
.tbl-empty, .muted { color: var(--muted); text-align: center; padding: 26px; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 36px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px); background: var(--primary); color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px; z-index: 90; opacity: 0; transition: transform .25s, opacity .25s; max-width: 90vw; }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.toast-err { background: var(--danger); }

/* ── Visualizador de PDF da folha (PDF.js — espelha o Accounting) ───────────── */
@media (max-width: 860px) { #toast { bottom: 94px; } }

/* ── Sobre / changelog ───────────────────────────────────────────── */
#changelog-text {
  white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--text); background: #f7f9fc; border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; max-height: 380px; overflow: auto; line-height: 1.5;
}


/* ═════════════════════════════════════════════════════════════════
   EDURE Maintenance Manuals — biblioteca (navegação + visualizador)
   ═════════════════════════════════════════════════════════════════ */
:root { --hl: rgba(255, 213, 0, .45); --hl-cur: rgba(255, 140, 0, .55); --pane: 340px; }

/* Sidebar recolhível (padrão Workspace: « / ») */
.sb-toggle { position: absolute; top: 14px; right: -12px; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--border); background: #fff; color: var(--primary); cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.15); z-index: 41; }
body.sb-collapsed .app-sidebar { width: 64px; }
body.sb-collapsed #main-content { margin-left: 64px; }
body.sb-collapsed .sidebar-header, body.sb-collapsed .sidebar-link span, body.sb-collapsed .sidebar-version,
body.sb-collapsed .sidebar-user .u-name, body.sb-collapsed .sidebar-user .fa-circle-user { display: none; }
body.sb-collapsed .sidebar-link { justify-content: center; padding: 11px 0; }
body.sb-collapsed .sidebar-user { justify-content: center; padding: 14px 0; }
body.sb-collapsed .sidebar-nav { padding-top: 50px; }
.sidebar-sep { height: 1px; background: rgba(255,255,255,.1); margin: 8px 6px; }

/* Biblioteca ocupa a altura toda */
main#view.view-lib { max-width: none; padding: 0; height: 100vh; }
.lib { display: flex; height: 100vh; min-height: 0; }
.lib-pane { width: var(--pane); flex-shrink: 0; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--border); }
.lib-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.pane-resize { width: 5px; cursor: col-resize; flex-shrink: 0; margin-left: -3px; z-index: 5; }
.pane-resize:hover, .pane-resize.drag { background: var(--accent); opacity: .35; }

/* Barra de busca do painel */
.pane-search { padding: 12px 12px 8px; border-bottom: 1px solid var(--border); }
.pane-search form { display: flex; gap: 6px; }
.pane-search .search input { padding-right: 34px; }
.pane-search .search .clr { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none;
  background: none; color: var(--muted); cursor: pointer; padding: 6px; left: auto; }
.btn-icon { width: 38px; height: 38px; padding: 0; flex-shrink: 0; border-radius: 10px; }
.rev-line { font-size: 11.5px; color: var(--muted); margin-top: 8px; display: flex; justify-content: space-between; gap: 8px; }
.rev-line b { color: var(--primary); }

.pane-tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--border); }
.pane-tab { flex: 1; border: none; background: none; padding: 9px 4px 10px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 6px; }
.pane-tab.active { color: var(--primary); border-bottom-color: var(--accent); }
.pane-tab .cnt { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 10.5px; }
.pane-body { flex: 1; overflow-y: auto; min-height: 0; padding: 6px 0 24px; overscroll-behavior: contain; }

/* Árvore */
.tree { list-style: none; }
.tree .tree { padding-left: 14px; }
.tn { display: flex; align-items: flex-start; gap: 6px; padding: 6px 10px 6px 8px; cursor: pointer; font-size: 13px;
  line-height: 1.35; border-radius: 8px; margin: 0 6px; color: var(--text); }
.tn:hover { background: #f1f5fb; }
/* Documento aberto: fundo na cor de destaque, texto branco, barra lateral. */
.tn.sel { background: var(--accent); color: #fff; font-weight: 600; box-shadow: inset 4px 0 0 var(--primary); }
.tn.sel:hover { background: var(--accent-hover); }
.tn.sel .ic, .tn.sel .ic.doc, .tn.sel .cnt, .tn.sel .chev, .tn.sel .lbl small { color: #fff; }
.tn.sel .rev-badge { background: rgba(255,255,255,.9); }
/* Caminho até ele (manual, capítulo, seção). */
.tn.path { color: var(--accent); font-weight: 600; }
.tn.path .ic { color: var(--accent); }
.tn .chev { width: 14px; flex-shrink: 0; color: var(--muted); font-size: 10px; margin-top: 4px; transition: transform .15s; }
.tn.open > .chev { transform: rotate(90deg); }
.tn .ic { width: 16px; flex-shrink: 0; text-align: center; color: var(--accent); margin-top: 2px; }
.tn .ic.doc { color: #9aa7b6; }
.tn .lbl { flex: 1; min-width: 0; word-break: break-word; }
.tn .lbl small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.tn .cnt { color: var(--muted); font-size: 11px; flex-shrink: 0; margin-top: 2px; }
.tn-man { font-weight: 600; padding-top: 9px; padding-bottom: 9px; }
.tn-man .lbl small { font-weight: 400; }
.tree-msg { padding: 10px 16px 10px 40px; color: var(--muted); font-size: 12.5px; }
.sec-head { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 16px 4px 38px; }

.man-chip { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .03em; padding: 1px 6px;
  border-radius: 5px; background: #e8eef7; color: var(--primary); vertical-align: 1px; }
.man-chip.AMM { background: #e3edfb; color: #1d4f9c; } .man-chip.FIM { background: #fde9e7; color: #a5341f; }
.man-chip.IPC { background: #e6f5ec; color: #17733f; } .man-chip.WDM { background: #f1e9fb; color: #6a35b5; }
.man-chip.SRM { background: #fdf1df; color: #9a5a07; } .man-chip.MPD { background: #e3f4f6; color: #0e6a76; }
.man-chip.ITEM, .man-chip.CPM, .man-chip.NEW { background: #eceff3; color: #4b5866; }
.rev-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px;
  background: #fff3cd; color: #8a6100; vertical-align: 1px; }
.rev-badge.new { background: #dff5e8; color: #17733f; }

/* Resultados */
.res-head { padding: 8px 14px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.res-filtros { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 14px 6px; }
.chip { font-size: 11px; background: #eef2f7; color: var(--text); border-radius: 12px; padding: 2px 9px; }
.res { padding: 10px 14px; border-bottom: 1px solid #eef2f6; cursor: pointer; }
.res:hover { background: #f5f9ff; }
.res.sel { background: #dce8fb; box-shadow: inset 4px 0 0 var(--accent); }
.res .r1 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.res .r1 .ref { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.res .r2 { font-weight: 600; font-size: 13px; color: var(--primary); margin: 3px 0 2px; line-height: 1.3; }
.res .r3 { font-size: 12px; color: #4b5866; line-height: 1.45; }
.res .r3 mark, .res-direto mark { background: var(--hl); color: inherit; border-radius: 2px; padding: 0 1px; }
.res-group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 12px 14px 4px; background: #f8fafc; border-bottom: 1px solid #eef2f6; }
.mais { display: block; margin: 12px auto; }

/* Busca avançada */
.adv { padding: 12px 14px 4px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.adv .field { margin-bottom: 9px; }
.adv .field > span { margin-bottom: 3px; font-size: 11.5px; }
.adv .field input, .adv .field select { padding: 8px 10px; font-size: 13px; border-radius: 8px; width: 100%;
  border: 1px solid var(--border); background: #fff; color: var(--text); font-family: inherit; }
.adv-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chk-grid { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 8px; cursor: pointer; user-select: none; }
.chk input { margin: 0; }
.chk:has(input:checked) { border-color: var(--accent); background: #eaf2fe; color: var(--primary); }
.adv-actions { display: flex; gap: 8px; margin: 10px 0 8px; }
.adv-actions .btn { flex: 1; }

/* Início (sem documento aberto) */
.home { padding: 28px 32px 60px; overflow-y: auto; height: 100%; }
.home h2 { color: var(--primary); font-size: 22px; margin-bottom: 4px; }
.home .sub { color: var(--muted); margin-bottom: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 26px; }
.tile { background: var(--surface); border-radius: 14px; padding: 14px 16px; box-shadow: 0 3px 14px rgba(0,0,0,.06);
  cursor: pointer; border: 1px solid transparent; }
.tile:hover { border-color: var(--accent); }
.tile .t1 { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary); }
.tile .t1 i { color: var(--accent); }
.tile .t2 { font-size: 12px; color: var(--muted); margin-top: 4px; }
.home-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.home-list .card { padding: 4px 0; }
.home-h { font-size: 13px; font-weight: 700; color: var(--primary); margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.home-h i { color: var(--accent); }

/* Visualizador */
.doc-head { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px 8px; }
.crumbs { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumbs a { color: var(--muted); cursor: pointer; text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { opacity: .5; }
.doc-line { display: flex; align-items: flex-start; gap: 10px; }
.doc-line .t { flex: 1; min-width: 0; }
.doc-line h2 { font-size: 16.5px; color: var(--primary); line-height: 1.3; }
.doc-line h2 .ref { color: var(--text); font-weight: 600; margin-right: 6px; font-variant-numeric: tabular-nums; }
.doc-meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.doc-acts { display: flex; gap: 6px; flex-shrink: 0; }
.doc-acts .btn { padding: 7px 10px; }
.btn.fav-on { color: #e0a100; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: #3c4043; color: #e8eaed; font-size: 12.5px; flex-wrap: wrap; }
.viewer-bar .grp { display: inline-flex; align-items: center; gap: 4px; }
.viewer-bar button { background: rgba(255,255,255,.1); border: none; color: #fff; border-radius: 7px; height: 28px; min-width: 30px;
  padding: 0 8px; cursor: pointer; font-size: 12.5px; font-family: inherit; }
.viewer-bar button:hover:not(:disabled) { background: rgba(255,255,255,.2); }
.viewer-bar button:disabled { opacity: .35; cursor: default; }
.viewer-bar button.on { background: var(--accent); }
.viewer-bar input { width: 46px; height: 28px; border-radius: 7px; border: none; text-align: center; font-size: 12.5px; }
.viewer-bar .spacer { flex: 1; }
.viewer-bar .occ { background: rgba(255, 213, 0, .18); border-radius: 8px; padding: 2px 4px 2px 10px; }
.viewer-wrap { flex: 1; min-height: 0; display: flex; position: relative; }
.viewer { flex: 1; overflow: auto; background: #525659; padding: 14px 0 40px; overscroll-behavior: contain; }
.pg { position: relative; margin: 0 auto 12px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.45); }
.pg canvas { display: block; width: 100%; height: 100%; }
.pg .lay { position: absolute; inset: 0; }
.pg .hl { position: absolute; background: var(--hl); mix-blend-mode: multiply; border-radius: 2px; pointer-events: none; }
.pg .hl.cur { background: var(--hl-cur); outline: 2px solid #ff8c00; }
.pg .lk { position: absolute; cursor: pointer; border-radius: 2px; }
.pg .lk:hover { background: rgba(47, 111, 214, .18); outline: 1px solid rgba(47,111,214,.6); }
.pg .pgno { position: absolute; right: -2px; bottom: -18px; font-size: 10.5px; color: #cfd3d7; }
.viewer-msg { color: #fff; text-align: center; padding: 60px 20px; }

/* Gaveta de referências */
.refs { width: 320px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; }
.refs h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 14px 14px 6px;
  display: flex; justify-content: space-between; align-items: center; }
.refs .ri { padding: 7px 14px; font-size: 12.5px; border-bottom: 1px solid #f0f3f7; cursor: pointer; line-height: 1.35; }
.refs .ri:hover { background: #f5f9ff; }
.refs .ri.off { color: var(--muted); cursor: default; }
.refs .ri.off:hover { background: none; }
.refs .ri b { font-variant-numeric: tabular-nums; }

/* Mobile: um painel por vez */
.m-back { display: none; }
@media (max-width: 860px) {
  main#view.view-lib { height: calc(100vh - 48px - env(safe-area-inset-top, 0px)); }
  .lib { height: 100%; }
  .lib-pane { width: 100%; border-right: none; padding-bottom: 90px; }
  .pane-resize { display: none; }
  .lib.has-doc .lib-pane { display: none; }
  .lib:not(.has-doc) .lib-main { display: none; }
  .m-back { display: inline-flex; }
  .home { display: none; }
  .refs { position: absolute; inset: 0; width: auto; z-index: 5; }
  .viewer { padding-bottom: 110px; }
  .home-cols { grid-template-columns: 1fr; }
  .doc-head { padding: 8px 12px; }
  .doc-line { flex-wrap: wrap; gap: 8px; }
  .doc-line .t { flex: 1 1 calc(100% - 52px); }
  .doc-line h2 { font-size: 15px; }
  .doc-acts { width: 100%; justify-content: flex-end; }
  .doc-acts .hist { display: none; }
  .crumbs { display: none; }
  .viewer-bar { gap: 6px; padding: 6px 8px; }
}

/* Ajuda (manual.html renderizado dentro do app) */
.help { max-width: 860px; }
.help section { background: var(--surface); border-radius: 14px; padding: 18px 22px; margin-bottom: 14px; box-shadow: 0 3px 14px rgba(0,0,0,.05); line-height: 1.6; }
.help h2 { color: var(--primary); font-size: 16.5px; margin: 0 0 8px; }
.help p { margin: 6px 0; }
.help ul { margin: 6px 0 6px 20px; }
.help li { margin: 4px 0; }
.help code { background: #eef2f7; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
