/* =====================================================================
   CoSecurity Admin - tema escuro (identidade do app)
   Azul-escuro #000a33 / #00041a, ciano #00aeef, vermelho #ec1651, verde #00ed88
   ===================================================================== */
:root {
    --bg: #00041a;
    --bg-alt: #000a33;
    --surface: #06123f;
    --surface-alt: #0b1a52;
    --surface-hover: #0f2160;
    --border: rgba(140, 170, 255, .11);
    --border-strong: rgba(140, 170, 255, .22);
    --text: #f2f6ff;
    --text-2: #a9b6d6;   /* AA sobre --surface */
    --text-3: #8391b8;   /* AA para textos pequenos auxiliares */
    --accent: #00aeef;
    --accent-hover: #33c2f5;
    --accent-strong: #0089c2;
    --accent-soft: rgba(0, 174, 239, .14);
    --accent-glow: rgba(0, 174, 239, .35);
    --online: #00ed88;
    --online-soft: rgba(0, 237, 136, .13);
    --offline: #ec1651;
    --danger-text: #ff5c85;
    --offline-soft: rgba(236, 22, 81, .14);
    --erro: #a78bfa;
    --erro-soft: rgba(167, 139, 250, .15);
    --warn: #ffbe3d;
    --warn-soft: rgba(255, 190, 61, .14);
    --sidebar-w: 248px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -12px rgba(0, 0, 0, .55);
    --focus: 0 0 0 3px rgba(0, 174, 239, .45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    background: var(--bg);
    background-image: radial-gradient(1200px 600px at 100% -10%, rgba(0, 174, 239, .07), transparent 60%);
    background-attachment: fixed;
    color: var(--text);
    font-family: "Montserrat", "Inter", ui-sans-serif, system-ui, sans-serif;
    font-size: .9rem;
    -webkit-font-smoothing: antialiased;
}
code, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.01em; }
::selection { background: var(--accent-glow); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.text-muted-2 { color: var(--text-2) !important; }
.text-muted-3 { color: var(--text-3) !important; }

/* ------------------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: linear-gradient(180deg, var(--bg-alt) 0%, #000628 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
}
.sidebar-brand {
    padding: 22px 22px 18px;
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-brand img { height: 34px; display: block; }
.sidebar-brand .brand-tag {
    font-size: .62rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 8px;
}
.sidebar-nav { flex: 1; padding: 6px 14px 14px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-section {
    font-size: .66rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    color: var(--text-3); padding: 16px 12px 6px;
}
.sidebar-nav .nav-link {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 500; font-size: .875rem;
    transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.sidebar-nav .nav-link.active {
    background: linear-gradient(90deg, rgba(0, 174, 239, .2), rgba(0, 174, 239, .04));
    color: #fff; font-weight: 600;
}
.sidebar-nav .nav-link.active i { color: var(--accent); filter: drop-shadow(0 0 6px var(--accent-glow)); }
.sidebar-nav .nav-link.active::before {
    content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }
.sidebar-foot .who {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
    padding: 8px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .03);
}
.sidebar-foot .avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    background: linear-gradient(135deg, var(--accent), #1d4ed8); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.sidebar-foot .name { font-size: .84rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.sidebar-foot .role { font-size: .72rem; color: var(--text-3); }
.sidebar-foot form { margin: 0; }
.sidebar-foot .btn-logout {
    width: 100%; font-size: .8rem; font-weight: 600;
    color: var(--text-2); background: transparent; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); padding: 8px;
}
.sidebar-foot .btn-logout:hover { color: #fff; background: var(--offline-soft); border-color: var(--offline); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 18px clamp(16px, 2.2vw, 40px);
    background: rgba(0, 4, 26, .82);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar > div:first-child { min-width: 0; }
.topbar h1 { font-size: 1.3rem; margin: 0; font-weight: 700; }
.topbar .subtitle { color: var(--text-3); font-size: .8rem; margin-top: 3px; }
.topbar > * { max-width: 100%; }
.topbar .d-flex { flex-wrap: wrap; }
.page { padding: 28px clamp(16px, 2.2vw, 40px) 64px; width: 100%; max-width: none; }

.mobile-bar { display: none; }
.sidebar-backdrop { display: none; }

/* ------------------------------------------------------------ cards */
.card {
    --bs-card-color: var(--text);
    --bs-card-bg: var(--surface);
    background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 40%), var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card > .table-responsive, .card > .table { border-radius: var(--radius); }
.card-section-title {
    font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}

.stat-card { padding: 20px 22px; position: relative; overflow: hidden; }
.stat-card::after {
    content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%;
    background: radial-gradient(circle, var(--accent-soft), transparent 70%);
}
.stat-card .stat-icon {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(0, 174, 239, .25);
    display: flex; align-items: center; justify-content: center; margin-bottom: 14px; font-size: 1.15rem;
}
.stat-card .stat-label { color: var(--text-2); font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.stat-card .stat-value { font-size: 2.1rem; font-weight: 800; margin-top: 2px; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-card .stat-foot { font-size: .76rem; color: var(--text-3); margin-top: 8px; }

.section-title {
    font-size: .98rem; font-weight: 700; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.section-title a { font-size: .78rem; font-weight: 600; }
.list-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row > div { min-width: 0; }
.list-row .primary { font-weight: 600; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .secondary { color: var(--text-3); font-size: .77rem; }
.bar-track { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; box-shadow: 0 0 10px rgba(0, 174, 239, .25); }
.quick-action {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: rgba(255, 255, 255, .02);
    color: var(--text); font-weight: 600; font-size: .85rem;
    transition: border-color .15s, background .15s, transform .15s;
}
.quick-action:hover { background: var(--accent-soft); border-color: rgba(0, 174, 239, .4); color: var(--text); transform: translateX(2px); }
.quick-action i {
    font-size: 1rem; color: var(--accent); width: 32px; height: 32px; border-radius: 9px;
    background: var(--accent-soft); display: flex; align-items: center; justify-content: center; flex: none;
}

/* ------------------------------------------------------------ tables */
.table-responsive { border-radius: var(--radius); }
.table { color: var(--text); margin-bottom: 0; --bs-table-bg: transparent; }
.table > :not(caption) > * > * {
    background: transparent; border-bottom-color: var(--border); color: var(--text);
    padding: 11px 12px; vertical-align: middle; font-size: .84rem;
}
.table > thead > tr > th {
    color: var(--text-3); font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    background: rgba(0, 0, 0, .18); border-bottom: 1px solid var(--border-strong); white-space: nowrap;
    padding-top: 12px; padding-bottom: 12px;
}
.table > tbody > tr:nth-child(even) > * { background: rgba(255, 255, 255, .015); }
.table-hover > tbody > tr:hover > * { background: rgba(0, 174, 239, .06); }
.table > tbody > tr:last-child > * { border-bottom: none; }
.table td.text-end, .table .cell-actions { white-space: nowrap; }
.table .cell-name { font-weight: 600; }
.table .cell-nowrap { white-space: nowrap; }
.table .cell-muted { color: var(--text-2) !important; }
.table td.empty-row, .table td[colspan].text-center { padding: 0 !important; }
.table td .text-truncate, .table td.text-truncate { display: block; }
td.text-truncate { display: table-cell !important; }

.avatar-sm {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .76rem;
    border: 1px solid rgba(0, 174, 239, .25);
}
.avatar-sm.avatar-square { border-radius: 9px; font-size: .85rem; }
.mini-stat-label { color: var(--text-3); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.mini-stat-value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-stat { padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .025); border: 1px solid var(--border); height: 100%; }

/* ------------------------------------------------------------ empty states */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 48px 16px; color: var(--text-3); text-align: center; font-size: .88rem;
}
.empty-state i {
    font-size: 1.6rem; color: var(--accent); width: 56px; height: 56px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center; margin-bottom: 6px;
    background: var(--accent-soft); border: 1px solid rgba(0, 174, 239, .2);
}
.empty-state strong { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------ forms */
.form-label { font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-label .opt, .form-hint { color: var(--text-3); font-weight: 400; font-size: .76rem; }
.form-control, .form-select {
    background-color: rgba(0, 4, 26, .55); border: 1px solid var(--border-strong); color: var(--text);
    border-radius: var(--radius-sm); padding: 9px 12px; font-size: .88rem;
    transition: border-color .15s, box-shadow .15s;
}
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2300aeef' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
.form-select option, .form-select optgroup { background: var(--bg-alt); color: var(--text); }
.form-control:hover, .form-select:hover { border-color: rgba(0, 174, 239, .45); }
.form-control:focus, .form-select:focus {
    background-color: rgba(0, 4, 26, .75); border-color: var(--accent); color: var(--text);
    box-shadow: var(--focus);
}
.form-control::placeholder { color: var(--text-3); opacity: .85; }
.form-control[readonly] { opacity: .65; cursor: not-allowed; }
.form-control-sm, .form-select-sm { padding-top: 6px; padding-bottom: 6px; font-size: .82rem; }
textarea.form-control { line-height: 1.5; }
.form-check-input { background-color: rgba(0, 4, 26, .55); border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: var(--focus); border-color: var(--accent); }
.form-check-label { color: var(--text); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); }
.form-section { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: none; }
.form-actions {
    display: flex; align-items: center; gap: 8px; padding-top: 18px; margin-top: 6px;
    border-top: 1px solid var(--border);
}
.form-section + .form-actions { border-top: none; padding-top: 0; margin-top: 0; }
.check-tile {
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px 12px 40px !important;
    background: rgba(255, 255, 255, .02); margin: 0; height: 100%;
}
.check-tile .form-check-input { margin-left: -26px; }
.check-tile:hover { border-color: rgba(0, 174, 239, .35); }
.filter-bar { align-items: center; }
.filter-bar .form-control, .filter-bar .form-select { flex: 1 1 200px; }

/* ------------------------------------------------------------ buttons */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .84rem; padding: 8px 14px; transition: all .15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-sm { padding: 6px 11px; font-size: .79rem; border-radius: 9px; }
.btn:focus-visible { box-shadow: var(--focus); }
.btn-primary {
    background: linear-gradient(180deg, #14bdf7, var(--accent)); border-color: var(--accent); color: #00142b;
    box-shadow: 0 4px 14px -6px var(--accent-glow);
}
.btn-primary:hover, .btn-primary:focus { background: var(--accent-hover); border-color: var(--accent-hover); color: #00142b; box-shadow: 0 6px 18px -6px var(--accent-glow); }
.btn-primary:disabled, .btn-primary.disabled { background: var(--accent); border-color: var(--accent); color: #00142b; opacity: .45; }
.btn-outline-primary { color: var(--accent); border-color: rgba(0, 174, 239, .55); background: transparent; }
.btn-outline-primary:hover { background: var(--accent-soft); color: #fff; border-color: var(--accent); }
.btn-outline-secondary { color: var(--text-2); border-color: var(--border-strong); background: rgba(255, 255, 255, .02); }
.btn-outline-secondary:hover, .btn-outline-secondary:focus { background: rgba(255, 255, 255, .07); color: var(--text); border-color: rgba(255, 255, 255, .3); }
.btn-outline-secondary.disabled { opacity: .35; }
.btn-outline-danger { color: var(--danger-text); border-color: rgba(236, 22, 81, .45); background: transparent; }
.btn-outline-danger:hover { background: var(--offline); border-color: var(--offline); color: #fff; }
.btn-danger { background: var(--offline); border-color: var(--offline); color: #fff; }
.btn-danger:hover { background: #ff2a66; border-color: #ff2a66; }
.btn-danger:disabled { background: var(--offline); border-color: var(--offline); opacity: .4; }
.btn-outline-warning { color: var(--warn); border-color: rgba(255, 190, 61, .45); }
.btn-outline-warning:hover { background: var(--warn); border-color: var(--warn); color: #1a1200; }
.btn-link { color: var(--text-2); font-weight: 500; text-decoration: none; }
.btn-link:hover { color: var(--text); }
.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-close { filter: invert(1) grayscale(1) brightness(1.6); opacity: .6; }

/* ------------------------------------------------------------ badges / pills */
.badge {
    font-weight: 600; font-size: .7rem; padding: .42em .75em; border-radius: 999px; letter-spacing: .02em;
    border: 1px solid transparent; display: inline-flex; align-items: center; gap: 4px;
}
.badge.bg-success { background: var(--online-soft) !important; color: var(--online) !important; border-color: rgba(0, 237, 136, .28); }
.badge.bg-secondary { background: rgba(255, 255, 255, .06) !important; color: var(--text-2) !important; border-color: var(--border-strong); }
.badge.bg-dark { background: rgba(255, 255, 255, .08) !important; color: var(--text) !important; border-color: var(--border-strong); }
.badge.bg-info { background: var(--accent-soft) !important; color: #4cc9f7 !important; border-color: rgba(0, 174, 239, .3); }
.badge.bg-warning { background: var(--warn-soft) !important; color: var(--warn) !important; border-color: rgba(255, 190, 61, .3); }
.badge.bg-danger { background: var(--offline-soft) !important; color: var(--danger-text) !important; border-color: rgba(236, 22, 81, .35); }

/* ------------------------------------------------------------ alerts */
.alert {
    border-radius: var(--radius-sm); border: 1px solid transparent; border-left-width: 4px;
    font-size: .86rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.alert.alert-block { display: block; }
.alert-danger { background: rgba(236, 22, 81, .1); border-color: rgba(236, 22, 81, .35); border-left-color: var(--offline); color: #ff9ab4; }
.alert-warning { background: rgba(255, 190, 61, .09); border-color: rgba(255, 190, 61, .3); border-left-color: var(--warn); color: #ffd780; }
.alert-success { background: rgba(0, 237, 136, .08); border-color: rgba(0, 237, 136, .28); border-left-color: var(--online); color: #7ff5c0; }
.alert-info { background: var(--accent-soft); border-color: rgba(0, 174, 239, .3); border-left-color: var(--accent); color: #8fdcff; }

/* ------------------------------------------------------------ status */
.status-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; flex: none; }
.status-ONLINE { background-color: var(--online); box-shadow: 0 0 0 3px rgba(0, 237, 136, .16), 0 0 8px rgba(0, 237, 136, .5); }
.status-OFFLINE { background-color: var(--offline); box-shadow: 0 0 0 3px rgba(236, 22, 81, .18); }
.status-ERRO_PERMANENTE { background-color: var(--erro); box-shadow: 0 0 0 3px rgba(167, 139, 250, .18); }

code { color: #5fd3ff; background: rgba(0, 174, 239, .08); padding: 2px 6px; border-radius: 6px; font-size: .82em; }

/* ------------------------------------------------------------ pagination */
.pager {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-top: 16px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .02);
}
.pager .pager-info { color: var(--text-3); font-size: .8rem; }
.pager .pager-info strong { color: var(--text); }

/* ------------------------------------------------------------ modal / tooltip */
.modal-content {
    background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
    border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8);
}
.modal-header, .modal-footer { border-color: var(--border); }
.modal-header .modal-title.text-danger { color: var(--danger-text) !important; display: flex; align-items: center; gap: 8px; }
.modal-backdrop.show { opacity: .7; }
.tooltip-inner { background: var(--bg-alt); border: 1px solid var(--border-strong); font-size: .76rem; }

/* ------------------------------------------------------------ login */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
    background:
        radial-gradient(800px 500px at 15% 10%, rgba(0, 174, 239, .22), transparent 60%),
        radial-gradient(700px 500px at 90% 90%, rgba(29, 78, 216, .25), transparent 60%),
        linear-gradient(160deg, #000a33 0%, #00041a 70%);
}
.login-card {
    width: 100%; max-width: 400px; padding: 40px 36px;
    background: rgba(6, 18, 63, .55) !important; backdrop-filter: blur(16px);
    border: 1px solid rgba(140, 170, 255, .18) !important;
    box-shadow: 0 30px 80px -24px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .06) !important;
}
.login-card .login-logo { height: 46px; display: block; margin: 0 auto 18px; }
.login-card .login-title { text-align: center; font-size: 1.15rem; margin-bottom: 4px; }
.login-card .login-sub { text-align: center; color: var(--text-3); font-size: .8rem; margin-bottom: 26px; }
.login-card .input-icon { position: relative; }
.login-card .input-icon i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.login-card .input-icon .form-control { padding-left: 38px; }
.login-foot { text-align: center; color: var(--text-3); font-size: .72rem; margin-top: 24px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%);
        transition: transform .22s ease; box-shadow: 20px 0 60px rgba(0, 0, 0, .6);
    }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(0, 2, 14, .65); z-index: 1035;
    }
    .mobile-bar {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 10px 16px; background: var(--bg-alt); border-bottom: 1px solid var(--border);
        position: sticky; top: 0; z-index: 1030;
    }
    .mobile-bar img { height: 28px; }
    .topbar { position: static; padding: 16px; }
    .page { padding: 18px 16px 48px; }
}
@media (max-width: 575.98px) {
    .topbar h1 { font-size: 1.12rem; }
    .stat-card { padding: 16px; }
    .stat-card .stat-value { font-size: 1.6rem; }
    .stat-card .stat-icon { width: 36px; height: 36px; margin-bottom: 10px; }
    .card.p-4 { padding: 18px !important; }
    .filter-bar .form-control, .filter-bar .form-select { max-width: none !important; flex-basis: 100%; }
}

/* ============================================================ imagens do app + Zion */
body {
    background-color: var(--bg);
    background-image:
        linear-gradient(180deg, rgba(0, 4, 26, .55), rgba(0, 4, 26, .78)),
        url("../images/app/bg-painel.jpg");
    background-size: cover; background-position: right center; background-attachment: fixed;
}
.sidebar {
    background:
        linear-gradient(180deg, rgba(0, 10, 51, .86), rgba(0, 6, 40, .94)),
        url("../images/app/bg-sistema.webp") center / cover no-repeat;
}
.sidebar-brand img { height: 26px; }
.mobile-bar img { height: 20px; }

/* gráficos 3D do app */
.graphic-3d { width: 64px; height: 64px; object-fit: contain; flex: none; filter: drop-shadow(0 6px 16px rgba(0, 174, 239, .25)); }
.graphic-3d.sm { width: 44px; height: 44px; }
.empty-state .graphic-3d { width: 92px; height: 92px; margin-bottom: 8px; }
.card-graphic { position: absolute; right: 18px; top: 16px; width: 56px; height: 56px; opacity: .9; pointer-events: none; }

/* card do Zion (igual ao app) */
.zion-card {
    position: relative; overflow: hidden; display: flex; align-items: center; gap: 20px;
    padding: 0 28px 0 0; min-height: 132px; border-radius: var(--radius);
    background: #051537; border: 1px solid rgba(0, 174, 239, .35); color: var(--text);
    box-shadow: 0 0 0 1px rgba(0, 174, 239, .08), 0 12px 40px -14px rgba(0, 174, 239, .45);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.zion-card::before {
    content: ""; position: absolute; left: -60px; top: 50%; width: 300px; height: 300px; transform: translateY(-50%);
    background: radial-gradient(circle, rgba(0, 174, 239, .45), rgba(0, 174, 239, 0) 65%); pointer-events: none;
}
.zion-card:hover { color: var(--text); transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 16px 48px -14px rgba(0, 174, 239, .6); }
.zion-card img { position: relative; height: 132px; width: auto; align-self: flex-end; flex: none; }
.zion-card .zion-body { position: relative; flex: 1; min-width: 0; padding: 18px 0; }
.zion-card .zion-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.zion-card .zion-title span { color: var(--accent); }
.zion-card .zion-text { color: var(--text-2); font-size: .86rem; margin: 0; max-width: 560px; }
.zion-card .zion-cta { position: relative; flex: none; }

/* botão flutuante do Zion */
.zion-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 1050;
    width: 58px; height: 58px; border-radius: 50%; overflow: hidden;
    background: #051537; border: 2px solid var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 174, 239, .15), 0 10px 28px -6px rgba(0, 174, 239, .6);
    display: block; transition: transform .15s, box-shadow .15s;
}
/* enquadra o rosto no centro do circulo (a imagem e larga e o personagem fica na parte esquerda) */
.zion-fab img {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; object-position: 36% 12%;
    transform: scale(1.18); transform-origin: 36% 40%;
}
.zion-fab:hover { transform: scale(1.07); box-shadow: 0 0 0 6px rgba(0, 174, 239, .22), 0 12px 32px -6px rgba(0, 174, 239, .75); }
.zion-fab:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* login com fundos do app */
.login-wrap {
    position: relative; overflow: hidden;
    background:
        linear-gradient(160deg, rgba(0, 10, 51, .55), rgba(0, 4, 26, .85)),
        url("../images/app/login-bg.webp") center / cover no-repeat, #00041a;
}
.login-wrap::before {
    content: ""; position: absolute; left: 50%; top: 50%; width: 900px; height: 1580px; transform: translate(-50%, -50%);
    background: url("../images/app/splash-rings.webp") center / contain no-repeat; opacity: .35; mix-blend-mode: screen; pointer-events: none;
}
.login-card { position: relative; }
.login-card .login-logo { height: 30px; }
.login-zion {
    display: flex; align-items: center; gap: 12px; margin-top: 22px; padding: 10px 14px 10px 0;
    border-radius: 12px; background: #051537; border: 1px solid rgba(0, 174, 239, .3); overflow: hidden; color: var(--text-2);
    font-size: .78rem; line-height: 1.35;
}
.login-zion:hover { color: var(--text); border-color: var(--accent); }
.login-zion img { height: 54px; align-self: flex-end; margin-bottom: -10px; }
.login-zion strong { color: var(--text); display: block; font-size: .82rem; }
@media (max-width: 575.98px) {
    .zion-card { flex-wrap: wrap; padding: 0 16px 16px 0; gap: 12px; }
    .zion-card img { height: 96px; align-self: flex-start; }
    .zion-card .zion-body { flex: 1 1 0; padding: 14px 0 0; }
    .zion-card .zion-title { font-size: 1rem; }
    .zion-card .zion-text { font-size: .8rem; }
    .zion-card .zion-cta { flex: 0 0 calc(100% - 16px); margin-left: 16px; }
    .zion-fab { width: 50px; height: 50px; right: 14px; bottom: 14px; }
}


/* ------------------------------------------------------------ menu recolhivel (desktop) */
.sidebar { transition: width .22s ease; }
.sidebar-collapse {
    position: absolute; top: 26px; right: -13px; z-index: 5;
    width: 26px; height: 26px; border-radius: 50%; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2, #0b1a45); color: var(--text-2); border: 1px solid var(--border-strong);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .45); cursor: pointer; font-size: .7rem;
    transition: color .15s, background .15s, transform .22s;
}
.sidebar-collapse:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
body.sidebar-collapsed .sidebar-collapse { transform: rotate(180deg); }

@media (min-width: 992px) {
    body.sidebar-collapsed { --sidebar-w: 76px; }
    body.sidebar-collapsed .sidebar-brand { padding: 22px 0 18px; justify-content: center; }
    body.sidebar-collapsed .sidebar-brand .brand-tag { display: none; }
    /* logo recortado: mostra so a marca (olho) */
    body.sidebar-collapsed .sidebar-brand a { width: 34px; height: 34px; overflow: hidden; display: block; }
    body.sidebar-collapsed .sidebar-brand img { height: 34px; width: auto; max-width: none; }
    body.sidebar-collapsed .nav-section { font-size: 0; padding: 10px 0 6px; margin: 0 14px; border-top: 1px solid var(--border); }
    body.sidebar-collapsed .nav-section:first-child { border-top: 0; }
    body.sidebar-collapsed .sidebar-nav { padding: 6px 10px 14px; }
    body.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; padding: 11px 0; }
    body.sidebar-collapsed .sidebar-nav .nav-link span { display: none; }
    body.sidebar-collapsed .sidebar-nav .nav-link i { font-size: 1.2rem; }
    body.sidebar-collapsed .sidebar-nav .nav-link.active::before { left: -10px; }
    body.sidebar-collapsed .sidebar-foot { padding: 12px 8px; }
    body.sidebar-collapsed .sidebar-foot .who { justify-content: center; padding: 6px 0; background: transparent; }
    body.sidebar-collapsed .sidebar-foot .who .text-truncate { display: none; }
    body.sidebar-collapsed .sidebar-foot .btn-logout span { display: none; }
}
@media (max-width: 991.98px) { .sidebar-collapse { display: none; } }

/* ============================================================ MONITORAMENTO (mosaico ao vivo) */
.monitor { --mon-offset: 270px; }
.mon-controls {
    display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 10px 12px; margin-bottom: 14px;
}
.mon-controls .form-control, .mon-controls .form-select { width: auto; flex: 0 1 auto; min-width: 0; height: 36px; padding-top: 4px; padding-bottom: 4px; font-size: .85rem; }
.mon-controls #monQ { flex: 1 1 220px; max-width: 340px; }
.mon-controls .form-select { max-width: 200px; }
.mon-controls .mon-apply { display: inline-flex; }
.mon-controls.is-js .mon-apply { display: none; }
.mon-layouts { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: rgba(0, 4, 26, .55); }
.mon-layout-btn {
    border: 0; background: transparent; color: var(--text-2); font-size: .78rem; font-weight: 600;
    padding: 5px 9px; border-radius: 7px; font-variant-numeric: tabular-nums; line-height: 1.2;
}
.mon-layout-btn:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, .07); }
.mon-layout-btn[aria-pressed="true"] { background: var(--accent); color: #00041a; box-shadow: 0 0 12px var(--accent-glow); }
.mon-layout-btn:disabled { opacity: .3; cursor: not-allowed; }
.mon-layout-btn:focus-visible, .mon-ibtn:focus-visible, .mon-retry:focus-visible { outline: 0; box-shadow: var(--focus); }

.mon-stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; width: 100%; }
.mon-grid {
    --cols: 2; --rows: 2;
    display: grid; gap: 10px; width: 100%;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    max-width: max(320px, calc((100vh - var(--mon-offset)) * 16 / 9 * var(--cols) / var(--rows)));
}
.mon-grid[hidden] { display: none; }

.mon-tile {
    position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #000;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
.mon-tile:hover, .mon-tile:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px var(--accent-glow); }
.mon-tile video, .mon-modal-video video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }

.mon-head {
    position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 8px;
    padding: 8px 96px 18px 10px; pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 4, 26, .92) 0%, rgba(0, 4, 26, .7) 55%, rgba(0, 4, 26, 0));
}
.mon-pager { padding-right: 84px; } /* reserva espaco para o botao flutuante do Zion */
.mon-names { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.mon-name, .mon-company { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon-name { font-size: .8rem; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.mon-company { font-size: .68rem; color: var(--text-2); }

.mon-badge {
    position: absolute; top: 8px; right: 8px; z-index: 3; padding: 3px 8px; border-radius: 999px;
    font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
    color: #fff; background: rgba(6, 18, 63, .85); border: 1px solid var(--border-strong);
}
.mon-badge[data-state="live"] { background: var(--offline); border-color: var(--offline); }
.mon-badge[data-state="live"]::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #fff; animation: mon-pulse 1.4s ease-in-out infinite; }
.mon-badge[data-state="connecting"] { color: var(--accent); border-color: rgba(0, 174, 239, .45); }
.mon-badge[data-state="error"] { color: var(--danger-text); border-color: rgba(236, 22, 81, .5); }
.mon-badge[data-state="paused"] { color: var(--text-2); }
@keyframes mon-pulse { 50% { opacity: .25; } }

.mon-overlay {
    position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    padding: 28px 12px 12px; text-align: center; color: var(--text-2); font-size: .78rem;
    background: radial-gradient(circle at 50% 40%, rgba(0, 174, 239, .08), rgba(0, 4, 26, .72) 70%);
}
.mon-overlay[hidden] { display: none; }
.mon-overlay[data-state="connecting"], .mon-overlay[data-state="paused"] { background: rgba(0, 4, 26, .55); pointer-events: none; }
.mon-overlay > .bi { font-size: 1.7rem; color: var(--text-3); }
.mon-overlay[data-state="error"] > .bi { color: var(--danger-text); }
.mon-ov-text { color: var(--text); font-weight: 600; }
.mon-ov-sub { max-width: 90%; color: var(--text-3); font-size: .7rem; line-height: 1.3; }
.mon-retry { margin-top: 6px; font-size: .72rem; padding: 3px 10px; }
.mon-spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(0, 174, 239, .25); border-top-color: var(--accent); animation: mon-spin .8s linear infinite; }
@keyframes mon-spin { to { transform: rotate(360deg); } }

.mon-actions {
    position: absolute; right: 6px; bottom: 6px; z-index: 4; display: flex; gap: 4px;
    opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s;
}
.mon-tile:hover .mon-actions, .mon-tile:focus-within .mon-actions { opacity: 1; transform: none; }
@media (hover: none) { .mon-actions { opacity: 1; transform: none; } }
.mon-ibtn {
    display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0;
    border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer;
    background: rgba(0, 10, 51, .82); backdrop-filter: blur(4px); font-size: .9rem;
}
.mon-ibtn:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #00041a; }
.mon-ibtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.mon-ibtn:disabled { opacity: .35; cursor: not-allowed; }

.mon-empty {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 56px 16px; text-align: center;
    color: var(--text-3); font-size: .88rem; width: 100%; border: 1px dashed var(--border-strong); border-radius: var(--radius);
    background: rgba(255, 255, 255, .015);
}
.mon-empty[hidden] { display: none; }
.mon-empty strong { color: var(--text); font-size: 1rem; }
.mon-empty .graphic-3d { width: 110px; height: 110px; margin-bottom: 8px; }
.mon-pager[hidden] { display: none; }

.mon-toast { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 20; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--offline); color: #fff; font-size: .82rem; }
.mon-toast[hidden] { display: none; }

/* ampliar */
.mon-modal { position: fixed; inset: 0; z-index: 1080; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(0, 2, 14, .86); backdrop-filter: blur(3px); }
.mon-modal[hidden] { display: none; }
.mon-modal-box { width: min(100%, calc((100vh - 130px) * 16 / 9)); max-height: 100%; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: 0 0 40px var(--accent-glow); overflow: hidden; }
.mon-modal-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.mon-modal-head .mon-badge { position: static; }
.mon-modal-titles { flex: 1; min-width: 0; }
.mon-modal-titles h2 { margin: 0; font-size: 1rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon-modal-sub { color: var(--text-3); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon-modal-video { position: relative; aspect-ratio: 16 / 9; background: #000; }
body.mon-modal-open .zion-fab { display: none; }

/* tela cheia (Fullscreen API no mosaico) */
.mon-fsbar { display: none; }
.mon-stage:fullscreen { background: #00041a; justify-content: center; padding: 8px; }
.mon-stage:-webkit-full-screen { background: #00041a; justify-content: center; padding: 8px; }
.mon-stage:fullscreen .mon-grid { max-width: max(320px, calc((100vh - 16px) * 16 / 9 * var(--cols) / var(--rows))); }
.mon-stage:fullscreen .mon-fsbar {
    display: flex; align-items: center; gap: 8px; position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 25;
    padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: 999px; background: rgba(0, 10, 51, .85); color: var(--text-2); font-size: .78rem;
    opacity: .35; transition: opacity .15s;
}
.mon-stage:fullscreen .mon-fsbar:hover, .mon-stage:fullscreen .mon-fsbar:focus-within { opacity: 1; }
.mon-stage:fullscreen .mon-modal-box { width: min(100%, calc((100vh - 90px) * 16 / 9)); }

/* mapa do portal */
.mapbar { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 14px; }
.mapbar label { margin: 0; font-size: .85rem; color: var(--text-2); }
.mapbar .form-control, .mapbar .form-select { width: auto; height: 36px; padding-top: 4px; padding-bottom: 4px; font-size: .85rem; }
.mapbar #mapQ { flex: 1 1 260px; max-width: 420px; }
.mapbox { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
#map { height: calc(100vh - 250px); min-height: 420px; background: #f2efe9; }
.map-popup { min-width: 210px; color: #0b1b2b; font-size: .82rem; }
.map-popup-item + .map-popup-item { margin-top: 10px; padding-top: 10px; border-top: 1px solid #d8dee6; }
.map-popup-title { font-weight: 700; font-size: .9rem; margin-bottom: 3px; }
@media (max-width: 575.98px) { #map { height: calc(100vh - 330px); } .mapbar #mapQ { max-width: none; } }

/* janela de parede (?wall=1): so o mosaico, sem menu/filtros, para monitores dedicados */
body.mon-wall .sidebar, body.mon-wall .sidebar-backdrop, body.mon-wall .mobile-bar, body.mon-wall .topbar,
body.mon-wall .mon-controls, body.mon-wall .mon-pager, body.mon-wall .zion-fab { display: none !important; }
body.mon-wall .page { padding: 8px; }
body.mon-wall, body.mon-wall .main { background: #00041a; }
body.mon-wall .monitor { --mon-offset: 16px; }
body.mon-wall .mon-stage { min-height: calc(100vh - 16px); justify-content: center; }
body.mon-wall .mon-fsbar {
    display: flex; align-items: center; gap: 8px; position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 25;
    padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: 999px; background: rgba(0, 10, 51, .85); color: var(--text-2); font-size: .78rem;
    opacity: .35; transition: opacity .15s;
}
body.mon-wall .mon-fsbar:hover, body.mon-wall .mon-fsbar:focus-within { opacity: 1; }

.mon-winpanel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 1030; width: 290px; padding: 14px;
    background: var(--surface, #000a33); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.mon-winpanel[hidden] { display: none; }
.mon-winpanel label { font-size: .78rem; color: var(--text-3); display: block; margin-bottom: 3px; }
.mon-winpanel .form-control { height: 34px; }
.mon-winpanel .mon-winlinks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

@media (max-width: 991.98px) {
    .monitor { --mon-offset: 330px; }
    .mon-controls .form-select, .mon-controls #monQ { flex: 1 1 140px; max-width: none; }
}
@media (max-width: 575.98px) {
    .mon-grid { max-width: none; }
    .mon-modal { padding: 8px; }
    .mon-modal-box { width: 100%; }
    .mon-modal-head { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    .mon-spinner, .mon-badge[data-state="live"]::before { animation: none; }
    .mon-tile, .mon-actions { transition: none; }
}

/* monitor: v2 (fila, reconectando, debug, aviso de host) */
.mon-badge[data-state="reconnecting"] { color: var(--warn); border-color: rgba(255, 190, 61, .5); }
.mon-badge[data-state="queued"] { color: var(--text-2); }
.mon-note {
    display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; padding: 7px 12px; font-size: .76rem; color: var(--warn);
    border: 1px solid rgba(255, 190, 61, .3); border-radius: var(--radius-sm); background: var(--warn-soft);
}
.mon-note[hidden] { display: none; }
.mon-debug {
    position: absolute; left: 6px; bottom: 6px; right: 150px; z-index: 5; padding: 2px 6px; border-radius: 6px; pointer-events: none;
    font: 500 .6rem/1.3 "JetBrains Mono", monospace; color: #9ff; background: rgba(0, 0, 0, .65); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* monitor: v3 (indicador carregando, barra do gate em debug) */
.mon-loading {
    position: absolute; left: 8px; bottom: 8px; z-index: 4; padding: 2px 8px; border-radius: 999px; pointer-events: none;
    font-size: .62rem; font-weight: 600; color: var(--accent); background: rgba(0, 10, 51, .78); border: 1px solid rgba(0, 174, 239, .35);
}
.mon-loading[hidden] { display: none; }
.mon-gatebar { margin: 0 0 8px; padding: 4px 10px; font: 500 .68rem/1.4 "JetBrains Mono", monospace; color: #9ff; background: rgba(0, 0, 0, .55); border-radius: 6px; }

/* ------------------------------------------------------------ interruptores (acesso app/site) e portal do cliente */
.check-tile.form-switch { padding-left: 64px !important; }
.check-tile.form-switch .form-check-input { width: 2.4em; height: 1.3em; margin-left: -50px; margin-top: .1em; cursor: pointer; }
.check-tile.form-switch .form-check-label { cursor: pointer; }
.badge-access { font-weight: 600; letter-spacing: .02em; }
.info-list { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 0; }
.info-list dt { color: var(--text-3); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; align-self: center; }
.info-list dd { margin: 0; font-size: .92rem; word-break: break-word; }
@media (max-width: 575.98px) { .info-list { grid-template-columns: 1fr; gap: 2px 0; } .info-list dd { margin-bottom: 10px; } }