/* ==========================================================================
   DataSIS v2 · Hoja de estilos autónoma (sin Bootstrap / AdminKit)
   ========================================================================== */

:root {
  --bg:          #f4f6fb;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --border:      #e3e8f0;
  --text:        #1f2733;
  --text-soft:   #5b6675;
  --text-mute:   #8a94a6;
  --primary:     #2f6fed;
  --primary-dark:#1f57c9;
  --primary-soft:#e8f0fe;
  --success:     #1f9d55;
  --success-soft:#e3f5ea;
  --danger:      #d64545;
  --danger-soft: #fbe9e9;
  --warning:     #b7791f;
  --warning-soft:#fdf3e2;
  --info:        #2b6cb0;
  --info-soft:   #e6f0f8;
  --shadow:      0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --shadow-lg:   0 10px 30px rgba(16,24,40,.12);
  --radius:      10px;
  --radius-sm:   7px;
  --sidebar-w:   264px;
  --topbar-h:    58px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0f141b; --surface:#161d27; --surface-2:#1b232f; --border:#2a3441;
    --text:#e6eaf0; --text-soft:#a9b4c2; --text-mute:#7c8797;
    --primary:#5a8df5; --primary-dark:#4a7de6; --primary-soft:#1c2b46;
    --success:#34b06a; --success-soft:#152c20; --danger:#e56767; --danger-soft:#38201f;
    --warning:#d6a44a; --warning-soft:#33290f; --info:#5a9bd8; --info-soft:#12283a;
    --shadow:0 1px 2px rgba(0,0,0,.4); --shadow-lg:0 12px 34px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg:#0f141b; --surface:#161d27; --surface-2:#1b232f; --border:#2a3441;
  --text:#e6eaf0; --text-soft:#a9b4c2; --text-mute:#7c8797;
  --primary:#5a8df5; --primary-dark:#4a7de6; --primary-soft:#1c2b46;
  --success:#34b06a; --success-soft:#152c20; --danger:#e56767; --danger-soft:#38201f;
  --warning:#d6a44a; --warning-soft:#33290f; --info:#5a9bd8; --info-soft:#12283a;
  --shadow:0 1px 2px rgba(0,0,0,.4); --shadow-lg:0 12px 34px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }

/* ---------- Shell ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .22s ease;
}
.sidebar__brand {
  font-weight: 750; font-size: 1.15rem; letter-spacing: .5px;
  padding: 0 1.25rem; height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center;
  border-bottom: 1px solid var(--border);
}
.sidebar__brand a { color: var(--text); display: flex; align-items: center; gap: .55rem; }
.sidebar__brand a:hover { text-decoration: none; }
.sidebar__brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }

.sidebar__nav {
  overflow-y: auto; overscroll-behavior: contain;
  padding: .6rem .55rem 2rem; flex: 1;
  scrollbar-width: thin;
}
.sidebar__nav::-webkit-scrollbar { width: 8px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* Grupos plegables */
.sidebar__group { margin-top: .35rem; }
.sidebar__grouphead {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: none; border: 0; cursor: pointer;
  font: inherit; font-size: .68rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-mute);
  padding: .7rem .7rem .4rem;
}
.sidebar__grouphead:hover { color: var(--text-soft); }
.sidebar__chevron { transition: transform .2s ease; font-size: .7em; }
.sidebar__group:not(.is-open) .sidebar__chevron { transform: rotate(-90deg); }
.sidebar__groupbody { display: none; }
.sidebar__group.is-open .sidebar__groupbody { display: block; }

.sidebar__link {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem .7rem; margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-soft); font-weight: 500;
  border-left: 3px solid transparent;
}
.sidebar__link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar__link i { width: 18px; text-align: center; font-size: .95em; opacity: .8; flex: 0 0 18px; }
.sidebar__link.is-active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 650;
  border-left-color: var(--primary);
}
.sidebar__link.is-active i { opacity: 1; color: var(--primary); }

.main {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-width: 0;
}

.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem 0 .75rem;
  position: sticky; top: 0; z-index: 30;
}
.topbar__left { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.topbar__right { display: flex; align-items: center; gap: .35rem; flex: 0 0 auto; }
.topbar__title {
  font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__user {
  display: flex; align-items: center; gap: .5rem; color: var(--text-soft);
  background: none; border: 0; cursor: pointer; font: inherit; padding: .3rem .4rem;
  border-radius: var(--radius-sm);
}
.topbar__user:hover { background: var(--surface-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary-dark); display: grid; place-items: center; font-weight: 700; font-size: .78rem;
  overflow: hidden; flex: 0 0 30px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.content { padding: 1.4rem 1.5rem 3rem; flex: 1; width: 100%; }
.footer { padding: 1rem 1.5rem; color: var(--text-mute); font-size: .8rem; border-top: 1px solid var(--border); }

.icon-btn {
  background: none; border: 1px solid transparent; color: var(--text-soft);
  width: 38px; height: 38px; border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem;
  display: grid; place-items: center; flex: 0 0 38px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.hamburger { display: none; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 1.25rem; }
.card__head { padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.card__head h1, .card__head h2 { margin: 0; font-size: 1.05rem; }
.card__body { padding: 1.15rem; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.05rem 1.1rem; box-shadow: var(--shadow); display: block; color: inherit;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.stat:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.stat__label { color: var(--text-soft); font-size: .82rem; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.stat__label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat__value { font-size: 1.9rem; font-weight: 750; margin-top: .35rem; letter-spacing: -.02em; }
.stat__label i { color: var(--text-mute); flex: 0 0 auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; justify-content: center;
  padding: .5rem .95rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: .875rem; cursor: pointer; line-height: 1.2;
  background: var(--surface-2); color: var(--text); text-decoration: none;
  min-height: 38px;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); filter: none; }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text-soft); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { padding: .32rem .55rem; font-size: .8rem; min-height: 32px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: .4rem; align-items: center; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data th, table.data td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data thead th {
  background: var(--surface-2); color: var(--text-soft); font-weight: 650; white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable::after { content: " ⇅"; color: var(--text-mute); font-size: .8em; }
table.data thead th.sort-asc::after { content: " ↑"; color: var(--primary); }
table.data thead th.sort-desc::after { content: " ↓"; color: var(--primary); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.actions { white-space: nowrap; text-align: right; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.table-empty { padding: 2rem; text-align: center; color: var(--text-mute); }
.pagination { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; margin-top: .9rem; color: var(--text-soft); font-size: .82rem; flex-wrap: wrap; }
.pagination button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: .3rem .6rem; cursor: pointer; min-height: 32px; }
.pagination button[disabled] { opacity: .45; cursor: default; }

/* ---------- Secret cells ---------- */
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; }
.secret__btn {
  border: 0; background: none; color: var(--primary); cursor: pointer; font-size: .78rem;
  padding: .15rem .35rem; font-weight: 600; min-height: 28px;
}
.secret__btn:hover { text-decoration: underline; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .18rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge--green { background: var(--success-soft); color: var(--success); }
.badge--gray  { background: var(--surface-2); color: var(--text-soft); }
.badge--blue  { background: var(--info-soft); color: var(--info); }
.badge--amber { background: var(--warning-soft); color: var(--warning); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid--single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .82rem; color: var(--text-soft); }
.input, textarea, select {
  width: 100%; padding: .58rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: .92rem;
  min-height: 40px;
}
.input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 62px; }
.field__hint { font-size: .76rem; color: var(--text-mute); }
.form-actions { margin-top: 1.25rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.req { color: var(--danger); }

.thumb { width: 90px; height: 90px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); background: var(--surface-2); }
.thumb--sm { width: 40px; height: 40px; }

/* ---------- Alerts ---------- */
.alert { padding: .7rem .9rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; font-size: .88rem; display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.alert--success { background: var(--success-soft); color: var(--success); border-color: currentColor; }
.alert--danger  { background: var(--danger-soft);  color: var(--danger);  border-color: currentColor; }
.alert--info    { background: var(--info-soft);    color: var(--info);    border-color: currentColor; }
.alert button { background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 .2rem; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; right: 0; top: calc(100% + .4rem); min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: .35rem; display: none; z-index: 50;
}
.dropdown.is-open .dropdown__menu { display: block; }
.dropdown__menu a, .dropdown__menu button {
  display: block; width: 100%; text-align: left; padding: .55rem .6rem; border-radius: 6px;
  color: var(--text); background: none; border: 0; cursor: pointer; font: inherit;
}
.dropdown__menu a:hover, .dropdown__menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown__header { padding: .5rem .6rem; color: var(--text-mute); font-size: .78rem; }
.dropdown__divider { height: 1px; background: var(--border); margin: .3rem 0; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth__card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2rem; }
.auth__brand { text-align: center; margin-bottom: 1.5rem; }
.auth__brand h1 { font-size: 1.5rem; letter-spacing: .5px; }
.auth__brand p { color: var(--text-mute); margin: 0; }

/* ---------- Utilities ---------- */
.text-mute { color: var(--text-mute); }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }

/* ---------- Mobile ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; display: none; }
.scrim.is-on { display: block; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: grid; }
  .content { padding: 1rem 1rem 3rem; }
  .form-grid { grid-template-columns: 1fr; }
  .card__head { gap: .6rem; }
  .card__head .btn { width: 100%; }
}

@media (max-width: 560px) {
  .d-none-mobile { display: none; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
  .stat__value { font-size: 1.5rem; }
  .content { padding: .8rem .8rem 3rem; }
  .card__body { padding: .9rem; }
}

/* Mensaje de error al revelar un secreto */
.reveal-error {
  margin-top: .25rem; font-size: .75rem; line-height: 1.3; color: var(--danger);
  max-width: 260px; white-space: normal;
}

/* ==========================================================================
   v2.1 · Ficha, Ficha 360, alertas del tablero, búsqueda global, sistema
   ========================================================================== */
.badge--red { background: var(--danger-soft); color: var(--danger); }
.hide-sm { display: inline; }
.no-scroll { overflow: hidden; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
td.wrap { white-space: normal; min-width: 220px; max-width: 460px; word-break: break-word; }
a.rowlink { font-weight: 650; color: var(--text); }
a.rowlink:hover { color: var(--primary); }
.avatar--sm { width: 40px; height: 40px; flex-basis: 40px; font-size: .85rem; }
.avatar--lg { width: 72px; height: 72px; flex-basis: 72px; font-size: 1.5rem; }
.thumb--lg { width: 72px; height: 72px; border-radius: 50%; }

/* Ficha (solo lectura) */
.ficha-title { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.ficha-title h1 { margin: .1rem 0 .25rem; overflow-wrap: anywhere; }
.ficha { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .15rem 2rem; margin: 0; }
.ficha__row { display: flex; flex-direction: column; padding: .6rem 0; border-bottom: 1px solid var(--border); min-width: 0; }
.ficha__row--full { grid-column: 1 / -1; }
.ficha dt { font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-mute); }
.ficha dd { margin: .15rem 0 0; overflow-wrap: anywhere; display: flex; align-items: baseline; gap: .15rem; flex-wrap: wrap; }
.ficha dd .copyable { flex: 0 1 auto; }
.ficha dd .secret__btn { opacity: .55; }
.ficha dd:hover .secret__btn { opacity: 1; }

/* Ficha 360: lo relacionado */
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.related__group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem .9rem; background: var(--surface-2); }
.related__group h3 { font-size: .9rem; margin: 0 0 .5rem; display: flex; align-items: center; gap: .45rem; }
.related__group ul { list-style: none; margin: 0; padding: 0; }
.related__group li { padding: .35rem 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; }
.related__group li:first-child { border-top: 0; }
.related__group small { color: var(--text-mute); }

/* Línea de tiempo (historial / actividad) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 110px 110px 1fr; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .86rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline__when { color: var(--text-mute); white-space: nowrap; }
.timeline__who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.timeline__what { overflow-wrap: anywhere; }

/* Tablero: avisos */
.attn { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .8rem; margin-bottom: 1.25rem; }
.attn__item { display: flex; gap: .8rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--radius); border: 1px solid transparent; color: inherit; }
a.attn__item:hover { text-decoration: none; filter: brightness(.97); }
.attn__item > i { font-size: 1.2rem; margin-top: .1rem; flex: 0 0 auto; }
.attn__item span { display: flex; flex-direction: column; min-width: 0; }
.attn__item small { color: var(--text-soft); font-size: .8rem; }
.attn__item--danger { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }
.attn__item--warn   { background: var(--warning-soft); color: var(--warning); border-color: currentColor; }
.attn__item--info   { background: var(--info-soft); color: var(--info); border-color: currentColor; }
.allgood { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border-radius: var(--radius); background: var(--success-soft); color: var(--success); border: 1px solid currentColor; margin-bottom: 1.25rem; font-weight: 600; }

/* Buscador de la barra superior */
.searchbtn {
  flex: 1 1 280px; max-width: 460px; margin: 0 1rem; min-height: 38px;
  display: flex; align-items: center; gap: .6rem; padding: 0 .8rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-mute); cursor: pointer; font: inherit; text-align: left;
}
.searchbtn:hover { border-color: var(--primary); color: var(--text-soft); }
.searchbtn__text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
kbd { font: inherit; font-size: .72rem; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35rem; background: var(--surface); color: var(--text-soft); }

/* Paleta de búsqueda global */
.palette { position: fixed; inset: 0; z-index: 100; background: rgba(15,20,27,.5); display: flex; justify-content: center; align-items: flex-start; padding: 8vh 1rem 1rem; }
.palette[hidden] { display: none; }
.palette__box { width: 100%; max-width: 640px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 80vh; }
.palette__input { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-mute); }
.palette__input input { flex: 1; border: 0; background: none; color: var(--text); font: inherit; font-size: 1.05rem; outline: none; min-width: 0; }
.palette__results { overflow-y: auto; padding: .4rem; flex: 1; }
.palette__hint { padding: 1.2rem 1rem; color: var(--text-mute); margin: 0; font-size: .9rem; }
.palette__group { padding: .55rem .7rem .25rem; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-mute); }
.palette__item { display: flex; gap: .8rem; align-items: center; padding: .55rem .7rem; border-radius: var(--radius-sm); color: var(--text); }
.palette__item:hover, .palette__item.is-sel { background: var(--primary-soft); text-decoration: none; }
.palette__item > i { width: 20px; text-align: center; color: var(--text-mute); flex: 0 0 20px; }
.palette__item span { display: flex; flex-direction: column; min-width: 0; }
.palette__item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette__item small { color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette__foot { display: flex; gap: 1rem; padding: .5rem 1rem; border-top: 1px solid var(--border); font-size: .74rem; color: var(--text-mute); }
.palette__foot kbd { margin-right: .2rem; }

/* Filtros (bitácora) y paginado por servidor */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1.1rem; align-items: end; }
.filters__actions { display: flex; gap: .5rem; }
.pager { display: flex; gap: .8rem; align-items: center; justify-content: flex-end; margin-top: .9rem; color: var(--text-soft); font-size: .85rem; }

/* Pantalla Sistema */
.health { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.health__item { display: flex; gap: .8rem; align-items: flex-start; padding: .65rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.health__item > i { font-size: 1.15rem; margin-top: .1rem; }
.health__item span { display: flex; flex-direction: column; min-width: 0; }
.health__item small { color: var(--text-soft); overflow-wrap: anywhere; }
.health__item--ok > i { color: var(--success); }
.health__item--warn > i { color: var(--warning); }
.health__item--fail > i { color: var(--danger); }
.logbox { margin: 0; max-height: 340px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem; font-size: .76rem; white-space: pre-wrap; overflow-wrap: anywhere; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; font-size: .85em; }

@media (max-width: 900px) {
  .searchbtn { flex: 0 0 38px; width: 38px; max-width: 38px; margin: 0 .3rem 0 auto; padding: 0; justify-content: center; border-radius: var(--radius-sm); }
  .searchbtn__text, .searchbtn__kbd { display: none; }
  .ficha { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: .1rem; }
  .palette { padding-top: 4vh; }
}
@media (max-width: 560px) {
  .hide-sm { display: none; }
  .card__head .btn-row { width: 100%; }
  .card__head .btn-row .btn { flex: 1; }
  .ficha-title { flex-wrap: wrap; }
  .palette__foot { display: none; }
}

/* ---------- v2.1.1 · Menú plegable (escritorio) y ajustes responsivos ---------- */
.hamburger { display: grid; }
.sidebar, .main { transition: width .2s ease, flex-basis .2s ease, margin-left .2s ease, transform .22s ease; }

@media (min-width: 901px) {
  html.sb-collapsed { --sidebar-w: 68px; }
  html.sb-collapsed .sidebar__brand { padding: 0; justify-content: center; }
  html.sb-collapsed .sidebar__brandtext,
  html.sb-collapsed .sidebar__link span,
  html.sb-collapsed .sidebar__chevron { display: none; }
  html.sb-collapsed .sidebar__nav { padding: .6rem .45rem 2rem; overflow-x: hidden; }
  html.sb-collapsed .sidebar__link { justify-content: center; padding: .6rem 0; border-left-width: 0; }
  html.sb-collapsed .sidebar__link i { font-size: 1.05rem; width: auto; flex: 0 0 auto; opacity: .9; }
  html.sb-collapsed .sidebar__link.is-active { box-shadow: inset 3px 0 0 var(--primary); }
  /* los grupos se vuelven separadores finos y siempre muestran sus íconos */
  html.sb-collapsed .sidebar__grouphead { font-size: 0; padding: 0; height: 1px; margin: .55rem .4rem; background: var(--border); cursor: default; pointer-events: none; }
  html.sb-collapsed .sidebar__groupbody { display: block; }
}

/* Tablet: contenido más compacto */
@media (max-width: 900px) {
  .topbar__title { max-width: 38vw; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .related { grid-template-columns: 1fr; }
  .attn { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Teléfono */
@media (max-width: 560px) {
  .topbar { padding: 0 .5rem; }
  .topbar__title { display: none; }
  .searchbtn { margin-left: auto; }
  .filters { grid-template-columns: 1fr; }
  .filters__actions .btn { flex: 1; }
  .form-actions .btn { flex: 1; }
  .table-toolbar .input { max-width: none !important; width: 100%; }
  table.data th, table.data td { padding: .5rem .55rem; }
  .pagination, .pager { justify-content: center; }
  .dropdown__menu { position: fixed; right: .5rem; left: auto; }
  .timeline li { padding: .6rem 0; }
}

/* Teléfono: las tablas de los módulos se ven como tarjetas (sin scroll lateral) */
@media (max-width: 560px) {
  table.data.js-table, table.data.js-table tbody, table.data.js-table tr, table.data.js-table td { display: block; width: 100%; }
  table.data.js-table thead { display: none; }
  table.data.js-table tr { border: 1px solid var(--border); border-radius: var(--radius); padding: .35rem .8rem; margin-bottom: .7rem; background: var(--surface); }
  table.data.js-table tbody tr:hover { background: var(--surface); }
  table.data.js-table td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border: 0; border-bottom: 1px dashed var(--border); padding: .45rem 0; text-align: right; overflow-wrap: anywhere; }
  table.data.js-table td:last-child { border-bottom: 0; }
  table.data.js-table td::before { content: attr(data-label); font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-mute); text-align: left; flex: 0 0 38%; }
  table.data.js-table td:empty { display: none; }
  table.data.js-table td.actions { justify-content: flex-end; }
  table.data.js-table td.actions::before, table.data.js-table td[data-label="Foto"]::before { content: none; }
  table.data.js-table td.table-empty { display: block; text-align: center; }
  table.data.js-table td.table-empty::before { content: none; }
  .table-wrap { overflow-x: visible; }
}

/* ---------- Colaboradores: pestañas, secciones, baja asistida ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--text-soft); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: .45rem; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.is-active { color: var(--primary); border-bottom-color: var(--primary); }
tr.row--baja td { opacity: .62; }
tr.row--baja td.actions, tr.row--baja td:first-child { opacity: 1; }
.formsec { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem 1.2rem; margin: 0 0 1.1rem; min-width: 0; }
.formsec legend { padding: 0 .5rem; font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); }
.ficha-group { margin: 1.1rem 0 .2rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); }
.ficha-group:first-child { margin-top: 0; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { padding: .4rem 0; border-top: 1px solid var(--border); }
.checklist li:first-child { border-top: 0; }
.checklist label { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.checklist input[type=checkbox] { margin-top: .25rem; width: 17px; height: 17px; flex: 0 0 17px; }
.checklist label > span { display: flex; flex-direction: column; min-width: 0; }
.checklist small { color: var(--text-mute); }
.checklist input:checked + input + span { text-decoration: line-through; opacity: .6; }

/* ---------- Responsivas de equipo ---------- */
.public { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 2.5rem; }
body { background: var(--bg); }
.public__brand { display: flex; justify-content: center; padding: .6rem 0 1rem; }
.public__card { margin-top: .4rem; }
.public__card h1 { font-size: 1.2rem; margin: 0; }
.public__h2 { margin: 1.1rem 0 .4rem; font-size: 1rem; }
.public__form { margin-top: 1rem; display: grid; gap: .9rem; }
.public__submit { width: 100%; justify-content: center; min-height: 46px; font-size: 1rem; }
.public__foot { text-align: center; color: var(--text-mute); font-size: .78rem; margin-top: 1.4rem; }
.public__done { text-align: center; padding: 1.4rem .6rem; }
.public__done > i { font-size: 2.6rem; color: var(--success); }
.public__done > i.fa-info-circle, .public__done > i.fa-times-circle { color: var(--text-mute); }
.public__done > i.fa-times-circle { color: var(--danger); }
.public__done h1 { margin: .6rem 0 .4rem; }

.terms { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem .9rem; background: var(--surface-2); font-size: .85rem; line-height: 1.5; }
.terms p { margin: 0 0 .55rem; text-align: justify; }
.terms ul { margin: 0 0 .55rem 1.1rem; padding: 0; }
.terms li { margin-bottom: .3rem; text-align: justify; }

table.info { width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: .6rem; }
table.info th, table.info td { border: 1px solid var(--border); padding: .4rem .55rem; text-align: left; vertical-align: top; }
table.info th { width: 36%; background: var(--surface-2); color: var(--text-soft); font-weight: 600; }

.check { display: flex; gap: .55rem; align-items: flex-start; cursor: pointer; font-size: .9rem; }
.check input { margin-top: .25rem; width: 18px; height: 18px; flex: 0 0 18px; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .45rem .8rem; }
.checkgrid .check { font-size: .86rem; }

.sigpad { display: block; width: 100%; height: 190px; border: 1.5px dashed var(--border); border-radius: var(--radius-sm); background: #fff; touch-action: none; cursor: crosshair; }
.alert ul { margin: 0; padding-left: 1rem; }

.steps { margin: .4rem 0 0 1.1rem; padding: 0; line-height: 1.6; }
.steps li { margin-bottom: .5rem; }
.assetload { margin-bottom: 1.2rem; }
.photo-form { margin-top: 1rem; display: grid; gap: .6rem; max-width: 460px; }

.signlink { border: 1px solid var(--primary); background: var(--primary-soft); border-radius: var(--radius-sm); padding: .8rem .9rem; margin-bottom: 1rem; }
.signlink code { word-break: break-all; font-size: .8rem; }
.signed-grid { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.sigshot { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: .3rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.gallery__item { margin: 0; position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.gallery__item img { display: block; width: 100%; height: 150px; object-fit: cover; }
.gallery__item form { position: absolute; top: .35rem; right: .35rem; margin: 0; }

@media (max-width: 560px) {
  .signed-grid { grid-template-columns: 1fr; }
  .public__card .card__body { padding: .9rem; }
  table.info th { width: 40%; }
}
