:root {
    --azul: #123a63;
    --azul-claro: #1c5590;
    --gris-bg: #f4f6f9;
    --gris-borde: #dfe3e8;
    --texto: #2b3542;
    --verde: #1f8a52;
    --rojo: #c0362c;
    --amarillo: #b8860b;
    --radius: 6px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--gris-bg);
    color: var(--texto);
}
a { color: var(--azul-claro); text-decoration: none; }

/* ---------- Auth (login / recuperar / instalar) ---------- */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, var(--azul), var(--azul-claro));
}
.auth-box {
    background: #fff; padding: 36px 32px; border-radius: var(--radius);
    width: 100%; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.auth-box h1 { font-size: 20px; margin: 0 0 4px; color: var(--azul); }
.auth-subtitle { color: #6b7684; font-size: 13px; margin: 0 0 20px; }
.auth-form label { display: block; font-size: 13px; margin: 12px 0 4px; font-weight: 600; }
.auth-form input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--gris-borde);
    border-radius: var(--radius); font-size: 14px;
}
.auth-link { display: block; text-align: center; margin-top: 16px; font-size: 13px; }
.alert { padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.alert-error { background: #fdecea; color: var(--rojo); border: 1px solid #f5c6cb; }
.alert-ok { background: #e8f7ee; color: var(--verde); border: 1px solid #c3e6cb; }

/* ---------- Layout general ---------- */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px; background: var(--azul); color: #fff; flex-shrink: 0;
    transition: margin-left .2s;
}
.sidebar-brand { padding: 18px 20px; font-weight: 700; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.15); }
.sidebar-nav { padding: 10px 0; }
.nav-group-title { padding: 14px 20px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #b9c8dc; }
.nav-link { display: block; padding: 10px 20px; color: #dbe6f4; font-size: 14px; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-sub { padding-left: 30px; font-size: 13.5px; }
.nav-disabled { color: #6f85a3; cursor: not-allowed; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; padding: 12px 20px; border-bottom: 1px solid var(--gris-borde);
}
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; }
.content { padding: 22px; }

/* ---------- Botones ---------- */
.btn {
    display: inline-block; padding: 9px 16px; border-radius: var(--radius);
    border: 1px solid transparent; font-size: 13.5px; cursor: pointer; font-weight: 600;
}
.btn-primary { background: var(--azul-claro); color: #fff; }
.btn-primary:hover { background: var(--azul); }
.btn-outline { background: #fff; border-color: var(--gris-borde); color: var(--texto); }
.btn-outline:hover { background: var(--gris-bg); }
.btn-danger { background: #fff; border-color: var(--rojo); color: var(--rojo); }
.btn-danger:hover { background: var(--rojo); color: #fff; }
.btn-success { background: #fff; border-color: var(--verde); color: var(--verde); }
.btn-success:hover { background: var(--verde); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------- Cards / tablas ---------- */
.card { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 20px; }
.card h2 { margin-top: 0; font-size: 16px; color: var(--azul); border-bottom: 1px solid var(--gris-borde); padding-bottom: 10px; }
.page-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.page-title h1 { font-size: 20px; color: var(--azul); margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table th, table td { padding: 8px 10px; border: 1px solid var(--gris-borde); text-align: center; }
table thead th { background: var(--gris-bg); font-weight: 600; }
table tfoot td { font-weight: 700; background: #f0f4f8; }
.table-scroll { overflow-x: auto; }
table input, table select { width: 100%; padding: 5px 6px; border: 1px solid var(--gris-borde); border-radius: 4px; font-size: 13px; }

.badge { padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-ok { background: #e8f7ee; color: var(--verde); }
.badge-warn { background: #fff6e0; color: var(--amarillo); }
.badge-pub { background: #e6f0fb; color: var(--azul-claro); }
.badge-priv { background: #f1f2f4; color: #6b7684; }

.actions-cell { white-space: nowrap; }
.actions-cell a, .actions-cell button { margin: 0 2px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 8px 10px; border: 1px solid var(--gris-borde); border-radius: var(--radius); font-size: 13.5px;
}
textarea { resize: vertical; }

.totales-row { background: #f0f4f8; font-weight: 700; }
.resumen-box { display: flex; gap: 16px; flex-wrap: wrap; }
.resumen-item { flex: 1; min-width: 150px; background: var(--gris-bg); border-radius: var(--radius); padding: 14px; text-align: center; }
.resumen-item .valor { font-size: 22px; font-weight: 700; color: var(--azul); }
.resumen-item .label { font-size: 12px; color: #6b7684; margin-top: 4px; }

.remove-row { color: var(--rojo); cursor: pointer; font-weight: 700; }

@media (max-width: 860px) {
    .sidebar { position: fixed; z-index: 20; height: 100%; margin-left: -260px; }
    .sidebar.open { margin-left: 0; }
}
