/* Refinamientos visuales sobre tema.css. Usa las variables de cada tema, así que funciona con claro, oscuro y atlántico. */
html { --radius: 14px; --radius-sm: 9px; --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
html body { text-rendering: optimizeLegibility; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* barra superior */
html nav { padding: 8px 22px; backdrop-filter: saturate(1.4) blur(6px); }
html nav > b { display: inline-flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
html nav > b::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
html nav > span { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
html nav a { font-weight: 550; }
html nav a.activo { box-shadow: inset 0 -2px 0 currentColor; border-radius: 8px 8px 4px 4px; }
html nav a.salir { margin-left: 8px; border: 1px solid var(--nav-border); }
html nav a.salir:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
html select#selector-tema { margin-left: auto; border-radius: 999px; padding: 5px 12px; cursor: pointer; }
html .menu-panel { border-radius: var(--radius); padding: 8px; animation: panel-in .12s ease-out; }
html nav .menu-panel a { font-weight: 500; }
@keyframes panel-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* contenido */
html main { max-width: 1240px; padding: 0 22px; margin-top: 22px; }
html h1 { font-size: 28px; margin: 4px 0 16px; }
html h3 { font-size: 15px; letter-spacing: .01em; }
html p { color: var(--text); }
html .card { border-radius: var(--radius); padding: 22px; transition: box-shadow .2s ease, border-color .2s ease; }
html .card:hover { box-shadow: 0 6px 20px rgba(15, 23, 42, .09); }
html .card.err { border-left: 4px solid var(--danger); }
html .kpis { gap: 14px; }
html .kpi { padding: 16px 18px; border-radius: var(--radius); transition: transform .15s ease, box-shadow .15s ease; }
html .kpi:hover { transform: translateY(-2px); }
html .kpi b, html .num { font-variant-numeric: tabular-nums; }
html .kpi b { margin-top: 6px; line-height: 1.15; }

/* botones y formularios */
html a.btn, html button { border-radius: var(--radius-sm); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
html a.btn:hover, html button:hover { box-shadow: 0 3px 10px rgba(15, 23, 42, .18); }
html a.btn.sec, html button.sec { box-shadow: none; }
html a.btn:focus-visible, html button:focus-visible, html summary:focus-visible { outline: none; box-shadow: var(--ring); }
html input, html select, html textarea { transition: border-color .15s ease, box-shadow .15s ease; }
html input:focus, html select:focus, html textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
html button[disabled], html a.btn[disabled] { opacity: .55; cursor: not-allowed; }
html details > summary { cursor: pointer; list-style-position: inside; }
html details[open] > summary { margin-bottom: 8px; }

/* tablas */
html table { width: 100%; }
html th, html td { padding: 10px 12px; }
html th { white-space: normal; }
html tr:hover > td { background: var(--surface2); }
html td a { text-decoration: none; font-weight: 550; }
html td a:hover { text-decoration: underline; }
html .tag { letter-spacing: .01em; }

/* botón volver (barra bajo el menú) */
html .barra-volver { margin: 0 0 6px !important; }
html .barra-volver a.btn { background: transparent; color: var(--muted); border: 1px solid var(--border); box-shadow: none; padding: 5px 12px; font-size: 13px; border-radius: 999px; }
html .barra-volver a.btn:hover { background: var(--surface2); color: var(--text); }

/* móvil */
@media (max-width: 720px) {
  html nav > span { width: 100%; margin-top: 6px; }
  html select#selector-tema { margin-left: 0; }
  html .menu-panel { position: fixed !important; left: 10px !important; right: 10px !important; top: 64px !important; max-height: 70vh; overflow: auto; }
  html table { font-size: 13px; }
  html th, html td { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { html nav, html .barra-volver, html select#selector-tema { display: none !important; } html .card { box-shadow: none; } }

/* paneles */
html .panel-filtros { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; }
html .panel-filtros span { color: var(--muted); font-size: 13px; margin-right: 4px; }
html .inm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; margin: 14px 0; }
html .inm-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, 14px); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 12px; transition: transform .15s ease, box-shadow .2s ease; }
html .inm-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15, 23, 42, .12); }
html .inm-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
html .inm-titulo { display: flex; flex-direction: column; min-width: 0; }
html .inm-ref { font-size: 17px; font-weight: 700; text-decoration: none; }
html .inm-nombre { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html .inm-loc { color: var(--muted); font-size: 13px; margin-top: -6px; }
html .inm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
html .inm-stats span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
html .inm-stats b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; margin-top: 2px; }
html .inm-acciones { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
@media (max-width: 520px) { html .inm-grid { grid-template-columns: 1fr; } html .inm-stats { grid-template-columns: repeat(2, 1fr); } }

/* widgets */
html .widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 16px; margin: 14px 0; align-items: start; }
html .widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, 14px); box-shadow: var(--shadow); padding: 18px; max-height: 440px; overflow: auto; min-width: 0; }
html .widget > .card { margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; overflow: visible; }
html .widget > .card:hover { box-shadow: none; }
html .widget > .card + .card, html .widget > .card + p, html .widget > p + .card { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
html .widget h3:first-child, html .widget > .card > h3:first-child { margin-top: 0; }
html .widget table { font-size: 13px; }

/* sin-scroll v2 */
html td, html th { overflow-wrap: break-word; }
html td[style*="nowrap"]:has(form, .btn, button) { white-space: normal !important; }
html td > form, html td > form.inline { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; max-width: 100%; }
html td > form input:not([type=checkbox]):not([type=radio]):not([type=hidden]), html td > form select { width: auto; min-width: 64px; max-width: 150px; margin: 0; padding: 4px 8px; }
html td > form input[type=date] { max-width: 140px; }
html td > form input[name="importe"], html td > form input[name="pct"] { max-width: 100px; }
html td > .btn, html td > form button { white-space: nowrap; }
html .acc { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
html .acc-det > summary { list-style: none; cursor: pointer; display: inline-block; }
html .acc-det > summary::-webkit-details-marker { display: none; }
html .acc-panel { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; }
html .acc-panel label { margin: 0; font-size: 12px; }
