/* =====================================================================
   bk_datos :: Estilos de la aplicacion
   ===================================================================== */

:root {
    --bg:            #f4f6fb;
    --card:          #ffffff;
    --text:          #1f2937;
    --muted:         #6b7280;
    --border:        #e5e7eb;
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-soft:  #eff6ff;
    --ok:            #059669;
    --ok-soft:       #ecfdf5;
    --alerta:        #b45309;
    --alerta-soft:   #fffbeb;
    --error:         #dc2626;
    --error-soft:    #fef2f2;
    --radius:        12px;
    --shadow:        0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg:     0 20px 45px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
p  { margin: 0; }
code {
    font-family: "Consolas", "Courier New", monospace;
    background: #f3f4f6;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: .85em;
}
small { font-size: .8rem; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- Barra superior */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: .65rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand { display: flex; align-items: center; gap: .7rem; }
.brand strong { display: block; font-size: .98rem; line-height: 1.2; }
.brand small { color: var(--muted); font-size: .76rem; }

/* ---------------------------------------------------------------- Logos */
.brand-logo { display: flex; align-items: center; flex-shrink: 0; }
.brand-logo img { display: block; height: 32px; width: auto; }
.brand-text { padding-left: .75rem; border-left: 1px solid var(--border); }
.logo-login { display: block; width: 215px; max-width: 100%; height: auto; margin: 0 auto .3rem; }

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
    letter-spacing: .02em;
}
.brand-mark-lg { width: 52px; height: 52px; font-size: 1rem; border-radius: 14px; }

.topbar-right { display: flex; align-items: center; gap: .6rem; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-radius: 999px;
    padding: .25rem .75rem .25rem .3rem;
    font-size: .85rem;
    font-weight: 500;
}

/* Aviso del atajo de teclado para abrir la configuracion */
.kbd-hint {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    color: var(--muted);
    font-size: .78rem;
    white-space: nowrap;
}
.kbd-hint kbd {
    font-family: inherit;
    font-size: .72rem;
    background: #f3f4f6;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: .05rem .32rem;
    color: #374151;
    line-height: 1.4;
}
.kbd-mas { margin: 0 .1rem; }
.avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
}

/* ---------------------------------------------------------------- Contenedor */
.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2.5rem;
    flex: 1;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.1rem;
}
.page-head p { margin-top: .25rem; font-size: .9rem; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline-flex; margin: 0; }

/* --------------------------------------------------- Formulario de descarga */
.descarga-form { align-items: center; gap: .45rem; }
.iframe-descarga {
    position: absolute;
    width: 0;
    height: 0;
    border: 0;
    visibility: hidden;
}
.campo-inline {
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 0;
}
.select-formato { width: auto; min-width: 270px; padding: .5rem .6rem; }

/* ---------------------------------------------------------------- Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: .55rem 1rem;
    font: inherit;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-soft { background: var(--primary-soft); color: var(--primary-dark); border-color: #dbeafe; }
.btn-soft:hover:not(:disabled) { background: #dbeafe; }

.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: #f9fafb; border-color: #d1d5db; }

.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; margin-top: .5rem; }

/* ---------------------------------------------------------------- Tarjetas */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.1rem;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .9rem;
}

.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .8rem;
    margin-bottom: 1.1rem;
}
.stat { display: flex; flex-direction: column; gap: .3rem; padding: .95rem 1.1rem; }
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.7rem; font-weight: 650; line-height: 1.1; }
.stat-value-sm { font-size: 1rem; font-weight: 600; word-break: break-word; }
.stat-value-sm small { color: var(--muted); font-weight: 400; }

/* ---------------------------------------------------------------- Tabla */
.table-scroll { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: .89rem; }
.tabla th {
    text-align: left;
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.tabla td {
    padding: .6rem;
    border-bottom: 1px solid #f1f3f6;
    vertical-align: top;
}
.tabla tbody tr:hover { background: #fafbfd; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; }
.detalle {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    color: #374151;
}

.vacio { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.vacio p { margin-bottom: .3rem; }

.buscador { display: flex; gap: .4rem; align-items: center; }
.buscador input[type="search"] { width: 260px; }

.paginacion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: .9rem;
    padding-top: .8rem;
    border-top: 1px solid var(--border);
    font-size: .85rem;
}
.paginacion-botones { display: flex; align-items: center; gap: .5rem; }
.pagina-actual { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Formularios */
.campo { display: block; margin-bottom: .9rem; }
.campo > span {
    display: block;
    margin-bottom: .3rem;
    font-size: .84rem;
    font-weight: 600;
    color: #374151;
}
.campo > span small { font-weight: 400; color: var(--muted); }
.campo .hint { display: block; margin-top: .3rem; color: var(--muted); font-size: .78rem; }

input[type="text"], input[type="password"], input[type="number"],
input[type="search"], textarea, select {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    font: inherit;
    font-size: .9rem;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
textarea { resize: vertical; font-family: "Consolas", "Courier New", monospace; font-size: .85rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; margin-top: .4rem; font-size: .8rem; color: var(--muted); font-weight: 400; }
.check input { width: auto; }

/* ---------------------------------------------------------------- Flash */
.flash {
    padding: .7rem .9rem;
    border-radius: 10px;
    border: 1px solid transparent;
    margin-bottom: .9rem;
    font-size: .89rem;
}
.flash-ok    { background: var(--ok-soft);    border-color: #a7f3d0; color: #065f46; }
.flash-error { background: var(--error-soft); border-color: #fecaca; color: #991b1b; }
.flash-alerta{ background: var(--alerta-soft);border-color: #fde68a; color: #92400e; }
.flash-info  { background: var(--primary-soft); border-color: #dbeafe; color: #1e40af; }

/* ---------------------------------------------------------------- Modal */
.modal { display: none; }
.modal.abierto { display: block; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(2px);
    z-index: 50;
}
.modal-dialog {
    position: fixed;
    z-index: 51;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(620px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
}
.modal-close {
    border: 0;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    padding: 0 .25rem;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.1rem 1.2rem; }
.modal-desc { color: var(--muted); font-size: .86rem; margin-bottom: 1rem; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1rem;
    padding-top: .9rem;
    border-top: 1px solid var(--border);
}
.modal-status { min-height: 1.2rem; font-size: .86rem; }
.modal-status .flash { margin: 0; }
.modal-status .chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.chip {
    border: 1px solid var(--border);
    background: #f9fafb;
    border-radius: 999px;
    padding: .15rem .6rem;
    font-size: .78rem;
    cursor: pointer;
    font-family: "Consolas", "Courier New", monospace;
}
.chip:hover { background: var(--primary-soft); border-color: #bfdbfe; color: var(--primary-dark); }
.chip.activa { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.vista { border-style: dashed; }
.chip.esquema { font-family: inherit; font-size: .8rem; }

/* Panel de diagnostico de la conexion */
.diag-panel { margin-top: .6rem; font-size: .82rem; color: var(--muted); }
.diag {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: .1rem .7rem;
    margin: 0;
    padding: .55rem .7rem;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.diag dt { font-weight: 600; }
.diag dd { margin: 0; color: var(--text); font-family: "Consolas", "Courier New", monospace; word-break: break-all; }
.diag-titulo { margin: .6rem 0 .3rem; font-weight: 600; color: var(--muted); }

/* ---------------------------------------------------------------- Login */
.body-login { background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #4f46e5 100%); }
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card {
    width: min(400px, 100%);
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 1.8rem;
}
.login-brand { text-align: center; margin-bottom: 1.3rem; }
.login-brand h1 { font-size: 1.2rem; margin-top: .7rem; }
.login-brand p { font-size: .85rem; margin-top: .2rem; }
.login-hint {
    margin-top: 1.1rem;
    padding: .7rem .8rem;
    background: var(--alerta-soft);
    border: 1px solid #fde68a;
    border-radius: 10px;
    font-size: .8rem;
    color: #92400e;
    text-align: center;
}

/* ---------------------------------------------------------------- Pie */
.footer {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: .9rem 1.25rem 1.4rem;
    color: var(--muted);
    font-size: .8rem;
    display: flex;
    gap: .4rem;
}

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 720px) {
    .grid-2 { grid-template-columns: 1fr; }
    .buscador { width: 100%; }
    .buscador input[type="search"] { width: 100%; }
    .topbar-inner { flex-wrap: wrap; }
    .acciones { width: 100%; }
    .acciones .btn, .acciones .inline-form .btn { flex: 1; }
    .inline-form { flex: 1; }
    .inline-form .btn { width: 100%; }
    .descarga-form { flex-wrap: wrap; }
    .descarga-form .campo-inline { width: 100%; }
    .select-formato { width: 100%; min-width: 0; }
    .brand-logo img { height: 28px; }
}
