:root {
  /* Active tokens default to the light palette. */
  --nexo-primary: #1D3341;
  --nexo-primary-hover: #2B84A2;
  --nexo-fg: #1a1a1a;
  --nexo-bg: #ffffff;
  --nexo-surface: #f5f5f5;
  --nexo-muted: #5a5a5a;
  --nexo-border: #e0e0e0;
  --nexo-error: #b00020;
  --nexo-warn: #9c5d0a;
  --nexo-link: #2B84A2;
  --nexo-success: #1b8a3d;
  --nexo-accent: #2B84A2;

  /* Dark palette values — single source of truth (aligned to the eppsc dark theme: soft,
     slightly blue-tinted, comfortable contrast), referenced by the dark selectors below. */
  --nexo-dark-primary: #4a7a9a;
  --nexo-dark-primary-hover: #5b9bb8;
  --nexo-dark-fg: #e6edf3;
  --nexo-dark-bg: #0f1419;
  --nexo-dark-surface: #1a2129;
  --nexo-dark-muted: #8b949e;
  --nexo-dark-border: #30363d;
  --nexo-dark-error: #ef5350;
  --nexo-dark-warn: #f0a64d;
  --nexo-dark-link: #5b9bb8;
  --nexo-dark-success: #4caf50;
  --nexo-dark-accent: #5b9bb8;
}

/* Dark theme token mapping. app.js resolves the light/dark/system preference and writes the
   effective value to data-theme, so this drives explicit dark *and* system→dark. The @media
   block only takes effect before app.js runs (or with JS disabled), giving the right palette
   from the OS preference with no flash. Only the mapping is restated; values live once above. */
:root[data-theme="dark"] {
  --nexo-primary: var(--nexo-dark-primary);
  --nexo-primary-hover: var(--nexo-dark-primary-hover);
  --nexo-fg: var(--nexo-dark-fg);
  --nexo-bg: var(--nexo-dark-bg);
  --nexo-surface: var(--nexo-dark-surface);
  --nexo-muted: var(--nexo-dark-muted);
  --nexo-border: var(--nexo-dark-border);
  --nexo-error: var(--nexo-dark-error);
  --nexo-warn: var(--nexo-dark-warn);
  --nexo-link: var(--nexo-dark-link);
  --nexo-success: var(--nexo-dark-success);
  --nexo-accent: var(--nexo-dark-accent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --nexo-primary: var(--nexo-dark-primary);
    --nexo-primary-hover: var(--nexo-dark-primary-hover);
    --nexo-fg: var(--nexo-dark-fg);
    --nexo-bg: var(--nexo-dark-bg);
    --nexo-surface: var(--nexo-dark-surface);
    --nexo-muted: var(--nexo-dark-muted);
    --nexo-border: var(--nexo-dark-border);
    --nexo-error: var(--nexo-dark-error);
    --nexo-warn: var(--nexo-dark-warn);
    --nexo-link: var(--nexo-dark-link);
    --nexo-success: var(--nexo-dark-success);
    --nexo-accent: var(--nexo-dark-accent);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--nexo-fg);
  background: var(--nexo-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

/* Consistent headings so content never reads as loose text floating on the page. */
h1 { font-size: 1.5rem; font-weight: 700; color: var(--nexo-fg); margin: 0 0 1.25rem; line-height: 1.2; }
h2 { font-size: 1.15rem; font-weight: 600; color: var(--nexo-fg); margin: 1.75rem 0 .75rem; line-height: 1.25; }
h3 { font-size: 1rem; font-weight: 600; color: var(--nexo-fg); margin: 1.25rem 0 .5rem; }
/* Standalone explanatory paragraphs read as muted intro text under the heading, not body noise. */
.page-content > p, .page-content > .home + p { color: var(--nexo-muted); max-width: 70ch; }

a { color: var(--nexo-link); }

/* Adjacent buttons never touch. Containers that already use flex gap opt out. */
.btn + .btn { margin-left: .5rem; }
:where(.row-actions, .page-header__actions, .pager__nav, .bulk-bar, .export-menu, .filters, .toolbar, .topbar-actions) .btn + .btn { margin-left: 0; }
td form + form, td form + .btn, td .btn + form, td a.btn + form, td form + a.btn { margin-left: .35rem; }
.inline-form { display: inline-flex; margin: 0; }

:focus-visible { outline: 3px solid var(--nexo-primary); outline-offset: 2px; }

/* ──────────── Layout: Sidebar + Topbar ──────────── */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar — fixed 250px */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  height: 100vh;
  background: #1D3341;
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 500;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand-logo { height: 52px; width: auto; max-width: 100%; display: block; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .5rem 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

.sidebar-section {
  padding: .75rem 1.25rem .25rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.4);
  font-weight: 600;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.25rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .875rem;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.sidebar-nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.sidebar-nav-link--active {
  background: rgba(43,132,162,.2);
  border-left-color: #2B84A2;
  color: #fff;
}
.sidebar-nav-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }

.sidebar-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  flex-shrink: 0;
}
.sidebar-user-name { font-weight: 600; color: #fff; }
.sidebar-user-meta { color: rgba(255,255,255,.5); font-size: .75rem; }
.sidebar-footer-links { display: flex; gap: 1rem; margin-top: 4px; }
.sidebar-footer-links a { color: rgba(255,255,255,.5); text-decoration: none; }
.sidebar-footer-links a:hover { color: #fff; }

/* Main content area — offset by sidebar */
.main-wrapper {
  margin-left: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar — sticky white bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.5rem;
  background: var(--nexo-bg);
  border-bottom: 1px solid var(--nexo-border);
  min-height: 52px;
}
[data-theme="dark"] .topbar { background: var(--nexo-surface); }

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--nexo-fg);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.topbar-actions .theme-toggle {
  margin-left: 0;
  color: var(--nexo-fg);
  border: 1px solid var(--nexo-border);
}
.topbar-actions .btn--ghost { color: var(--nexo-fg); }

/* User menu dropdown (no-JS <details>; app.js closes it on outside click). */
.user-menu { position: relative; }
.user-menu__btn { list-style: none; display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; padding: .25rem .5rem; border-radius: 8px; color: var(--nexo-fg); }
.user-menu__btn::-webkit-details-marker { display: none; }
.user-menu__btn:hover { background: var(--nexo-surface); }
.user-menu__avatar { font-size: 1.4rem; line-height: 1; color: var(--nexo-muted); display: flex; }
.user-menu__id { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.user-menu__name { font-size: .88rem; font-weight: 600; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu__role { font-size: .72rem; color: var(--nexo-muted); }
.user-menu__caret { font-size: .7rem; color: var(--nexo-muted); transition: transform .15s; }
.user-menu[open] .user-menu__caret { transform: rotate(180deg); }
.user-menu__pop { position: absolute; right: 0; top: calc(100% + .4rem); min-width: 14rem; display: flex; flex-direction: column; background: var(--nexo-bg); border: 1px solid var(--nexo-border); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: .35rem; z-index: 600; }
.user-menu__pop a, .user-menu__pop button { display: flex; align-items: center; gap: .6rem; padding: .55rem .65rem; border-radius: 6px; background: none; border: none; color: var(--nexo-fg); text-decoration: none; font: inherit; width: 100%; text-align: left; cursor: pointer; }
.user-menu__pop a:hover, .user-menu__pop button:hover { background: var(--nexo-surface); }
.user-menu__pop form { margin: 0; }
.user-menu__pop hr { border: none; border-top: 1px solid var(--nexo-border); margin: .3rem .2rem; }
@media (max-width: 640px) { .user-menu__id { display: none; } }

/* Hamburger — hidden on desktop */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--nexo-fg);
  font-size: 1.3rem;
  padding: .25rem;
  cursor: pointer;
}

/* Page content */
.page-content {
  flex: 1;
  padding: 1.75rem 2rem;
}

/* Frontend variant (agent-facing, pladecof feel): readable max width. Both surfaces share the
   base page background; cards/panels use the elevated --nexo-surface so they always stand out. */
.layout-wrapper--front .page-content > .container,
.layout-wrapper--front .home { max-width: 1100px; margin-inline: auto; }

/* ──────────── Home dashboard (after-login) ──────────── */
.home-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.home-header h1 { margin: 0; font-size: 1.5rem; }
.home-header .notif-badge { margin-left: auto; }
.notif-badge { display: inline-flex; align-items: center; gap: .35rem; background: var(--nexo-accent); color: #fff; font-size: .8rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; text-decoration: none; }
.home-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: start; }
.home-panel { background: var(--nexo-surface); border: 1px solid var(--nexo-border); border-radius: 10px; padding: 1.1rem 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.home-panel h2 { margin: 0 0 .85rem; font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.home-panel h2 a { color: var(--nexo-fg); text-decoration: none; }
.home-panel h2 a:hover { color: var(--nexo-link); }
.home-panel .empty { color: var(--nexo-muted); font-size: .9rem; margin: .25rem 0; }
.home-panel--pending { grid-column: span 2; }

.pending-list, .novedad-feed, .favorito-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.pending-item { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--nexo-border); }
.pending-item:last-child { border-bottom: none; }
.pending-item a { flex: 1; color: var(--nexo-fg); text-decoration: none; font-weight: 500; }
.pending-item a:hover { color: var(--nexo-link); }
.pending-item__type { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--nexo-muted); background: var(--nexo-surface); padding: .1rem .45rem; border-radius: 4px; }
.pending-item__deadline { font-size: .8rem; color: var(--nexo-muted); }
.pending-item--overdue a { color: var(--nexo-error); }
.pending-item--overdue .pending-item__deadline { color: var(--nexo-error); font-weight: 600; }

.novedad-feed li { padding: .5rem 0; border-bottom: 1px solid var(--nexo-border); display: flex; flex-direction: column; gap: .15rem; }
.novedad-feed li:last-child { border-bottom: none; }
.novedad-feed__titulo { color: var(--nexo-fg); text-decoration: none; font-weight: 500; }
.novedad-feed__titulo:hover { color: var(--nexo-link); }
.novedad-feed__time { font-size: .78rem; color: var(--nexo-muted); }
.panel-more { display: inline-block; margin-top: .6rem; font-size: .85rem; color: var(--nexo-link); text-decoration: none; }
.panel-more:hover { text-decoration: underline; }

.favorito-list li { padding: .4rem 0; }
.favorito-list a { display: flex; align-items: center; gap: .5rem; color: var(--nexo-fg); text-decoration: none; }
.favorito-list a:hover { color: var(--nexo-link); }
.favorito-icon { font-size: 1.1rem; }

@media (max-width: 860px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-panel--pending { grid-column: auto; }
}

/* Backoffice footer */
.backoffice-footer {
  padding: .75rem 1.5rem;
  font-size: .8rem;
  color: var(--nexo-muted);
  border-top: 1px solid var(--nexo-border);
  text-align: center;
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 499;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar--open {
    transform: translateX(0);
  }
  .sidebar-overlay--visible {
    display: block;
  }
  .main-wrapper {
    margin-left: 0;
  }
  .hamburger {
    display: inline-flex;
  }
}

/* Flat data tables: clean rows, uppercase header, subtle row hover. Not a card. */
table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: .9rem; }
th, td { text-align: left; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--nexo-border); vertical-align: middle; }
th { color: var(--nexo-muted); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 2px solid var(--nexo-border); }
tbody tr:hover { background: var(--nexo-surface); }
/* Action column: a tight, right-aligned cell of icon buttons (the .row-actions wrapper). */
td:has(.row-actions), th.col-actions { width: 1%; white-space: nowrap; text-align: right; }

form { margin: 1rem 0; }
label { display: block; margin: 0.85rem 0 0.3rem; font-size: .9rem; font-weight: 500; }
input, select, textarea { padding: 0.5rem 0.65rem; font: inherit; color: var(--nexo-fg); background: var(--nexo-bg); border: 1px solid var(--nexo-border); border-radius: 6px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--nexo-accent); box-shadow: 0 0 0 3px rgba(43,132,162,.15); }
button {
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--nexo-primary);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: var(--nexo-primary-hover); }
button + button { margin-left: .5rem; }

.error { color: var(--nexo-error); font-weight: 600; }
.perm-list { list-style: none; padding: 0; }
.perm-list li { margin: 0.25rem 0; }
.perm-list label { display: flex; align-items: baseline; gap: 0.5rem; margin: 0; }
/* List controls: search filters, bulk-action bar, export bar, pager — all consistent toolbars. */
.filters { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.bulk-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.bulk-bar__label { color: var(--nexo-muted); font-size: .9rem; }
.export-menu { display: flex; align-items: center; gap: .5rem; margin: 1rem 0; }
.export-menu__label { color: var(--nexo-muted); font-size: .9rem; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 1rem 0; flex-wrap: wrap; }
.pager__range { color: var(--nexo-muted); font-size: .85rem; }
.pager__nav { display: flex; gap: .5rem; }
.empty { color: var(--nexo-muted); }
.btn.is-disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; cursor: default; }

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  margin-left: auto;
}
.theme-toggle:hover { background: rgba(255,255,255,0.15); }

/* SW update notification bar */
.sw-update-bar {
  position: sticky; top: 0; z-index: 1000;
  background: var(--color-info, #2563eb); color: #fff;
  padding: .5rem 1rem; display: flex; align-items: center; gap: 1rem;
  font-size: .9rem;
}
.sw-update-bar .btn { background: #fff; color: #2563eb; border: none; }

/* Idle-timeout warning modal */
.idle-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.idle-modal__box {
  background: var(--nexo-surface); padding: 2rem; border-radius: .5rem;
  max-width: 24rem; width: 90%; text-align: center;
}
.idle-modal__box h2 { margin: 0 0 .75rem; }
.idle-modal__box p { margin: 0 0 1.5rem; }

/* Account switcher */
.accsw { position: relative; display: inline-block; margin-left: auto; }
.accsw__toggle { background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; padding: .25rem .6rem; font: inherit; font-size: .85rem; border-radius: 4px; cursor: pointer; }
.accsw__toggle:hover { background: rgba(255,255,255,.15); }
.accsw__menu { position: absolute; right: 0; top: calc(100% + .25rem); background: var(--nexo-surface); border: 1px solid var(--nexo-border); border-radius: 4px; min-width: 13rem; z-index: 300; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.accsw__item { display: block; padding: .5rem .75rem; font-size: .9rem; text-decoration: none; color: var(--nexo-fg); border-bottom: 1px solid var(--nexo-border); }
.accsw__item:last-child { border-bottom: none; }
.accsw__item--current { color: var(--nexo-muted); font-style: italic; cursor: default; }
.accsw__item:not(.accsw__item--current):hover { background: var(--nexo-bg); }
.accsw__item--add { color: var(--nexo-link); font-size: .85rem; }

/* ──────────── Components ──────────── */

/* Buttons — a complete style so anchors and <button>s look identical (an .btn anchor must
   read as a button, never a bare link). Variants override colour. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .9rem; font: inherit; font-size: .9rem; font-weight: 500; line-height: 1.2;
  color: #fff; background: var(--nexo-primary); border: 1px solid transparent; border-radius: 6px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--nexo-primary-hover); color: #fff; }
.btn--primary { background: var(--nexo-accent); border-color: var(--nexo-accent); color: #fff; }
.btn--primary:hover { background: var(--nexo-primary-hover); }
.btn--ghost { background: none; color: var(--nexo-fg); border: 1px solid var(--nexo-border); }
.btn--ghost:hover { background: var(--nexo-surface); color: var(--nexo-fg); }
.btn--sm { padding: .3rem .6rem; font-size: .82rem; }
.back-link { display: inline-flex; align-items: center; gap: .35rem; margin-bottom: 1rem; }
.back-link i { font-size: .9em; }
.push-optin { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: 1rem 0 1.5rem; padding: .9rem 1rem; background: var(--nexo-surface); border: 1px solid var(--nexo-border); border-radius: 8px; }
.push-optin__status { margin: 0; flex: 1 1 16rem; color: var(--nexo-muted); }
.btn--secondary { background: #2B84A2; border-color: #2B84A2; color: #fff; }
.btn--secondary:hover { background: #236f89; color: #fff; }
.btn--danger { background: var(--nexo-error); border-color: var(--nexo-error); color: #fff; }
.btn--danger:hover { opacity: .9; }
.btn--outline { background: none; color: var(--nexo-link); border-color: var(--nexo-border); }
.btn--outline:hover { background: var(--nexo-surface); }

/* Card */
.card {
  background: var(--nexo-surface);
  border: 1px solid var(--nexo-border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card--help { border-left: 3px solid var(--nexo-accent); }
.card--danger { border-left: 3px solid var(--nexo-error); }
/* Key/value detail table inside a card reads as a clean definition list. */
.card > .table-detail { margin: 0; }
.card > .table-detail td { padding: .4rem .25rem; }

/* Tablero list card — color accent from CSS variable set via style attr */
.card-grid .card { border-top: 4px solid var(--card-color, var(--nexo-accent)); }

/* Toolbar: page title on the left, primary action (e.g. "Nuevo X") pushed to the right
   (eppsc parity). Filter forms reuse .toolbar but keep their controls grouped left. */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}
.toolbar h1 { margin: 0; font-size: 1.3rem; }
.toolbar .muted { color: var(--nexo-muted); font-size: .9rem; }
form.toolbar { justify-content: flex-start; flex-wrap: wrap; }
/* List/detail page header: title on the left, primary action(s) pushed right (eppsc parity). */
.page-header, .admin-page-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-header h1, .admin-page-header h1 { margin: 0; font-size: 1.3rem; }
.page-header__actions, .admin-page-header__actions { display: flex; align-items: center; gap: .5rem; }

/* Badges and tags */
.badge {
  display: inline-block;
  padding: .15em .55em;
  font-size: .8rem;
  font-weight: 600;
  border-radius: 10px;
  white-space: nowrap;
}
/* Tone backgrounds are translucent so the same rule reads on both light and dark themes;
   the text uses the theme-aware semantic token. */
.badge--ok { background: rgba(27,138,61,.16); color: var(--nexo-success); }
.badge--warn { background: rgba(184,115,10,.16); color: var(--nexo-warn); }
.badge--bad { background: rgba(176,0,32,.16); color: var(--nexo-error); }
.badge--alert { background: var(--nexo-error); color: #fff; }

.tag {
  display: inline-block;
  padding: .1em .45em;
  font-size: .75rem;
  font-weight: 500;
  border-radius: 4px;
  background: var(--nexo-surface);
  border: 1px solid var(--nexo-border);
  color: var(--nexo-muted);
}
.tag-critical { background: rgba(176,0,32,.16); color: var(--nexo-error); border-color: transparent; }
.tag-high { background: rgba(184,115,10,.16); color: var(--nexo-warn); border-color: transparent; }
.tag-medium { background: rgba(43,132,162,.16); color: var(--nexo-link); border-color: transparent; }
.tag-low { background: var(--nexo-surface); color: var(--nexo-muted); }
.tag-info { background: rgba(27,138,61,.16); color: var(--nexo-success); border-color: transparent; }
.tag-resolved { background: rgba(27,138,61,.16); color: var(--nexo-success); border-color: transparent; }
.tag-open { background: rgba(176,0,32,.16); color: var(--nexo-error); border-color: transparent; }

/* State badges */
.state-online { color: var(--nexo-success); }
.state-offline { color: var(--nexo-muted); }
.state-disabled { color: var(--nexo-warn); }
.state-decommissioned { color: var(--nexo-error); }

/* Detail table */
.table-detail { width: auto; background: none; border: none; border-radius: 0; }
.table-detail td { padding: .4rem .75rem; border: none; }
.table-detail tbody tr:hover { background: none; }
.detail-label {
  width: 140px;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--nexo-muted);
  font-weight: 600;
  vertical-align: top;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 1rem 0;
  font-size: .9rem;
  color: var(--nexo-muted);
}
.pagination a { text-decoration: none; }

/* Tablero board — main area with tinted background from CSS variable */
.tablero-board {
  background: color-mix(in srgb, var(--board-color, #4B7BE5) 13%, transparent);
}
.tablero-board .tablero-header h1 { color: var(--board-color, var(--nexo-primary)); }

/* Calendar color dots — color from CSS variable */
.calendar-dot { background: var(--dot-color, #4B7BE5); }
.calendar-event-pill { background: var(--pill-color, #4B7BE5); }

/* Toast notifications */
#toasts {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 380px;
}
.toast {
  background: var(--nexo-surface);
  border: 1px solid var(--nexo-border);
  border-radius: 8px;
  padding: .85rem 1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  font-size: .9rem;
  border-left: 4px solid var(--nexo-muted);
  animation: toast-in .3s ease;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.toast-success { border-left-color: var(--nexo-success); }
.toast-info { border-left-color: var(--nexo-accent); }
.toast-error { border-left-color: var(--nexo-error); }
.toast-hide { animation: toast-out .3s ease forwards; }
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* Help card */
.help-card {
  background: var(--nexo-surface);
  border: 1px solid var(--nexo-border);
  border-left: 3px solid var(--nexo-accent);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.help-card .help-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  margin-bottom: .25rem;
}

/* Password field */
.password-field { position: relative; }
.password-field input { padding-right: 2.5rem; }
.password-toggle {
  position: absolute;
  right: .4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--nexo-muted);
  cursor: pointer;
  padding: .25rem;
  font-size: 1rem;
}
.password-actions {
  display: flex;
  gap: .5rem;
  margin-top: .35rem;
  font-size: .8rem;
}

/* Busy state */
.is-busy { position: relative; pointer-events: none; }
.is-busy::after {
  content: "";
  display: inline-block;
  width: .85rem;
  height: .85rem;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-left: .4rem;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1D3341;
  padding: 1rem;
}
.login-card {
  /* The login card is always a light surface on the navy page, in any theme. Re-mapping the
     semantic tokens here keeps every inner rule (labels, inputs, icon prefixes) correct
     light-on-white without per-element overrides, and fixes the dark-box / faint-label
     artifacts that appeared when the page theme was dark. */
  --nexo-fg: #1a2535;
  --nexo-bg: #ffffff;
  --nexo-surface: #f1f3f5;
  --nexo-border: #d8dde3;
  --nexo-muted: #6b7280;
  background: #fff;
  color: var(--nexo-fg);
  border-radius: 12px;
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
/* Neutralise the browser's yellow autofill so it doesn't clash with the white card. */
.login-card input:-webkit-autofill,
.login-card input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 30px #fff inset;
  -webkit-text-fill-color: #1a2535;
  caret-color: #1a2535;
}
.login-brand-logo { display: block; height: 56px; width: auto; margin: 0 auto 1rem; }
.login-card h1 {
  color: #1D3341;
  font-size: 1.3rem;
  text-align: center;
  margin: 0 0 .25rem;
}
.login-card .login-subtitle {
  text-align: center;
  color: var(--nexo-muted);
  font-size: .85rem;
  margin-bottom: 1.5rem;
}
.login-card label { margin: .75rem 0 .25rem; font-size: .85rem; font-weight: 500; color: var(--nexo-fg); }
.login-card .input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--nexo-border);
  border-radius: 6px;
  overflow: hidden;
}
.login-card .input-group i {
  padding: .5rem .65rem;
  color: var(--nexo-muted);
  background: var(--nexo-surface);
  font-size: 1rem;
}
.login-card .input-group input {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: .55rem .65rem;
  background: transparent;
}
.login-card .input-group:focus-within { border-color: #2B84A2; }
.login-card button[type="submit"] {
  width: 100%;
  padding: .65rem;
  font-size: 1rem;
  background: #2B84A2;
  border-radius: 6px;
  margin-top: 1.25rem;
}
.login-card button[type="submit"]:hover { background: #236f89; }
.login-card .login-footer { text-align: center; margin-top: 1rem; font-size: .85rem; }
.login-remember-wrapper { margin-top: .75rem; }
.checkbox-label { display: flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 400; margin: 0; }
.checkbox-label input[type="checkbox"] { width: auto; }
.login-passkey-wrapper { text-align: center; margin-top: .75rem; }
.inline-form { margin: 0; display: inline; }

/* Iconized row actions (view / edit / delete) — uniform across every list */
.row-actions { display: inline-flex; align-items: center; gap: .25rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0;
  border: 1px solid var(--nexo-border); border-radius: 6px;
  background: var(--nexo-bg); color: var(--nexo-fg);
  cursor: pointer; text-decoration: none; font-size: 1rem; line-height: 1;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--nexo-surface); border-color: var(--nexo-primary); color: var(--nexo-primary); }
.icon-btn--danger:hover { background: var(--nexo-error); border-color: var(--nexo-error); color: #fff; }
.login-version {
  position: fixed;
  bottom: .5rem;
  right: 1rem;
  font-size: .75rem;
  color: rgba(255,255,255,.4);
}

/* Profile grid */
.profile-grid { display: grid; grid-template-columns: 140px 1fr; gap: .35rem .75rem; font-size: .9rem; }
.profile-grid dt { color: var(--nexo-muted); font-weight: 600; font-size: .8rem; }

/* Glossary */
.glossary { max-width: 600px; }
.glossary dt { font-weight: 600; margin-top: 1rem; color: var(--nexo-primary); }
.glossary dd { margin: .25rem 0 0 1rem; color: var(--nexo-fg); font-size: .9rem; }

/* Help page */
.help-toc { display: flex; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--nexo-border); }
.help-toc a { font-size: .9rem; text-decoration: none; }
.help-toc a:hover { text-decoration: underline; }
.help-page section { margin-bottom: 1.5rem; }
.help-page section h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.help-page section p { color: var(--nexo-fg); line-height: 1.6; }

/* Dashboard stats */
.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.dashboard-stat { background: var(--nexo-surface); border: 1px solid var(--nexo-border); border-radius: 8px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.dashboard-stat--alert { border-left: 3px solid var(--nexo-error); }
.dashboard-stat__label { font-size: .8rem; color: var(--nexo-muted); text-transform: uppercase; letter-spacing: .04em; }
.dashboard-stat__value { font-size: 1.8rem; font-weight: 700; color: var(--nexo-primary); margin: .25rem 0; }
.dashboard-stat__trend { font-size: .85rem; color: var(--nexo-muted); }
.dashboard-stat--link { display: block; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.dashboard-stat--link:hover { border-color: var(--nexo-accent); box-shadow: 0 4px 14px rgba(0,0,0,.12); transform: translateY(-1px); }
.dashboard-stat__more { display: inline-flex; align-items: center; gap: .3rem; margin-top: .6rem; font-size: .82rem; font-weight: 500; color: var(--nexo-link); }

/* Create/edit form cards: a boxed, intentional form (replaces raw fields at page bottom). */
.form-card { max-width: 680px; }
.form-card > h2:first-child { margin-top: 0; }

/* Section cards (profile, detail pages): each logical section is a boxed panel, not loose text. */
.profile-section { margin-bottom: 1.25rem; }
.profile-section > h2:first-child, .profile-section > h2:nth-child(2) { margin-top: 0; }
.profile-section > table:last-child, .profile-section > form:last-child { margin-bottom: 0; }

/* In real (non-inline) forms, fields stack under their label — cleaner than label-beside-field,
   and fixes textareas that rendered next to their label. Inline filter/search forms keep rows. */
.form-card label, .form-grid label { display: block; }
.form-card label > input:not([type=checkbox]):not([type=radio]):not([type=color]),
.form-card label > select, .form-card label > textarea,
.form-grid label > input:not([type=checkbox]):not([type=radio]):not([type=color]),
.form-grid label > select, .form-grid label > textarea { display: block; margin-top: .3rem; width: 100%; max-width: 460px; }
textarea { min-height: 7rem; resize: vertical; width: 100%; max-width: 460px; }

/* Branded error / not-found page: centered card with the status code. */
.error-page { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center; }
.error-card { max-width: 460px; }
.error-card__code { font-size: 4rem; font-weight: 800; color: var(--nexo-accent); line-height: 1; margin-bottom: .25rem; }
.error-card h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
.error-card p { color: var(--nexo-muted); margin: .35rem 0; }
.error-card .btn { margin-top: 1.25rem; }

/* System health / diagnostics */
.health-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.health-timestamp { color: var(--nexo-muted); font-size: .85rem; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-top: 1rem; }
.health-card { background: var(--nexo-surface); border: 1px solid var(--nexo-border); border-radius: 8px; padding: 1.1rem 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.health-card--wide { grid-column: 1 / -1; }
.health-card h2 { font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; color: var(--nexo-muted); margin: 0 0 .75rem; }
.health-card dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .75rem; margin: 0; }
.health-card dt { color: var(--nexo-muted); font-size: .85rem; }
.health-card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.health-dead { margin-top: 1rem; }
.health-dead h3 { font-size: .8rem; color: var(--nexo-muted); margin: 0 0 .35rem; }
.health-dead-err { color: var(--nexo-error); font-size: .8rem; }
.table--compact th, .table--compact td { padding: .3rem .5rem; font-size: .82rem; }
.health-services { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .5rem .75rem; }
.health-service { display: flex; align-items: center; gap: .5rem; }
.health-service-name { flex: 1; }
.health-service-state { font-weight: 600; font-size: .85rem; }
.health-service-detail { color: var(--nexo-muted); font-size: .8rem; }
.status-dot { width: .65rem; height: .65rem; border-radius: 50%; flex-shrink: 0; display: inline-block; background: var(--nexo-muted); }
.status-dot--ok { background: var(--nexo-success); }
.status-dot--bad { background: var(--nexo-error); }

/* System tasks / job queue */
.tasks-section { margin: 1.5rem 0; }
.tasks-section > .muted { color: var(--nexo-muted); font-size: .85rem; margin: .25rem 0 .75rem; }
.status-badge { display: inline-block; padding: .1em .5em; border-radius: 4px; font-size: .78rem; font-weight: 600; background: var(--nexo-surface); border: 1px solid var(--nexo-border); }
.status-badge--ready { color: var(--nexo-link); }
.status-badge--active { color: var(--nexo-warn); }
.status-badge--retry { color: var(--nexo-warn); }
.status-badge--done { color: var(--nexo-success); }
.status-badge--dead { color: var(--nexo-error); border-color: var(--nexo-error); }
.status-badge--draft { color: var(--nexo-muted); }
.status-badge--published { color: var(--nexo-success); }
.status-badge--archived { color: var(--nexo-muted); }

/* Utilities — no inline styles */
.wysiwyg-source { display: none; }
.hidden-form { display: none; }
.form-row { display: flex; gap: 1rem; }
.text-muted { color: var(--nexo-muted); }
.text-sm { font-size: .85rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.is-hidden { display: none; }
.user-search-input { width: 100%; }
.chart-box { position: relative; height: 220px; margin-bottom: 1rem; }
.kanban { display: flex; gap: 1rem; align-items: flex-start; overflow-x: auto; }
.kanban-col { flex: 1 1 0; min-width: 220px; background: var(--nexo-surface); border-radius: 6px; padding: 0.5rem; }
.kanban-col__title { font-size: 0.9rem; margin: 0 0 0.5rem; display: flex; justify-content: space-between; align-items: center; }
.kanban-col__count { background: var(--nexo-border); border-radius: 999px; padding: 0 0.5rem; font-size: 0.75rem; }
.kanban-card { display: block; background: var(--nexo-bg); border: 1px solid var(--nexo-border); border-radius: 4px; padding: 0.5rem; margin-bottom: 0.5rem; box-shadow: 0 1px 2px rgba(0,0,0,.08); text-decoration: none; color: inherit; }
.kanban-card__folio { font-weight: 600; font-size: 0.85rem; }
.kanban-card__tipo { font-size: 0.8rem; color: var(--nexo-muted); }
.kanban-card__assignee { font-size: 0.75rem; color: var(--nexo-muted); margin-top: 0.25rem; }
.kanban-card__escalation { display: inline-block; margin-top: 0.25rem; font-size: 0.7rem; color: var(--nexo-error); font-weight: 600; }
.wip-input { width: 3.5rem; }
.kanban-wip { font-size: 0.75rem; color: var(--nexo-muted); background: var(--nexo-surface); border-radius: 999px; padding: 0 0.4rem; }
.kanban-wip--full { background: rgba(176,0,32,.16); color: var(--nexo-error); font-weight: 600; }
.kanban-col-wip summary { cursor: pointer; list-style: none; }

/* ──────────── Public landing (anonymous home) ──────────── */
.landing-nav { background: var(--nexo-primary); color: #fff; }
.landing-nav__inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 1.5rem; padding: .85rem 1.5rem; }
.landing-nav__brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: .02em; }
.landing-nav__links { display: flex; gap: 1rem; }
.landing-nav__links a { color: rgba(255,255,255,.85); text-decoration: none; font-size: .95rem; }
.landing-nav__links a:hover { color: #fff; }
.landing-nav__actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.landing-nav .theme-toggle { background: transparent; color: rgba(255,255,255,.85); border: 1px solid rgba(255,255,255,.25); border-radius: 6px; padding: .4rem .55rem; line-height: 1; }
.landing-nav .theme-toggle:hover { color: #fff; background: rgba(255,255,255,.12); }
/* The login control is a real button on the dark nav: light fill = primary action. */
.landing-nav__login.btn-cta { background: #fff; color: var(--nexo-primary); }
.landing-nav__login.btn-cta:hover { background: rgba(255,255,255,.88); color: var(--nexo-primary); }
.btn-cta--sm { padding: .45rem 1rem; font-size: .95rem; }

.landing { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.landing-hero { text-align: center; padding: 4rem 1rem 3rem; border-bottom: 1px solid var(--nexo-border); }
.landing-hero h1 { font-size: clamp(1.9rem, 4vw, 3rem); font-weight: 800; line-height: 1.1; margin: 0 0 1rem; color: var(--nexo-fg); }
.landing-hero__lead { max-width: 680px; margin: 0 auto 2rem; color: var(--nexo-muted); font-size: 1.1rem; line-height: 1.5; }
.btn-cta { display: inline-flex; align-items: center; gap: .5rem; background: var(--nexo-primary); color: #fff; text-decoration: none; padding: .8rem 1.6rem; border-radius: 6px; font-weight: 600; font-size: 1.05rem; }
.btn-cta:hover { background: var(--nexo-primary-hover); }

.landing-features { padding: 3rem 0 4rem; }
.landing-features h2 { text-align: center; font-size: 1.5rem; font-weight: 700; margin: 0 0 .35rem; color: var(--nexo-fg); }
.landing-features__sub { text-align: center; color: var(--nexo-muted); margin: 0 0 2.5rem; }
.landing-features__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem 2rem; }
.landing-feature { display: flex; gap: .75rem; align-items: flex-start; }
.landing-feature i { color: var(--nexo-accent); font-size: 1.35rem; line-height: 1.3; flex-shrink: 0; }
.landing-feature strong { display: block; font-size: .95rem; color: var(--nexo-fg); margin-bottom: .15rem; }
.landing-feature span { display: block; font-size: .85rem; color: var(--nexo-muted); line-height: 1.4; }

.landing-footer { text-align: center; color: var(--nexo-muted); font-size: .85rem; padding: 1.75rem 1rem; border-top: 1px solid var(--nexo-border); }

@media (max-width: 900px) { .landing-features__grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .landing-features__grid { grid-template-columns: 1fr; } .landing-nav__links { display: none; } }
