:root {
  --bg: #f3f6fa;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --line: #d3dde9;
  --text: #12263a;
  --muted: #5a6d82;
  --primary: #1f4f82;
  --accent: #2f6ea8;
  --danger: #c53030;
  --warning: #b7791f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Public Sans", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fafc 0%, #edf2f7 100%);
  min-height: 100vh;
  transition: background 180ms ease, color 180ms ease;
}

.bg-orb {
  display: none;
}

.bg-orb-a {
  background: #4cc3ff;
  top: -120px;
  left: -90px;
}

.bg-orb-b {
  background: #18d2a8;
  right: -100px;
  bottom: -120px;
}

.topbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.4rem;
  background: #ffffff;
  border-bottom: 1px solid #dbe4ee;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #c5d3e2;
  background: #f7fbff;
  color: #1f4f82;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.logout-form {
  display: inline-flex;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.brand h1 {
  font-family: "Merriweather", serif;
  font-size: 1.2rem;
  margin: 0;
  color: #173a5f;
}

.brand-logo-wrap {
  width: 156px;
  height: 52px;
  border-radius: 0.6rem;
  background: #ffffff;
  border: 1px solid #d1deea;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.2rem 0.35rem;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.topbar-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  border: 1px solid #c5d3e2;
  background: #ffffff;
  color: #1f4f82;
  border-radius: 0.5rem;
  padding: 0.4rem 0.65rem;
}

.theme-toggle {
  border: 1px solid #c5d3e2;
  background: #ffffff;
  color: #1f4f82;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  filter: brightness(0.98);
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1rem;
  padding: 1rem;
}

.sidebar {
  background: #ffffff;
  border: 1px solid #d3deea;
  border-radius: 0.9rem;
  display: grid;
  grid-template-rows: auto auto 1fr;
  padding: 0;
  gap: 0;
  min-height: calc(100vh - 2rem);
  position: sticky;
  top: 1rem;
  overflow: hidden;
}

.sidebar-profile {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: linear-gradient(180deg, #f7fbff, #eff5fb);
  border-bottom: 1px solid #d8e2ee;
}

.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  color: #ffffff;
  background: #2f6ea8;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.profile-meta strong {
  font-size: 1.02rem;
}

.profile-meta span {
  color: #5f7388;
  font-size: 0.86rem;
}

.sidebar-section {
  margin: 0;
  padding: 0.68rem 1rem;
  border-top: 1px solid #e2e9f1;
  border-bottom: 1px solid #e2e9f1;
  background: #f8fbff;
  color: #6a7f95;
  letter-spacing: 0.06em;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.sidebar-links {
  display: grid;
  grid-auto-rows: minmax(42px, auto);
  gap: 0.32rem;
  padding: 0.5rem;
  align-content: start;
}

.sidebar-toggle {
  border: 0;
  background: #eef4fa;
  color: #1f4f82;
  border-radius: 999px;
  padding: 0.35rem 0.62rem;
  min-width: 42px;
  min-height: 34px;
  cursor: pointer;
  margin-left: auto;
  font-size: 1rem;
  line-height: 1;
}

body.sidebar-collapsed .layout {
  grid-template-columns: 72px 1fr;
}

body.sidebar-collapsed .sidebar {
  min-height: calc(100vh - 2rem);
  grid-template-rows: auto 1fr;
}

body.sidebar-collapsed .sidebar .profile-meta,
body.sidebar-collapsed .sidebar .profile-avatar,
body.sidebar-collapsed .sidebar .sidebar-section,
body.sidebar-collapsed .sidebar .nav-text,
body.sidebar-collapsed .sidebar .nav-caret {
  display: none;
}

body.sidebar-collapsed .sidebar .sidebar-profile {
  justify-content: center;
  grid-template-columns: 1fr;
  padding: 0.7rem 0.4rem;
}

body.sidebar-collapsed .sidebar .sidebar-links {
  padding: 0.45rem 0.2rem;
}

body.sidebar-collapsed .sidebar .nav-link {
  padding: 0.6rem 0.25rem;
  grid-template-columns: 1fr;
  justify-items: center;
}

body.sidebar-collapsed .sidebar .sidebar-toggle {
  padding: 0.35rem 0.55rem;
  min-width: 44px;
}

.nav-link {
  color: #2b425a;
  text-decoration: none;
  padding: 0.68rem 0.72rem;
  border-radius: 0.6rem;
  font-size: 0.93rem;
  transition: 160ms ease;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 0.62rem;
  position: relative;
  border: 1px solid transparent;
}

.nav-icon {
  color: #1f4f82;
  background: #edf4fb;
  border: 1px solid #c8d7e7;
  border-radius: 0.35rem;
  min-height: 24px;
  min-width: 28px;
  padding: 0.12rem 0.28rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon-img {
  width: 15px;
  height: 15px;
  display: block;
}

.nav-caret {
  color: #7a8ea3;
  font-size: 1.25rem;
  line-height: 1;
}

.nav-link:hover,
.nav-link.active {
  background: #edf4fb;
  color: #173a5f;
  border-color: #d6e4f2;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -0.35rem;
  top: 0.45rem;
  bottom: 0.45rem;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0.01em;
  color: #15395d;
  font-family: "Merriweather", serif;
}

.section-head p {
  margin: 0.42rem 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  max-width: 78ch;
}

.flash-stack {
  display: grid;
  gap: 0.6rem;
}

.flash {
  padding: 0.7rem 0.85rem;
  border-radius: 0.55rem;
  border: 1px solid transparent;
}

.flash-ok {
  background: #edf9f3;
  border-color: #9ed7b8;
}

.flash-error {
  background: #fff1f1;
  border-color: #f3b4b4;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.75rem;
}

.metric-card {
  background: #ffffff;
  border: 1px solid #d5e0ec;
  border-radius: 0.8rem;
  padding: 0.9rem;
  box-shadow: 0 2px 8px rgba(16, 40, 66, 0.05);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 40, 66, 0.08);
  border-color: #c6d4e4;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.metric-card strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.6rem;
  letter-spacing: 0.01em;
}

.metric-note {
  display: inline-flex;
  margin-top: 0.45rem;
  color: #5a6f85;
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.metric-card.alert strong {
  color: var(--warning);
}

.panel {
  background: #ffffff;
  border: 1px solid #d6e1ec;
  border-radius: 0.9rem;
  padding: 1rem;
  box-shadow: 0 2px 10px rgba(19, 42, 66, 0.04);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.panel:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(19, 42, 66, 0.06);
}

.panel h3 {
  font-family: "Merriweather", serif;
  margin-top: 0;
  color: #1d3f60;
}

.panel-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.8rem;
  align-items: end;
}

.form-grid.compact {
  grid-template-columns: 1fr;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
}

.retiro-form {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.retiro-lines,
.retiro-lines-actions {
  grid-column: 1 / -1;
}

.retiro-lines {
  display: grid;
  gap: 0.7rem;
}

.retiro-line {
  border: 1px solid #d6e1ec;
  border-radius: 0.7rem;
  padding: 0.75rem;
  background: #f8fbff;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(120px, 0.35fr) auto;
  gap: 0.7rem;
  align-items: end;
}

.retiro-line .line-remove {
  min-height: 40px;
  justify-self: start;
}

.retiro-line .seriales-field {
  grid-column: 1 / -1;
}

.retiro-lines-actions {
  margin-top: -0.2rem;
}

.retiro-form .btn-primary {
  justify-self: start;
  min-width: 220px;
}

.retiro-form .seriales-field {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
}

.retiro-form .seriales-field textarea {
  min-height: 96px;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #c9d6e4;
  color: var(--text);
  border-radius: 0.45rem;
  padding: 0.55rem 0.6rem;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

input::placeholder,
select::placeholder,
textarea::placeholder {
  color: #8aa0b6;
}

input:not(:placeholder-shown):invalid,
select:not(:placeholder-shown):invalid {
  border-color: #d98686;
  box-shadow: 0 0 0 2px rgba(201, 103, 103, 0.12);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #2f6ea8;
  box-shadow: 0 0 0 2px rgba(47, 110, 168, 0.16);
}

textarea {
  resize: vertical;
  min-height: 92px;
}

.seriales-field small {
  margin-top: 0.18rem;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  border: 0;
  border-radius: 0.45rem;
  padding: 0.6rem 0.82rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.36rem;
  min-height: 38px;
  font-weight: 600;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.btn-primary {
  background: #1f4f82;
  color: #f8fbff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(31, 79, 130, 0.22);
}

.btn-secondary {
  background: #e8eff6;
  color: #244a70;
}

.btn-danger {
  background: #fdf0f0;
  color: #9f2f2f;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover {
  filter: brightness(0.98);
  transform: translateY(-1px);
}

.btn-primary:active,
.btn-secondary:active,
.btn-danger:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 0.92em;
  line-height: 1;
}

.search-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.search-row input {
  flex: 1;
}

.filter-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.bulk-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.filter-row input {
  flex: 1 1 180px;
}

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.pagination-links {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}

.page-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  padding: 0.45rem 0.65rem;
  border-radius: 0.45rem;
  text-decoration: none;
  color: #2e4f6e;
  background: #edf3f9;
  border: 1px solid #d0dce8;
}

.page-chip.active {
  background: #1f4f82;
  color: #f7fbff;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  max-height: 62vh;
  border: 1px solid #dce5ef;
  border-radius: 0.7rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid #e0e8f1;
  padding: 0.55rem;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #2e4c69;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f8fbff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.sort-link {
  color: #2e4c69;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.sort-link:hover {
  color: #163a5f;
}

.sort-ind {
  font-size: 0.74rem;
  line-height: 1;
}

tr:hover td {
  background: #f3f8fc;
}

tbody tr:nth-child(even) td {
  background: #fbfdff;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 0.24rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-low {
  color: #8a2c2c;
  background: #fdeeed;
  border-color: #efc7c4;
}

.status-ok {
  color: #245845;
  background: #e9f6ef;
  border-color: #bedecb;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.inline-form-stack {
  flex-wrap: wrap;
}

.inline-form input {
  min-width: 78px;
}

.table-edit-form {
  display: contents;
}

.table-edit-form input {
  width: 100%;
}

.actions-cell {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.muted {
  color: var(--muted);
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.user-status-panel {
  margin-bottom: 1rem;
  color: var(--text);
}

.perm-grid {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.65rem;
  border: 1px solid #d6e1ec;
  border-radius: 0.7rem;
  padding: 0.9rem;
}

.perm-grid legend {
  padding: 0 0.25rem;
  font-weight: 700;
  color: var(--text);
}

.perm-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.8rem;
}

.perm-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid #dbe6f1;
  border-radius: 0.55rem;
  background: #f8fbff;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.perm-item input {
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.user-list {
  display: grid;
  gap: 0.9rem;
}

.user-card {
  border: 1px solid #d6e1ec;
  border-radius: 0.85rem;
  padding: 0.9rem;
  background: #f8fbff;
  display: grid;
  gap: 0.8rem;
}

.user-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.user-card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.user-panel {
  margin-top: 0.2rem;
  border-top: 1px solid #dbe6f1;
  padding-top: 0.8rem;
}

.user-toggle {
  cursor: pointer;
}

.user-card-head h4 {
  margin: 0;
  font-family: "Merriweather", serif;
  color: #173a5f;
}

.user-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: radial-gradient(circle at top, #173a5f 0%, #0c1525 55%, #060b13 100%);
}

.auth-shell {
  width: min(100%, 460px);
  padding: 1rem;
}

.auth-card {
  background: rgba(16, 27, 44, 0.92);
  border: 1px solid rgba(120, 149, 182, 0.22);
  border-radius: 1rem;
  padding: 1.2rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  color: #eef4ff;
}

.auth-brand {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 1rem;
}

.auth-brand img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 0.4rem;
}

.auth-brand h1 {
  margin: 0;
  font-family: "Merriweather", serif;
  font-size: 1.2rem;
}

.auth-brand p,
.auth-note {
  margin: 0.3rem 0 0;
  color: #a9bad0;
}

.auth-form {
  display: grid;
  gap: 0.85rem;
}

.auth-form label {
  color: #d6e4f5;
}

.auth-form input {
  background: #0f1a2c;
  border-color: #39506e;
  color: #eef4ff;
}

.auth-form .btn-primary {
  width: 100%;
}

body.theme-dark {
  --text: #e7eef7;
  --muted: #9fb1c5;
  --warning: #f1bb4d;
  background: linear-gradient(180deg, #0d1722 0%, #111f2d 100%);
}

body.theme-dark .topbar {
  background: #101c29;
  border-bottom-color: #25384b;
}

body.theme-dark .brand h1 {
  color: #e7eef7;
}

body.theme-dark .brand-logo-wrap {
  background: #142232;
  border-color: #35506b;
}

body.theme-dark .theme-toggle,
body.theme-dark .menu-toggle {
  background: #182838;
  border-color: #35506b;
  color: #d8e6f5;
}

body.theme-dark .sidebar {
  background: #142232;
  border-color: #294056;
}

body.theme-dark .sidebar-profile {
  background: linear-gradient(180deg, #193046, #152739);
  border-bottom-color: #2f4a63;
}

body.theme-dark .sidebar-section {
  background: #182b3d;
  border-top-color: #2f4a63;
  border-bottom-color: #2f4a63;
  color: #9eb2c7;
}

body.theme-dark .sidebar-toggle {
  background: #1a2f42;
  color: #dbe8f6;
}

body.theme-dark .nav-link {
  color: #d8e6f4;
}

body.theme-dark .nav-icon {
  color: #d8e6f4;
  background: #223d56;
  border-color: #3d5c79;
}

body.theme-dark .nav-icon-img {
  filter: brightness(1.25);
}

body.theme-dark .nav-caret {
  color: #9eb4c9;
}

body.theme-dark .nav-link:hover,
body.theme-dark .nav-link.active {
  background: #20364c;
  color: #f0f6ff;
  border-color: #36526d;
}

body.theme-dark .nav-link.active::before {
  background: #7db3e8;
}

body.theme-dark .flash-ok {
  background: #15372d;
  border-color: #2c6b57;
}

body.theme-dark .flash-error {
  background: #3a2020;
  border-color: #7d3b3b;
}

body.theme-dark .metric-card,
body.theme-dark .panel {
  background: #182839;
  border-color: #2f475f;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

body.theme-dark .metric-note {
  color: #95a9be;
}

body.theme-dark .panel h3 {
  color: #e6eef7;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #132435;
  border-color: #36516c;
  color: #e7eef7;
}

body.theme-dark input::placeholder,
body.theme-dark select::placeholder,
body.theme-dark textarea::placeholder {
  color: #88a0b6;
}

body.theme-dark .btn-primary {
  background: #2b5f97;
  color: #f5f9ff;
}

body.theme-dark .btn-secondary {
  background: #21384f;
  color: #dce9f7;
}

body.theme-dark .btn-danger {
  background: #4a2428;
  color: #ffdfe3;
}

body.theme-dark .page-chip {
  color: #d9e8f8;
  background: #22384d;
  border-color: #3c5873;
}

body.theme-dark .page-chip.active {
  background: #2b5f97;
  color: #f7fbff;
}

body.theme-dark th,
body.theme-dark td {
  border-bottom-color: #30495f;
}

body.theme-dark th {
  color: #bed4ea;
  background: #1b2d3f;
}

body.theme-dark .sort-link {
  color: #bed4ea;
}

body.theme-dark .sort-link:hover {
  color: #ffffff;
}

body.theme-dark tr:hover td {
  background: #1f3448;
}

body.theme-dark tbody tr:nth-child(even) td {
  background: #1a2c3e;
}

body.theme-dark .table-wrap {
  border-color: #2f475f;
}

body.theme-dark .status-low {
  color: #ffd8d8;
  background: #5a2a2d;
  border-color: #7e3a3f;
}

body.theme-dark .status-ok {
  color: #d5f1e1;
  background: #25493d;
  border-color: #346454;
}

body.theme-dark .user-pill {
  background: #14243a;
  border-color: #315276;
  color: #d8e7f7;
}

body.theme-dark .perm-grid,
body.theme-dark .user-card {
  border-color: #315276;
}

body.theme-dark .user-card {
  background: #13263b;
}

body.theme-dark .perm-item {
  background: #162a40;
  border-color: #2f4a63;
  color: #dce8f5;
}

body.theme-dark .retiro-line {
  border-color: #315276;
  background: #132e49;
}

body.theme-dark .muted,
body.theme-dark .topbar-sub,
body.theme-dark .section-head p,
body.theme-dark .metric-card span,
body.theme-dark .pagination-bar {
  color: #9fb1c5;
}

@media (max-width: 980px) {
  .topbar {
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: center;
  }

  .topbar-actions {
    margin-left: 0;
  }

  .menu-toggle {
    display: inline-flex;
    order: 2;
  }

  .theme-toggle {
    order: 1;
  }

  .topbar-sub {
    width: 100%;
    order: 4;
    font-size: 0.82rem;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  body.sidebar-collapsed .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: none;
    order: -1;
    width: 100%;
    overflow: hidden;
    min-height: auto;
    animation: menuDrop 180ms ease;
  }

  .sidebar-profile {
    border-top-left-radius: 0.9rem;
    border-top-right-radius: 0.9rem;
  }

  .sidebar.open {
    display: grid;
  }

  .nav-link {
    white-space: normal;
  }

  .split-grid {
    grid-template-columns: 1fr;
  }

  .perm-list {
    grid-template-columns: 1fr;
  }

  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .retiro-form .btn-primary {
    justify-self: stretch;
    min-width: 0;
  }

  .retiro-line {
    grid-template-columns: 1fr;
  }

  .retiro-line .line-remove {
    justify-self: stretch;
  }

  .retiro-form .seriales-field {
    grid-column: auto;
  }

  .search-row {
    flex-direction: column;
  }

  .filter-row {
    flex-direction: column;
  }

  .pagination-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions-cell {
    flex-wrap: wrap;
  }

  table,
  thead,
  tbody,
  tr,
  td,
  th {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 0.65rem;
  }

  tr {
    border: 1px solid #d4dfeb;
    border-radius: 0.75rem;
    padding: 0.45rem 0.65rem;
    background: #ffffff;
  }

  td {
    border-bottom: 0;
    display: grid;
    grid-template-columns: minmax(84px, 34%) 1fr;
    gap: 0.55rem;
    padding: 0.45rem 0;
  }

  td::before {
    content: attr(data-label);
    color: #5f7389;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
  }

  .inline-form {
    width: 100%;
    justify-content: flex-start;
  }

  .inline-form input {
    min-width: 0;
    flex: 1;
  }

  .btn-primary,
  .btn-secondary,
  .btn-danger {
    min-height: 40px;
  }
}

@media (max-width: 640px) {
  .layout {
    padding: 0.7rem;
    gap: 0.7rem;
  }

  .topbar {
    padding: 0.85rem 1rem;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .brand-logo-wrap {
    width: 118px;
    height: 40px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .metric-card strong {
    font-size: 1.25rem;
  }
}

@keyframes menuDrop {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Skin Dashboard estilo ISP oscuro --- */
body.theme-dark {
  background: radial-gradient(circle at 12% 10%, #18283a 0%, #111927 52%, #0f1722 100%);
}

body.theme-dark .topbar {
  background: #121a25;
  border-bottom: 1px solid #273446;
  padding: 0.62rem 1.2rem;
}

body.theme-dark .brand h1 {
  font-family: "Public Sans", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #cbd8e8;
}

body.theme-dark .brand-logo-wrap {
  width: 180px;
  height: 48px;
  border-radius: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.topbar-search {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  width: min(420px, 38vw);
  background: #1a2432;
  border: 1px solid #2d3c4f;
  border-radius: 999px;
  overflow: hidden;
}

.topbar-search input {
  border: 0;
  background: transparent;
  color: #deebf8;
  width: 100%;
  padding: 0.56rem 0.85rem;
}

.topbar-search button {
  border: 0;
  background: transparent;
  color: #93a7bd;
  padding: 0.52rem 0.9rem;
}

.topbar-icon {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  color: #f2b968;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.2rem;
}

.topbar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2d8ddb;
  color: #e9f3ff;
  font-weight: 700;
  font-size: 0.78rem;
}

.topbar-user-name {
  color: #e2edf8;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

body.theme-dark .layout {
  grid-template-columns: 246px 1fr;
  gap: 0.9rem;
}

/* --- Rediseño web: operaciones claras, identidad TNET y menos ruido visual --- */
:root {
  --bg: #f4f1eb;
  --bg-soft: #fbfaf7;
  --card: #fffdfa;
  --line: #ded8ce;
  --text: #202a2d;
  --muted: #6d7777;
  --primary: #e2633d;
  --accent: #188f89;
  --danger: #b8473f;
  --warning: #c98727;
  --shadow: 0 14px 30px rgba(50, 43, 34, 0.08);
}

body {
  background: var(--bg);
  font-family: "Public Sans", sans-serif;
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: linear-gradient(rgba(32, 42, 45, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(32, 42, 45, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.75rem clamp(1rem, 3vw, 2.4rem);
  background: rgba(255, 253, 250, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand-logo-wrap {
  width: 142px;
  height: 42px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.brand h1 {
  font-family: "Public Sans", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}

.topbar-search {
  width: min(390px, 34vw);
  background: #f1eee8;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
}

.topbar-search input {
  background: transparent;
  color: var(--text);
}

.topbar-search button,
.topbar-icon {
  color: var(--primary);
}

.topbar-user-avatar,
.profile-avatar {
  background: var(--primary);
}

.topbar-user-name {
  color: var(--text);
}

.layout {
  grid-template-columns: 236px minmax(0, 1fr);
  gap: clamp(1rem, 2.5vw, 2rem);
  padding: clamp(1rem, 2.5vw, 2rem) clamp(1rem, 3vw, 2.4rem);
  max-width: 1680px;
  margin: 0 auto;
}

.sidebar {
  background: rgba(255, 253, 250, 0.82);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  min-height: calc(100vh - 6.5rem);
  box-shadow: var(--shadow);
}

.sidebar-profile {
  background: #f0ece5;
  border-bottom-color: var(--line);
  padding: 1.15rem 1rem;
}

.sidebar-section {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  padding-top: 1rem;
}

.nav-link {
  color: #4d5959;
  border-radius: 0.35rem;
  padding: 0.72rem 0.65rem;
}

.nav-icon {
  color: var(--accent);
  background: #e5f2ef;
  border-color: #c7e1dc;
}

.nav-link:hover,
.nav-link.active {
  background: #f8e7df;
  color: #8e3d2b;
  border-color: #f0c5b5;
}

.nav-link.active::before {
  background: var(--primary);
}

.content {
  gap: 1.25rem;
  min-width: 0;
  animation: contentIn 360ms ease both;
}

.section-head {
  padding: 0.35rem 0 0.4rem;
}

.section-head h2 {
  font-family: "Merriweather", serif;
  color: var(--text);
  font-size: clamp(1.45rem, 2.4vw, 2rem);
}

.section-head p {
  color: var(--muted);
}

.panel,
.metric-card {
  background: rgba(255, 253, 250, 0.94);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(1rem, 2vw, 1.35rem);
}

.panel:hover,
.metric-card:hover {
  transform: translateY(-2px);
  border-color: #cfc2b5;
  box-shadow: 0 18px 35px rgba(50, 43, 34, 0.11);
}

.panel h3 {
  color: var(--text);
  font-family: "Public Sans", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

label {
  color: var(--text);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

input,
select,
textarea {
  background: #fffdfa;
  border-color: #d5cec3;
  border-radius: 0.35rem;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24, 143, 137, 0.14);
}

.btn-primary,
.btn-secondary,
.btn-danger {
  border-radius: 0.35rem;
  min-height: 40px;
}

.btn-primary {
  background: var(--primary);
  box-shadow: 0 5px 12px rgba(226, 99, 61, 0.22);
}

.btn-secondary {
  background: #e6f0ee;
  color: #176d69;
}

.btn-danger {
  background: #fae8e3;
  color: #9b3935;
}

.table-wrap {
  border-color: var(--line);
  border-radius: 0.4rem;
}

th {
  background: #f1eee8;
  color: #586260;
  font-size: 0.74rem;
}

th,
td {
  border-bottom-color: #e8e2d9;
  padding: 0.72rem 0.65rem;
}

tr:hover td {
  background: #fff6f1;
}

tbody tr:nth-child(even) td {
  background: #fcfaf6;
}

.status-low {
  color: #9b3935;
  background: #fae8e3;
  border-color: #efc4ba;
}

.status-ok {
  color: #176d69;
  background: #e3f2ee;
  border-color: #b9ddd5;
}

.retiro-line,
.user-card,
.perm-item {
  border-color: var(--line);
  background: #f8f5f0;
}

.flash-ok {
  background: #e3f2ee;
  border-color: #b9ddd5;
  color: #176d69;
}

.flash-error {
  background: #fae8e3;
  border-color: #efc4ba;
  color: #9b3935;
}

body.theme-dark {
  --bg: #172023;
  --bg-soft: #1d292b;
  --card: #213033;
  --line: #344346;
  --text: #edf1ed;
  --muted: #a9b5b1;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.2);
  background: #172023;
}

body.theme-dark::before {
  opacity: 0.12;
  background-image: linear-gradient(rgba(236, 241, 237, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(236, 241, 237, 0.08) 1px, transparent 1px);
}

body.theme-dark .topbar,
body.theme-dark .panel,
body.theme-dark .metric-card,
body.theme-dark .sidebar {
  background: rgba(31, 45, 47, 0.94);
  border-color: var(--line);
}

body.theme-dark .topbar-search,
body.theme-dark .sidebar-profile,
body.theme-dark th,
body.theme-dark tbody tr:nth-child(even) td,
body.theme-dark .retiro-line,
body.theme-dark .user-card,
body.theme-dark .perm-item {
  background: #263638;
}

body.theme-dark .brand h1,
body.theme-dark .section-head h2,
body.theme-dark .panel h3,
body.theme-dark .topbar-user-name,
body.theme-dark label {
  color: var(--text);
}

body.theme-dark .nav-link:hover,
body.theme-dark .nav-link.active {
  background: #3b302d;
  border-color: #69453b;
  color: #ffd9cb;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #182629;
  border-color: #405356;
}

body.theme-dark tr:hover td {
  background: #303c3e;
}

@keyframes contentIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.section-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent) !important;
  font-size: 0.7rem !important;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.dashboard-date {
  color: var(--muted);
  border-left: 2px solid var(--primary);
  padding: 0.25rem 0 0.25rem 0.7rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 0.75rem;
}

.dashboard-metrics .metric-card {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
}

.dashboard-metrics .metric-card span {
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.35;
}

.dashboard-metrics .metric-card strong {
  margin-top: 0.55rem;
  font-size: 2rem;
  color: var(--text);
}

.dashboard-metrics .metric-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.dashboard-metrics .metric-card-featured {
  border-top: 3px solid var(--accent);
}

.dashboard-metrics .metric-card-alert {
  border-top: 3px solid var(--warning);
}

.dashboard-alerts h3 {
  margin-bottom: 1rem;
}

.auth-page {
  background: #172023;
  position: relative;
  overflow: hidden;
}

.auth-page::before,
.auth-page::after {
  content: "";
  position: absolute;
  width: 42vw;
  height: 42vw;
  border: 1px solid rgba(226, 99, 61, 0.25);
  border-radius: 50%;
  pointer-events: none;
}

.auth-page::before { top: -25vw; right: -12vw; }
.auth-page::after { bottom: -30vw; left: -15vw; border-color: rgba(24, 143, 137, 0.25); }

.auth-card {
  position: relative;
  z-index: 1;
  background: #213033;
  border: 1px solid #405154;
  border-radius: 0.55rem;
  padding: clamp(1.5rem, 4vw, 2.25rem);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.auth-brand {
  align-items: flex-start;
  margin-bottom: 1.7rem;
}

.auth-brand img {
  width: 68px;
  height: 68px;
  border-radius: 0.35rem;
  background: #fffdfa;
}

.auth-brand h1 {
  color: #edf1ed;
  font-family: "Merriweather", serif;
  line-height: 1.35;
}

.auth-brand p,
.auth-note {
  color: #a9b5b1;
}

.auth-form input {
  background: #182629;
  border-color: #405356;
  color: #edf1ed;
}

.auth-form .btn-primary {
  margin-top: 0.45rem;
  min-height: 44px;
}

@media (max-width: 1180px) {
  .dashboard-metrics { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
}

@media (max-width: 640px) {
  .dashboard-head { align-items: flex-start; flex-direction: column; }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-metrics .metric-card { min-height: 118px; padding: 0.8rem; }
  .dashboard-metrics .metric-card strong { font-size: 1.55rem; }
}

/* --- Sistema visual integral de modulos --- */
.content > .section-head,
.content > .dashboard-head {
  border-bottom: 1px solid var(--line);
  padding: 0.25rem 0 1.1rem;
}

.content > .section-head h2,
.content > .dashboard-head h2 {
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  letter-spacing: -0.03em;
}

.panel-actions {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.85rem;
}

.panel-actions h3 { margin: 0; }

.form-grid,
.filter-row {
  background: #f4f1eb;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 1rem;
}

.filter-row {
  align-items: center;
  margin-bottom: 1rem;
}

.filter-row input { min-height: 40px; }

.bulk-actions {
  padding-bottom: 0.1rem;
}

.bulk-actions .btn-primary { letter-spacing: 0.01em; }

.metric-card {
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  width: 72px;
  height: 72px;
  right: -28px;
  bottom: -34px;
  border: 1px solid rgba(24, 143, 137, 0.22);
  border-radius: 50%;
}

.cards-grid { gap: 1rem; }

.table-wrap {
  box-shadow: inset 0 0 0 1px rgba(222, 216, 206, 0.24);
}

table { font-size: 0.88rem; }

tbody tr { transition: background-color 140ms ease; }

.actions-cell .btn-danger,
.actions-cell .btn-secondary { min-height: 34px; padding: 0.45rem 0.62rem; font-size: 0.78rem; }

.split-grid { align-items: start; }

.split-grid > .panel { min-width: 0; }

.user-card { box-shadow: none; }

.user-card-head h4 { font-family: "Public Sans", sans-serif; letter-spacing: 0.01em; }

.perm-grid { background: #f4f1eb; }

.perm-item { transition: border-color 140ms ease, background-color 140ms ease; }

.perm-item:has(input:checked) { border-color: #a9d3ca; background: #e9f4f1; }

.pagination-bar { border-top: 1px solid var(--line); padding-top: 1rem; }

.page-chip { border-radius: 0.35rem; }

.auth-page .auth-card { max-width: 460px; }

body.theme-dark .form-grid,
body.theme-dark .filter-row,
body.theme-dark .perm-grid { background: #263638; border-color: var(--line); }

body.theme-dark .perm-item:has(input:checked) { background: #29433f; border-color: #477c71; }

@media (max-width: 980px) {
  .form-grid,
  .filter-row { padding: 0.85rem; }
  .dashboard-metrics { gap: 0.65rem; }
}

/* La barra compacta conserva los accesos, pero deja respirar al contenido. */
body.sidebar-collapsed .layout,
body.theme-dark.sidebar-collapsed .layout {
  grid-template-columns: 68px minmax(0, 1fr);
}

.layout {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.sidebar {
  align-self: start;
  height: fit-content;
  min-height: 0;
}

body.theme-dark .sidebar,
body.theme-dark.sidebar-collapsed .sidebar {
  height: fit-content;
  min-height: 0;
}

body.sidebar-collapsed .sidebar {
  width: 68px;
  min-width: 68px;
  height: fit-content;
  min-height: 0;
  border-radius: 0.45rem;
}

body.sidebar-collapsed .sidebar .sidebar-profile {
  min-height: 76px;
  padding: 0.7rem 0.35rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
}

body.sidebar-collapsed .sidebar .profile-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  font-size: 0.75rem;
}

body.sidebar-collapsed .sidebar .sidebar-toggle {
  min-width: 34px;
  width: 34px;
  min-height: 30px;
  padding: 0;
  margin: 0;
  font-size: 0.82rem;
}

body.sidebar-collapsed .sidebar .sidebar-links {
  padding: 0.65rem 0.35rem;
  gap: 0.45rem;
}

body.sidebar-collapsed .sidebar .nav-link {
  min-height: 42px;
  padding: 0.45rem 0.2rem;
  grid-template-columns: 1fr;
  justify-items: center;
  border-radius: 0.35rem;
}

body.sidebar-collapsed .sidebar .nav-icon {
  width: 34px;
  height: 34px;
}

body.sidebar-collapsed .sidebar .nav-link.active::before {
  left: -0.35rem;
  top: 0.5rem;
  bottom: 0.5rem;
}

@media (max-width: 980px) {
  body.sidebar-collapsed .layout,
  body.theme-dark.sidebar-collapsed .layout {
    grid-template-columns: 1fr;
  }

  body.sidebar-collapsed .sidebar { width: 100%; min-width: 0; }

  .layout { padding-left: 0.7rem; padding-right: 0.7rem; }
}

.mapeo-embed-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--card);
  box-shadow: var(--shadow);
}

.layout:has(.mapeo-embed-shell) {
  column-gap: 0.55rem;
}

.mapeo-embed-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 2vw, 1.5rem);
  border-bottom: 1px solid var(--line);
}

.mapeo-embed-header h2 { margin: 0; font-family: "Merriweather", serif; }

.mapeo-embed-header .section-kicker { margin-bottom: 0.25rem; }

.mapeo-embed-description {
  max-width: 38rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.mapeo-embed-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 170px);
  min-height: 0;
  border: 0;
  background: var(--bg);
}

@media (max-width: 700px) {
  .mapeo-embed-header { align-items: flex-start; flex-direction: column; }
  .mapeo-embed-description { text-align: left; }
}

body.theme-dark.sidebar-collapsed .layout {
  grid-template-columns: 72px 1fr;
}

body.theme-dark .sidebar {
  border-radius: 0;
  border: 1px solid #253241;
  background: #1a2331;
}

/* Fuente única del sistema, incluida en reglas heredadas de modulos antiguos. */
html body,
html body button,
html body input,
html body select,
html body textarea,
html body h1,
html body h2,
html body h3,
html body h4,
html body .ref-head h2,
html body .ref-kpi,
html body .metric-card,
html body .panel,
html body .nav-link {
  font-family: "Times New Roman", Times, serif;
}

/* --- Responsive final para telefonos --- */
@media (max-width: 640px) {
  html,
  body { max-width: 100%; overflow-x: hidden; }

  .topbar {
    min-height: 64px;
    padding: 0.55rem 0.7rem;
    gap: 0.45rem;
  }

  .brand { min-width: 0; gap: 0.45rem; }

  .brand-logo-wrap {
    width: 92px;
    height: 34px;
    flex: 0 0 92px;
  }

  .brand h1 {
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    line-height: 1.2;
    white-space: nowrap;
  }

  .topbar-actions {
    gap: 0.3rem;
    margin-left: auto;
  }

  .topbar-user { gap: 0.25rem; }
  .topbar-user-avatar { width: 30px; height: 30px; font-size: 0.68rem; }
  .topbar-user-name { display: none; }

  .logout-form .btn-secondary {
    min-height: 36px;
    padding: 0.42rem 0.55rem;
    font-size: 0.78rem;
  }

  .theme-toggle,
  .menu-toggle {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
  }

  .layout {
    display: block;
    padding: 0.7rem;
  }

  .sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin-bottom: 0.7rem;
    border-radius: 0.45rem;
  }

  .sidebar-profile {
    min-height: 0;
    padding: 0.8rem;
  }

  .sidebar-links { padding: 0.45rem; }

  .nav-link {
    min-height: 44px;
    font-size: 0.9rem;
  }

  .content { gap: 0.8rem; }

  .section-head h2,
  .content > .section-head h2,
  .content > .dashboard-head h2 { font-size: 1.55rem; }

  .section-head p { font-size: 0.84rem; line-height: 1.45; }

  .panel { padding: 0.8rem; border-radius: 0.45rem; }
  .panel h3 { font-size: 0.95rem; }

  .dashboard-head { gap: 0.45rem; }
  .dashboard-date { align-self: flex-start; }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
  .dashboard-metrics .metric-card { min-height: 106px; padding: 0.7rem; }
  .dashboard-metrics .metric-card strong { font-size: 1.45rem; }
  .dashboard-metrics .metric-card span { font-size: 0.7rem; }

  .form-grid,
  .filter-row { display: grid; grid-template-columns: 1fr; gap: 0.7rem; padding: 0.7rem; }
  .form-grid .btn-primary,
  .form-grid .btn-secondary,
  .filter-row .btn-primary,
  .filter-row .btn-secondary,
  .filter-row .btn-danger { width: 100%; }

  input,
  select,
  textarea { width: 100%; min-height: 42px; font-size: 0.9rem; }

  textarea { min-height: 100px; }

  .panel-actions { align-items: stretch; }
  .panel-actions form,
  .panel-actions button { width: 100%; }

  .search-row { gap: 0.55rem; }
  .bulk-actions { justify-content: stretch; }
  .bulk-actions button { width: 100%; }

  .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 680px; }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td,
  .table-wrap th { display: table; }

  .table-wrap table { display: table; width: 100%; }
  .table-wrap thead { display: table-header-group; }
  .table-wrap tbody { display: table-row-group; }
  .table-wrap tr { display: table-row; }
  .table-wrap th,
  .table-wrap td { display: table-cell; white-space: nowrap; }
  .table-wrap td::before { display: none; }

  .split-grid { grid-template-columns: 1fr; gap: 0.8rem; }
  .perm-list { grid-template-columns: 1fr; }
  .perm-item { min-height: 42px; }
  .user-card-actions { width: 100%; }
  .user-card-actions form,
  .user-card-actions button { flex: 1; }
  .user-card-actions button { width: 100%; }

  .retiro-line { grid-template-columns: 1fr; padding: 0.7rem; }
  .retiro-line .line-remove { width: 100%; }
  .retiro-form .btn-primary { width: 100%; }

  .pagination-bar { align-items: stretch; }
  .pagination-links { width: 100%; }
  .pagination-links .btn-secondary,
  .page-chip { flex: 1; }

  .mapeo-embed-shell { margin-inline: -0.1rem; }
  .mapeo-embed-header { padding: 0.9rem; }
  .mapeo-embed-header h2 { font-size: 1.3rem; }
  .mapeo-embed-frame { min-height: 0; }
}

body.theme-dark.sidebar-collapsed .sidebar {
  min-height: calc(100vh - 2rem);
  grid-template-rows: auto 1fr;
}

body.theme-dark .sidebar-profile {
  background:
    linear-gradient(180deg, rgba(13, 20, 31, 0.1), rgba(13, 20, 31, 0.8)),
    radial-gradient(circle at 30% 30%, rgba(62, 116, 216, 0.26), transparent 56%);
  border-bottom: 1px solid #2f3f52;
  min-height: 104px;
}

body.theme-dark.sidebar-collapsed .sidebar-profile {
  min-height: auto;
  justify-content: center;
  grid-template-columns: 1fr;
  padding: 0.7rem 0.4rem;
}

body.theme-dark.sidebar-collapsed .sidebar .profile-meta,
body.theme-dark.sidebar-collapsed .sidebar .profile-avatar,
body.theme-dark.sidebar-collapsed .sidebar .sidebar-section,
body.theme-dark.sidebar-collapsed .sidebar .nav-text,
body.theme-dark.sidebar-collapsed .sidebar .nav-caret {
  display: none;
}

body.theme-dark.sidebar-collapsed .sidebar .sidebar-links {
  padding: 0.45rem 0.2rem;
}

body.theme-dark.sidebar-collapsed .sidebar .nav-link {
  padding: 0.6rem 0.25rem;
  grid-template-columns: 1fr;
  justify-items: center;
}

body.theme-dark.sidebar-collapsed .sidebar .sidebar-toggle {
  padding: 0.35rem 0.55rem;
  min-width: 44px;
}

body.theme-dark .profile-avatar {
  width: 38px;
  height: 38px;
  background: #2f8ddd;
}

body.theme-dark .profile-meta strong {
  color: #ffffff;
}

body.theme-dark .profile-meta span {
  color: #b8cbdf;
}

body.theme-dark .sidebar-section {
  background: #202b3b;
  color: #9bb0c9;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.95rem;
}

body.theme-dark .sidebar-links {
  gap: 0.16rem;
  padding: 0.38rem;
}

/* Tipografia final aplicada a todo el gestor */
body,
button,
input,
select,
textarea { font-family: "Times New Roman", Times, serif; }

h1,
h2,
h3,
h4,
.brand h1,
.section-head h2,
.panel h3,
.auth-brand h1,
.mapeo-embed-header h2 { font-family: "Times New Roman", Times, serif; }

.profile-avatar,
.topbar-user-avatar,
code,
pre { font-family: "Times New Roman", Times, serif; }

body.theme-dark .nav-link {
  border-radius: 0.45rem;
  font-size: 1.03rem;
  color: #becde0;
  padding: 0.74rem 0.7rem;
}

body.theme-dark .nav-icon {
  background: transparent;
  border: 0;
}

body.theme-dark .nav-icon-img {
  width: 18px;
  height: 18px;
  filter: brightness(1.15);
}

body.theme-dark .nav-link.active,
body.theme-dark .nav-link:hover {
  background: #243244;
  border-color: transparent;
}

body.theme-dark .content {
  gap: 0.86rem;
}

.ref-head h2 {
  color: #f1f5fb;
  font-family: "Public Sans", sans-serif;
  font-weight: 600;
  font-size: 2.1rem;
}

.ref-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.86rem;
}

.ref-kpi {
  border-radius: 0.35rem;
  padding: 1rem 1rem 0.8rem;
  color: #f4faff;
  position: relative;
  overflow: hidden;
  min-height: 128px;
}

.ref-kpi::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -24px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 16px solid rgba(255, 255, 255, 0.1);
}

.ref-kpi-label {
  font-size: 0.73rem;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

.ref-kpi strong {
  display: block;
  margin-top: 0.28rem;
  font-size: 2.1rem;
  font-weight: 700;
}

.ref-kpi p {
  margin: 0.08rem 0 0;
  font-size: 0.84rem;
  font-weight: 600;
}

.ref-kpi a {
  display: block;
  margin-top: 0.72rem;
  color: #e9f3ff;
  text-decoration: none;
  text-align: right;
  font-weight: 600;
}

.ref-kpi-cyan { background: #0399a3; }
.ref-kpi-blue { background: #2f76c5; }
.ref-kpi-violet { background: #5c2ab8; }
.ref-kpi-dark { background: #232f3f; }

.ref-main-grid {
  display: grid;
  grid-template-columns: 1.55fr 0.62fr 1fr;
  gap: 0.86rem;
}

body.theme-dark .panel {
  border-radius: 0.3rem;
  border-color: #2a3848;
  background: #1a2331;
}

.ref-traffic h3,
.ref-donut-card h3,
.ref-summary h3 {
  font-family: "Public Sans", sans-serif;
  margin-bottom: 0.25rem;
}

.ref-chart-wrap {
  margin-top: 0.8rem;
  border-radius: 0.2rem;
  background: #1d2837;
  border: 1px solid #2e3d4f;
  padding: 0.6rem;
}

.ref-chart {
  width: 100%;
  height: 250px;
}

.ref-chart-grid line {
  stroke: #3f4f60;
  stroke-width: 1;
}

.ref-chart-line {
  fill: none;
  stroke: #51aef8;
  stroke-width: 3;
}

.ref-chart-points circle {
  fill: #49b4ff;
  stroke: #a8dbff;
  stroke-width: 2;
}

.ref-donut {
  margin: 1rem auto 0;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #1a2331 58%, transparent 59%),
    conic-gradient(#43a4ec 0deg 275deg, #2d3a4b 275deg 360deg);
  border: 1px solid #3a4a5e;
  display: grid;
  place-content: center;
  text-align: center;
}

.ref-donut span {
  font-size: 2.8rem;
  font-weight: 700;
  color: #ecf4ff;
  line-height: 1;
}

.ref-donut small {
  color: #c9d7e8;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.ref-legend {
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}

.ref-legend li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #c7d6e8;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-a { background: #43a4ec; }
.dot-b { background: #42e8ef; }

.ref-summary ul {
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
}

.ref-summary li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.72rem 0;
  border-bottom: 1px solid #2f3d4e;
  color: #dbe7f5;
}

.ref-summary li:last-child {
  border-bottom: 0;
}

.ref-summary b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: #1f9849;
  color: #eaffe9;
  font-size: 0.82rem;
}

@media (max-width: 1320px) {
  .ref-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ref-main-grid {
    grid-template-columns: 1fr;
  }

  .ref-donut {
    width: 170px;
    height: 170px;
  }
}

@media (max-width: 980px) {
  .topbar-search {
    width: 100%;
    order: 4;
    margin-left: 0;
  }

  .topbar-actions {
    margin-left: auto;
  }
}

@media (max-width: 640px) {
  .ref-kpi-grid {
    grid-template-columns: 1fr;
  }

  .topbar-user-name {
    display: none;
  }

  .topbar-icon {
    display: none;
  }
}

html body h1,
html body h2,
html body h3,
html body h4,
html body .ref-head h2,
html body .ref-kpi,
html body .metric-card,
html body .panel,
html body .nav-link,
html body button,
html body input,
html body select,
html body textarea {
  font-family: "Times New Roman", Times, serif !important;
}

/* Regla final: la barra no se alarga hasta el alto de la ventana. */
body .sidebar,
body.theme-dark .sidebar,
body.theme-dark.sidebar-collapsed .sidebar {
  align-self: start;
  height: fit-content;
  min-height: 0;
}

body.sidebar-collapsed .sidebar,
body.theme-dark.sidebar-collapsed .sidebar {
  height: fit-content;
  min-height: 0;
}
