:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --border: #1f2937;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #16848f;
    --accent-light: #38bdf8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* ── Login ── */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
}
.login-card {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 32px; width: 100%; max-width: 380px;
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-header h1 { font-size: 1.5rem; color: var(--accent-light); }
.login-header p { color: var(--text-muted); font-size: 0.85rem; }

/* ── Admin Layout ── */
.admin-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    width: 220px; flex: 0 0 220px; background: var(--bg-secondary); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
    overflow-y: auto; z-index: 100;
}
.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }
.logo { font-size: 1.1rem; color: var(--accent-light); font-weight: 700; }

.nav-menu { list-style: none; padding: 6px 0; flex: 1; }
.nav-section {
    padding: 10px 14px 3px; font-size: 0.65rem; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600;
}
.nav-item a {
    display: flex; align-items: center; gap: 8px; padding: 5px 14px;
    color: var(--text-secondary); text-decoration: none; font-size: 0.78rem;
    border-radius: 6px; margin: 1px 6px; transition: all 0.15s;
}
.nav-item a:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-item a.active {
    background: rgba(22,132,143,0.15); color: var(--accent-light);
    font-weight: 600;
}
.nav-icon { font-size: 0.45rem; opacity: 0.7; }

.sidebar-footer {
    padding: 12px 16px; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.user-name { font-size: 0.78rem; color: var(--text-muted); }
.logout-link { font-size: 0.78rem; color: var(--danger); }

/* ── Main Content (inside wrapper) ── */
.main-content {
    flex: 1; padding: 20px 24px; min-height: calc(100vh - 72px);
}

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.page-header h1 { font-size: 1.2rem; font-weight: 700; }

/* ── Stats Grid ── */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; text-align: center;
}
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--accent-light); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ── Tables ── */
.table-container { overflow-x: auto; }
.data-table {
    width: 100%; border-collapse: collapse; font-size: 0.82rem;
}
.data-table th {
    text-align: left; padding: 8px 12px; color: var(--text-muted);
    border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.data-table td { padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.td-bold { font-weight: 600; }
.td-mono { font-family: 'SF Mono', monospace; font-size: 0.78rem; }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 2px 8px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 600;
    min-width: 72px; text-align: center;
    line-height: 1.5; box-sizing: border-box;
    vertical-align: middle;
}
.badge-ok { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(56,189,248,0.15); color: var(--accent-light); }

/* ── Buttons ── */
.btn {
    display: inline-block; padding: 8px 16px; border-radius: 8px; border: none; cursor: pointer;
    font-size: 0.82rem; font-weight: 600; transition: all 0.15s; text-align: center;
    color: #fff; background: var(--accent);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-light); }
.btn-full { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 0.72rem; border-radius: 6px; }
.btn-xs { padding: 2px 7px; font-size: 0.68rem; border-radius: 5px; line-height: 1.4; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn .spin {
    display: inline-block; width: 10px; height: 10px; margin-right: 4px;
    border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
    border-radius: 50%; animation: svcSpin 0.7s linear infinite; vertical-align: -1px;
}
@keyframes svcSpin { to { transform: rotate(360deg); } }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; font-size: 0.78rem; color: var(--text-muted);
    margin-bottom: 4px; font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 9px 12px; background: var(--bg-primary);
    border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary);
    font-size: 0.85rem; outline: none; transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--accent);
}

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.82rem; }
.alert-danger { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

/* ── Toast Notifications ── */
.toast-container {
    position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 9999;
    display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 10px; padding: 12px 20px;
    border-radius: 10px; font-size: 0.85rem; font-weight: 500;
    box-shadow: 0 4px 24px rgba(0,0,0,0.6); pointer-events: auto;
    min-width: 300px; max-width: 440px; position: relative; overflow: hidden;
    animation: toastIn 0.3s ease;
}
.toast-success { background: #111; color: #fff; border: 1px solid #333; }
.toast-error { background: #1a1a1a; color: #fff; border: 1px solid #dc2626; }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; color: #fff; }
.toast-msg { flex: 1; color: #fff; }
.toast-close {
    background: none; border: none; color: #fff; font-size: 1.1rem;
    cursor: pointer; opacity: 0.6; padding: 0 4px; flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }
.toast-progress {
    position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
    background: rgba(255,255,255,0.1);
}
.toast-progress-fill {
    height: 100%; background: #22c55e; width: 100%;
}
.toast-progress.error-bar .toast-progress-fill { display: none; }
@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.toast.closing {
    animation: toastOut 0.3s ease forwards;
}
@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-box {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; width: 90%; max-width: 480px; animation: modalIn 0.2s ease;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; margin: 0; color: var(--text-primary); }
@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ── Utilities ── */
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* ── Dashboard ── */
.aj-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.aj-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.aj-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.aj-section {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px;
}
.aj-section h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; color: var(--text-primary); }
.aj-logo-box { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.aj-logo-box > label { font-size: 0.75rem; color: var(--text-muted); text-align: center; }
.aj-logo-box .btn { font-weight: 700; letter-spacing: 0.02em; color: #fff !important; background: var(--accent) !important; }
.aj-logo-preview {
    width: 80px; height: 80px; border: 2px dashed var(--border); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    background: var(--bg-primary);
}
.aj-logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.aj-logo-preview span { font-size: 1.5rem; color: var(--text-muted); }
.aj-file-input { display: none; }

/* Toggle checkbox */
.aj-toggle-label {
    display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none;
    font-size: 0.85rem; color: var(--text-secondary); padding: 8px 0;
}
.aj-toggle { position: absolute; opacity: 0; width: 0; height: 0; }
.aj-toggle-slider {
    width: 36px; height: 20px; background: var(--border); border-radius: 10px;
    position: relative; transition: background 0.2s; flex-shrink: 0; display: inline-block;
}
.aj-toggle-slider::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    background: #fff; border-radius: 50%; transition: transform 0.2s;
}
.aj-toggle:checked + .aj-toggle-slider { background: var(--accent); }
.aj-toggle:checked + .aj-toggle-slider::after { transform: translateX(16px); }

/* ── Dashboard ── */
.dash-grid-4 {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px;
}
.dash-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px;
}
.dash-card-icon {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0;
}
.dash-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dash-card-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
.dash-card-value { font-size: 1rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dash-panel {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px;
}
.dash-panel h3 { font-size: 0.85rem; font-weight: 700; margin-bottom: 10px; color: var(--text-primary); }
.dash-panel p { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 6px; }
.dash-link { color: var(--accent-light); font-size: 0.78rem; text-decoration: none; word-break: break-all; }
.dash-link:hover { text-decoration: underline; }

.dash-section {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; margin-bottom: 12px;
}
.dash-section-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.dash-section-header h2 { font-size: 0.9rem; font-weight: 700; margin: 0; }

.resource-bar {
    width: 80px; height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px;
    display: inline-block; vertical-align: middle; margin-right: 6px;
}
.resource-bar-fill {
    height: 100%; background: var(--accent); border-radius: 2px; min-width: 1px;
}

/* ── Stats Bar (gauge circles) ── */
.main-wrapper { flex: 1 1 0; min-width: 0; }

.stats-bar {
    display: flex; align-items: center; justify-content: center; gap: 80px;
    padding: 16px 40px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    min-height: 80px;
    overflow-x: auto;
}
.stats-bar-loading {
    color: var(--text-muted); font-size: 0.82rem; width: 100%; text-align: center;
}
.stats-gauge {
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}
.gauge-svg {
    width: 64px; height: 64px;
}
.gauge-value {
    fill: var(--text-primary); font-size: 18px; font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.gauge-label {
    fill: var(--text-muted); font-size: 10px; font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.gauge-meta {
    display: flex; flex-direction: column; gap: 1px;
}
.gauge-meta-label {
    font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.gauge-meta-detail {
    font-size: 0.7rem; color: var(--text-muted);
}

.main-content {
    flex: 1; padding: 20px 24px; min-height: calc(100vh - 72px);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { width: 60px; flex-basis: 60px; }
    .sidebar .nav-link span:not(.nav-icon) { display: none; }
    .sidebar .logo, .sidebar .sidebar-header h2 { font-size: 0.8rem; }
    .sidebar .nav-section, .sidebar-footer .user-name { display: none; }
    .main-content { padding: 12px; }
    .stats-bar { padding: 8px 12px; gap: 12px; }
    .gauge-svg { width: 48px; height: 48px; }
    .dash-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Modal de progreso ── */
.prog-box { padding: 1.5rem; }
.prog-spinner .spin {
    display: inline-block; width: 22px; height: 22px;
    border: 3px solid rgba(56,189,248,0.25); border-top-color: var(--accent-light);
    border-radius: 50%; animation: svcSpin 0.7s linear infinite;
}
.prog-icon { width: 52px; height: 52px; margin: 0 auto; }
.prog-check { width: 52px; height: 52px; }
.prog-check circle { stroke: #22c55e; stroke-width: 3; opacity: 0.3; }
.prog-check path { stroke: #22c55e; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
    stroke-dasharray: 50; stroke-dashoffset: 0; animation: progDraw 0.5s ease forwards; }
.prog-check.err circle { stroke: #ef4444; }
.prog-check.err path { stroke: #ef4444; }
@keyframes progDraw { to { stroke-dashoffset: 0; } }
.prog-bar {
    height: 8px; background: var(--bg-secondary); border-radius: 6px; overflow: hidden;
    margin-top: 14px; border: 1px solid var(--border);
}
.prog-bar-fill {
    height: 100%; width: 0; background: var(--accent); border-radius: 6px;
    transition: width 0.5s ease;
    background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
    background-size: 20px 20px;
    animation: progStripe 1s linear infinite;
}
.prog-bar-fill.ok { background: #22c55e; background-image: none; animation: none; }
.prog-bar-fill.err { background: #ef4444; background-image: none; animation: none; }
@keyframes progStripe { to { background-position: 20px 0; } }
.prog-detalles {
    margin-top: 10px; padding: 8px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: 6px;
    font-family: monospace; font-size: 0.72rem; color: var(--text-muted);
    text-align: left; max-height: 120px; overflow-y: auto; word-break: break-word;
}

/* ── Inputs (compactos, corporativos, dark) ── */
.input-control,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
select.input-control,
select:not([type]),
textarea {
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    height: 34px;
    box-sizing: border-box;
}
textarea { height: auto; resize: vertical; line-height: 1.5; }
.input-control:hover,
input[type="text"]:hover,
input[type="number"]:hover,
select:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.input-control:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
}
.input-control::placeholder,
input::placeholder { color: var(--text-muted); opacity: 0.55; }
.input-control:disabled,
input:disabled,
select:disabled { opacity: 0.45; cursor: not-allowed; }
select, select.input-control { cursor: pointer; }
/* variantes */
.input-control.compact,
input.compact { padding: 3px 7px; height: 26px; font-size: 0.75rem; border-radius: 5px; }
.input-control.w-sm { width: 140px; }
.input-control.w-md { width: 240px; }
/* checkbox / radio no heredan el look de input */
input[type="checkbox"],
input[type="radio"],
input[type="range"],
input[type="file"],
input[type="color"] {
    width: auto; height: auto; padding: 0; background: none; border: none;
    box-shadow: none; accent-color: var(--accent); cursor: pointer; font-size: inherit;
}
input[type="checkbox"]:focus,
input[type="radio"]:focus { box-shadow: none; }
/* inputs de tablas (MariaDB/Pool) */
.db-in, .pool-in {
    padding: 3px 7px; height: 26px; font-size: 0.75rem; border-radius: 5px;
    background: var(--bg-secondary); color: var(--text-primary);
    border: 1px solid var(--border); width: 96px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.db-in:focus, .pool-in:focus {
    border-color: var(--accent); box-shadow: 0 0 0 2px rgba(56,189,248,0.18);
}
/* ── Fila compacta etiqueta + input (buscadores de página) ── */
.inline-field {
    display: flex; align-items: center; gap: 8px;
}
.inline-field label {
    font-size: 0.72rem; color: var(--text-muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; margin: 0;
}
.inline-field .input-control { height: 30px; font-size: 0.8rem; }

/* ── Submenús del sidebar (Backups) — acordeón compacto ── */
.nav-item.nav-parent > a { justify-content: space-between; }
.nav-chevron {
    color: var(--text-muted); font-size: 0.9rem; line-height: 1;
    transition: transform 0.15s; display: inline-block;
}
.nav-chevron.open { transform: rotate(90deg); }
.nav-sub { list-style: none; margin: 0; padding: 1px 0 3px; }
.nav-item.nav-sub a {
    padding: 2px 12px 2px 30px;
    font-size: 0.74rem;
    color: var(--text-muted);
    margin: 0 6px;
    border-radius: 5px;
}
.nav-item.nav-sub a:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-item.nav-sub a.active { color: var(--accent-light); background: rgba(22,132,143,0.10); }

/* ── Tablas compactas (filas finas, sin reducir tipografía) ── */
.data-table th { padding: 5px 10px; }
.data-table td { padding: 5px 10px; }

/* ── Barra de sección (título + acciones en ancho completo) ── */
.section-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 10px; margin: 1.1rem 0 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.section-bar:first-of-type { margin-top: 0; }
.section-bar-title {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
}
.section-bar .actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ── Barra de título delgada + pestañas full-width (tipo Webuzo) ── */
.svc-titlebar {
    background: #e8eaed;
    border: 1px solid #d0d3d8;
    color: var(--accent); text-align: center;
    padding: 4px 10px; border-radius: 6px; margin-bottom: 6px;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase;
}
.svc-tabs {
    display: flex; margin-bottom: 12px;
    border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.svc-tab {
    flex: 1; padding: 8px 6px; border: none; cursor: pointer;
    font-size: 0.78rem; font-weight: 600;
    background: var(--bg-secondary); color: var(--text-muted);
    border-right: 1px solid var(--border);
    transition: background 0.12s, color 0.12s;
}
.svc-tab:last-child { border-right: none; }
.svc-tab.activo { background: var(--accent); color: #fff; }
.svc-tab:not(.activo):hover { background: rgba(56,189,248,0.12); color: var(--text-primary); }
.svc-pane-actions {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px; gap: 8px; flex-wrap: wrap;
}

/* ── Botones de acción en tablas: ancho fijo, centrados, tipo columna ── */
.data-table td { vertical-align: middle; }
.data-table td > .btn {
    min-width: 74px;
    text-align: center;
    padding-left: 4px;
    padding-right: 4px;
    white-space: nowrap;
}
/* celdas con grupo de botones: alineados con su encabezado (izq) */
.data-table td[style*="display:flex"] {
    justify-content: flex-start;
    gap: 4px;
    align-items: center;
}
.data-table td[style*="display:flex"] > .btn {
    min-width: 74px;
}
/* columnas de acción propias (th + td centrados) */
.data-table th.th-acc, .data-table td.td-acc {
    text-align: center;
}
.data-table td.td-acc > .btn {
    display: block;
    margin: 0 auto;
    min-width: 74px;
}
/* badges no deben estirar la celda */
.data-table td .badge { white-space: nowrap; }
