:root {
    --bg: #eef4fb;
    --bg-alt: #dfeaf7;
    --panel: rgba(255, 255, 255, 0.94);
    --panel-strong: rgba(248, 251, 255, 0.98);
    --line: rgba(86, 111, 145, 0.18);
    --line-strong: rgba(86, 111, 145, 0.32);
    --text: #17324d;
    --muted: #5f748f;
    --accent: #2f7de1;
    --accent-soft: rgba(47, 125, 225, 0.14);
    --ok: #2f9d57;
    --ok-soft: rgba(47, 157, 87, 0.14);
    --warn: #c88700;
    --warn-soft: rgba(200, 135, 0, 0.14);
    --danger: #d84c4c;
    --danger-soft: rgba(216, 76, 76, 0.14);
    --shadow: 0 18px 40px rgba(42, 65, 94, 0.12);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    min-height: 100%;
    background:
        radial-gradient(circle at top right, rgba(47, 125, 225, 0.16), transparent 36%),
        radial-gradient(circle at top left, rgba(216, 76, 76, 0.10), transparent 28%),
        linear-gradient(180deg, #eef4fb 0%, #dfeaf7 100%);
    color: var(--text);
    font-family: Inter, Segoe UI, Arial, Helvetica, sans-serif;
    overflow: hidden;
    zoom: 0.8;
}
.app-shell {
    height: 125vh;
    display: grid;
    grid-template-rows: auto 1fr;
}
@supports not (zoom: 1) {
    body {
        zoom: 1;
    }
    .app-shell {
        transform: scale(0.8);
        transform-origin: top left;
        width: 125%;
        height: 125vh;
    }
}
.topbar {
    position: relative;
    padding: 22px 24px 16px 24px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(247, 250, 255, 0.98), rgba(239, 246, 255, 0.94));
    backdrop-filter: blur(16px);
}
.topbar::after {
    content: "";
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(47, 125, 225, 0.04), rgba(47, 125, 225, 0.40), rgba(216, 76, 76, 0.04));
}
.title-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.title-block h1 {
    margin: 0;
    font-size: 28px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.title-block p {
    margin: 6px 0 0 0;
    color: var(--muted);
    font-size: 14px;
}
.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    color: var(--muted);
    font-size: 13px;
}
.chip strong { color: var(--text); font-weight: 700; }
.chip.live { border-color: rgba(47, 125, 225, 0.34); color: #24538a; }
.toolbar-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: stretch;
}
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
}
.panel-form {
    padding: 18px;
}
.panel-form form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px auto;
    gap: 12px;
    align-items: end;
}
.field label {
    display: block;
    margin: 0 0 8px 0;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.field input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid rgba(111, 136, 171, 0.28);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    outline: none;
}
.field input:focus {
    border-color: rgba(47, 125, 225, 0.52);
    box-shadow: 0 0 0 4px rgba(47, 125, 225, 0.10);
}
.field input[readonly] {
    background: rgba(244, 248, 253, 0.98);
    color: #365270;
}
.botao {
    height: 46px;
    padding: 0 20px;
    border: 1px solid rgba(47, 125, 225, 0.34);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.96), rgba(37, 99, 235, 0.96));
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
}
.botao:hover { filter: brightness(1.06); }
.botao:disabled {
    cursor: wait;
    opacity: 0.7;
}
.telemetry {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.metric {
    position: relative;
    padding: 16px 18px;
    min-height: 92px;
    overflow: hidden;
}
.metric::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, rgba(83, 167, 255, 0.9), rgba(83, 167, 255, 0.16));
}
.metric.ok::before { background: linear-gradient(180deg, rgba(115, 217, 139, 0.95), rgba(115, 217, 139, 0.16)); }
.metric.warn::before { background: linear-gradient(180deg, rgba(255, 209, 102, 0.95), rgba(255, 209, 102, 0.18)); }
.metric.danger::before { background: linear-gradient(180deg, rgba(255, 109, 109, 0.95), rgba(255, 109, 109, 0.16)); }
.metric .label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.metric .value {
    margin-top: 10px;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.metric .hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}
.metric-fim .value {
    margin-top: 6px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fim-carga {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}
.fim-carga.ativo {
    display: flex;
}
.fim-carga-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid rgba(83, 167, 255, 0.18);
    border-top-color: rgba(47, 125, 225, 0.92);
    animation: giro-consulta-dados 0.9s linear infinite;
}
.fim-carga-texto {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #1f3e63;
}
.fim-execucao-texto.oculto {
    display: none;
}
@keyframes giro-consulta-dados {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.status-bar {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2f7de1;
    box-shadow: 0 0 12px rgba(47, 125, 225, 0.28);
}
.status-text {
    flex: 1 1 320px;
    min-width: 0;
    color: #1f3e63;
    font-size: 14px;
    white-space: normal;
    overflow-wrap: anywhere;
}
.cache-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.86);
    color: var(--muted);
    font-size: 12px;
}
.cache-pill.cache-online { border-color: rgba(47, 125, 225, 0.36); color: #24538a; }
.cache-pill.cache-local { border-color: rgba(47, 157, 87, 0.30); color: #256c3f; }
.cache-pill.cache-empty { border-color: rgba(200, 135, 0, 0.28); color: #8a5a00; }
.content-shell {
    min-height: 0;
    padding: 18px 24px 24px 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.surface {
    flex: 1 1 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.surface-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(248, 251, 255, 0.99), rgba(240, 246, 255, 0.95));
}
.surface-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.surface-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}
.table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.table-wrap table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}
.table-wrap th,
.table-wrap td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(128, 148, 180, 0.10);
    text-align: left;
    vertical-align: middle;
}
.table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(180deg, rgba(229, 238, 249, 0.99), rgba(217, 229, 243, 0.98));
    color: #1f3e63;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    box-shadow: inset 0 -1px 0 rgba(128, 148, 180, 0.16);
}
.table-wrap tbody tr:not(.linha-grupo):nth-child(even) td { background: rgba(47, 125, 225, 0.018); }
.table-wrap tbody tr:not(.linha-grupo):hover td { background: rgba(47, 125, 225, 0.06); }
.table-wrap tbody tr.linha-verde td { background: rgba(232, 245, 237, 0.98); }
.table-wrap tbody tr.linha-vermelha td { background: rgba(255, 239, 239, 0.98); }
.table-wrap tbody tr.linha-grupo td {
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(229, 236, 246, 0.98), rgba(220, 230, 243, 0.96)) !important;
    color: #17324d;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    white-space: nowrap;
    border-top: 1px solid rgba(128, 148, 180, 0.20);
    border-bottom: 1px solid rgba(128, 148, 180, 0.16);
}
.table-wrap tbody tr.linha-grupo td::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 10px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(47, 125, 225, 0.96), rgba(36, 98, 184, 0.96));
    box-shadow: 0 0 0 4px rgba(47, 125, 225, 0.10);
    vertical-align: middle;
}
.table-wrap thead th,
.table-wrap tbody tr:not(.linha-grupo) td {
    width: 12.5%;
}
.table-wrap td .link-quantidade,
.table-wrap td .texto-quantidade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    max-width: 100%;
    height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(83, 167, 255, 0.28);
    background: rgba(47, 125, 225, 0.10);
    color: #1f3e63;
    text-decoration: none;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table-wrap td .link-quantidade:hover {
    background: rgba(47, 125, 225, 0.16);
    border-color: rgba(47, 125, 225, 0.34);
}
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    padding: 22px;
    color: var(--muted);
    text-align: center;
    border-top: 1px solid var(--line);
}
@media (max-width: 1200px) {
    .telemetry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    body { overflow: auto; }
    .app-shell { height: auto; min-height: 100vh; grid-template-rows: auto auto; }
    .title-row { flex-direction: column; align-items: flex-start; }
    .tag-row { justify-content: flex-start; }
    .panel-form form { grid-template-columns: 1fr; }
    .telemetry { grid-template-columns: 1fr; }
    .content-shell { padding-top: 12px; }
    .table-wrap { overflow: auto; }
}

.table-wrap th.col-nome,
.table-wrap td.col-nome,
.table-wrap th.col-database,
.table-wrap td.col-database,
.table-wrap th.col-rede,
.table-wrap td.col-rede,
.table-wrap th.col-log,
.table-wrap td.col-log,
.table-wrap th.col-log-sis,
.table-wrap td.col-log-sis,
.table-wrap th.col-quantidade,
.table-wrap td.col-quantidade {
    width: 12.5%;
    min-width: 12.5%;
    max-width: 12.5%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table-wrap td.col-log .texto-info-banco,
.table-wrap td.col-log-sis .texto-info-banco,
.table-wrap td.col-rede .texto-info-banco {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    max-width: 100%;
    padding: 0 10px;
    border-radius: 12px;
    border: 1px solid rgba(86, 111, 145, 0.16);
    background: rgba(255, 255, 255, 0.74);
    color: #183957;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}
.table-wrap td.col-rede .texto-info-banco {
    border-color: rgba(47, 125, 225, 0.22);
    background: rgba(47, 125, 225, 0.08);
}
.table-wrap td.col-log .texto-info-banco,
.table-wrap td.col-log-sis .texto-info-banco {
    justify-content: flex-start;
}
.table-wrap td.col-log .texto-info-banco.alerta,
.table-wrap td.col-log-sis .texto-info-banco.alerta {
    border-color: rgba(216, 76, 76, 0.24);
    background: rgba(216, 76, 76, 0.10);
    color: #ad2d2d;
}
