/* =====================================================================
   Gestão de Saúde Ocupacional — ESTILO BASE (cores, fontes, layout, menu)
   Identidade visual: laranja (destaque), branco (fundo),
   cinza-claro (áreas secundárias), cinza-escuro (texto e navegação).
   ===================================================================== */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('../assets/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('../assets/fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('../assets/fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('../assets/fonts/inter-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 800; font-display: swap; src: url('../assets/fonts/inter-latin-800-normal.woff2') format('woff2'); }

:root {
  --o-50: #FFF5EE; --o-100: #FFE7D6; --o-200: #FFCBA6; --o-400: #F7894A; --o-500: #F26A1B; --o-600: #D9570C; --o-700: #B4460A;
  --g-950: #15181C; --g-900: #1F2328; --g-850: #262A30; --g-800: #2E333A; --g-700: #3D434B; --g-600: #565D66; --g-500: #6B7280;
  --g-400: #9CA3AF; --g-300: #D3D7DD; --g-200: #E6E8EB; --g-150: #EDEEF1; --g-100: #F3F4F6; --g-50: #F8F9FA; --white: #FFFFFF;
  --ok: #16A34A; --ok-bg: #EBF9F0; --ok-tx: #157F3D;
  --warn: #D97706; --warn-bg: #FFF6E5; --warn-tx: #A14D04;
  --danger: #DC2626; --danger-bg: #FEF1F1; --danger-tx: #B42318;
  --info: #2563EB; --info-bg: #EEF4FF; --info-tx: #1D4ED8;
  --purple: #7C3AED; --teal: #0D9488;
  --bg: var(--white); --surface: var(--white); --surface-2: var(--g-50); --line: var(--g-200); --line-2: var(--g-150);
  --text: var(--g-900); --text-2: var(--g-600); --text-3: var(--g-500);
  --accent: var(--o-500); --accent-hover: var(--o-600); --accent-soft: var(--o-50);
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-2: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .06);
  --sh-3: 0 12px 40px rgba(16, 24, 40, .16);
  --side-w: 264px; --side-w-c: 74px; --top-h: 64px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--g-50); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; color: var(--g-900); }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
h4 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
a { color: var(--o-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; background: var(--g-100); padding: 1px 6px; border-radius: 6px; color: var(--g-700); }
:focus-visible { outline: 2px solid var(--o-400); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.mt { margin-top: 10px; }
.ic { width: 18px; height: 18px; flex: none; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { padding: 40px; text-align: center; }

/* ---------------- Layout do aplicativo ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--g-900); color: #C9CDD3;
  display: flex; flex-direction: column; z-index: 40; transition: width .2s var(--ease), transform .25s var(--ease);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 16px 18px; height: var(--top-h); border-bottom: 1px solid rgba(255, 255, 255, .06); color: #fff; text-decoration: none !important; }
.brand img { border-radius: 9px; flex: none; }
.brand-t { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; overflow: hidden; }
.brand-t b { font-size: 15.5px; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.brand-t small { font-size: 11.5px; color: #8D939B; }
.menu { flex: 1; overflow-y: auto; padding: 10px 10px 20px; scrollbar-width: thin; scrollbar-color: #3a3f46 transparent; }
.menu-group { margin-top: 6px; }
.menu-group-t {
  width: 100%; display: flex; align-items: center; justify-content: space-between; background: none; border: 0;
  color: #7E848C; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 10px 10px 6px;
}
.menu-group-t .ic { width: 14px; height: 14px; transition: transform .2s; }
.menu-group.closed .menu-group-t .ic { transform: rotate(-90deg); }
.menu-group.closed .menu-items { display: none; }
.menu-item {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin: 1px 0; border-radius: 9px;
  color: #C3C8CF; font-weight: 500; font-size: 13.5px; text-decoration: none !important; white-space: nowrap;
}
.menu-item .ic { width: 18px; height: 18px; color: #8D939B; }
.menu-item span { overflow: hidden; text-overflow: ellipsis; }
.menu-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.menu-item.active { background: rgba(242, 106, 27, .14); color: #fff; }
.menu-item.active .ic { color: var(--o-500); }
.menu-item.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--o-500); }
.menu-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--o-500); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.side-conn { padding: 10px 12px 0; border-top: 1px solid rgba(255, 255, 255, .06); }
.side-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; border: 1px dashed rgba(255, 255, 255, .2); background: none; color: #C3C8CF; font-weight: 550; font-size: 13px; white-space: nowrap; overflow: hidden; }
.side-btn .ic { color: var(--o-400); }
.side-btn:hover { background: rgba(255, 255, 255, .05); color: #fff; border-color: var(--o-500); }
.side-foot { padding: 12px 18px 16px; font-size: 11.5px; color: #7E848C; border-top: 1px solid rgba(255, 255, 255, .06); white-space: nowrap; overflow: hidden; }
.side-foot a { color: var(--o-400); }
.menu-scrim { display: none; }

.main { flex: 1; min-width: 0; margin-left: var(--side-w); display: flex; flex-direction: column; transition: margin .2s var(--ease); }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 14px; padding: 0 22px;
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(160%) blur(8px); border-bottom: 1px solid var(--line);
}
.crumb { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.crumb h2 { font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-name { font-size: 11.5px; color: var(--text-3); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-name:empty { display: none; }
.conn { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.view { flex: 1; padding: 24px 26px 60px; outline: none; }
.page { max-width: 1440px; margin: 0 auto; animation: fadeUp .22s var(--ease); }
body.booting .page { visibility: hidden; }
body.leaving .view { opacity: .55; pointer-events: none; transition: opacity .15s; }
.app-foot { padding: 14px 26px 22px; text-align: center; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--line); background: #fff; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-3); padding: 40px; justify-content: center; }

/* Menu recolhido (desktop) */
body.menu-collapsed .sidebar { width: var(--side-w-c); }
body.menu-collapsed .main { margin-left: var(--side-w-c); }
body.menu-collapsed .brand-t, body.menu-collapsed .menu-item span, body.menu-collapsed .menu-group-t span, body.menu-collapsed .side-foot, body.menu-collapsed .side-btn span { display: none; }
body.menu-collapsed .side-btn { justify-content: center; padding: 9px 0; }
body.menu-collapsed .menu-group-t { justify-content: center; padding: 8px 0 4px; }
body.menu-collapsed .menu-group-t .ic { display: none; }
body.menu-collapsed .menu-group-t::before { content: ''; display: block; width: 22px; height: 1px; background: rgba(255, 255, 255, .1); }
body.menu-collapsed .menu-group.closed .menu-items { display: block; }
body.menu-collapsed .menu-item { justify-content: center; padding: 10px 0; }
body.menu-collapsed .menu-badge { position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
body.menu-collapsed .brand { justify-content: center; padding: 16px 0; }

/* ---------------- Boas-vindas ---------------- */
.welcome {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #FFE7D6 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #EDEEF1 0%, transparent 60%), var(--white);
}
.welcome-card { width: min(780px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--sh-3); padding: 36px 38px 26px; }
.welcome-brand { display: flex; align-items: center; gap: 16px; }
.welcome-brand img { border-radius: 14px; box-shadow: 0 6px 18px rgba(242, 106, 27, .3); }
.welcome-brand h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.welcome-brand p { color: var(--text-3); font-weight: 500; }
.welcome-lead { margin: 18px 0 22px; color: var(--text-2); font-size: 15px; max-width: 640px; }
.welcome-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.big-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 20px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--g-50); transition: transform .15s var(--ease), box-shadow .15s, border-color .15s;
}
.big-btn .ic { width: 28px; height: 28px; color: var(--g-700); margin-bottom: 6px; }
.big-btn b { font-size: 16px; font-weight: 700; }
.big-btn span { color: var(--text-2); font-size: 13px; }
.big-btn:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--g-300); }
.big-btn.primary { background: var(--o-500); border-color: var(--o-500); color: #fff; }
.big-btn.primary .ic, .big-btn.primary span { color: rgba(255, 255, 255, .92); }
.big-btn.primary:hover { background: var(--o-600); border-color: var(--o-600); }
.resume {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px 16px; margin-bottom: 14px;
  border-radius: 14px; border: 1.5px solid var(--o-200); background: var(--o-50); color: var(--g-900);
}
.resume > .ic:first-child { width: 24px; height: 24px; color: var(--o-600); }
.resume div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.resume b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume span { font-size: 12.5px; color: var(--text-2); }
.resume:hover { border-color: var(--o-400); }
.welcome-note { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 11px 14px; border-radius: 12px; font-size: 13px; }
.welcome-note.ok { background: var(--ok-bg); color: var(--ok-tx); }
.welcome-note.warn { background: var(--warn-bg); color: var(--warn-tx); }
.welcome-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 12.5px; }
.welcome-foot > span { display: inline-flex; align-items: center; gap: 6px; }
.welcome-foot .ic { width: 15px; height: 15px; }
.welcome-credit { margin-top: 12px; font-size: 12px; color: var(--text-3); text-align: center; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--o-600); font-weight: 600; padding: 4px; }
.link-btn .ic { width: 16px; height: 16px; }

/* ---------------- Responsivo ---------------- */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); width: min(290px, 86vw); box-shadow: var(--sh-3); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .menu-scrim { display: block; position: fixed; inset: 0; background: rgba(15, 18, 22, .45); z-index: 35; }
  .main, body.menu-collapsed .main { margin-left: 0; }
  body.menu-collapsed .sidebar { width: min(290px, 86vw); }
  body.menu-collapsed .brand-t, body.menu-collapsed .menu-item span, body.menu-collapsed .menu-group-t span, body.menu-collapsed .side-foot { display: revert; }
  .topbar { padding: 0 12px; gap: 8px; }
  .view { padding: 16px 16px 60px; }
  .conn-file { display: none !important; }
  #btn-info { display: none; }
  .top-backup span { display: none; }
  .top-backup { width: 38px; padding: 0; }
}
@media (max-width: 640px) {
  .welcome-card { padding: 24px 18px 18px; border-radius: 18px; }
  .welcome-actions { grid-template-columns: 1fr; }
  .welcome-brand h1 { font-size: 23px; }
  .conn .conn-text { display: none; }
  .crumb h2 { font-size: 15px; }
}


/* ---------------- Abertura da base (sobre a página) ---------------- */
.boot-overlay { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1000px 520px at 10% -10%, #FFE7D6 0%, transparent 60%), rgba(248, 249, 250, .97); }
.boot-card { width: min(520px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--sh-3); padding: 30px 30px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.boot-card img { border-radius: 14px; box-shadow: 0 6px 18px rgba(242, 106, 27, .28); }
.boot-card h2 { font-size: 20px; font-weight: 750; }
.boot-card p { color: var(--text-2); }
.boot-card .resume { margin: 6px 0 0; }
.boot-links a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.boot-links .ic { width: 16px; height: 16px; }
.boot-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.loading-card { padding: 34px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--o-100); border-top-color: var(--o-500); animation: spin .8s linear infinite; }

/* ---------------- Lembrete de backup ---------------- */
.reminder { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 1440px; margin: 0 auto 16px; padding: 12px 16px; border-radius: 14px; background: var(--o-50); border: 1.5px solid var(--o-200); color: var(--g-900); }
.reminder > .ic { width: 26px; height: 26px; color: var(--o-600); flex: none; }
.reminder > div { flex: 1 1 280px; display: flex; flex-direction: column; }
.reminder > div > b { font-weight: 700; }
.reminder > div > span { font-size: 13px; color: var(--text-2); }

/* ---------------- Tela inicial (index.html) ---------------- */
.welcome { min-height: 100vh; }
.welcome-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.welcome-steps div { background: var(--g-50); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; color: var(--text-2); }
.welcome-steps b { display: block; color: var(--g-900); font-size: 13px; margin-bottom: 2px; }
@media (max-width: 640px) { .welcome-steps { grid-template-columns: 1fr; } }
.loading .spinner { width: 18px; height: 18px; border-width: 2px; }
.page-ic:empty { display: none; }

/* Escolha visual da base e saída */
#btn-exit { border: 1px solid var(--g-300); white-space: nowrap; }
#btn-exit:hover { background: var(--o-50); border-color: var(--o-400); color: var(--o-700); }
.base-options .base-option { padding: 18px; gap: 10px; background: white; border: 1.5px solid #c7dccc; box-shadow: 0 3px 12px rgba(30,60,40,.06); }
.base-options .create-option { border-color: #efcfb6; }
.base-options .base-illustration { display: block; width: 100%; height: 130px; flex: none; }
.base-options .option-tag { align-self: flex-start; padding: 4px 8px; border-radius: 6px; background: #e6f5ed; color: #216747; font-size: 10px; font-weight: 750; letter-spacing: .05em; }
.base-options .create-option .option-tag { background: #fff0e4; color: #a5470e; }
.base-options .base-option b { font-size: 20px; line-height: 1.25; }
.base-options .option-description { font-size: 13px; line-height: 1.6; color: var(--g-700); }
.base-options .option-example { font-size: 12px; line-height: 1.5; color: var(--g-500); margin-bottom: 6px; }
.base-options .option-cta { margin-top: auto; width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 9px; background: #237750; color: white; font-weight: 650; font-size: 13px; }
.base-options .create-option .option-cta { background: #c45112; }
.base-options .option-cta .ic { width: 18px; height: 18px; margin: 0; color: white; }
.base-options .access-option:hover { border-color: #237750; }
.base-options .create-option:hover { border-color: #c45112; }
.welcome-exit { margin-bottom: 14px; padding: 12px 14px; border-radius: 10px; background: #e6f5ed; color: #216747; font-size: 13px; }
@media (max-width: 640px) { .base-options .base-illustration { height: 110px; } #btn-exit { padding: 6px 8px; } }
