/* ============ nadunet · tema unificado (claro/oscuro) ============ */
:root {
    --accent: #00b3a4;
    --accent-hover: #009c8f;
    --accent-soft: rgba(0, 179, 164, .12);
    --bg: #f4f7f6;
    --card: #ffffff;
    --ink: #16211f;
    --muted: #6b7a77;
    --line: #e3e9e7;
    --sidebar-bg: #ffffff;
    --sidebar-ink: #46534f;
    --danger: #c0392b;
    --danger-soft: #fdecea;
    --ok-soft: #e3f6f1;
    --ok-ink: #0c6b54;
    --warn-soft: #fdf6e3;
    --warn-ink: #8a6d1a;
    --shadow: 0 1px 3px rgba(22, 33, 31, .07);
}
html[data-theme="dark"] {
    --bg: #0e1414;
    --card: #17201f;
    --ink: #e4ecea;
    --muted: #8fa09c;
    --line: #263231;
    --sidebar-bg: #121a19;
    --sidebar-ink: #a8b8b4;
    --danger: #e07060;
    --danger-soft: #3a1f1c;
    --ok-soft: #12302a;
    --ok-ink: #6fd6bd;
    --warn-soft: #33290f;
    --warn-ink: #e0c36a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0; padding: 40px 24px;
    background: var(--bg); color: var(--ink);
    transition: background .25s ease, color .25s ease;
}
body.centrado { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.wrap { max-width: 1000px; margin: 0 auto; }
a { color: var(--accent); }
h1 { margin: 0 0 6px; font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; margin-top: 0; }
.sub, .muted { color: var(--muted); font-size: 14px; }

/* ---- Logo ---- */
.logo { display: inline-block; line-height: 0; }
.logo img { height: 34px; width: auto; }
.logo .logo-d { display: none; }
html[data-theme="dark"] .logo .logo-l { display: none; }
html[data-theme="dark"] .logo .logo-d { display: inline; }
.login-card .logo img { height: 44px; margin-bottom: 18px; }
.sidebar .logo img { height: 26px; }

/* ---- Layout con barra lateral ---- */
.layout { display: flex; min-height: 100vh; margin: -40px -24px; }
.sidebar {
    width: 220px; flex-shrink: 0;
    background: var(--sidebar-bg); color: var(--sidebar-ink);
    border-right: 1px solid var(--line);
    padding: 24px 16px; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
}
.sidebar .brand { font-weight: 700; font-size: 15px; margin-bottom: 20px; color: var(--ink); }
.sidebar .brand .logo { display: block; margin-bottom: 10px; }
.sidebar nav a, .sidebar .back {
    display: block; color: var(--sidebar-ink); text-decoration: none;
    padding: 9px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 3px;
}
.sidebar nav a:hover { background: var(--accent-soft); color: var(--ink); }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar .back { margin-top: auto; font-size: 13px; }
.content { flex: 1; padding: 28px; min-width: 0; }

/* ---- Tarjetas ---- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 12px; padding: 24px; box-shadow: var(--shadow);
    margin-bottom: 18px;
}

/* ---- Cabecera del panel ---- */
.cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; padding-right: 58px; }
.acciones-top { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.acciones-top a { text-decoration: none; }
.acciones-top a.salir { color: var(--danger); }
.admin-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; padding-right: 58px; }
.admin-nav a { color: var(--accent); text-decoration: none; margin-left: 16px; font-size: 14px; }
.admin-nav a.salir { color: var(--danger); }

/* ---- Rejilla de herramientas ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.seccion-titulo { margin: 28px 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tool {
    display: flex; flex-direction: column; background: var(--card);
    border: 1px solid var(--line); border-radius: 12px; padding: 22px;
    text-decoration: none; color: inherit; box-shadow: var(--shadow);
    transition: transform .12s ease, border-color .12s ease;
}
.tool:hover { transform: translateY(-2px); border-color: var(--accent); }
.tool h2 { margin: 0 0 8px; font-size: 17px; }
.tool p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.tool .go { margin-top: 16px; font-size: 14px; font-weight: 700; color: var(--accent); }
.tool.soon { opacity: .55; cursor: default; border-style: dashed; }
.tool.soon:hover { transform: none; border-color: var(--line); }
.badge { align-self: flex-start; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; font-weight: 700; }
.badge.gris { background: var(--line); color: var(--muted); }

/* ---- Formularios ---- */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input, select {
    width: 100%; box-sizing: border-box; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--card); color: var(--ink); font-size: 14px;
}
/* Checkboxes/radios no son campos de texto: sin esto heredan el width:100%
   de arriba y quedan como un bloque enorme, empujando su texto debajo. */
input[type=checkbox], input[type=radio] { width: auto; padding: 0; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.radio { font-weight: 400; display: block; margin: 6px 0; }
.barra { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; }
.filtros { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filtros label { font-size: 13px; margin-bottom: 5px; }
.filtros input, .filtros select { width: auto; }
.form-router .campos, .card-form .campos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card-form { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; max-width: 560px; margin-bottom: 18px; }
.card-form label { margin: 14px 0 6px; }
.form-cambio label { margin: 14px 0 6px; }
.form-cambio select, .form-cambio input[type=text], .form-cambio input[type=date] { max-width: 420px; }
.login-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 34px; box-shadow: var(--shadow); width: 100%; max-width: 380px; text-align: left;
}
.login-card h1 { font-size: 21px; }
.login-card label { margin: 14px 0 6px; }
.login-card button { margin-top: 20px; width: 100%; }

/* ---- Botones ---- */
button, .btn {
    display: inline-block; background: var(--accent); color: #fff;
    border: 0; padding: 10px 16px; border-radius: 8px; cursor: pointer;
    font-size: 14px; text-decoration: none; font-weight: 600;
}
button:hover, .btn:hover { background: var(--accent-hover); }
.btn.sec, button.sec { background: var(--line); color: var(--ink); }
.btn.sec:hover, button.sec:hover { background: var(--accent-soft); }
.btn.peligro, button.peligro { background: var(--danger); color: #fff; }

/* ---- Tablas ---- */
table, table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; background: transparent; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr:hover td { background: var(--accent-soft); }
.tabla-scroll { overflow-x: auto; }
table.tabla { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.tabla th { background: var(--bg); }

/* ---- Estados y avisos ---- */
.pill { background: var(--accent-soft); color: var(--accent); padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.error { background: var(--danger-soft); color: var(--danger); padding: 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.ok { background: var(--ok-soft); color: var(--ok-ink); padding: 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.aviso { background: var(--warn-soft); color: var(--warn-ink); padding: 12px 14px; border-radius: 8px; font-size: 14px; }
.aviso ul { margin: 8px 0 0; padding-left: 20px; }
.vacio { color: var(--muted); padding: 24px 0; text-align: center; }
.estado-activo { color: var(--ok-ink); font-weight: 700; }
.estado-inactivo { color: var(--danger); font-weight: 700; }
.empleado-actual { display: inline-block; padding: 8px 14px; background: var(--accent-soft); color: var(--accent); border-radius: 8px; font-weight: 700; }
.temp-pw { font-family: monospace; font-size: 16px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; display: inline-block; letter-spacing: 1px; }
.score-box { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
pre { background: #10201d; color: #d8e6e2; padding: 16px; border-radius: 10px; overflow: auto; }
.acciones-fila { display: flex; gap: 8px; flex-wrap: wrap; }
.confirmar { background: var(--warn-soft); border: 1px solid var(--warn-ink); border-radius: 10px; padding: 18px 20px; }
.confirmar h2 { margin-top: 0; }
.confirmar ul { line-height: 1.9; }
.topbar { margin-bottom: 16px; }
.topbar a { text-decoration: none; font-size: 14px; }

/* ---- Chips de avisos (tarifas) ---- */
.avisos-top { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; padding-right: 58px; }
.chip { display: inline-block; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; text-decoration: none; }
.chip-rev { background: var(--warn-soft); color: var(--warn-ink); }
.chip-prog { background: var(--accent-soft); color: var(--accent); }
.chip-inc { background: var(--danger-soft); color: var(--danger); }
.chip-mini { display: inline-block; margin-left: 8px; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill-soon { font-size: 12px; color: var(--muted); background: var(--line); padding: 4px 10px; border-radius: 999px; }

/* ---- Interruptor de tema y toast ---- */
.theme-toggle {
    position: fixed; top: 16px; right: 16px; z-index: 60;
    width: 42px; height: 42px; border-radius: 999px;
    background: var(--card); border: 1px solid var(--line); color: var(--ink);
    font-size: 19px; cursor: pointer; box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: center; padding: 0;
}
.theme-toggle:hover { background: var(--accent-soft); }
.theme-toast {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: var(--bg);
    padding: 13px 22px; border-radius: 999px; font-size: 14px; font-weight: 600;
    opacity: 0; transition: opacity .3s ease, transform .3s ease;
    z-index: 70; max-width: 90vw; text-align: center; pointer-events: none;
}
.theme-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 760px) {
    body { padding: 20px 14px; }
    .layout { margin: -20px -14px; flex-direction: column; }
    .sidebar { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 16px; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidebar .brand { margin-bottom: 0; margin-right: 12px; }
    .sidebar .brand .logo { margin-bottom: 0; }
    .sidebar nav { display: flex; gap: 4px; flex-wrap: wrap; }
    .sidebar nav a, .sidebar .back { margin-bottom: 0; padding: 7px 10px; }
    .sidebar .back { margin-top: 0; margin-left: auto; }
    .barra, .grid, .form-router .campos, .card-form .campos { grid-template-columns: 1fr; }
    .theme-toggle { top: 10px; right: 10px; }
}
.chip-fact { background: var(--ok-soft); color: var(--ok-ink); }

/* Barra lateral plegable (tablas anchas), con animación suave */
.sidebar { transition: width .28s ease, padding .28s ease, border-color .28s ease; white-space: nowrap; overflow-x: hidden; }
.content { transition: padding .28s ease; }
.wrap { transition: max-width .28s ease; }
.plegar-lateral { position: absolute; top: 12px; right: 10px; width: 26px; height: 26px; padding: 0; font-size: 15px; line-height: 1; background: transparent; color: var(--muted); border: 0; cursor: pointer; border-radius: 6px; }
.plegar-lateral:hover { color: var(--ink); background: var(--accent-soft); }
.abrir-lateral { display: none; position: fixed; top: 14px; left: 14px; z-index: 55; width: 40px; height: 40px; padding: 0; font-size: 18px; line-height: 1; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; transition: background .15s ease, transform .15s ease; }
.abrir-lateral:hover { background: var(--accent-soft); transform: scale(1.05); }
.layout.plegado .sidebar { width: 0; padding-left: 0; padding-right: 0; border-right-color: transparent; }
.layout.plegado .abrir-lateral { display: flex; align-items: center; justify-content: center; }
.layout.plegado .content { padding-left: 60px; }
.layout.plegado .wrap { max-width: none; }
@media (max-width: 760px) {
    .plegar-lateral { display: none; }
    .layout.plegado .sidebar { width: auto; padding: 12px 16px; }
    .layout.plegado .abrir-lateral { display: none; }
    .layout.plegado .content { padding-left: 14px; }
}

/* Pulido de interacción (micro-transiciones) */
button, .btn { transition: background .15s ease, transform .08s ease, box-shadow .15s ease; }
button:active, .btn:active { transform: translateY(1px); }
td { transition: background .12s ease; }
.card { transition: box-shadow .2s ease, border-color .2s ease; }
input, select { transition: border-color .15s ease, box-shadow .15s ease, background .2s ease; }
.chip { transition: transform .12s ease, box-shadow .15s ease; }
.chip:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.sidebar nav a { transition: background .15s ease, color .15s ease, padding-left .15s ease; }
.sidebar nav a:hover { padding-left: 16px; }

/* ===== Iconos ===== */
.ico { width: 20px; height: 20px; display: inline-block; vertical-align: middle; }

/* Tarjetas de herramienta con icono y acento propio */
.tool { --tool-accent: var(--accent); }
.tool:hover { border-color: var(--tool-accent); box-shadow: 0 6px 20px color-mix(in srgb, var(--tool-accent) 18%, transparent); }
.tool-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.tool-top .badge { margin-bottom: 0; }
.tool-ico { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 13px; background: color-mix(in srgb, var(--tool-accent) 14%, transparent); color: var(--tool-accent); transition: transform .15s ease; }
.tool-ico .ico { width: 25px; height: 25px; }
.tool:hover .tool-ico { transform: scale(1.06); }
.tool .go { color: var(--tool-accent); }

/* Iconos en el menú lateral */
.sidebar nav a { display: flex; align-items: center; gap: 10px; }
.sidebar nav a .ico { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar .back { display: flex; align-items: center; gap: 8px; }
.sidebar .back .ico { width: 16px; height: 16px; flex-shrink: 0; }

/* ===== Tarjetas de cifra (stats) ===== */
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { flex: 1; min-width: 150px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; transition: transform .15s ease, border-color .15s ease; }
.stat:hover { transform: translateY(-2px); }
.stat .stat-ico { width: 40px; height: 40px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.stat .stat-ico .ico { width: 22px; height: 22px; }
.stat .n { font-size: 26px; font-weight: 700; line-height: 1; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.warn .stat-ico { background: var(--warn-soft); color: var(--warn-ink); }
.stat.warn .n { color: var(--warn-ink); }
.stat.danger .stat-ico { background: var(--danger-soft); color: var(--danger); }
.stat.danger .n { color: var(--danger); }
.stat.ok .stat-ico { background: var(--ok-soft); color: var(--ok-ink); }
.stat.ok .n { color: var(--ok-ink); }

/* ===== Mini gráfico de barras ===== */
.barchart { display: flex; flex-direction: column; gap: 11px; }
.barrow { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 12px; font-size: 13px; }
.barrow .track { background: var(--bg); border-radius: 999px; height: 15px; overflow: hidden; }
.barrow .fill { height: 100%; border-radius: 999px; background: var(--accent); min-width: 3px; transition: width .5s ease; }
.barrow .cnt { text-align: right; font-weight: 700; }
.barrow .lbl { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { .barrow { grid-template-columns: 110px 1fr 34px; } }

/* ===== Estados y feedback ===== */
.cargando-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); animation: aparecer .15s ease; }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.ok, .error, .aviso { animation: aparecer .3s ease; }
@keyframes aparecer { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ===== Densidad de tablas (modo compacto "pro") ===== */
.density-toggle { position: fixed; top: 16px; right: 66px; z-index: 60; width: 42px; height: 42px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-size: 16px; cursor: pointer; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; padding: 0; transition: background .15s ease; }
.density-toggle:hover { background: var(--accent-soft); }
html.compacto table th, html.compacto table td { padding: 5px 10px; font-size: 13px; }
html.compacto .stat { padding: 10px 14px; }
html.compacto .card { padding: 16px; }
@media (max-width: 760px) { .density-toggle { top: 10px; right: 60px; } }
