:root {
    --bg: #05070a;
    --panel: #0b0f14;
    --card: #0f141a;
    --card-2: #121820;
    --text: #f8fafc;
    --muted: #9aa4b2;
    --line: rgba(255, 255, 255, 0.07);

    --primary: #ffcf33;
    --primary-dark: #f2c200;
    --primary-soft: rgba(255, 207, 51, 0.14);

    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;

    --table-head: #090d12;
    --table-row-hover: rgba(255, 255, 255, 0.028);
    --input-bg: #0a0f15;
    --input-line: #273241;
    --input-focus: #ffcf33;

    --shadow: 0 14px 36px rgba(0, 0, 0, 0.34);
    --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.22);

    --brand-logo-size: 68px;
    --brand-text-size: 21px;

    --petal-1: #fff1b8;
    --petal-2: #ffe082;
    --petal-3: #ffd54f;
    --petal-stroke: rgba(255, 255, 255, 0.22);

    --core-ring: #c59600;
    --core-fill: #fff8dc;
    --core-dot: #8a6700;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 24%),
        linear-gradient(180deg, #070a0f 0%, #05070a 100%);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

a:hover {
    text-decoration: underline;
    color: #ffe082;
}

.portal-topbar-main-shell {
    position: sticky;
    top: 0;
    z-index: 80;
    background: linear-gradient(180deg, #05070a 0%, #080c11 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

.portal-topbar-main {
    min-height: 88px;
}

.portal-topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 16px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.portal-topbar-nav-shell {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.015) 0%, rgba(255, 255, 255, 0.005) 100%);
}

.portal-nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.portal-nav a {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    font-size: 14px;
    font-weight: 700;
    transition: .18s ease;
}

.portal-nav a:hover {
    background: rgba(255, 255, 255, 0.10);
    text-decoration: none;
    transform: translateY(-1px);
    color: #fff7d1;
}

.portal-nav a.active {
    background: linear-gradient(180deg, #ffcf33, #f2c200);
    color: #241b00;
    border-color: transparent;
    box-shadow: 0 8px 18px rgba(255, 207, 51, 0.16);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-toggle {
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 18px;
    cursor: pointer;
}

.mobile-only {
    display: none !important;
}

.desktop-only {
    display: inline-flex !important;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    text-decoration: none;
    min-width: 0;
}

.brand:hover {
    text-decoration: none;
}

.brand-logo {
    width: var(--brand-logo-size);
    height: var(--brand-logo-size);
    display: block;
    overflow: visible;
    flex: 0 0 auto;
    filter:
        drop-shadow(0 0 8px rgba(255, 207, 51, 0.18)) drop-shadow(0 0 18px rgba(255, 207, 51, 0.08));
}

.brand-wrap {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.brand-title {
    display: flex;
    align-items: center;
    line-height: 1.05;
}

.brand-title-subline {
    margin-top: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #cbd5e1;
    letter-spacing: .01em;
}

.brand-text {
    font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", "Verdana", sans-serif;
    font-size: var(--brand-text-size);
    font-weight: 800;
    letter-spacing: .4px;
    line-height: 1;
    color: #fffdf7;
    display: inline-block;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-shadow:
        0 0 1px rgba(255, 255, 255, .18),
        0 0 12px rgba(255, 207, 51, .10);
}

.brand-text-r {
    color: #ffe082;
    text-shadow:
        0 0 1px rgba(255, 255, 255, .16),
        0 0 12px rgba(255, 207, 51, .18);
}

.rk-petal .petal {
    stroke: var(--petal-stroke);
    stroke-width: 2.1;
    vector-effect: non-scaling-stroke;
}

.rk-petal .p1 {
    fill: var(--petal-1);
}

.rk-petal .p2 {
    fill: var(--petal-2);
}

.rk-petal .p3 {
    fill: var(--petal-3);
}

.rk-core-ring {
    fill: var(--core-ring);
}

.rk-core-fill {
    fill: var(--core-fill);
}

.rk-core-dot {
    fill: var(--core-dot);
}

.rk-core {
    transform-origin: 50px 50px;
    animation: rk-core-pulse 3.2s ease-in-out infinite;
}

.rk-petal {
    transform-box: view-box;
    transform-origin: 50px 50px;
    will-change: transform;
    transition: transform .12s linear;
}

@keyframes rk-core-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.06);
    }
}

.portal-main {
    min-height: calc(100vh - 140px);
}

.wrap {
    max-width: 1400px;
    margin: 24px auto;
    padding: 0 16px;
}

.back-row {
    margin-bottom: 16px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.card {
    background: linear-gradient(180deg, #11161d 0%, #0d1218 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 18px;
    box-shadow: var(--shadow-soft);
}

.card h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--muted);
    font-weight: 600;
}

.big {
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
}

.big-sm {
    font-size: 22px;
}

.panel {
    background: linear-gradient(180deg, #10151c 0%, #0c1117 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.panel-head {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 700;
    background: linear-gradient(180deg, #0a0e13 0%, #090c11 100%);
    color: #ffffff;
}

.panel-section {
    padding: 16px;
}

.panel-section-topless {
    padding-top: 0;
}

.panel-toggle {
    display: block;
}

.panel-toggle>summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.panel-toggle>summary::-webkit-details-marker {
    display: none;
}

.panel-head-toggle {
    position: relative;
    padding-right: 36px;
}

.panel-head-toggle::after {
    content: "▸";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.18s ease;
    opacity: 0.9;
}

.panel-toggle[open]>.panel-head-toggle::after {
    transform: translateY(-50%) rotate(90deg);
}

.section-gap {
    margin-bottom: 20px;
}

.table-wrap {
    width: 100%;
    overflow: auto;
}

.table-wrap.table-wrap-y-420 {
    max-height: 420px;
}

.table-wrap.table-wrap-y-520 {
    max-height: 520px;
}

.table-wrap table {
    min-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 14px;
    text-align: left;
    vertical-align: middle;
    color: var(--text);
}

th {
    background: var(--table-head);
    color: #f8fafc;
    font-weight: 700;
}

tr:hover td {
    background: var(--table-row-hover);
}

.label-col {
    width: 220px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

.ok {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.2);
}

.no {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.2);
}

.btn {
    background: var(--primary);
    color: #2b2100;
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
    transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
    box-shadow: 0 8px 18px rgba(255, 207, 51, 0.16);
}

.btn:hover {
    background: var(--primary-dark);
    color: #241b00;
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-ghost-light {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: none;
}

.btn-ghost-light:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 8px 18px rgba(239, 68, 68, 0.14);
}

.btn-danger:hover {
    background: #dc2626;
    color: #fff;
}

.btn-muted {
    background: #3b4452;
    color: #f8fafc;
    box-shadow: none;
}

.btn-muted:hover {
    background: #4b5563;
    color: #fff;
}

.btn-warn {
    background: var(--warn);
    color: #231600;
    box-shadow: 0 8px 18px rgba(245, 158, 11, 0.12);
}

.btn-warn:hover {
    background: #d97706;
    color: #231600;
}

.login-box {
    max-width: 420px;
    margin: 90px auto;
    background: linear-gradient(180deg, #11161d 0%, #0d1218 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.login-box h1 {
    margin-top: 0;
    font-size: 24px;
    color: #ffffff;
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--text);
}

.field input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--input-line);
    border-radius: 10px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text);
}

.error {
    color: #fca5a5;
    margin-bottom: 12px;
    font-weight: 700;
}

.form-control,
.form-control-sm,
.form-select,
textarea,
input[type="text"],
input[type="password"],
input[type="number"],
select {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--input-line);
    border-radius: 10px;
    outline: none;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
}

.form-control-sm {
    width: 180px;
    padding: 10px 12px;
}

.form-select {
    padding: 10px 12px;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
.form-control:focus,
.form-control-sm:focus,
.form-select:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(255, 207, 51, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: #6b7280;
}

.form-check-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.form-check-inline input[type="checkbox"] {
    accent-color: var(--primary);
}

.actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.help-text {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.text-wrap {
    white-space: pre-wrap;
    word-break: break-word;
}

.cell-break {
    white-space: normal;
    word-break: break-word;
}

.bg-soft {
    background: rgba(255, 255, 255, 0.018);
}

.meta-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 12px;
}

.log-box {
    margin: 8px 0 0 0;
    padding: 12px;
    border-radius: 8px;
    font-family: Consolas, "Courier New", monospace;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    max-height: 340px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.log-box.log-box-dark {
    background: #020617;
    color: #dbeafe;
}

.log-box.log-box-error {
    background: #3f0d14;
    color: #fecaca;
    border-color: rgba(239, 68, 68, 0.2);
}

.log-box.log-box-light {
    background: #0d131b;
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.log-box.log-box-command {
    background: rgba(255, 207, 51, 0.08);
    color: #fff2b3;
    border: 1px solid rgba(255, 207, 51, 0.14);
}

.terminal-textarea {
    min-height: 120px;
    font-family: Consolas, monospace;
}

.app-desc-textarea {
    min-height: 100px;
}

.advanced-block {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.hidden {
    display: none;
}

.text-center {
    text-align: center;
}

.detail-block {
    margin-bottom: 8px;
}

/* Mensagens flash */
.flash-messages {
    max-width: 1400px;
    margin: 16px auto 0 auto;
    padding: 0 16px;
}

.flash-message {
    margin-bottom: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    font-weight: 700;
    border: 1px solid transparent;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.flash-message.error {
    background: rgba(127, 29, 29, 0.26);
    color: #fecaca;
    border-color: rgba(239, 68, 68, 0.2);
}

.flash-message.success {
    background: rgba(6, 95, 70, 0.24);
    color: #a7f3d0;
    border-color: rgba(34, 197, 94, 0.2);
}

.flash-message.info {
    background: rgba(255, 207, 51, 0.12);
    color: #fde68a;
    border-color: rgba(255, 207, 51, 0.18);
}

.portal-footer {
    margin-top: 24px;
    padding: 0 0 18px;
}

.portal-footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: 1px;
}

.nav-logout-form {
    margin: 0;
    width: 100%;
}

.nav-logout-btn {
    width: 100%;
    justify-content: center;
}

@media (max-width: 1024px) {
    .grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 640px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .portal-topbar-inner {
        padding: 12px 14px 10px;
    }

    .brand-logo {
        width: 58px;
        height: 58px;
    }

    .brand-text {
        font-size: 18px;
    }

    .brand-title-subline {
        font-size: 12px;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: inline-flex !important;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .portal-nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 14px 12px;
    }

    .portal-nav.is-open {
        display: flex;
    }

    .portal-nav a {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .wrap {
        padding: 0 10px;
    }

    .flash-messages {
        padding: 0 10px;
    }

    .portal-footer-inner {
        padding: 0 10px;
    }
}

/* ===== Console remoto maior ===== */
#console-remoto .table-wrap.table-wrap-y-520 {
    max-height: min(78vh, 980px);
}

#console-remoto .log-box {
    max-height: min(62vh, 760px);
}

#console-remoto .terminal-textarea {
    min-height: 140px;
}

/* ===== Destaque geral dos botões ===== */
.btn,
.btn-muted,
.btn-warn,
.btn-danger,
.btn-ghost-light,
.portal-nav a,
.terminal-tab-btn {
    border: 1px solid rgba(255, 207, 51, 0.28);
}

.btn:hover,
.btn-muted:hover,
.btn-warn:hover,
.btn-danger:hover,
.btn-ghost-light:hover,
.portal-nav a:hover,
.terminal-tab-btn:hover {
    border-color: rgba(255, 207, 51, 0.85);
    box-shadow:
        0 0 0 1px rgba(255, 207, 51, 0.22),
        0 10px 24px rgba(255, 207, 51, 0.12);
}

/* ===== Abas do terminal ===== */
.terminal-tab-nav {
    gap: 12px;
}

.terminal-tab-btn {
    min-width: 140px;
    justify-content: center;
    font-weight: 700;
}

.terminal-tab-btn.is-active {
    background: linear-gradient(180deg, #ffcf33, #f2c200);
    color: #241b00;
    border-color: #ffcf33;
    box-shadow:
        0 0 0 1px rgba(255, 207, 51, 0.28),
        0 10px 24px rgba(255, 207, 51, 0.18);
}

.relatorio-a4 {
    max-width: 1120px;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 12mm;
    }

    body {
        background: #fff !important;
        color: #000 !important;
    }

    .portal-topbar-main-shell,
    .portal-topbar-nav-shell,
    .portal-footer,
    .flash-messages,
    .no-print {
        display: none !important;
    }

    .wrap,
    .relatorio-a4 {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .panel,
    .card {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #bbb !important;
        box-shadow: none !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .panel-head,
    th,
    td,
    .big,
    .big-sm,
    .help-text,
    .meta-row,
    .badge,
    a,
    label,
    div,
    span {
        color: #000 !important;
        background: transparent !important;
        text-shadow: none !important;
        box-shadow: none !important;
    }

    table {
        width: 100% !important;
    }

    .table-wrap {
        overflow: visible !important;
        max-height: none !important;
    }

    .btn {
        display: none !important;
    }
}

/* ===== Relatório de terminais ===== */
.relatorio-tabela-terminais th,
.relatorio-tabela-terminais td {
    vertical-align: top;
}

.relatorio-tabela-terminais th:nth-child(1),
.relatorio-tabela-terminais td:nth-child(1) {
    width: 18%;
}

.relatorio-tabela-terminais th:nth-child(2),
.relatorio-tabela-terminais td:nth-child(2) {
    width: 16%;
    white-space: nowrap;
}

.relatorio-tabela-terminais th:nth-child(3),
.relatorio-tabela-terminais td:nth-child(3) {
    width: 20%;
}

.relatorio-tabela-terminais th:nth-child(4),
.relatorio-tabela-terminais td:nth-child(4) {
    width: 23%;
}

.relatorio-tabela-terminais th:nth-child(5),
.relatorio-tabela-terminais td:nth-child(5) {
    width: 7%;
    white-space: nowrap;
}

.relatorio-tabela-terminais th:nth-child(6),
.relatorio-tabela-terminais td:nth-child(6) {
    width: 9%;
    white-space: nowrap;
}

.relatorio-tabela-terminais th:nth-child(7),
.relatorio-tabela-terminais td:nth-child(7) {
    width: 12%;
    white-space: nowrap;
}

.cliente-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 207, 51, 0.28);
    color: #f8fafc;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    line-height: 1.1;
    box-shadow: none;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.cliente-btn:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 207, 51, 0.85);
    color: #fff7d1;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow:
        0 0 0 1px rgba(255, 207, 51, 0.22),
        0 10px 24px rgba(255, 207, 51, 0.12);
}

.cliente-btn:active {
    transform: translateY(0);
}