/* ============================================================
   WHM Manager — Admin (tema claro/escuro)
   Classes globais carregadas via admin/_inc/header.php.
   Antes ficavam num <style> no header; mantidas aqui para o
   usuário poder editar/estender como arquivo .css separado.
   ============================================================ */

:root {
    color-scheme: light;
    --bg: #F3F2F1;
    --surface: #FAF9F8;
    --border: #E1DFDD;
    --dashboard: #E1DFDD;
    --text: #201F1E;
    --text-secondary: #605E5C;
    --accent: #2564CF;
    --danger: #A4262C;
}
html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1B1A19;
    --surface: #242322;
    --border: #3B3A39;
    --dashboard: #1e4453;
    --text: #F3F2F1;
    --text-secondary: #C8C6C4;
    --accent: #6EA8FF;
    --danger: #FF5C66;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}
header.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; }
header.topbar .brand { font-weight: 600; margin-right: 24px; }
header.topbar nav { display: flex; align-items: center; gap: 20px; flex: 1; }
header.topbar a { color: var(--text-secondary); text-decoration: none; font-size: 14px; }
header.topbar a:hover { color: var(--accent); }
header.topbar a.active { color: var(--accent); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-right .topbar-user { margin: 0; white-space: nowrap; }
.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}
.menu-toggle:hover { background: var(--border); }
.menu-toggle .icon-close { display: none; }
main {
    max-width: 90%;
    margin: 32px auto;
    padding: 0 24px;
}
/* Páginas de login: corpo ocupa a tela toda e centraliza o main */
body.login-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
body.login-screen main {
    flex: 1;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1.6px 3.6px rgba(0,0,0,.133);
    margin-bottom: 24px !important;
}
/* Logotipo + título do login: cada versão aparece conforme o tema */
.login-brand { display: flex; align-items: center; gap: 10px; margin: 8px 0 32px 0; }
.login-logo { height: 28px; width: auto; display: none; }
html[data-theme="light"] .login-logo-light { display: inline-block; }
html[data-theme="dark"] .login-logo-dark { display: inline-block; }
.login-card {
    max-width: 380px;
    margin: 0 auto;
    width: 100%;
    --tw-ring-offset-shadow: 0 0 #0000;
    --tw-ring-shadow: 0 0 #0000;
    --tw-shadow: 0 6.4px 14.4px 0 #0002, 0 1.2px 3.6px 0 #0000001c;
    box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.login-title { font-size: 20px; margin: 0 0 6px; }
.login-card .muted { margin-top: 0; margin-bottom: 16px; }
.login-card .login-link {
    display: block;
    margin-top: 14px;
    text-align: center;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
}
.login-card .login-link:hover { text-decoration: underline; }
.login-footer {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 12px;
    font-weight: 300;
    color: var(--text-secondary);
}
.login-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -6px 0 18px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.login-remember input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 16px;
}
input[type="email"], input[type="password"], input[type="text"], input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}
button, .btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    display: inline-block;
    text-decoration: none;
}
button:hover, .btn:hover { opacity: 0.9; }
.btn-secondary { background: var(--ms-gray-60, #C8C6C4); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.error {
    background: #FDE7E9;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 14px;
}
.success {
    background: #DFF6DD;
    color: #0E5814;
    border: 1px solid #0E5814;
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 14px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; }
.badge-ok { background: #DFF6DD; color: #0E5814; }
.badge-off { background: #FDE7E9; color: var(--danger); }
.badge-warn { background: #FFF4CE; color: #7A5B00; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat-grid .card { margin-bottom: 0; }
.stat-value { font-size: 28px; font-weight: 600; }
.stat-label { color: var(--text-secondary); font-size: 13px; }
form.inline { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--text-secondary); font-size: 13px; }
button[disabled] { opacity: 0.7; cursor: not-allowed; }
.spinner {
    display: inline-block;
    width: 11px;
    height: 11px;
    margin-left: 7px;
    vertical-align: middle;
    border: 2px solid rgba(255,255,255,.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
.btn-secondary .spinner { border-color: rgba(0,0,0,.2); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar {
    width: 100%;
    max-width: 420px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 16px 0 4px;
}
.progress-bar-fill { height: 100%; border-radius: 4px; }
.progress-bar-fill.ok { background: #0E5814; }
.progress-bar-fill.warn { background: #C19C00; }
.progress-bar-fill.danger { background: var(--danger); }

/* ---- Tema escuro: componentes de cor fixa ---- */
html[data-theme="dark"] .error { background: #42282B; border-color: var(--danger); color: #FF9AA3; }
html[data-theme="dark"] .success { background: #20301F; border-color: #4E8A3C; color: #7BD66B; }
html[data-theme="dark"] .badge-ok { background: #20301F; color: #7BD66B; }
html[data-theme="dark"] .badge-off { background: #42282B; color: #FF9AA3; }
html[data-theme="dark"] .badge-warn { background: #3A3310; color: #E0C24A; }
html[data-theme="dark"] .btn-secondary { background: #3B3A39; color: var(--text); }
html[data-theme="dark"] .btn-secondary .spinner { border-color: rgba(255,255,255,.25); border-top-color: var(--text); }
html[data-theme="dark"] .progress-bar { background: var(--border); }

/* ---- Alternador de tema (Sol/Lua) ---- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}
.theme-toggle:hover { background: var(--border); }
body.login-screen .theme-toggle { position: fixed; top: 14px; right: 14px; z-index: 50; }
.theme-toggle svg { pointer-events: none; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---- Página de Atualizações ---- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.notice {
    background: #E5F1FB;
    color: #004578;
    border: 1px solid #2564CF;
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 14px;
}
html[data-theme="dark"] .notice { background: #12324A; color: #9CCBFF; border-color: #2564CF; }
details.file-group { margin-bottom: 10px; }
details.file-group summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); padding: 4px 0; }
.file-group ul { margin: 6px 0 6px 18px; padding: 0; font-size: 12px; }
.file-group li { padding: 1px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---- Página de backups (admin/backups.php) ---- */
.bk-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.bk-cell { border: 1px solid var(--border); border-radius: 6px; min-height: 64px; padding: 6px; font-size: 12px; position: relative; background: var(--surface); }
.bk-cell.other { opacity: .45; }
.bk-cell .day { font-weight: 600; margin-bottom: 4px; }
.bk-badge { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 11px; color: #fff; margin-top: 2px; }
.bk-badge.ok { background: #0E5814; }
.bk-badge.fail { background: #A4262C; }
.bk-badge.run { background: #C19C00; }
.bk-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.bk-status.ok { background: #0E5814; } .bk-status.fail { background: #A4262C; } .bk-status.run { background: #C19C00; }
/* Seletor de contas (sem ?account_id): cards por domínio */
.bk-acct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 4px; }
.bk-acct {
    display: flex; flex-direction: column; gap: 6px;
    padding: 14px 16px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); text-decoration: none; color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.bk-acct:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.bk-acct-domain { font-weight: 600; font-size: 15px; word-break: break-all; }
.bk-acct .badge { align-self: flex-start; }
.bk-acct .muted { margin: 0; font-size: 12px; }
.bk-acct-link { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--accent); }
.bk-cal-nav { display: flex; align-items: center; gap: 10px; }
.bk-cal-title { white-space: nowrap; }
.bk-cal-legend { margin-top: 10px; color: var(--text-secondary); font-size: 13px; }
.bk-pass-state { display: inline-flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 12px; color: var(--text-secondary); }
.bk-pass-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.bk-pass-state.ok { color: #0E5814; }
.bk-pass-state.ok .bk-pass-dot { background: #0E5814; }
html[data-theme="dark"] .bk-pass-state.ok { color: #7BD66B; }
html[data-theme="dark"] .bk-pass-state.ok .bk-pass-dot { background: #7BD66B; }
.bk-pass-remove { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.bk-pass-remove input[type="checkbox"] { width: 14px; height: 14px; margin: 0; accent-color: var(--danger); cursor: pointer; }

/* ---- Dashboard ---- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.dash-grid .card { margin-bottom: 0; }
.dash-feat-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.dash-kpis { display: flex; flex-direction: column; gap: 8px; }
.dash-kpis > div { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.dash-num { font-size: 24px; font-weight: 600; color: var(--text); }
.dash-donut {
    --p-ok: 0%;
    --p-bad: 0%;
    width: 92px; height: 92px; border-radius: 50%; flex-shrink: 0;
    background: conic-gradient(#0E5814 var(--p-ok), #A4262C calc(var(--p-ok) + var(--p-bad)), var(--border) 0);
    display: flex; align-items: center; justify-content: center;
}
.dash-donut-inner {
    width: 66px; height: 66px; border-radius: 50%;
    background: var(--surface);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.dash-donut-inner strong { font-size: 16px; line-height: 1.1; }
.dash-donut-inner small { color: var(--text-secondary); font-size: 11px; }
.dash-progress { display: flex; }
.dash-progress .progress-bar-fill { flex: 0 0 auto; }
.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0; border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.dash-list li:last-child { border-bottom: none; }
.dash-list a { color: var(--text); text-decoration: none; }
.dash-list a:hover { color: var(--accent); }
.dash-list .muted { margin-left: auto; }

/* ---- Navegação do topo da página da conta ("← Contas | Backups da conta") ---- */
a.backups_contas {
    display: inline-block;
    padding: 6px 12px;
    margin-right: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
}
a.backups_contas:hover { border-color: var(--accent); color: var(--accent); }

a.dashboard_links {
    display: inline-block;
    padding: 6px 12px;
    margin-right: 6px;
    border: 1px solid var(--surface);
    border-radius: 4px;
    background: var(--dashboard);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
}
a.dashboard_links:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Página de Uptime (admin/uptime.php) ---- */
.up-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.up-dot.up { background: #0E5814; }
.up-dot.down { background: #A4262C; }
.up-dot.unknown { background: var(--border); }
html[data-theme="dark"] .up-dot.up { background: #7BD66B; }
html[data-theme="dark"] .up-dot.down { background: #FF5C66; }
.up-grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.up-daybars { display: flex; align-items: flex-end; gap: 4px; overflow-x: auto; padding: 8px 0 2px; }
.up-day { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; }
.up-bar { width: 10px; min-height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .85; }
.up-day .muted { font-size: 9px; }
.up-chips { display: flex; flex-wrap: wrap; gap: 3px; max-width: 720px; }
.up-chip { width: 11px; height: 16px; border-radius: 2px; background: var(--border); }
.up-chip.up { background: #0E5814; }
.up-chip.down { background: #A4262C; }
html[data-theme="dark"] .up-chip.up { background: #4E8A3C; }
html[data-theme="dark"] .up-chip.down { background: #FF5C66; }

/* ---- Utilitários (para substituir style="..." nas páginas) ---- */
.u-mt0 { margin-top: 0; }
.u-mt4 { margin-top: 4px; }
.u-mt6 { margin-top: 6px; }
.u-mt8 { margin-top: 8px; }
.u-mt10 { margin-top: 10px; }
.u-mt12 { margin-top: 12px; }
.u-mt14 { margin-top: 14px; }
.u-mb6 { margin-bottom: 6px; }
.u-mb8 { margin-bottom: 8px; }
.u-mb12 { margin-bottom: 12px; }
.u-mb16 { margin-bottom: 16px; }
.u-wfull { max-width: none; }
.u-card-title { margin: 0 0 12px; font-size: 16px; }
.u-dash-h1 { margin: 0 0 6px; font-size: 20px; }
.u-stat-sm { font-size: 16px; }
.u-subtitle { font-size: 13px; margin: 16px 0 8px; }
.u-section { font-size: 14px; margin: 12px 0 6px; }
.u-link-row { margin: 10px 0 0; }
.u-inline { display: inline; }
.u-check { width: auto; margin-right: 6px; vertical-align: middle; }
.u-danger { color: var(--danger); }
.u-w640 { max-width: 640px; }
.u-block8 { display: block; margin-bottom: 8px; }
.u-block12 { display: block; margin-bottom: 12px; }
.u-errlist { margin: 8px 0 0 18px; }
.u-errlist li { margin: 4px 0; }
/* ---- Utilitários extras (margens, flex, formulários) ---- */
.u-mt16 { margin-top: 16px; }
.u-mt20 { margin-top: 20px; }
.u-ml6 { margin-left: 6px; }
.u-ml10 { margin-left: 10px; }
.u-mlauto { margin-left: auto; }
.u-mv8 { margin: 8px 0; }
.u-mv16 { margin: 16px 0; }
.u-nt6 { margin-top: -6px; }
.u-center { text-align: center; }
.u-break { word-break: break-all; }
.u-hide { display: none; }
.u-input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}
.u-text-secondary { color: var(--text-secondary); }
.u-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 20px 0 0;
    font-size: 14px;
    color: var(--text);
    font-weight: 400;
    cursor: pointer;
}
.u-box-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    cursor: pointer;
}
.u-box-label.disabled { color: var(--text-secondary); cursor: not-allowed; }
.u-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.u-row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.u-form-row { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.u-form-row.end { align-items: flex-end; }
.u-flex1 { flex: 1; min-width: 240px; }
.u-flex-grow { flex: 1; }
.u-w320 { max-width: 320px; }
.u-w480 { max-width: 480px; }
.u-w280 { width: 280px; max-width: 100%; }
.u-scrollbox {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 16px;
}
.u-codebox {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 15px;
    line-height: 2;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
    word-break: break-all;
}
.u-cols2 { columns: 2; column-gap: 24px; }
.u-h3sec { font-size: 14px; margin: 0 0 8px; }
.u-h2 { margin: 0; font-size: 16px; }
.u-h3 { font-size: 14px; }
.u-fs13 { font-size: 13px; }
.u-sep { border-top: 1px solid var(--border); padding-top: 12px; }
.u-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.u-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.u-grid2 .u-span2 { grid-column: 1 / -1; }
.u-legend { margin: 14px 0 4px; font-weight: 600; font-size: 13px; }
.u-qrbox {
    background: #fff;
    padding: 16px;
    border-radius: 4px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: center;
}
.badge-neutral { background: var(--border); color: var(--text-secondary); }

/* ---- Responsivo (mobile) ---- */
@media (max-width: 960px) {
    main { max-width: 100%; margin: 18px auto; padding: 0 14px; }
    header.topbar { padding: 10px 16px; }
    .card { padding: 16px; }
    .stat-grid { gap: 10px; }
    .dash-grid { grid-template-columns: 1fr; }
    .dash-grid .card { margin-bottom: 16px; }
    .dash-grid .card:last-child { margin-bottom: 0; }
}
@media (max-width: 820px) {
    header.topbar { flex-wrap: wrap; row-gap: 8px; }
    header.topbar nav { display: none; flex-basis: 100%; order: 3; }
    header.topbar.nav-open nav {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        border-top: 1px solid var(--border);
        padding: 6px 0 2px;
    }
    header.topbar.nav-open nav a {
        padding: 11px 4px;
        border-bottom: 1px solid var(--border);
        font-size: 15px;
    }
    header.topbar.nav-open nav a:last-child { border-bottom: none; }
    .menu-toggle { display: inline-flex; }
    header.topbar.nav-open .menu-toggle .icon-burger { display: none; }
    header.topbar.nav-open .menu-toggle .icon-close { display: inline; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .up-grid-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
    .card { overflow-x: auto; }
    .card > table, table { min-width: 540px; }
    .bk-grid { min-width: 460px; }
    .bk-acct-grid, .up-grid-form { grid-template-columns: 1fr; }
    .login-card { width: 100%; }
    .dash-feat-row { align-items: flex-start; }
    header.topbar .topbar-user { display: none; }
    .u-grid2, .u-grid3 { grid-template-columns: 1fr; }
}
