/* ============================================================================
   MDBack — sistema de design
   ----------------------------------------------------------------------------
   Referência: ferramenta de operação (Grafana/Datadog/Linear), não landing page.
   Princípios aplicados aqui:
     - Densidade honesta: tabela é tabela, painel é painel. Card só onde há
       agrupamento real de conteúdo heterogêneo.
     - Uma fonte de UI (Inter) + uma de dados (JetBrains Mono). Mono SÓ para
       dado real: comando, tamanho, timestamp, caminho, versão.
     - Caixa alta apenas em rótulos micro (11px). Título e botão em frase.
     - Roxo da marca (#703191) com disciplina: preenchimento sólido, item ativo,
       foco e seleção. Nunca como cor de texto sobre fundo escuro (contraste
       ~2:1) -- para isso existe --brand-text, mesmo matiz, mais claro.
     - Status é indicador preciso (ponto + rótulo), não texto colorido solto.
   ========================================================================= */

:root {
    /* superfícies -- neutro levemente frio, sem virar azul */
    --bg: #0e0f13;
    --bg-elev: #13151a;
    --surface: #181b21;
    --surface-hover: #1e222a;
    --surface-active: #242932;
    --border: #242832;
    --border-strong: #333947;

    --fg: #e6e8ec;
    --fg-muted: #979fac;
    /* 4.6:1 sobre --surface. Não escurecer: este token é usado em rótulos de
       11px (tabela, métrica, meta), que precisam do mínimo de 4.5:1. */
    --fg-subtle: #7d8493;

    /* marca MDotti */
    --brand: #703191;
    --brand-hover: #80399f;
    --brand-fg: #f7f2fb;
    --brand-text: #c49ae4;
    --brand-ring: rgba(112, 49, 145, 0.45);
    --brand-wash: rgba(112, 49, 145, 0.13);

    /* status -- dessaturados o suficiente pra não competir com a marca */
    --ok: #43a06a;
    --ok-text: #63c189;
    --ok-wash: rgba(67, 160, 106, 0.12);
    --warn: #b07d24;
    --warn-text: #dba53d;
    --warn-wash: rgba(176, 125, 36, 0.12);
    --danger: #bb443c;
    --danger-text: #e2665d;
    --danger-wash: rgba(187, 68, 60, 0.12);
    --idle: #2b303a;

    /* Largura da coluna de conteudo. A barra do topo usa a MESMA, para o
       titulo e o botao "Atualizar" nascerem alinhados com o que esta abaixo. */
    --content-max: 1320px;

    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 10px;

    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);

    --sidebar-w: 236px;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 13.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv05", "cv11";
}

h1, h2, h3, p { margin: 0; }

a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

::selection { background: var(--brand-ring); color: var(--fg); }

/* números alinhados em coluna -- detalhe que faz tabela de dados parecer séria */
.tnum, td, .metric-value, .mono { font-variant-numeric: tabular-nums; }

.mono { font-family: var(--mono); }

/* ============================================================== shell/layout */

.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.24s var(--ease);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 57px;
    padding: 0 var(--sp-4);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.brand-mark {
    width: 26px; height: 26px;
    border-radius: var(--r-sm);
    background: var(--brand);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.brand-mark svg { width: 15px; height: 15px; color: var(--brand-fg); }
.brand-text { font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; }
.brand-text span { color: var(--brand-text); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-2); }

.nav-group + .nav-group { margin-top: var(--sp-5); }
.nav-group-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-subtle);
    padding: 0 var(--sp-3) var(--sp-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px var(--sp-3);
    margin-bottom: 1px;
    border: none;
    border-radius: var(--r-md);
    background: none;
    color: var(--fg-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    position: relative;
    transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: var(--surface-hover); color: var(--fg); }
.nav-item.is-active { background: var(--brand-wash); color: var(--fg); font-weight: 600; }
.nav-item.is-active svg { color: var(--brand-text); opacity: 1; }
.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: 0; top: 50%;
    width: 2px; height: 15px;
    background: var(--brand-text);
    border-radius: 0 2px 2px 0;
    transform: translateY(-50%);
}
.nav-count {
    margin-left: auto;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger-wash);
    color: var(--danger-text);
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 600;
    text-align: center;
    line-height: 17px;
}
.nav-count[hidden] { display: none; }
/* "Sem rotina" é pendência de configuração, não falha ativa -- usar o vermelho
   dos alertas aqui gastaria o sinal mais forte da interface com outra coisa. */
.nav-count.is-warn { background: var(--warn-wash); color: var(--warn-text); }

.sidebar-foot {
    border-top: 1px solid var(--border);
    padding: var(--sp-3);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.avatar {
    width: 27px; height: 27px;
    border-radius: 999px;
    background: var(--surface-active);
    border: 1px solid var(--border-strong);
    display: grid;
    place-items: center;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--fg-muted);
    flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 10.5px; color: var(--fg-subtle); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 57px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid transparent;
    transition: height 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
/* cabeçalho reage à rolagem: encolhe e ganha contorno, pra separar do conteúdo */
.topbar.is-scrolled {
    height: 49px;
    border-bottom-color: var(--border);
    box-shadow: var(--shadow-sm);
}
/* A barra pinta a largura toda (o vidro e a linha inferior atravessam a tela),
   mas o CONTEUDO dela para na mesma coluna do `.content`. */
.topbar-inner {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    height: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding: 0 var(--sp-5);
}

.topbar-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

.menu-toggle { display: none; }

/* Centralizado de proposito. Antes era `max-width` sem `margin-inline`, entao
   em tela larga tudo se amontoava a esquerda e sobrava um vazio enorme a
   direita -- a tela parecia inacabada. */
.content {
    padding: var(--sp-5) var(--sp-5) var(--sp-7);
    max-width: var(--content-max);
    margin-inline: auto;
}

.view { display: none; }
.view.is-active { display: block; }

/* Revelação na rolagem -- 8px e 0.32s: ritmo sem atrasar leitura.
   O estado escondido é aplicado por JS (.is-armed), nunca no CSS base -- se o
   observer falhar ou o JS não rodar, o conteúdo aparece normalmente em vez de
   ficar invisível. */
.reveal.is-armed { opacity: 0; transform: translateY(8px); }
.reveal.is-in {
    opacity: 1;
    transform: none;
    transition: opacity 0.32s var(--ease-out), transform 0.32s var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .reveal, .reveal.is-armed { opacity: 1; transform: none; }
}

/* ==================================================================== texto */

.section-head {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    margin: var(--sp-6) 0 var(--sp-3);
}
.section-head:first-child { margin-top: 0; }
.section-title { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }
.section-note { font-size: 11.5px; color: var(--fg-subtle); }
.section-head .spacer { flex: 1; }
/* Controles à direita do título da seção (ex.: "Atualizar lista" do inventário).
   `margin-left:auto` empurra pra direita sem precisar de um .spacer no meio. */
.section-aside {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.hint { font-size: 12px; color: var(--fg-subtle); max-width: 68ch; }
.hint strong { color: var(--fg-muted); font-weight: 600; }
.hint code {
    font-family: var(--mono);
    font-size: 11.5px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 4px;
}

/* =================================================================== painéis */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.panel + .panel { margin-top: var(--sp-3); }

.panel-head {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg-elev);
}
.panel-head .spacer { flex: 1; }
.panel-title { font-size: 12.5px; font-weight: 600; }
.panel-body { padding: var(--sp-4); }
.panel-body.is-flush { padding: 0; }

/* ---- faixa de resumo: divisões, não seis cards iguais ---- */

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.metric {
    padding: var(--sp-4);
    border-right: 1px solid var(--border);
    min-width: 0;
}
.metric:last-child { border-right: none; }
.metric-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-subtle);
    margin-bottom: 6px;
}
.metric-value {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
    display: flex;
    align-items: center;
    gap: 8px;
}
.metric-value.is-sm { font-size: 14px; font-weight: 550; letter-spacing: 0; }
.metric-foot { font-size: 11.5px; color: var(--fg-subtle); margin-top: 3px; }
.metric-value .of { color: var(--fg-subtle); font-weight: 500; font-size: 15px; }
.metric.is-ok .metric-value { color: var(--ok-text); }
.metric.is-warn .metric-value { color: var(--warn-text); }
.metric.is-danger .metric-value { color: var(--danger-text); }

/* ================================================================== status */

.dot {
    width: 7px; height: 7px;
    border-radius: 999px;
    background: var(--idle);
    flex-shrink: 0;
    display: inline-block;
}
.dot.is-ok { background: var(--ok); box-shadow: 0 0 0 2.5px var(--ok-wash); }
.dot.is-warn { background: var(--warn); box-shadow: 0 0 0 2.5px var(--warn-wash); }
.dot.is-danger { background: var(--danger); box-shadow: 0 0 0 2.5px var(--danger-wash); }
.dot.is-idle { background: var(--idle); box-shadow: 0 0 0 2.5px rgba(255, 255, 255, 0.03); }

/* pulso discreto só no que exige ação agora */
.dot.is-live { animation: dot-pulse 2.4s var(--ease) infinite; }
@keyframes dot-pulse {
    0%, 100% { box-shadow: 0 0 0 2.5px var(--danger-wash); }
    50% { box-shadow: 0 0 0 5px rgba(187, 68, 60, 0.05); }
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--fg-muted);
    white-space: nowrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 550;
    border: 1px solid transparent;
    white-space: nowrap;
}
.pill.is-ok { background: var(--ok-wash); color: var(--ok-text); border-color: rgba(67, 160, 106, 0.25); }
.pill.is-warn { background: var(--warn-wash); color: var(--warn-text); border-color: rgba(176, 125, 36, 0.25); }
.pill.is-danger { background: var(--danger-wash); color: var(--danger-text); border-color: rgba(187, 68, 60, 0.25); }
.pill.is-idle { background: var(--surface-active); color: var(--fg-subtle); border-color: var(--border); }
.pill.is-brand { background: var(--brand-wash); color: var(--brand-text); border-color: rgba(112, 49, 145, 0.35); }
.pill.is-neutral { background: var(--surface-active); color: var(--fg-muted); border-color: var(--border); }

/* Linha de tabela esmaecida: usada no inventário do Proxmox para guest que
   deixou de existir no hipervisor -- continua visível (o operador precisa ver
   que sumiu), mas sem competir com as linhas ativas. */
tr.is-muted > td { opacity: 0.62; }

/* Aviso em bloco, dentro de um painel ou seção. Menos alarmante que um alerta
   da página inteira, mais visível que um .hint. */
.note {
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--fg-muted);
    background: var(--surface-active);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-3);
}
.note strong { color: var(--fg); font-weight: 600; }
.note.is-warn {
    background: var(--warn-wash);
    border-color: rgba(176, 125, 36, 0.28);
    color: var(--warn-text);
}
.note.is-warn strong { color: var(--warn-text); }
.note .mono { font-family: var(--mono); }

/* Cabecalho de grupo dentro de uma tabela de dados.
   Usado na lista de arquivos para fita: o vzdump do Proxmox e o backup que
   outro sistema largou no share sao origens diferentes e nao devem se misturar
   numa lista corrida. Nao e linha clicavel -- e rotulo. */
.data tbody tr.row-group td {
    background: var(--surface-active);
    padding-top: var(--sp-2);
    padding-bottom: var(--sp-2);
    border-top: 1px solid var(--border);
    color: var(--fg);
    font-size: 12px;
}
.data tbody tr.row-group svg {
    width: 13px;
    height: 13px;
    vertical-align: -2px;
    margin-right: 5px;
    color: var(--fg-muted);
}
.data tbody tr.row-group .cell-sub { display: inline; margin-left: 4px; }
.data tbody tr.row-group.is-clickable { cursor: pointer; }
.data tbody tr.row-group:hover td { background: var(--surface-hover); }

/* Seta do grupo: aponta pra direita retraido, pra baixo aberto. */
/* Arvore de "Hosts e VMs": grupo > no > guests.
   O recuo e o unico sinal de profundidade -- sem ele as tres alturas viram a
   mesma lista corrida que a arvore veio substituir. */
.data tbody tr.arvore-no > td:first-child { padding-left: 22px; }
.data tbody tr.arvore-guest > td:first-child {
    padding-left: 46px;
    position: relative;
}
/* Fio vertical ligando o guest ao no a que ele pertence. */
.data tbody tr.arvore-guest > td:first-child::before {
    content: "";
    position: absolute;
    left: 30px;
    top: 0;
    bottom: 0;
    border-left: 1px solid var(--border);
}
.data tbody tr.arvore-no .grupo-seta { margin-right: 2px; }

.grupo-seta {
    display: inline-block;
    transition: transform 0.12s var(--ease);
    vertical-align: -2px;
}
.grupo-seta.is-open { transform: rotate(90deg); }
.data tbody tr.row-group .grupo-seta svg { margin-right: 2px; }

/* Barra de andamento. Usada na copia para fita, onde a operacao leva horas.
   Deliberadamente simples: o valor esta no numero e na etapa ao lado, a barra
   e so a leitura periferica de "esta andando". */
.barra {
    height: 6px;
    border-radius: 3px;
    background: var(--surface-active);
    overflow: hidden;
}
.barra-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--brand);
    transition: width 0.4s var(--ease);
}

/* Lista curta dentro de uma celula (alertas do drive de fita). Sem marcador:
   ja esta dentro de um contexto rotulado, e bolinha ali vira ruido. */
.lista-seca {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    font-size: 11.5px;
    color: var(--fg-muted);
}
.lista-seca li { margin-top: 3px; }
.lista-seca strong { color: var(--fg); font-weight: 550; }

/* ============================================= timeline de 30 dias (assinatura) */
/* É o elemento memorável do produto: a leitura de "rodou / não rodou / falhou"
   dos últimos 30 dias numa tira densa. Cada barra é um dia. */

.timeline { display: flex; gap: 2px; align-items: flex-end; height: 26px; }
.tl-day {
    flex: 1 1 0;
    min-width: 3px;
    height: 100%;
    border-radius: 2px;
    background: var(--idle);
    position: relative;
    transition: transform 0.12s var(--ease), filter 0.12s var(--ease);
}
.tl-day.is-success { background: var(--ok); }
.tl-day.is-failed { background: var(--danger); }
.tl-day.is-none { background: var(--idle); }
.tl-day:hover { transform: scaleY(1.14); filter: brightness(1.25); z-index: 1; }
.timeline.is-compact { height: 18px; }

.tl-legend {
    display: flex;
    gap: var(--sp-4);
    font-size: 11px;
    color: var(--fg-subtle);
    margin-top: var(--sp-2);
}
.tl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tl-key { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ================================================================== tabelas */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left;
    padding: 9px var(--sp-4);
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-subtle);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
table.data td {
    padding: 10px var(--sp-4);
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background 0.1s var(--ease); }
table.data tbody tr.is-clickable { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-hover); }
table.data tbody tr.is-selected td { background: var(--brand-wash); }
table.data .num { text-align: right; font-family: var(--mono); font-size: 11.5px; }
table.data .col-actions { text-align: right; width: 1%; white-space: nowrap; }
table.data .cell-strong { font-weight: 550; color: var(--fg); }
table.data .cell-sub { font-size: 11px; color: var(--fg-subtle); }

/* ações da linha aparecem no hover, mas seguem acessíveis por teclado */
.row-action { opacity: 0; transition: opacity 0.12s var(--ease); }
tr:hover .row-action, .row-action:focus-visible { opacity: 1; }
@media (hover: none) { .row-action { opacity: 1; } }

/* ================================================================= controles */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 13px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--fg);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 550;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s var(--ease), border-color 0.12s var(--ease), transform 0.08s var(--ease);
}
.btn:hover { background: var(--surface-hover); border-color: var(--fg-subtle); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
.btn svg { width: 14px; height: 14px; }

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-fg);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-primary:disabled:hover { background: var(--brand); border-color: var(--brand); }

.btn-ghost { background: none; border-color: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--surface-hover); border-color: transparent; color: var(--fg); }

.btn-sm { height: 26px; padding: 0 9px; font-size: 11.5px; }
.btn-icon { width: 32px; padding: 0; }
.btn-icon.btn-sm { width: 26px; }

.btn.is-loading { color: transparent; position: relative; pointer-events: none; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 13px; height: 13px;
    border-radius: 999px;
    border: 1.5px solid currentColor;
    border-top-color: transparent;
    color: var(--brand-fg);
    animation: spin 0.6s linear infinite;
}
.btn:not(.btn-primary).is-loading::after { color: var(--fg-muted); }
@keyframes spin { to { transform: rotate(360deg); } }

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}
.toolbar .spacer { flex: 1; }
.toolbar-count { font-size: 11.5px; color: var(--fg-subtle); font-family: var(--mono); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 11.5px; font-weight: 550; color: var(--fg-muted); }
.field-hint { font-size: 11px; color: var(--fg-subtle); }

.input, .select {
    height: 32px;
    padding: 0 10px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-elev);
    color: var(--fg);
    font-family: inherit;
    font-size: 12.5px;
    transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
.input::placeholder { color: var(--fg-subtle); }
.input:hover, .select:hover { border-color: var(--fg-subtle); }
.input:focus, .select:focus {
    outline: none;
    border-color: var(--brand-text);
    box-shadow: 0 0 0 3px var(--brand-ring);
}
.select { cursor: pointer; padding-right: 26px; }
.input.is-error { border-color: var(--danger); }

.search { position: relative; display: flex; align-items: center; }
.search svg {
    position: absolute;
    left: 9px;
    width: 14px; height: 14px;
    color: var(--fg-subtle);
    pointer-events: none;
}
.search .input { padding-left: 29px; min-width: 210px; }

.segmented {
    display: inline-flex;
    padding: 2px;
    gap: 2px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.segmented button {
    height: 27px;
    padding: 0 13px;
    border: none;
    border-radius: var(--r-sm);
    background: none;
    color: var(--fg-muted);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 550;
    cursor: pointer;
    transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.segmented button:hover { color: var(--fg); }
.segmented button.is-active { background: var(--surface-active); color: var(--fg); box-shadow: var(--shadow-sm); }

/* opções de SO na instalação: escolha com consequência explicada */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: var(--sp-2); }
.choice {
    display: flex;
    gap: 10px;
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elev);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: var(--fg);
    transition: border-color 0.12s var(--ease), background 0.12s var(--ease);
}
.choice:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.choice.is-active { border-color: var(--brand-text); background: var(--brand-wash); }
.choice svg { width: 17px; height: 17px; color: var(--fg-muted); flex-shrink: 0; margin-top: 1px; }
.choice.is-active svg { color: var(--brand-text); }
.choice-title { font-size: 12.5px; font-weight: 600; margin-bottom: 2px; }
.choice-desc { font-size: 11.5px; color: var(--fg-subtle); line-height: 1.4; }

/* ============================================================ bloco de código */

.code-block { position: relative; }
.code-block pre {
    margin: 0;
    padding: var(--sp-3) var(--sp-4);
    padding-right: 96px;
    background: #0a0b0e;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.65;
    color: #b7e6c6;
    white-space: pre-wrap;
    word-break: break-all;
}
.code-block .btn { position: absolute; top: 8px; right: 8px; }

/* =============================================================== formulários */

.form-stack { display: flex; flex-direction: column; gap: var(--sp-4); max-width: 620px; }
.form-row { display: flex; gap: var(--sp-2); align-items: flex-end; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 190px; }

.steps { counter-reset: step; display: flex; flex-direction: column; gap: var(--sp-3); }
.step { display: flex; gap: 11px; }
.step-num {
    counter-increment: step;
    flex-shrink: 0;
    width: 20px; height: 20px;
    border-radius: 999px;
    background: var(--surface-active);
    border: 1px solid var(--border-strong);
    color: var(--fg-muted);
    font-family: var(--mono);
    font-size: 11px;
    display: grid;
    place-items: center;
}
.step-num::before { content: counter(step); }
.step-body { font-size: 12.5px; color: var(--fg-muted); padding-top: 1px; }

/* ================================================================== alertas */

.alert-row {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-bottom: 1px solid var(--border);
    position: relative;
}
.alert-row:last-child { border-bottom: none; }
.alert-row::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: var(--warn);
}
.alert-row.is-critico::before { background: var(--danger); }
.alert-row .alert-icon { padding-top: 2px; }
.alert-body { flex: 1; min-width: 0; }
.alert-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: 3px; }
.alert-kind { font-size: 12.5px; font-weight: 600; }
.alert-target { font-family: var(--mono); font-size: 11px; color: var(--fg-subtle); }
.alert-msg { font-size: 12.5px; color: var(--fg-muted); }
.alert-meta { font-size: 11px; color: var(--fg-subtle); margin-top: 6px; font-family: var(--mono); }

/* =============================================================== estado vazio */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-7) var(--sp-4);
    text-align: center;
}
.empty-icon {
    width: 38px; height: 38px;
    border-radius: var(--r-md);
    background: var(--surface-active);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--fg-subtle);
}
.empty-icon svg { width: 18px; height: 18px; }
.empty-title { font-size: 13px; font-weight: 600; }
.empty-text { font-size: 12px; color: var(--fg-subtle); max-width: 44ch; }

.inline-empty {
    padding: var(--sp-5);
    text-align: center;
    font-size: 12px;
    color: var(--fg-subtle);
}

/* ================================================================ skeletons */

.skeleton {
    background: linear-gradient(90deg, var(--surface-hover) 25%, var(--surface-active) 50%, var(--surface-hover) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s linear infinite;
    border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-line { height: 11px; margin-bottom: 8px; }
.sk-row { display: flex; align-items: center; gap: var(--sp-4); padding: 11px var(--sp-4); border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: none; }

/* ============================================== movimento com significado

   Regra desta interface: animação só onde ela CARREGA INFORMAÇÃO. Numa
   ferramenta de monitoramento, tudo que se mexe compete com o ponto vermelho
   que quer dizer "o backup falhou" -- se tudo pulsa, nada chama atenção.

   Por isso ficaram de fora a esteira infinita e o "respirar": bonitos, mas
   decorativos aqui. O que entrou, entrou com trabalho a fazer.

   Tudo abaixo herda o `prefers-reduced-motion` declarado no topo do arquivo. */

/* Pulsar -- só no contador de alertas ATIVOS do menu. É a única coisa na tela
   que significa "precisa de você agora". Escala mínima e anel que se abre: o
   elemento não sai do lugar, então não empurra o menu nem rouba o clique. */
.nav-count.is-live {
    animation: alerta-pulsa 2.2s var(--ease) infinite;
}
@keyframes alerta-pulsa {
    0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 var(--danger-wash); }
    50%      { transform: scale(1.06); box-shadow: 0 0 0 9px rgba(187, 68, 60, 0); }
}

/* Contador -- o número sobe uma vez, na PRIMEIRA carga da Visão geral. Não a
   cada atualização: quem clica em "Atualizar" quer ler o valor, não assistir a
   ele chegar. `tabular-nums` evita a largura dançar enquanto conta. */
.metric-value { font-variant-numeric: tabular-nums; }

/* =================================================================== drawer */

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
    z-index: 50;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(560px, 100vw);
    background: var(--bg-elev);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.26s var(--ease-out);
    z-index: 51;
    display: flex;
    flex-direction: column;
}
.drawer.is-open { transform: none; }
.drawer-head {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.drawer-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.drawer-sub { font-size: 12px; color: var(--fg-subtle); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-4); }
.drawer-foot {
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 9px var(--sp-4); }
.kv dt { font-size: 11.5px; color: var(--fg-subtle); }
.kv dd { margin: 0; font-size: 12.5px; min-width: 0; overflow-wrap: anywhere; }

/* ============================================== modal de confirmação (destrutivo) */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: grid;
    place-items: center;
    padding: var(--sp-4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s var(--ease);
    z-index: 70;
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }

.modal {
    width: min(440px, 100%);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    transform: scale(0.97);
    transition: transform 0.16s var(--ease-out);
}
.modal-backdrop.is-open .modal { transform: none; }

.modal-head { display: flex; gap: var(--sp-3); padding: var(--sp-4); }
.modal-icon {
    flex-shrink: 0;
    width: 30px; height: 30px;
    border-radius: 999px;
    background: var(--danger-wash);
    color: var(--danger-text);
    display: grid;
    place-items: center;
}
.modal-icon svg { width: 16px; height: 16px; }
.modal-title { font-size: 14px; font-weight: 600; }
.modal-sub { font-size: 12px; color: var(--fg-subtle); margin-top: 1px; }
.modal-body { padding: 0 var(--sp-4) var(--sp-4) 58px; font-size: 12.5px; color: var(--fg-muted); }
.modal-body ul { margin: var(--sp-2) 0 0; padding-left: 17px; }
.modal-body li { margin-bottom: 3px; }
.modal-body strong { color: var(--fg); font-weight: 600; }
.modal-input-wrap { padding: 0 var(--sp-4) var(--sp-4) 58px; }
.modal-input-wrap .input { width: 100%; }

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border);
}
/* ícone/botão neutros quando o modal não é destrutivo (ex.: renomear) */
.modal-backdrop.is-neutral .modal-icon { background: var(--brand-wash); color: var(--brand-text); }

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #cc4c43; border-color: #cc4c43; }

.btn-danger-ghost { background: none; border-color: transparent; color: var(--fg-subtle); }
.btn-danger-ghost:hover { background: var(--danger-wash); border-color: transparent; color: var(--danger-text); }

/* ==================================================================== toasts */

.toasts {
    position: fixed;
    bottom: var(--sp-5);
    right: var(--sp-5);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 260px;
    max-width: 380px;
    padding: 11px var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    font-size: 12.5px;
    pointer-events: auto;
    animation: toast-in 0.24s var(--ease-out);
}
.toast.is-leaving { animation: toast-out 0.18s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast.is-ok .toast-icon { color: var(--ok-text); }
.toast.is-warn .toast-icon { color: var(--warn-text); }
.toast.is-danger .toast-icon { color: var(--danger-text); }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; }
.toast-text { color: var(--fg-muted); font-size: 12px; margin-top: 1px; }

/* ================================================== navegador de arquivos */

.crumbs {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
    padding: var(--sp-2) var(--sp-4);
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 11.5px;
}
.crumbs button {
    background: none;
    border: none;
    color: var(--brand-text);
    font-family: var(--mono);
    font-size: 11.5px;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
}
.crumbs button:hover { background: var(--surface-hover); }
.crumbs .sep { color: var(--fg-subtle); }
.crumbs .current { color: var(--fg-muted); padding: 2px 4px; }

.fs-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px var(--sp-4);
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}
.fs-row:last-child { border-bottom: none; }
.fs-row:hover { background: var(--surface-hover); }
.fs-row svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--fg-subtle); }
.fs-row.is-dir svg { color: var(--brand-text); }
.fs-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-row.is-dir .fs-name { cursor: pointer; font-weight: 550; }
.fs-row.is-dir .fs-name:hover { text-decoration: underline; }
.fs-size { font-family: var(--mono); font-size: 11px; color: var(--fg-subtle); }

/* ==================================================================== login */

/* A tela de login é a ÚNICA do sistema sem dado competindo por atenção -- não
   há status, número nem alerta aqui. É onde o gradiente em movimento cabe, e
   por isso ele existe só neste lugar.

   9 segundos e amplitude curta: a pessoa passa 4 segundos nesta tela. O efeito
   é para ser percebido de canto de olho, não assistido. */
body.login {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 620px 320px at 50% 0%, rgba(112, 49, 145, 0.16), transparent 70%),
        linear-gradient(120deg, var(--bg), #141019, #1b1226, #141019, var(--bg));
    background-size: auto, 300% 300%;
    animation: login-fundo 9s var(--ease) infinite;
}
@keyframes login-fundo {
    0%, 100% { background-position: 50% 0%, 0% 50%; }
    50%      { background-position: 50% 0%, 100% 50%; }
}
.login-card {
    width: min(370px, calc(100vw - 32px));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
    box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--sp-5); }
.login-brand .brand-text { font-size: 16px; }
.login-heading { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.login-sub { font-size: 12px; color: var(--fg-subtle); margin-bottom: var(--sp-5); }
.login-card .field + .field { margin-top: var(--sp-3); }
.login-card .btn { width: 100%; margin-top: var(--sp-5); height: 36px; }
.form-error {
    display: none;
    align-items: center;
    gap: 7px;
    margin-top: var(--sp-3);
    padding: 8px 10px;
    background: var(--danger-wash);
    border: 1px solid rgba(187, 68, 60, 0.3);
    border-radius: var(--r-md);
    font-size: 12px;
    color: var(--danger-text);
}
.form-error.is-visible { display: flex; }

/* ================================================================ responsivo */

@media (max-width: 1000px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: none; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .content { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
    .topbar-inner { padding: 0 var(--sp-4); }
}

@media (max-width: 720px) {
    body { font-size: 13px; }
    .summary { grid-template-columns: repeat(2, 1fr); }
    .metric { border-bottom: 1px solid var(--border); }
    .metric:nth-child(2n) { border-right: none; }
    .toasts { left: var(--sp-3); right: var(--sp-3); bottom: var(--sp-3); }
    .toast { max-width: none; }
    .drawer { width: 100vw; }

    /* tabela de hosts vira lista legível em vez de rolagem horizontal cega */
    table.stacked thead { display: none; }
    table.stacked tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 2px var(--sp-3);
        padding: var(--sp-3) var(--sp-4);
        border-bottom: 1px solid var(--border);
    }
    table.stacked tbody tr:hover td { background: none; }
    table.stacked td { border: none; padding: 0; }
    table.stacked td[data-label]::before {
        content: attr(data-label) " ";
        font-size: 10.5px;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--fg-subtle);
        margin-right: 6px;
    }
    table.stacked td.col-name { grid-column: 1 / -1; font-size: 13.5px; }
    table.stacked td.col-name::before { content: none; }
    table.stacked td.col-actions { grid-column: 1 / -1; text-align: left; margin-top: 6px; }
    table.stacked td.col-actions::before { content: none; }

    /* Cabecalho de grupo: em stacked a linha vira grid e o colspan e ignorado,
       o que jogaria o rotulo do grupo pra coluna da direita. Volta a ser bloco. */
    table.stacked tbody tr.arvore-no > td:first-child,
    table.stacked tbody tr.arvore-guest > td:first-child { padding-left: var(--sp-3); }
    table.stacked tbody tr.arvore-guest > td:first-child::before { display: none; }
    table.stacked tbody tr.row-group { display: block; }
    table.stacked tbody tr.row-group td:first-child { display: none; }

    .row-action { opacity: 1; }
}

/* ==================================================== agendamentos (rotinas) */

/* Modal mais largo: o formulário de rotina tem dias, horário, destino e três
   campos de retenção -- na largura padrão (440px) viraria uma coluna estreita. */
.modal.is-wide { width: min(560px, 100%); }

/* Corpo rolável: em tela baixa o formulário não pode empurrar os botões pra
   fora da viewport. */
.modal-scroll {
    padding: 0 var(--sp-4) var(--sp-4);
    max-height: min(62vh, 560px);
    overflow-y: auto;
}

.modal-icon.is-brand { background: var(--brand-wash); color: var(--brand-text); }

/* Seletor de dias da semana. Botões de alternância em vez de checkboxes:
   sete caixas com rótulo ocupariam duas linhas e leriam pior. */
.daypick { display: flex; gap: 6px; flex-wrap: wrap; }
.daypick-btn {
    min-width: 44px;
    padding: 7px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--bg-elev);
    color: var(--fg-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 550;
    cursor: pointer;
    transition: background 0.12s var(--ease), color 0.12s var(--ease), border-color 0.12s var(--ease);
}
.daypick-btn:hover { border-color: var(--fg-subtle); color: var(--fg); }
.daypick-btn.is-on {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-fg);
}
.daypick-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* Retenção: três campos numéricos lado a lado, com rótulo em cima. */
.ret-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-2);
    margin-top: var(--sp-2);
}
.ret-cell { display: flex; flex-direction: column; gap: 4px; }
.ret-cell > span { font-size: 11px; color: var(--fg-subtle); }
.ret-cell .input { width: 100%; }

/* Rodapé de painel: ação que age sobre a seleção da tabela acima. */
.panel-foot {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Checkbox de seleção em massa -- alvo de clique confortável na linha. */
.sched-check { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

@media (max-width: 560px) {
    .ret-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .daypick-btn { min-width: 40px; }
}

/* Linha "backups vão para X" no cabeçalho do host, na página de Agendamentos.
   Fica junto do nome do host porque destino é propriedade do nó, não de cada
   agendamento -- foi a dúvida do operador: "onde configuro o destino?". */
.dest-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: 11.5px;
}
.dest-label { color: var(--fg-subtle); }
.dest-value { color: var(--fg); }
.dest-value.is-unset { color: var(--fg-subtle); font-style: italic; }

/* Resultado da verificação, na própria linha -- o operador não precisa procurar
   em outro lugar o que ele acabou de mandar testar. */
.dest-result { display: inline-flex; align-items: center; gap: 5px; }
.dest-result svg { width: 12px; height: 12px; flex-shrink: 0; }
.dest-testing { color: var(--fg-subtle); }
.dest-good { color: var(--ok-text); display: inline-flex; align-items: center; gap: 5px; }
.dest-bad { color: var(--danger-text); display: inline-flex; align-items: center; gap: 5px; }

/* Botão discreto para ações auxiliares dentro de uma linha de texto. */
.btn-quiet {
    background: transparent;
    border-color: transparent;
    color: var(--brand-text);
    padding: 2px 6px;
    height: auto;
    font-size: 11.5px;
}
.btn-quiet:hover { background: var(--bg-elev); border-color: var(--border); }

/* ============================== árvore host → guests (Visão geral) */

/* Linha do nó: cursor e caret que gira ao abrir. A hierarquia substitui 12
   linhas soltas por 1 que expande -- o nó Proxmox do parque real tem 11 guests. */
.tree-name { display: flex; align-items: center; gap: 6px; }
.tree-caret {
    display: inline-flex;
    color: var(--fg-subtle);
    transition: transform 0.14s var(--ease);
}
.tree-caret svg { width: 13px; height: 13px; }
tr.is-open .tree-caret { transform: rotate(90deg); color: var(--brand-text); }
tr.is-parent:hover .tree-caret { color: var(--fg); }

/* Linha filha: recuo com guia vertical, pra leitura não depender só do recuo. */
tr.is-child > td:first-child { padding-left: 30px; position: relative; }
tr.is-child > td:first-child::before {
    content: "";
    position: absolute;
    left: 17px; top: 0; bottom: 0;
    width: 1px;
    background: var(--border-strong);
}
.tree-child-name { font-weight: 500; }
tr.is-child > td { background: color-mix(in srgb, var(--bg-elev) 55%, transparent); }
