/* Interface inicial PIV: conserva cabeçalho preto, menu escuro e conteúdo branco. */
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; }
body, input, button { font-family: "Segoe UI", Arial, Helvetica, sans-serif; }
button, input { font-size: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #559fe1; outline-offset: 3px; }

/* Login: formulário simples, centrado, como no projeto original. */
.auth-page {
    min-height: 100vh; min-height: 100dvh; padding: 28px 18px;
    display: flex; align-items: center; justify-content: center;
    background: #f5f5f5; color: #18212c;
}
.auth-box { width: 430px; max-width: 100%; padding: 40px; background: #fff; border-radius: 10px; box-shadow: 0 0 20px rgba(0,0,0,.10); }
.auth-eyebrow { font-size: 10px; font-weight: 700; color: #697585; letter-spacing: 1.6px; line-height: 1.6; }
.auth-box h1 { font-size: 28px; line-height: 1.25; font-weight: 650; margin: 15px 0 12px; }
.auth-description { color: #596573; font-size: 14px; line-height: 1.65; margin: 0 0 25px; overflow-wrap: anywhere; }
.auth-form { display: flex; flex-direction: column; }
.auth-form label { margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.auth-form input:not([type="hidden"]) { width: 100%; height: 46px; padding: 10px 12px; border: 1px solid #cbd2da; border-radius: 5px; color: #18212c; background: #fff; }
.auth-form input::placeholder { color: #8892a0; }
.primary-button { border: 0; border-radius: 5px; background: #23354d; color: #fff; height: 46px; margin-top: 18px; font-weight: 600; }
.primary-button:hover { background: #304967; }
.auth-form .code-input { font-size: 25px; text-align: center; letter-spacing: 8px; }
.auth-note { font-size: 12px; line-height: 1.6; color: #727c89; text-align: center; margin: 23px 0 0; }
.auth-back { display: block; margin-top: 18px; font-size: 13px; text-align: center; color: #294c70; text-underline-offset: 3px; }
.error, .notice { padding: 12px 14px; border-radius: 5px; font-size: 13px; line-height: 1.5; margin: 0 0 18px; }
.error { color: #982727; background: #fff1f1; border: 1px solid #f1d1d1; }
.notice { color: #3d566d; background: #f0f6fc; border: 1px solid #d7e6f3; }

/* Estrutura exterior. */
.portal-page { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; background: #0f1117; }
.app { width: 100%; height: 100%; display: flex; flex-direction: column; }
.header { flex: 0 0 120px; min-height: 120px; background: #000; border-bottom: 1px solid #222; display: flex; align-items: center; padding: 0 30px 0 10px; gap: 18px; }
.brand-link { flex: 0 0 auto; display: flex; align-items: center; }
.app-logo { display: block; height: 118px; width: 177px; object-fit: contain; }
#theme-container { flex: 1; min-width: 0; text-align: right; }
#theme-title { color: #fff; font-size: 26px; font-weight: 700; line-height: 1.2; }
#theme-subtitle { color: #d6d9dd; font-size: 16px; margin-top: 8px; line-height: 1.45; }
.main { flex: 1; min-height: 0; display: flex; position: relative; overflow: hidden; }

/* Os dois artigos e a árvore de futuros subitens. */
.sidebar { flex: 0 0 320px; width: 320px; background: linear-gradient(90deg, #171923, #1a1f2d); border-right: 1px solid #2d3748; display: flex; flex-direction: column; min-height: 0; }
.sidebar-heading { flex-shrink: 0; padding: 27px 23px 16px; color: #9aa9bd; font-size: 10px; font-weight: 700; letter-spacing: 2px; }
.tree { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 20px; }
.tree-root, .tree-root ul { list-style: none; margin: 0; padding: 0; }
.tree-item { margin: 0 0 6px; }
.node { display: flex; align-items: center; min-height: 48px; border-radius: 6px; border: 1px solid transparent; border-left: 3px solid transparent; transition: background .15s; padding: 0 10px 0 8px; }
.node:hover { background: #222c3e; }
.node.active { background: #25364c; border-color: #33465e; border-left-color: #6facde; }
.tree .title { display: block; flex: 1; min-width: 0; padding: 13px 0; text-decoration: none; color: #f8fafc; font-size: 14px; line-height: 1.4; font-weight: 500; overflow-wrap: anywhere; }
.tree-leaf, .tree-toggle { flex: 0 0 26px; width: 26px; height: 30px; display: flex; align-items: center; justify-content: flex-start; color: #98a9bf; margin-right: 4px; }
.tree-leaf svg { width: 18px; height: 18px; }
.tree-toggle { background: transparent; border: 0; padding: 0; border-radius: 3px; }
.tree-toggle svg { width: 15px; height: 15px; transition: transform .15s; }
.tree-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.tree-root .tree-children { margin: 5px 0 8px 22px; padding: 0 0 0 10px; border-left: 1px solid #3b4a60; }
.tree-children .title { font-size: 13px; }
.tree-children .node { min-height: 40px; padding-left: 5px; }
.sidebar-session { flex-shrink: 0; padding: 16px 22px; border-top: 1px solid #303949; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.session-label { display: flex; align-items: center; gap: 7px; font-size: 11px; color: #b3becd; }
.session-dot { width: 5px; height: 5px; border-radius: 50%; background: #81aaa0; }
.logout-button { border: 0; background: transparent; color: #d1d9e4; display: flex; align-items: center; gap: 5px; padding: 7px 3px; font-size: 12px; }
.logout-button:hover { color: #fff; }
.logout-button svg { width: 16px; height: 16px; }
.content { flex: 1; min-width: 0; background: #fff; overflow: hidden; }
.content iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.footer { flex: 0 0 32px; min-height: 32px; background: #000; border-top: 1px solid #222; display: flex; align-items: center; justify-content: center; color: #999; font-size: 12px; padding: 0 12px; text-align: center; }
.tree::-webkit-scrollbar { width: 6px; }
.tree::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.icon-button { width: 36px; height: 36px; align-items: center; justify-content: center; border: 1px solid #364152; border-radius: 5px; color: #d8e0eb; background: #171d28; padding: 7px; }
.icon-button svg { width: 20px; height: 20px; }
.menu-toggle { display: none; }
.sidebar-overlay { position: absolute; inset: 0; border: 0; background: rgba(10,16,25,.42); z-index: 2; }

/* Páginas vazias: apenas a área de trabalho inicial, sem dados ou funcionalidades. */
.workspace-page { min-height: 100vh; color: #223044; background: #fff; }
.workspace { min-height: 100vh; display: flex; flex-direction: column; padding: 42px 46px; }
.workspace-header { padding: 0 0 25px; border-bottom: 1px solid #e9edf2; }
.eyebrow { font-size: 10px; color: #718094; font-weight: 700; letter-spacing: 1.8px; line-height: 1.5; margin: 0 0 11px; }
.workspace h1 { font-size: 28px; font-weight: 600; line-height: 1.3; margin: 0; letter-spacing: -.4px; }
.workspace-subtitle { color: #6e7a89; font-size: 14px; line-height: 1.6; margin: 12px 0 0; }
.workspace-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 55px 0 80px; }
.empty-state { text-align: center; max-width: 380px; margin: 0 auto; }
.empty-icon { display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; width: 76px; height: 76px; border: 1px solid #e4eaf1; background: #f7f9fc; border-radius: 16px; color: #7d93ad; }
.empty-icon svg { width: 38px; height: 38px; stroke-width: 1.5; }
.empty-state h2 { font-size: 18px; font-weight: 600; color: #3b4d63; line-height: 1.4; margin: 0 0 10px; }
.empty-state p { font-size: 14px; line-height: 1.7; color: #7a8696; margin: 0; }

@media (max-width: 1100px) {
    #theme-title { font-size: 22px; }
    #theme-subtitle { font-size: 13px; }
    .sidebar { flex-basis: 290px; width: 290px; }
    .workspace { padding: 34px 30px; }
}
@media (max-width: 800px) {
    .header { flex-basis: 92px; min-height: 92px; gap: 8px; padding: 0 15px; }
    .app-logo { height: 84px; width: 126px; }
    .menu-toggle { display: flex; flex: 0 0 36px; }
    #theme-title { font-size: 17px; }
    #theme-subtitle { font-size: 11px; margin-top: 5px; }
    .sidebar { position: absolute; inset: 0 auto 0 0; z-index: 3; width: min(320px, 88vw); transform: translateX(-100%); visibility: hidden; transition: transform .18s, visibility .18s; }
    .sidebar-open .sidebar { transform: translateX(0); visibility: visible; }
    .footer { font-size: 10px; }
    .workspace { padding: 28px 24px; }
    .workspace h1 { font-size: 25px; }
}
@media (max-width: 520px) {
    .header { gap: 10px; padding: 0 12px; }
    .app-logo { width: 75px; height: 66px; }
    #theme-title { font-size: 14px; line-height: 1.3; }
    #theme-subtitle { display: none; }
    .workspace { padding: 28px 22px; }
    .workspace-body { padding: 45px 0 70px; }
    .auth-box { padding: 30px 25px; }
    .auth-box h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
