:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --positive: #3fb950;
    --negative: #f85149;
    --warning: #d29922;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-links a:hover { color: var(--accent); }

/* Contenedor principal */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

h1 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.15rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* Grid de métricas */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-card .label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-card .value {
    font-size: 1.5rem;
    font-weight: 600;
}

.metric-card.positive .value { color: var(--positive); }
.metric-card.negative .value { color: var(--negative); }

/* Gráficas */
.chart-section { margin-bottom: 2rem; }

.chart-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    height: 400px;
    position: relative;
}

.chart-container.small { height: 300px; max-width: 400px; }

/* Tabla */
.filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.filters input, .filters select, .filters button {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.filters button {
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    border: none;
}

.filters button:hover { opacity: 0.85; }

.table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th { color: var(--text-secondary); font-weight: 500; }

td.positive { color: var(--positive); }
td.negative { color: var(--negative); }

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.pagination button {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
}

.pagination button:hover { border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Páginas de autenticación --- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.auth-card h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"] {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.65rem 0.85rem;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group.checkbox label {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    display: flex;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
}

.btn-primary {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 0.5rem;
}

.btn-primary:hover { opacity: 0.85; }

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--accent);
    text-decoration: none;
}

.auth-footer a:hover { text-decoration: underline; }

/* --- Flash messages --- */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border-left: 3px solid;
}

.flash-success {
    background: rgba(63, 185, 80, 0.1);
    border-color: var(--positive);
    color: var(--positive);
}

.flash-error {
    background: rgba(248, 81, 73, 0.1);
    border-color: var(--negative);
    color: var(--negative);
}

.flash-warning {
    background: rgba(210, 153, 34, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

/* --- Navbar: usuario --- */
.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-logout:hover {
    border-color: var(--negative);
    color: var(--negative);
}

/* --- Perfil --- */
.profile-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.profile-section h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.profile-info p {
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.profile-info strong { color: var(--text-primary); }

.hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.hint code {
    background: var(--bg-primary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--accent);
}

.key-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(63, 185, 80, 0.15);
    color: var(--positive);
}

.badge-warning {
    background: rgba(210, 153, 34, 0.15);
    color: var(--warning);
}

.key-status code {
    background: var(--bg-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(88, 166, 255, 0.1);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--negative);
    color: var(--negative);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 1rem;
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.1);
}

.profile-section hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* --- Bot selector (navbar) --- */
.context-badge {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.context-badge strong { color: var(--accent); }

.bot-selector {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.bot-selector:hover { border-color: var(--accent); }

/* --- Lista de bots en perfil --- */
.bot-list {
    list-style: none;
    margin-bottom: 1rem;
}

.bot-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.bot-name {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.btn-small {
    padding: 0.3rem 0.7rem !important;
    font-size: 0.8rem !important;
    margin-top: 0 !important;
}