/* ============================================================
   RES_SYSTEM // Resistência — folha de estilos
   ============================================================ */

* { box-sizing: border-box; }

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000000;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: white;
}

#gridCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.muted { color: rgba(255,255,255,.45); }
.small { font-size: .8rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------------- App shell ---------------- */

#app {
    position: relative;
    z-index: 2;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-navbar {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 24px;
    background: rgba(11, 11, 30, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.btn-menu {
    background: transparent;
    border: none;
    width: 24px;
    height: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    padding: 0;
}

.btn-menu span {
    display: block;
    width: 100%;
    height: 1px;
    background-color: #ffffff;
}

.nav-logo {
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 3px;
    white-space: nowrap;
}

.nav-logo-with-icon {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-res {
    height: 34px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-item {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    letter-spacing: 1px;
    position: relative;
    padding: 6px 0;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.nav-item:hover { color: rgba(255, 255, 255, 0.9); }

.nav-item.active {
    color: #ffffff;
    font-weight: 500;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #00e5ff;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.nav-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,.2);
}

.nav-user .user-name {
    font-size: .82rem;
    color: rgba(255,255,255,.8);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------- Layout ---------------- */

.layout {
    flex: 1;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 22px 16px;
    background: rgba(8, 8, 20, 0.55);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.main-view {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 28px 32px 60px;
}

/* ---------------- Login ---------------- */

.login-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: rgba(10, 10, 26, 0.8);
    border: 1px solid rgba(0, 229, 255, 0.18);
    border-radius: 10px;
    padding: 34px 30px;
    box-shadow: 0 0 60px rgba(0, 229, 255, 0.08);
    backdrop-filter: blur(10px);
}

.login-logo {
    text-align: center;
    letter-spacing: 6px;
    font-size: .8rem;
    color: #00e5ff;
    margin-bottom: 8px;
}

.login-card h1 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: 4px;
    margin: 0 0 4px;
}

.login-sub {
    text-align: center;
    font-size: .8rem;
    color: rgba(255,255,255,.4);
    margin: 0 0 24px;
}

.login-card form { display: flex; flex-direction: column; gap: 14px; }

.login-hint {
    margin-top: 20px;
    text-align: center;
    font-size: .75rem;
    color: rgba(255,255,255,.35);
}

.login-hint code {
    color: #00e5ff;
    font-family: ui-monospace, Consolas, monospace;
}

/* Lista de contas existentes nesta base: ajuda a ver se a conta está aqui. */
.login-accounts {
    margin-top: 16px;
    color: rgba(255,255,255,.5);
}

.login-accounts strong {
    color: #00e5ff;
    font-weight: 400;
    font-family: ui-monospace, Consolas, monospace;
    letter-spacing: .5px;
}

.form-error {
    color: #ff6b81;
    font-size: .8rem;
    min-height: 1em;
}

/* ---------------- Formulários ---------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.field > span, .field-label {
    font-size: .72rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,.5);
}

.input, select.input, textarea.input {
    width: 100%;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.12);
    color: #fff;
    padding: 9px 12px;
    border-radius: 4px;
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.input:focus {
    border-color: rgba(0, 229, 255, .6);
    box-shadow: 0 0 0 2px rgba(0, 229, 255, .12);
}

select.input option { background: #0b0b1e; color: #fff; }

textarea.input { min-height: 120px; resize: vertical; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    color: rgba(255,255,255,.75);
}

.checkbox-row input { accent-color: #00e5ff; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 140px; }

.form-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---------------- Botões ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.14);
    color: #fff;
    padding: 9px 16px;
    border-radius: 4px;
    font-size: .85rem;
    letter-spacing: .5px;
    cursor: pointer;
    transition: all .2s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); }

.btn-primary {
    background: rgba(0, 229, 255, .14);
    border-color: rgba(0, 229, 255, .5);
    color: #8ff3ff;
}
.btn-primary:hover { background: rgba(0, 229, 255, .25); border-color: #00e5ff; }

.btn-danger {
    background: rgba(255, 70, 90, .1);
    border-color: rgba(255, 70, 90, .4);
    color: #ff8fa0;
}
.btn-danger:hover { background: rgba(255, 70, 90, .22); border-color: #ff465a; }

.btn-success {
    background: rgba(0, 255, 170, .1);
    border-color: rgba(0, 255, 170, .4);
    color: #7dffd4;
}
.btn-success:hover { background: rgba(0, 255, 170, .2); }

.btn-sm { padding: 5px 10px; font-size: .75rem; }

.btn-block { width: 100%; }

.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- Cards / grids ---------------- */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.card {
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    padding: 18px;
    transition: border-color .2s, transform .2s;
}

.card.hoverable { cursor: pointer; }
.card.hoverable:hover { border-color: rgba(0,229,255,.4); transform: translateY(-2px); }

.card h3 { margin: 0 0 6px; font-weight: 500; font-size: 1rem; letter-spacing: .5px; }

.stat-card { text-align: left; }

.stat-num {
    font-size: 2rem;
    font-weight: 300;
    color: #00e5ff;
    line-height: 1.1;
}

.stat-label {
    font-size: .72rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,.45);
}

.section-title {
    font-size: 1.15rem;
    font-weight: 400;
    letter-spacing: 1px;
    margin: 30px 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::before {
    content: '//';
    color: #00e5ff;
    font-family: ui-monospace, monospace;
    font-size: .85rem;
}

.panel {
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 18px;
}

.panel-title {
    font-size: .78rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,.5);
    margin: 0 0 12px;
}

/* ---------------- Badges ---------------- */

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: .68rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: 1px solid rgba(255,255,255,.2);
    color: rgba(255,255,255,.7);
}

.badge-combate { border-color: rgba(255,120,90,.6); color: #ff9d88; }
.badge-exploracao { border-color: rgba(0,229,255,.5); color: #7deeff; }
.badge-cargueira { border-color: rgba(255,210,90,.5); color: #ffe08a; }
.badge-admin { border-color: rgba(255,80,120,.5); color: #ff9db0; }
.badge-alert { border-color: rgba(255,70,90,.6); color: #ff8fa0; }
.badge-ok { border-color: rgba(0,255,170,.5); color: #7dffd4; }
.badge-pausado { border-color: rgba(255,210,90,.6); color: #ffe08a; }
.badge-morto { border-color: rgba(255,70,90,.7); color: #ff5c70; }

/* ---------------- Barras ---------------- */

.bar-block { margin-bottom: 14px; }

.bar-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 5px;
}

.bar-name {
    font-size: .72rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,.55);
}

.bar-value { font-size: .8rem; font-family: ui-monospace, monospace; color: rgba(255,255,255,.85); }

.bar {
    height: 16px;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    width: 0%;
    transition: width .5s ease;
    border-radius: 2px 0 0 2px;
}

.fill-energia, .fill-energy { background: linear-gradient(90deg, #d96b00, #ffb347); }
.fill-combustivel { background: linear-gradient(90deg, #6a2bd9, #c79bff); }
.fill-escudo, .fill-shield { background: linear-gradient(90deg, #63d8ff, #bdeeff); }
.fill-vida { background: linear-gradient(90deg, #0a8a5f, #2ee6a0); }
.fill-hp { background: linear-gradient(90deg, #0a8a5f, #2ee6a0); }
.fill-oxygen { background: linear-gradient(90deg, #0e7490, #38e0ff); }
.fill-radiation { background: linear-gradient(90deg, #8a6d00, #ffe94a); }
.fill-weight { background: linear-gradient(90deg, #0a8a5f, #2ee6a0); }
.fill-weight.over { background: linear-gradient(90deg, #a3122b, #ff465a); }
.fill-mini { height: 6px; border-radius: 2px; }

/* Ajuste manual das barras (admin/Mestre) */
.bar-adjust {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.bar-adjust input[type="range"] {
    flex: 1;
    min-width: 0;
    accent-color: #00e5ff;
    height: 4px;
}
.bar-adjust input[type="number"] {
    width: 76px;
    padding: 4px 6px;
    font-size: .75rem;
}

.bar-mini {
    height: 6px;    background: rgba(255,255,255,.06);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}

/* ---------------- Sistemas passivos ---------------- */

.pips { display: inline-flex; gap: 3px; }

.pip {
    width: 11px;
    height: 15px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 2px;
}

.pip.on { background: #00e5ff; border-color: #00e5ff; box-shadow: 0 0 6px rgba(0,229,255,.5); }

.class-bom { color: #2ee6a0; }
.class-moderado { color: #ffe08a; }
.class-critico { color: #ff6b81; }

.sys-table { width: 100%; border-collapse: collapse; }

.sys-table th, .sys-table td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: .84rem;
    vertical-align: middle;
}

.sys-table th {
    font-size: .68rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
    font-weight: 500;
}

/* ---------------- Tabelas ---------------- */

.tbl { width: 100%; border-collapse: collapse; }

.tbl th, .tbl td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: .85rem;
    vertical-align: middle;
}

.tbl th {
    font-size: .68rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
    font-weight: 500;
}

.tbl tr:hover td { background: rgba(255,255,255,.02); }

/* ---------------- Sub abas ---------------- */

.subtabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.subtab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(255,255,255,.45);
    padding: 10px 14px;
    font-size: .85rem;
    letter-spacing: .5px;
    cursor: pointer;
    font-family: inherit;
}

.subtab:hover { color: #fff; }

.subtab.active {
    color: #fff;
    border-bottom-color: #00e5ff;
}

/* ---------------- Sidebar / árvore ---------------- */

.side-header {
    font-size: .7rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
    margin-bottom: 12px;
}

.side-nav { display: flex; flex-direction: column; gap: 4px; }

.side-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 4px;
    color: rgba(255,255,255,.55);
    text-decoration: none;
    font-size: .85rem;
    cursor: pointer;
    border: 1px solid transparent;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.side-link:hover { color: #fff; background: rgba(255,255,255,.04); }

.side-link.active {
    color: #fff;
    background: rgba(0,229,255,.08);
    border-color: rgba(0,229,255,.25);
}

.side-link .count {
    font-size: .7rem;
    color: rgba(255,255,255,.35);
    font-family: ui-monospace, monospace;
}

.tree { list-style: none; margin: 0; padding: 0; }

.tree ul { list-style: none; margin: 2px 0 2px 16px; padding: 0 0 0 10px; border-left: 1px solid rgba(255,255,255,.08); }

.tree-item { margin: 2px 0; }

.tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: .85rem;
    cursor: pointer;
    color: rgba(255,255,255,.6);
}

.tree-row:hover { background: rgba(255,255,255,.05); color: #fff; }

.tree-row.active { background: rgba(0,229,255,.1); color: #fff; }

.tree-toggle {
    width: 14px;
    text-align: center;
    font-size: .7rem;
    color: rgba(255,255,255,.4);
    flex-shrink: 0;
}

.side-section { margin-bottom: 24px; }

/* ---------------- Chat ---------------- */

.chat-box {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 2px 12px;
    min-height: 260px;
    max-height: 460px;
}

.chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: .85rem;
}

.chat-avatar {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    letter-spacing: .5px;
    color: rgba(0,229,255,.85);
    background: rgba(0,229,255,.08);
    border: 1px solid rgba(0,229,255,.28);
    overflow: hidden;
    user-select: none;
}

.chat-avatar-system {
    color: rgba(255,210,90,.9);
    background: rgba(255,210,90,.08);
    border-color: rgba(255,210,90,.28);
}

.chat-body { flex: 1; min-width: 0; }

.chat-msg .chat-meta {
    font-size: .68rem;
    color: rgba(255,255,255,.35);
    margin-bottom: 3px;
    letter-spacing: .5px;
}

.chat-text { overflow-wrap: anywhere; }

.chat-msg.system { border-color: rgba(255,210,90,.3); background: rgba(255,210,90,.05); }
.chat-msg.alert { border-color: rgba(255,70,90,.35); background: rgba(255,70,90,.06); }
.chat-msg.alert .chat-meta { color: #ff8fa0; }

.chat-input-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.chat-input-row .input { flex: 1; }
.chat-as { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.chat-as > span {
    font-size: .66rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,.45);
}
.chat-as select { width: auto; max-width: 190px; padding: 8px 10px; }

/* ---------------- Inventário ---------------- */

.inv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 92px);
    gap: 12px;
    margin-top: 16px;
}

.inv-cell {
    width: 92px;
    height: 92px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 6px;
    background: rgba(255,255,255,.03);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: default;
    overflow: hidden;
}

.inv-cell img { width: 100%; height: 100%; object-fit: cover; opacity: .85; }

.inv-qty {
    position: absolute;
    right: 4px;
    bottom: 4px;
    background: rgba(0,0,0,.8);
    border: 1px solid rgba(0,229,255,.5);
    color: #8ff3ff;
    font-size: .7rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-family: ui-monospace, monospace;
}

.inv-tooltip {
    position: absolute;
    inset: auto 0 0 0;
    background: rgba(0,0,0,.92);
    font-size: .68rem;
    text-align: center;
    padding: 5px 4px;
    color: rgba(255,255,255,.85);
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}

.inv-cell:hover .inv-tooltip { opacity: 1; }

/* ---------------- Entradas (Banco de Dados) ---------------- */

.entry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 200px);
    gap: 16px;
}

.entry-card {
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0,0,0,.4);
    cursor: pointer;
    transition: border-color .2s, transform .2s;
}

.entry-card:hover { border-color: rgba(0,229,255,.4); transform: scale(1.02); }

.entry-card img { width: 100%; height: 150px; object-fit: cover; opacity: .8; display: block; }

.entry-card-body { padding: 10px 12px; }

.entry-card-title { font-size: .88rem; color: rgba(255,255,255,.9); }

.entry-card-meta { font-size: .7rem; color: rgba(255,255,255,.4); margin-top: 4px; }

.entry-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.entry-head-body { flex: 1; min-width: 0; }

.entry-title {
    font-weight: 400;
    letter-spacing: 2px;
    margin: 0 0 6px;
}

.entry-meta { margin: 0 0 10px; }

/* Moldura da entrada: fica uma camada acima e limita a imagem. */
.entry-detail-frame {
    position: relative;
    z-index: 1;
    flex: 0 0 112px;
    width: 112px;
    height: 112px;
    max-width: 112px;
    max-height: 112px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.03);
    isolation: isolate;
}

.entry-detail-frame::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}

.entry-detail-img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    border: 0;
    border-radius: 0;
    margin: 0;
    background: transparent;
}

/* Ícones/avatares quadrados: recorte redondo, como no Kanka. */
.entry-detail-frame.is-icon {
    border-radius: 50%;
    border-color: rgba(0,229,255,.35);
    box-shadow: 0 0 0 4px rgba(0,229,255,.05), 0 8px 22px rgba(0,0,0,.45);
}

.entry-detail-frame.is-icon::after { box-shadow: inset 0 0 0 1px rgba(0,229,255,.2); }

@media (max-width: 640px) {
    .entry-detail-frame {
        flex-basis: 84px;
        width: 84px;
        height: 84px;
        max-width: 84px;
        max-height: 84px;
    }
}

.entry-text { line-height: 1.65; font-size: .95rem; color: rgba(255,255,255,.85); }
.entry-text p { margin: 0 0 12px; }
.entry-text img { max-width: 100%; border-radius: 4px; }

.wikilink {
    color: #00e5ff;
    text-decoration: none;
    border-bottom: 1px dashed rgba(0,229,255,.5);
    cursor: pointer;
}
.wikilink:hover { background: rgba(0,229,255,.12); }

.backlinks-list { list-style: none; margin: 0; padding: 0; }
.backlinks-list li { padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.05); font-size: .85rem; }

.kv-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.kv-table td {
    padding: 7px 10px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: .85rem;
}
.kv-table td:first-child {
    color: rgba(255,255,255,.45);
    width: 160px;
    font-size: .72rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ---------------- Modal ---------------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 3, 12, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    background: #0b0b1e;
    border: 1px solid rgba(0,229,255,.25);
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 0 80px rgba(0,229,255,.12);
}

.modal h3 { margin: 0 0 16px; font-weight: 400; letter-spacing: 1px; }

/* ---------------- Toasts ---------------- */

#toastRoot {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #0b0b1e;
    border: 1px solid rgba(0,229,255,.4);
    border-radius: 6px;
    padding: 11px 16px;
    font-size: .85rem;
    color: #dffaff;
    box-shadow: 0 6px 24px rgba(0,0,0,.5);
    animation: toastIn .25s ease;
    max-width: 320px;
}

.toast.error { border-color: rgba(255,70,90,.5); color: #ffd6dc; }
.toast.success { border-color: rgba(0,255,170,.5); color: #d2ffee; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Pausa ---------------- */

.pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(2, 2, 8, 0.92);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pause-menu {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 260px;
}

.pause-title {
    font-size: .8rem;
    letter-spacing: 4px;
    color: #00e5ff;
    margin-bottom: 8px;
}

/* ---------------- Utilidades ---------------- */

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.grow { flex: 1; min-width: 0; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255,255,255,.35);
    font-size: .9rem;
}

.empty-state .big { font-size: 1.6rem; display: block; margin-bottom: 10px; color: rgba(255,255,255,.5); }

.notice {
    border: 1px solid rgba(255,210,90,.3);
    background: rgba(255,210,90,.05);
    border-radius: 6px;
    padding: 12px 16px;
    font-size: .85rem;
    color: #ffe9a8;
    margin-bottom: 16px;
}

.notice.info {
    border-color: rgba(0,229,255,.25);
    background: rgba(0,229,255,.05);
    color: #bdf3ff;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.05);
}

.crew-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    padding: 14px;
    background: rgba(255,255,255,.02);
}

.crew-card.dead { border-color: rgba(255,70,90,.4); opacity: .75; }

.role-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(0,229,255,.5);
    color: #00e5ff;
    font-size: .95rem;
    font-family: ui-monospace, monospace;
}

.item-thumb {
    width: 38px;
    height: 38px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.04);
}

.activity-item {
    font-size: .8rem;
    color: rgba(255,255,255,.55);
    padding: 7px 0;
    border-bottom: 1px solid rgba(255,255,255,.05);
}
.activity-item .when { color: rgba(255,255,255,.3); font-family: ui-monospace, monospace; font-size: .7rem; }

/* ---------------- Enquadramento de imagens ---------------- */

.img-editor { display: flex; flex-direction: column; gap: 8px; }

.img-preview {
    position: relative;
    width: min(100%, calc(320px * var(--ratio, 1.7778)));
    aspect-ratio: var(--ratio, 16 / 9);
    max-height: 320px;
    margin: 0 auto;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.12);
    background-color: #0a0a16;
    background-image:
        linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.05) 75%),
        linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.05) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
}
.img-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.img-preview .img-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: rgba(255,255,255,.25);
    font-size: .8rem;
    letter-spacing: 1px;
}

/* Cropper */
.cropper-stage {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0,229,255,.3);
    background-color: #070712;
    background-image:
        linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.05) 75%),
        linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.05) 75%);
    background-size: 18px 18px;
    background-position: 0 0, 9px 9px;
    touch-action: none;
}
.cropper-stage canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: grab;
}
.cropper-stage canvas.dragging { cursor: grabbing; }
.cropper-controls {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-top: 12px;
}
.cropper-zoom { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 160px; font-size: .72rem; color: rgba(255,255,255,.5); }
.cropper-zoom input[type="range"] { accent-color: #00e5ff; }

.img-editor-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.img-editor-actions label.btn { margin: 0; cursor: pointer; }

/* ---------------- Editor de texto rico ---------------- */

.rte {
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 6px;
    background: rgba(0,0,0,.25);
    overflow: hidden;
}

.rte-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px;
    background: rgba(0,229,255,.05);
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.rte-toolbar button {
    min-width: 30px;
    height: 28px;
    padding: 0 7px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: rgba(255,255,255,.75);
    font-size: .8rem;
    cursor: pointer;
    line-height: 1;
}
.rte-toolbar button:hover {
    background: rgba(0,229,255,.12);
    border-color: rgba(0,229,255,.25);
    color: #eafcff;
}
.rte-sep {
    width: 1px;
    align-self: stretch;
    margin: 2px 4px;
    background: rgba(255,255,255,.12);
}

.rte-area {
    min-height: 200px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 12px 14px;
    outline: none;
    line-height: 1.65;
    font-size: .95rem;
    color: rgba(255,255,255,.9);
    overflow-wrap: break-word;
}
.rte-area:empty::before {
    content: attr(data-placeholder);
    color: rgba(255,255,255,.28);
    pointer-events: none;
}
.rte-area:focus { background: rgba(0,229,255,.02); }
.rte-area p { margin: 0 0 10px; }
.rte-area h2, .rte-area h3 { margin: 4px 0 10px; font-size: 1.1rem; color: #eafcff; }
.rte-area blockquote {
    margin: 8px 0;
    padding: 4px 12px;
    border-left: 2px solid rgba(0,229,255,.45);
    color: rgba(255,255,255,.7);
}
.rte-area pre {
    margin: 8px 0;
    padding: 8px 10px;
    background: rgba(0,0,0,.35);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: .85rem;
    overflow-x: auto;
}
.rte-area ul, .rte-area ol { margin: 6px 0 10px; padding-left: 22px; }
.rte-area a { color: #7fe9ff; }

/* Imagens dentro do texto (estilo Docs) */

.doc-img {
    position: relative;
    display: block;
    width: 320px;
    max-width: 100%;
    margin: 8px auto;
    line-height: 0;
    border-radius: 4px;
    vertical-align: top;
}
.doc-img img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}
.doc-img[data-align="left"] { float: left; margin: 6px 14px 8px 0; }
.doc-img[data-align="right"] { float: right; margin: 6px 0 8px 14px; }
.doc-img[data-align="center"] { float: none; margin: 8px auto; }

/* controles flutuantes no editor */
.doc-img-tools {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 2px;
    padding: 3px;
    border-radius: 5px;
    background: rgba(2,2,10,.9);
    border: 1px solid rgba(0,229,255,.35);
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
    line-height: 1;
    white-space: nowrap;
    z-index: 3;
}
.doc-img:hover .doc-img-tools,
.doc-img:focus-within .doc-img-tools { display: flex; }
.rte-area .doc-img:hover { outline: 1px dashed rgba(0,229,255,.55); outline-offset: 2px; }
.rte-area .doc-img { cursor: default; }
.doc-img-tools button {
    width: 24px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: #d8fbff;
    font-size: .72rem;
    cursor: pointer;
}
.doc-img-tools button:hover { background: rgba(0,229,255,.22); }
.doc-img-tools button[data-action="doc-img-remove"]:hover { background: rgba(255,70,90,.35); }

/* alças para arrastar e redimensionar pela borda */
.doc-img-resize {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 12px;
    display: none;
    cursor: ew-resize;
    z-index: 4;
    touch-action: none;
}
.doc-img-resize[data-edge="left"] { left: -6px; }
.doc-img-resize[data-edge="right"] { right: -6px; }
.doc-img-resize::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 46px;
    transform: translate(-50%, -50%);
    border-radius: 2px;
    background: rgba(0,229,255,.8);
    box-shadow: 0 0 8px rgba(0,229,255,.55);
}
.rte-area .doc-img:hover > .doc-img-resize,
.rte-area .doc-img:focus-within > .doc-img-resize { display: block; }

/* visualização final: sem ferramentas, texto contorna a imagem */
.entry-text .doc-img { cursor: default; }
.entry-text::after { content: ''; display: block; clear: both; }

/* Galeria de imagens extras */

.gallery-editor {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.gallery-item {
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    padding: 8px;
    background: rgba(255,255,255,.02);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gallery-item .img-preview { aspect-ratio: 4 / 3; max-height: 180px; }
.gallery-item-remove { align-self: flex-end; }

.entry-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.entry-gallery figure {
    margin: 0;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0,0,0,.4);
    cursor: zoom-in;
}

.entry-gallery img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
    transition: transform .25s;
}

.entry-gallery figure:hover img { transform: scale(1.04); }

/* ---------------- Notificações críticas ---------------- */

#criticalRoot {
    position: fixed;
    top: 74px;
    right: 20px;
    z-index: 3200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.critical-toast {
    pointer-events: auto;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    width: 330px;
    max-width: calc(100vw - 40px);
    padding: 13px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,70,90,.65);
    background: linear-gradient(135deg, rgba(30,5,14,.97), rgba(12,4,22,.97));
    box-shadow: 0 0 34px rgba(255,50,80,.28), 0 12px 30px rgba(0,0,0,.55);
    animation: criticalIn .28s ease;
}

.critical-toast.out { animation: criticalOut .3s ease forwards; }

.critical-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,70,90,.6);
    color: #ff8fa0;
    font-size: .95rem;
    animation: criticalPulse 1.1s ease-in-out infinite;
}

.critical-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.critical-body strong {
    font-size: .78rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ff9dac;
}
.critical-body span { font-size: .8rem; color: rgba(255,255,255,.85); line-height: 1.4; }

.critical-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,.4);
    cursor: pointer;
    font-size: .8rem;
    padding: 0 2px;
}
.critical-close:hover { color: #fff; }

@keyframes criticalIn {
    from { opacity: 0; transform: translateX(24px) scale(.97); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes criticalOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(24px); }
}
@keyframes criticalPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,70,90,.35); }
    50% { box-shadow: 0 0 0 6px rgba(255,70,90,0); }
}

/* ---------------- Anatomia / saúde corporal ---------------- */

.crew-vitals { display: flex; gap: 16px; align-items: flex-start; margin-top: 10px; flex-wrap: wrap; }
.crew-vitals-bars { flex: 1; min-width: 190px; }

.anatomy-wrap {
    width: 108px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.anatomy-svg { width: 100%; height: auto; overflow: visible; }

.anatomy-part {
    fill: rgba(0,229,255,.10);
    stroke: rgba(0,229,255,.55);
    stroke-width: 1.6;
    transition: fill .2s, stroke .2s;
}

.anatomy-svg[data-editable="1"] .anatomy-part { cursor: pointer; }
.anatomy-svg[data-editable="1"] .anatomy-part:hover { fill: rgba(0,229,255,.24); }

.anatomy-part.wounded {
    fill: rgba(255,70,90,.4);
    stroke: rgba(255,70,90,.95);
}

.anatomy-label {
    font-size: .58rem;
    letter-spacing: 1px;
    color: rgba(255,255,255,.35);
    text-transform: uppercase;
}

.health-bar .bar-fill { transition: width .3s; }
.fill-health { background: linear-gradient(90deg, #00ffaa, #7dffcf); }
.fill-health.warn { background: linear-gradient(90deg, #ffd25a, #ffe9a8); }
.fill-health.bad { background: linear-gradient(90deg, #ff465a, #ff8fa0); }

/* ---------------- Chat expandido ---------------- */

.chat-panel { display: flex; flex-direction: column; height: calc(100vh - 230px); min-height: 420px; }

.chat-panel .chat-messages {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.chat-panel .chat-input-row { margin-top: auto; padding-top: 10px; }

/* ---------------- Barras de rolagem (tema neon, visíveis só ao rolar) ---------------- */

:root {
    --sb-track: transparent;
    --sb-thumb: linear-gradient(180deg, rgba(0, 229, 255, .7), rgba(139, 92, 246, .7));
    --sb-thumb-hover: linear-gradient(180deg, rgba(0, 229, 255, .95), rgba(139, 92, 246, .95));
}

/* Áreas roláveis: trilho invisível, polegar aparece só enquanto rola. */
.sidebar,
.main-view,
.login-screen,
.chat-messages,
.modal,
.rte-area,
textarea {
    scrollbar-gutter: stable;
}

/* Firefox não tem ::-webkit-scrollbar: usa as propriedades padrão.
   (No Chrome/Edge/Safari elas desativariam as regras ::-webkit-scrollbar
   e trariam de volta as setinhas nativas.) */
@supports (-moz-appearance: none) {
    .sidebar,
    .main-view,
    .login-screen,
    .chat-messages,
    .modal,
    .rte-area,
    textarea {
        scrollbar-width: thin;
        scrollbar-color: transparent transparent;
    }

    .sidebar.is-scrolling,
    .main-view.is-scrolling,
    .login-screen.is-scrolling,
    .chat-messages.is-scrolling,
    .modal.is-scrolling,
    .rte-area.is-scrolling,
    textarea.is-scrolling {
        scrollbar-color: rgba(0, 229, 255, .55) transparent;
    }
}

.sidebar::-webkit-scrollbar,
.main-view::-webkit-scrollbar,
.login-screen::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.rte-area::-webkit-scrollbar,
textarea::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.sidebar::-webkit-scrollbar-track,
.main-view::-webkit-scrollbar-track,
.login-screen::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track,
.rte-area::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
    background: var(--sb-track);
    border-radius: 999px;
}

/* Polegar invisível em repouso (espaço reservado, sem salto de layout). */
.sidebar::-webkit-scrollbar-thumb,
.main-view::-webkit-scrollbar-thumb,
.login-screen::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb,
.rte-area::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
    background-image: none;
    background-color: transparent;
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
    min-height: 42px;
}

.sidebar.is-scrolling::-webkit-scrollbar-thumb,
.main-view.is-scrolling::-webkit-scrollbar-thumb,
.login-screen.is-scrolling::-webkit-scrollbar-thumb,
.chat-messages.is-scrolling::-webkit-scrollbar-thumb,
.modal.is-scrolling::-webkit-scrollbar-thumb,
.rte-area.is-scrolling::-webkit-scrollbar-thumb,
textarea.is-scrolling::-webkit-scrollbar-thumb {
    background-image: var(--sb-thumb);
    background-color: transparent;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.main-view::-webkit-scrollbar-thumb:hover,
.login-screen::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.modal::-webkit-scrollbar-thumb:hover,
.rte-area::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover {
    background-image: var(--sb-thumb-hover);
}

/* Sem setas nem cantos brancos */
.sidebar::-webkit-scrollbar-button,
.main-view::-webkit-scrollbar-button,
.login-screen::-webkit-scrollbar-button,
.chat-messages::-webkit-scrollbar-button,
.modal::-webkit-scrollbar-button,
.rte-area::-webkit-scrollbar-button,
textarea::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

.sidebar::-webkit-scrollbar-corner,
.main-view::-webkit-scrollbar-corner,
.login-screen::-webkit-scrollbar-corner,
.chat-messages::-webkit-scrollbar-corner,
.modal::-webkit-scrollbar-corner,
.rte-area::-webkit-scrollbar-corner,
textarea::-webkit-scrollbar-corner {
    background: transparent;
}

/* Nenhuma seta nas extremidades de nenhuma barra de rolagem. */
::-webkit-scrollbar-button {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
    border: 0 !important;
}

::-webkit-scrollbar-corner { background: transparent !important; }

@media (max-width: 900px) {
    .sidebar { display: none; }
    .main-view { padding: 20px 16px 50px; }
    .nav-user .user-name { display: none; }
    .chat-panel { height: calc(100vh - 190px); min-height: 340px; }
    .crew-vitals { flex-direction: column; }
    .anatomy-wrap { width: 92px; }
}
