/* Tema dark — identidade visual Hexan (roxo #8B5CF6, fundos #08050F+, Space Grotesk/Inter) */
:root {
    --purple-200: #DDD6FE;
    --purple-300: #C4B5FD;
    --purple-400: #A78BFA;
    --purple-500: #8B5CF6;
    --purple-600: #7C3AED;
    --purple-700: #6D28D9;

    --bg-base: #08050F;
    --bg-surface: #0F0A1C;
    --bg-elevated: #150E27;
    --bg-elevated-2: #1B1232;

    --text-hi: #F5F2FC;
    --text-mid: #AFA3CB;
    --text-low: #6F6390;

    --border: rgba(167, 139, 250, 0.12);
    --border-strong: rgba(167, 139, 250, 0.28);

    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --glow: 0 4px 24px rgba(139, 92, 246, 0.40);
    --t: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --font-display: 'Space Grotesk', 'Inter', sans-serif;

    /* Aliases mantidos para compatibilidade com as páginas existentes */
    --bg: var(--bg-base);
    --panel: var(--bg-elevated);
    --text: var(--text-hi);
    --muted: var(--text-mid);
    --primary: var(--purple-500);
    --primary-dark: var(--purple-700);

    /* Cores semânticas adaptadas para fundo escuro */
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #F87171;
    --info: var(--purple-400);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-base);
    color: var(--text-hi);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--purple-400); text-decoration: none; transition: color var(--t); }
a:hover { color: var(--purple-300); text-decoration: none; }

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

/* Fundo sutil com brilho roxo no topo, como no hero da Hexan */
.app::before {
    content: "";
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 70% 50% at 70% -10%, rgba(139, 92, 246, 0.12), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Sidebar */
.sidebar {
    width: 230px;
    background: var(--bg-surface);
    color: var(--text-mid);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    z-index: 1;
}

.brand {
    padding: 22px 20px;
    border-bottom: 1px solid var(--border);
}

/* Logo Hexan (PNG preto) renderizado em branco sobre o fundo dark */
.brand-logo {
    width: 158px;
    max-width: 100%;
    height: auto;
    display: block;
    filter: brightness(0) invert(1);
}

.sidebar nav { flex: 1; padding: 14px 0; }

.sidebar nav a {
    display: block;
    padding: 11px 20px;
    color: var(--text-mid);
    border-left: 3px solid transparent;
    font-weight: 500;
    transition: all var(--t);
}

.sidebar nav a:hover { background: var(--bg-elevated); color: var(--text-hi); }

.sidebar nav a.active {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.16), transparent);
    color: var(--text-hi);
    border-left-color: var(--purple-500);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-footer-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.user-name {
    font-size: 13px;
    color: var(--text-low);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-link {
    background: none;
    border: none;
    color: var(--purple-400);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    font-family: inherit;
    transition: color var(--t);
}

.btn-link:hover { color: var(--purple-300); }

/* Conteúdo */
.content { flex: 1; padding: 26px 30px; min-width: 0; position: relative; z-index: 1; }
.content-anon { display: flex; align-items: center; justify-content: center; min-height: 100vh; position: relative; z-index: 1; }

h1 { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 20px; color: var(--text-hi); }
h2 { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin: 24px 0 10px; color: var(--text-hi); }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header h1 { margin: 0; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 14px; margin-bottom: 22px; }

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    transition: border-color var(--t), transform var(--t);
}

.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }

.card .card-label { font-size: 11px; color: var(--text-low); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.card .card-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; color: var(--text-hi); }
.card .card-value.ok { color: var(--success); }
.card .card-value.warn { color: var(--warning); }
.card .card-value.bad { color: var(--danger); }

.panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.panel h2 { margin-top: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tabelas */
table { width: 100%; border-collapse: collapse; }

th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); vertical-align: middle; }

th { font-size: 11px; color: var(--text-low); text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; font-weight: 600; }
th a { color: var(--text-low); }
th a:hover { color: var(--purple-400); }

tbody tr { transition: background var(--t); }
tr:hover td { background: var(--bg-elevated-2); }

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

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-elevated-2);
    color: var(--text-mid);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.badge-success { background: rgba(52, 211, 153, 0.14); color: #6EE7B7; border-color: rgba(52, 211, 153, 0.3); }
.badge-danger { background: rgba(248, 113, 113, 0.14); color: #FCA5A5; border-color: rgba(248, 113, 113, 0.3); }
.badge-warning { background: rgba(251, 191, 36, 0.14); color: #FCD34D; border-color: rgba(251, 191, 36, 0.3); }
.badge-info { background: rgba(167, 139, 250, 0.16); color: var(--purple-300); border-color: rgba(167, 139, 250, 0.32); }
.badge-muted { background: var(--bg-elevated-2); color: var(--text-low); border-color: var(--border); }

/* Formulários */
input[type=text], input[type=password], input[type=number], select {
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-surface);
    color: var(--text-hi);
    font-family: inherit;
    transition: border-color var(--t), box-shadow var(--t);
}

input::placeholder { color: var(--text-low); }

input:focus, select:focus {
    outline: none;
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

select option { background: var(--bg-surface); color: var(--text-hi); }

label { font-size: 13px; color: var(--text-mid); display: block; margin-bottom: 5px; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.form-field { display: flex; flex-direction: column; }

.btn {
    display: inline-block;
    padding: 9px 18px;
    background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--glow);
    transition: transform var(--t), box-shadow var(--t), filter var(--t);
}

.btn:hover { color: #fff; filter: brightness(1.1); transform: translateY(-1px); text-decoration: none; }

.btn-secondary {
    background: var(--bg-elevated-2);
    color: var(--text-hi);
    border: 1px solid var(--border-strong);
    box-shadow: none;
}

.btn-secondary:hover { background: var(--bg-surface); color: var(--text-hi); filter: none; border-color: var(--purple-500); }

.btn-danger { background: linear-gradient(135deg, #F87171, #DC2626); box-shadow: 0 4px 20px rgba(220, 38, 38, 0.35); }
.btn-danger:hover { filter: brightness(1.08); }

/* Ghost neutro — ação secundária discreta (sem preenchimento). */
.btn-ghost {
    background: transparent;
    color: var(--text-mid);
    border: 1px solid var(--border-strong);
    box-shadow: none;
}
.btn-ghost:hover { background: var(--bg-elevated-2); color: var(--text-hi); border-color: var(--purple-500); filter: none; }

/* Ghost destrutivo — perigoso, mas rebaixado; só fica vermelho cheio no hover. */
.btn-ghost-danger {
    background: transparent;
    color: #FCA5A5;
    border: 1px solid rgba(248, 113, 113, 0.35);
    box-shadow: none;
}
.btn-ghost-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); filter: none; }

.btn-sm { padding: 5px 11px; font-size: 12px; }

/* Barra de ações no cabeçalho da tela de detalhes. */
.action-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.action-bar form { display: inline-flex; margin: 0; }
.action-bar .btn { display: inline-flex; align-items: center; gap: 6px; }
.action-divider { width: 1px; height: 22px; background: var(--border); display: inline-block; margin: 0 2px; }
.btn svg { flex-shrink: 0; }

/* Login */
.login-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 22px;
    padding: 38px 40px;
    width: 380px;
    box-shadow: var(--shadow), var(--glow);
}

.login-box h1 { text-align: center; margin-bottom: 24px; }

.login-logo { text-align: center; margin-bottom: 6px; }
.login-logo img {
    width: 210px;
    max-width: 80%;
    height: auto;
    filter: brightness(0) invert(1);
}
.login-subtitle {
    text-align: center;
    color: var(--text-mid);
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin: 0 0 26px;
}

.login-box .form-field { margin-bottom: 16px; }
.login-box input { width: 100%; }
.login-box .btn { width: 100%; margin-top: 10px; padding: 11px; }

.error-text { color: #FCA5A5; font-size: 13px; margin: 8px 0; }
.muted { color: var(--text-mid); }
.success-text { color: #6EE7B7; font-size: 13px; margin: 8px 0; }

/* Barras de uso */
.usage-bar { background: var(--bg-elevated-2); border-radius: 999px; height: 8px; min-width: 80px; overflow: hidden; border: 1px solid var(--border); }
.usage-bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--purple-500), var(--purple-400)); }
.usage-bar > div.warn { background: linear-gradient(90deg, #D97706, var(--warning)); }
.usage-bar > div.bad { background: linear-gradient(90deg, #DC2626, var(--danger)); }
.usage-cell { display: flex; align-items: center; gap: 8px; }
.usage-cell span { min-width: 46px; font-variant-numeric: tabular-nums; }

/* Detalhes */
.kv { display: grid; grid-template-columns: 220px 1fr; row-gap: 7px; }
.kv dt { color: var(--text-low); }
.kv dd { margin: 0; color: var(--text-hi); }

/* Medidores radiais de desempenho */
.gauges { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.gauge { text-align: center; width: 112px; }
.gauge svg { width: 92px; height: 92px; }
.gauge-val { fill: var(--text-hi); font-size: 18px; font-weight: 700; font-family: var(--font-display); }
.gauge-label { font-size: 12px; color: var(--text-mid); margin-top: 2px; }

.chart { width: 100%; height: 180px; }
.chart-legend { font-size: 12px; color: var(--text-mid); display: flex; gap: 18px; margin-top: 8px; flex-wrap: wrap; }
.chart-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }

code.token {
    background: var(--bg-base);
    border: 1px solid var(--border-strong);
    padding: 5px 9px;
    border-radius: 8px;
    font-size: 13px;
    word-break: break-all;
    color: var(--purple-300);
}

.report-list { list-style: none; padding: 0; margin: 0; }
.report-list li { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.report-list li:last-child { border-bottom: none; }

/* Scrollbar dark */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated-2); border-radius: 6px; border: 2px solid var(--bg-surface); }
::-webkit-scrollbar-thumb:hover { background: var(--purple-700); }
