/* VAULT — paleta Nexalia: forest · gold · white · sand */
:root {
  --forest: #003F3E;
  --forest-soft: #0A5553;
  --forest-deep: #002B2A;
  --teal: #003F3E;
  --gold: #C0A153;
  --gold-soft: #D4B86A;
  --white: #FFFFFF;
  --sand: #F5F4F0;

  --mist: #FFFFFF;
  --steel: #C0A153;
  --slate: #6B7A78;
  --charcoal: #003F3E;
  --ink: #003F3E;
  --muted-on-dark: rgba(245, 244, 240, 0.72);

  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --surface-2: #F5F4F0;
  --line: rgba(0, 63, 62, 0.10);
  --line-strong: rgba(0, 63, 62, 0.18);
  --shadow: 0 10px 28px rgba(0, 63, 62, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 63, 62, 0.12);

  --radius: 20px;
  --radius-sm: 14px;
  --sidebar-w: 248px;
  --rail-w: 300px;
  --topbar-h: 84px;

  --font: "Manrope", system-ui, sans-serif;
  --display: "Michroma", system-ui, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--sand);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  min-height: 100vh;
  background: var(--sand);
}

/* ——— Sidebar ——— */
.sidebar {
  background: linear-gradient(
    180deg,
    #0a2e29 0%,
    #062522 42%,
    #041614 100%
  );
  color: var(--white);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 20;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 120px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.brand {
  padding: 6px 8px 4px;
}

.brand-lockup {
  display: inline-grid;
  grid-template-columns: max-content auto;
  grid-template-rows: 1fr;
  align-items: end;
  column-gap: 4px;
  width: fit-content;
  max-width: 100%;
  line-height: 1;
}

.brand-logo {
  grid-column: 1;
  grid-row: 1;
  display: block;
  height: 26px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  object-position: left bottom;
}

.brand-product {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  margin-bottom: 1px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}

.brand-name {
  font-family: var(--display);
  font-size: 1.65rem;
  letter-spacing: 0.02em;
  line-height: 1;
}

.brand-tag {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.48);
  letter-spacing: 0.08em;
  text-transform: none;
}

.brand-wordmark {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  width: auto;
  height: 16px;
  max-width: calc(100% - 72px);
  object-fit: contain;
  object-position: left center;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  padding: 14px 2px 4px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

.sidebar-foot .brand-wordmark {
  height: 20px;
  width: auto;
  max-width: calc(100% - 76px);
  flex: 0 1 auto;
  margin-left: -1px;
}

.sidebar-foot .brand-tag {
  flex: 0 0 auto;
  font-size: 0.62rem;
  line-height: 1;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow: auto;
  padding-right: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.72);
  transition: background 0.25s var(--ease), color 0.25s var(--ease), transform 0.25s var(--ease);
  position: relative;
  font-weight: 500;
  font-size: 0.92rem;
}

.nav-item:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.10);
}

.nav-item.active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.16);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gold);
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--white);
  font-size: 0.68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Main */
.main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  background: var(--sand);
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  flex-shrink: 0;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Candado edición (modo Excel) */
.excel-lock-wrap {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

body.excel-mode .excel-lock-wrap {
  display: none;
}

body.excel-mode:not(.is-dashboard) .excel-lock-wrap {
  display: flex;
}

.excel-lock-wrap #inpLock {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.btn-lock {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 63, 62, 0.28);
  background: var(--forest);
  cursor: pointer;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.2s var(--ease);
}

.btn-lock:hover {
  transform: translateY(-1px);
  background: var(--forest-soft);
}

.btn-lock svg {
  display: block;
  width: 18px;
  height: 22px;
  fill: none;
  overflow: visible;
  transform: none;
}

.btn-lock svg .bling {
  stroke: var(--white);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 3;
  stroke-dashoffset: 15;
  transition: all 0.3s ease;
}

.btn-lock svg .lock {
  stroke: var(--white);
  stroke-width: 4;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 36;
  transition: all 0.4s ease;
}

.btn-lock svg .lockb {
  fill: var(--white);
  fill-rule: evenodd;
  clip-rule: evenodd;
  transform: rotate(8deg);
  transform-origin: 14px 20px;
  transition: all 0.2s ease;
}

#inpLock:checked + .btn-lock {
  background: var(--gold);
  border-color: rgba(192, 161, 83, 0.45);
}

#inpLock:checked + .btn-lock:hover {
  background: var(--gold-soft);
}

#inpLock:checked + .btn-lock svg .bling {
  animation: lock-bling 0.3s linear forwards;
  animation-delay: 0.2s;
}

#inpLock:checked + .btn-lock svg .lock {
  stroke-dasharray: 48;
  animation: lock-closed 0.3s linear forwards;
}

#inpLock:checked + .btn-lock svg .lockb {
  transform: rotate(0);
  transform-origin: 14px 22px;
}

@keyframes lock-bling {
  50% {
    stroke-dasharray: 3;
    stroke-dashoffset: 12;
  }
  100% {
    stroke-dasharray: 3;
    stroke-dashoffset: 9;
  }
}

@keyframes lock-closed {
  50% {
    transform: translateY(1px);
  }
}

.page-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.2;
  color: var(--forest);
}

.page-sub {
  margin: 4px 0 0;
  color: var(--slate);
  font-size: 0.84rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  height: 42px;
  min-width: 220px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-box:focus-within {
  border-color: rgba(192, 161, 83, 0.55);
  box-shadow: 0 0 0 4px rgba(192, 161, 83, 0.16);
}

.search-box svg {
  width: 16px;
  height: 16px;
  color: var(--steel);
  flex-shrink: 0;
}

.search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  font-size: 0.88rem;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: var(--surface-2);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  color: var(--charcoal);
}

.profile-wrap {
  position: relative;
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 10px 0 6px;
  background: var(--surface);
  border-radius: 999px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-sizing: border-box;
}

.profile:hover {
  background: var(--surface-2);
}

.profile-caret {
  width: 16px;
  height: 16px;
  color: var(--slate);
  flex-shrink: 0;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--forest);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  padding-right: 2px;
  text-align: left;
}

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

.profile-meta span {
  font-size: 0.7rem;
  color: var(--steel);
  text-transform: capitalize;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 40;
  animation: fadeUp 0.2s var(--ease);
}

.profile-menu[hidden] {
  display: none;
}

.profile-menu-item {
  width: 100%;
  display: block;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.profile-menu-item:hover {
  background: var(--sand);
}

.profile-menu-item.danger {
  color: #8a4a4a;
}

.profile-menu-divider {
  height: 1px;
  margin: 4px 8px;
  background: var(--line);
}

.profile-menu-item.excel-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

.excel-switch {
  font-size: 12px;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 4em;
  height: 2em;
}

.excel-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.excel-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(0, 63, 62, 0.22);
  transition: 0.35s var(--ease);
  border-radius: 30px;
  box-shadow: inset 0 0 12px rgba(0, 43, 42, 0.18);
}

.excel-slider::before {
  position: absolute;
  content: "";
  height: 1.6em;
  width: 1.6em;
  border-radius: 20px;
  left: 0.2em;
  bottom: 0.2em;
  background-color: var(--white);
  transition: 0.35s var(--ease);
  box-shadow: 0 2px 4px rgba(0, 43, 42, 0.2);
}

.excel-switch input:checked + .excel-slider {
  background-color: var(--forest);
}

.excel-switch input:focus-visible + .excel-slider {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.excel-switch input:checked + .excel-slider::before {
  transform: translateX(2em);
  background-color: var(--gold);
  box-shadow: 0 2px 4px rgba(0, 43, 42, 0.28);
}

.excel-slider::after {
  content: "OFF";
  color: var(--white);
  position: absolute;
  right: 0.45em;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: opacity 0.35s var(--ease);
  opacity: 0.95;
  pointer-events: none;
}

.excel-switch input:checked + .excel-slider::after {
  content: "ON";
  left: 0.5em;
  right: auto;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr var(--rail-w);
  gap: 18px;
  padding: 0 22px 22px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

body.is-dashboard .content-grid {
  grid-template-columns: 1fr;
}

body.is-dashboard .rail {
  display: none !important;
}

body.is-dashboard .content {
  overflow: hidden;
  padding-right: 0;
}

.content,
.rail {
  overflow: auto;
  min-height: 0;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(82, 92, 105, 0.35) transparent;
}

/* ??? Cards & layout ??? */
.fade-in {
  animation: fadeUp 0.45s var(--ease) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.kpi-panel {
  padding: 8px 8px 10px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.kpi-item {
  padding: 14px 18px 16px;
  border-right: 1px solid var(--line);
}

.kpi-item:last-child {
  border-right: 0;
}

.kpi-label {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--slate);
}

.kpi-value {
  margin: 0;
  font-family: var(--font);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--charcoal);
  font-variant-numeric: tabular-nums;
}

.kpi-card,
.kpi-icon,
.kpi-top,
.kpi-copy,
.kpi-index,
.kpi-delta {
  display: none;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.panel-head span {
  color: var(--slate);
  font-size: 0.8rem;
}

.panel-link {
  color: var(--slate);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.panel-link:hover {
  color: var(--forest);
  text-decoration: underline;
}

.muted {
  color: var(--slate);
  font-size: 0.8rem;
}

.panel .muted,
.panel .empty,
.toolbar .muted {
  color: var(--slate);
}

.panel-grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.chart-wrap {
  height: 220px;
  position: relative;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: center;
}

.donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--forest) 0 var(--p1, 40%), var(--gold) var(--p1, 40%) var(--p2, 70%), var(--sand) var(--p2, 70%) 100%);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 63, 62, 0.08);
}

.donut::after {
  content: attr(data-center);
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--ink);
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-row strong {
  margin-left: auto;
}

/* ??? Tables / CRUD ??? */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.list-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

.list-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 360px;
  width: 360px;
  max-width: 100%;
  min-width: 200px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  height: 42px;
}

.list-searches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.list-search-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--slate);
  letter-spacing: 0.02em;
  flex: 1 1 140px;
  min-width: 120px;
  max-width: 200px;
}

.list-search--sm {
  flex: none;
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
}

.list-search--sm input {
  font-size: 0.84rem;
}

.list-search svg {
  width: 16px;
  height: 16px;
  color: var(--gold);
  flex-shrink: 0;
}

.list-search--sm svg {
  width: 14px;
  height: 14px;
}

.list-search input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  font-size: 0.88rem;
}

.list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.list-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--slate);
  letter-spacing: 0.02em;
  position: relative;
}

.list-filter select {
  height: 42px;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  padding: 0 12px;
  color: var(--ink);
}

.list-actions {
  margin-left: auto;
  display: flex;
  align-items: end;
  gap: 10px;
}

.fancy-select {
  position: relative;
}

.fancy-select--field {
  width: 100%;
}

.fancy-select--field .fancy-select-trigger {
  width: 100%;
  min-width: 0;
  height: 42px;
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.modal-step-panel .fancy-select--field .fancy-select-trigger {
  height: 36px;
  border-radius: 10px;
  padding: 0 10px;
  font-size: 0.88rem;
}

.fancy-select.is-invalid .fancy-select-trigger {
  border-color: #8a4a4a;
  box-shadow: 0 0 0 3px rgba(138, 74, 74, 0.14);
}

.fancy-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 42px;
  min-width: 148px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fancy-select-trigger:hover,
.fancy-select.is-open .fancy-select-trigger {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(192, 161, 83, 0.18);
}

.fancy-select-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fancy-select-caret {
  width: 16px;
  height: 16px;
  color: var(--gold);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.fancy-select.is-open .fancy-select-caret {
  transform: rotate(180deg);
}

.fancy-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 100%;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-height: 220px;
  overflow: auto;
}

.fancy-select-option {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.fancy-select-option:hover {
  background: rgba(192, 161, 83, 0.16);
  color: var(--forest);
}

.fancy-select-option.is-selected {
  background: var(--gold);
  color: var(--forest);
  font-weight: 700;
}

.fancy-select-option.is-selected:hover {
  background: var(--gold-soft);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.pager--excel {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
}

.pager-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.pager .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 650;
  font-size: 0.88rem;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--gold);
  color: var(--forest);
  box-shadow: 0 8px 20px rgba(192, 161, 83, 0.35);
}

.btn.primary:hover {
  background: var(--gold-soft);
}

.btn.ghost {
  background: transparent;
  color: var(--slate);
  border: 1px solid var(--line-strong);
}

.btn.danger {
  background: transparent;
  color: #8a4a4a;
  border: 1px solid rgba(138, 74, 74, 0.25);
}

.btn.sm {
  padding: 7px 10px;
  font-size: 0.78rem;
  border-radius: 9px;
}

.table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

table.data th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--steel);
  font-weight: 700;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.th-sort:hover {
  color: var(--forest);
}

.th-sort-icon {
  display: inline-flex;
  opacity: 0.35;
  line-height: 0;
}

.th-sort:hover .th-sort-icon,
.th-sort.is-active .th-sort-icon {
  opacity: 0.9;
}

.th-sort-icon svg {
  display: block;
}

.th-sort-icon .arrow-up,
.th-sort-icon .arrow-down {
  fill: currentColor;
}

.th-sort.asc .arrow-down,
.th-sort.desc .arrow-up {
  opacity: 0.25;
}

.th-sort.is-active {
  color: var(--forest);
}

table.data td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr {
  transition: background 0.15s ease;
}

table.data tbody tr:hover {
  background: rgba(0, 63, 62, 0.04);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--slate);
}

.pill.ok { background: rgba(0, 63, 62, 0.10); color: var(--forest); }
.pill.warn { background: rgba(192, 161, 83, 0.22); color: #8A7340; }
.pill.bad { background: rgba(138, 74, 74, 0.12); color: #8a4a4a; }
.pill.info { background: rgba(0, 63, 62, 0.08); color: #4a6664; }

.contact-select {
  display: block;
  width: 100%;
  max-width: 220px;
  min-width: 140px;
  height: 32px;
  margin: 0;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7c7a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  background-size: 12px;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  box-shadow: none;
}

.contact-select:focus {
  outline: 0;
  border-color: rgba(192, 161, 83, 0.55);
  box-shadow: 0 0 0 3px rgba(192, 161, 83, 0.14);
}

.contact-select option {
  border-radius: 0;
}

.contacts-field .contacts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.contacts-field .contacts-head label {
  margin: 0;
}

.contacts-field .contacts-add {
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
}

.contacts-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contacts-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contacts-row input {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.contacts-row .contacts-remove {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  box-shadow: none;
}

.contacts-row .contacts-remove svg {
  width: 14px;
  height: 14px;
}

.audit-pill {
  white-space: nowrap;
  font-size: 0.72rem;
}

.log-panel {
  padding-bottom: 0.5rem;
}

.log-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.log-filters-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.log-filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.log-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.log-filter-input,
.log-filter-field--date input[type="date"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  font: inherit;
  font-size: 0.84rem;
  color: var(--ink);
  background: var(--white);
}

.log-filter-input:focus,
.log-filter-field--date input[type="date"]:focus {
  outline: 2px solid rgba(192, 161, 83, 0.35);
  border-color: rgba(192, 161, 83, 0.55);
}

.log-filters-panel .fancy-select-trigger {
  min-height: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 0.84rem;
}

.log-filter-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--steel);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.log-filters-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.log-filters-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.log-filters-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.log-auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--steel);
  cursor: pointer;
}

.log-filters-count {
  font-size: 0.88rem;
  color: var(--steel);
}

.log-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.log-feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.log-card {
  background: #fffdf8;
  border: 1px solid rgba(192, 161, 83, 0.28);
  border-left: 4px solid rgba(192, 161, 83, 0.55);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 10px 28px rgba(0, 63, 62, 0.04);
}

.log-card--auth { background: rgba(0, 63, 62, 0.03); border-color: rgba(0, 63, 62, 0.12); border-left-color: rgba(0, 63, 62, 0.45); }
.log-card--empresa { background: #fffdf8; border-color: rgba(192, 161, 83, 0.28); border-left-color: rgba(192, 161, 83, 0.65); }
.log-card--usuario { background: rgba(0, 63, 62, 0.025); border-color: rgba(0, 63, 62, 0.10); border-left-color: rgba(0, 63, 62, 0.30); }
.log-card--nexalia { background: rgba(107, 122, 120, 0.05); border-color: rgba(107, 122, 120, 0.18); border-left-color: rgba(107, 122, 120, 0.45); }
.log-card--tone-bad { border-left-color: rgba(138, 74, 74, 0.55); }

.log-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.log-card-head-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: 0;
}

.log-card-head-text {
  min-width: 0;
}

.log-card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.log-card-subtitle {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--steel);
}

.log-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.log-card-field {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 63, 62, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
}

.log-card-field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--steel);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.log-card-field-label svg {
  width: 14px;
  height: 14px;
  color: #8A7340;
}

.log-card-field-value {
  display: block;
  margin-top: 8px;
  font-size: 0.92rem;
  color: var(--ink);
}

.log-card-field-sub {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--steel);
}

.log-card-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(192, 161, 83, 0.12);
  color: #6d5d34;
  font-size: 0.82rem;
}

.log-card-banner svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.log-card-toggle {
  width: 100%;
  margin-top: 12px;
  padding: 10px 0 0;
  border: 0;
  border-top: 1px solid rgba(0, 63, 62, 0.08);
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--forest);
  cursor: pointer;
}

.log-card-toggle-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.15s var(--ease);
}

.log-card-toggle.is-open .log-card-toggle-icon {
  transform: rotate(180deg);
}

.log-card-meta {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 63, 62, 0.08);
}

.log-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 63, 62, 0.06);
  font-size: 0.84rem;
}

.log-meta-row:last-child {
  border-bottom: 0;
}

.log-meta-row span {
  color: var(--steel);
}

.log-feed-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.log-feed-icon svg {
  width: 22px;
  height: 22px;
}

.log-feed-icon--auth { background: rgba(0, 63, 62, 0.10); color: var(--forest); }
.log-feed-icon--empresa { background: rgba(192, 161, 83, 0.18); color: #8A7340; }
.log-feed-icon--usuario { background: rgba(0, 63, 62, 0.08); color: #4a6664; }
.log-feed-icon--nexalia { background: rgba(107, 122, 120, 0.12); color: var(--steel); }
.log-feed-icon--other { background: var(--sand); color: var(--steel); }

.log-feed-empty {
  margin-top: 0.5rem;
}

.log-feed-pager {
  margin-top: 4px;
}

.log-detail-hero {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 1rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  background: var(--sand);
  border: 1px solid var(--line);
}

.log-detail-hero--ok { background: rgba(0, 63, 62, 0.05); }
.log-detail-hero--bad { background: rgba(138, 74, 74, 0.06); }
.log-detail-hero--warn { background: rgba(192, 161, 83, 0.10); }

.log-detail-hero-desc {
  margin: 8px 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.log-detail-hero-meta {
  margin: 0;
  font-size: 0.82rem;
}

.list-filter--date {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 8.5rem;
}

.list-filter--date span {
  font-size: 0.72rem;
  color: var(--steel);
}

.list-filter--date input[type="date"] {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  font: inherit;
  color: var(--ink);
  background: var(--white);
}

.log-detail-modal .log-meta-block {
  margin-top: 1rem;
}

.log-meta-json {
  margin: 0.35rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--sand);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow: auto;
  max-height: 220px;
  white-space: pre-wrap;
  word-break: break-word;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions--icons {
  gap: 8px;
  justify-content: flex-end;
}

table.data th.col-actions-th,
table.data td.col-actions-td {
  position: sticky;
  right: 0;
  z-index: 2;
  width: 1%;
  white-space: nowrap;
  text-align: right;
  padding-left: 10px;
  box-shadow: -8px 0 12px -10px rgba(0, 63, 62, 0.18);
}

table.data th.col-actions-th {
  background: var(--surface-2);
}

table.data td.col-actions-td {
  background: var(--surface);
}

table.data tbody tr:hover td.col-actions-td {
  background: rgba(0, 63, 62, 0.04);
}

table.data th .col-actions {
  display: inline-block;
  width: 100%;
  text-align: right;
}

/* ——— Modo Excel (solo módulos CRUD, no Inicio) ——— */
body.excel-mode:not(.is-dashboard) .table-wrap {
  border-radius: 0;
  border: 1px solid var(--line-strong);
}

body.excel-mode:not(.is-dashboard) table.data {
  font-family: "Segoe UI", Calibri, Arial, sans-serif;
  font-size: 0.8rem;
}

body.excel-mode:not(.is-dashboard) table.data th,
body.excel-mode:not(.is-dashboard) table.data td {
  border: 1px solid #d0d0d0;
  padding: 4px 8px;
}

body.excel-mode:not(.is-dashboard) table.data th {
  background: var(--forest);
  color: #fff;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  font-size: 0.8rem;
  border-color: var(--forest-deep);
}

body.excel-mode:not(.is-dashboard) table.data tr:last-child td {
  border-bottom: 1px solid #d0d0d0;
}

body.excel-mode:not(.is-dashboard) table.data tbody tr:nth-child(even) {
  background: #f3f3f3;
}

body.excel-mode:not(.is-dashboard) table.data tbody tr:hover {
  background: rgba(0, 63, 62, 0.06);
}

body.excel-mode:not(.is-dashboard) .th-sort:hover,
body.excel-mode:not(.is-dashboard) .th-sort.is-active {
  color: #fff;
}

body.excel-mode:not(.is-dashboard) table.data th.col-actions-th {
  background: var(--forest);
  box-shadow: -8px 0 12px -10px rgba(0, 0, 0, 0.25);
}

body.excel-mode:not(.is-dashboard) table.data td.col-actions-td {
  background: var(--surface);
  box-shadow: -8px 0 12px -10px rgba(0, 0, 0, 0.18);
}

body.excel-mode:not(.is-dashboard) table.data tbody tr:nth-child(even) td.col-actions-td {
  background: #f3f3f3;
}

body.excel-mode:not(.is-dashboard) table.data tbody tr:hover td.col-actions-td {
  background: rgba(0, 63, 62, 0.06);
}

/* Modo Excel: tabla a ancho completo (salvo Inicio) */
body.excel-mode:not(.is-dashboard) .content-grid {
  grid-template-columns: 1fr;
}

body.excel-mode:not(.is-dashboard) .rail {
  display: none !important;
}

.toolbar-excel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn.excel-edit {
  background: var(--forest);
  color: var(--white);
  border-color: var(--forest);
}

.btn.excel-edit:hover {
  background: var(--forest-soft);
  border-color: var(--forest-soft);
  color: var(--white);
}

body.excel-mode:not(.is-dashboard) .excel-cell-input {
  display: block;
  width: 100%;
  min-width: 4.5rem;
  margin: 0;
  border: 1px solid #9f9f9f;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.3;
  padding: 3px 6px;
  box-shadow: none;
}

body.excel-mode:not(.is-dashboard) select.excel-cell-input {
  cursor: pointer;
  padding-right: 1.5rem;
}

body.excel-mode:not(.is-dashboard) .excel-cell-input:focus {
  outline: 2px solid var(--gold);
  outline-offset: -1px;
  border-color: var(--gold);
  background: #fffef5;
}

body.excel-mode:not(.is-dashboard) .excel-cell-input.is-dirty {
  border-color: #3d8bfd;
  background: rgba(61, 139, 253, 0.12);
  box-shadow: inset 0 0 0 1px rgba(61, 139, 253, 0.35);
}

body.excel-mode:not(.is-dashboard) .excel-cell-input.is-dirty:focus {
  outline-color: #3d8bfd;
  border-color: #3d8bfd;
  background: rgba(61, 139, 253, 0.16);
}

body.excel-mode:not(.is-dashboard) td.is-dirty {
  background: rgba(61, 139, 253, 0.06);
}

.excel-status-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
  min-width: 0;
}

.excel-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--forest);
  color: rgba(245, 244, 240, 0.88);
  font-size: 0.78rem;
  font-weight: 600;
}

.excel-status-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.excel-status-item svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.excel-status-sep {
  width: 1px;
  height: 14px;
  background: rgba(245, 244, 240, 0.22);
}

.excel-status-changes #excel-change-count {
  color: rgba(245, 244, 240, 0.72);
}

.excel-status-changes #excel-change-count.has-changes {
  color: var(--gold-soft);
}

.excel-status-legend {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.74rem;
  color: var(--slate);
  font-weight: 600;
}

.excel-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.excel-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.excel-swatch--modified {
  background: #3d8bfd;
  box-shadow: 0 0 0 1px rgba(61, 139, 253, 0.35);
}

.excel-swatch--clean {
  background: #d0d0d0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.excel-legend-locked {
  color: var(--forest);
  font-weight: 700;
}

body.excel-mode:not(.is-dashboard) .table-wrap.is-excel-editing tbody tr:hover {
  background: inherit;
}

body.excel-mode:not(.is-dashboard) .table-wrap.is-excel-editing tbody tr:nth-child(even):hover {
  background: #f3f3f3;
}

body.excel-mode:not(.is-dashboard) .table-wrap.is-excel-editing tbody tr:hover td.is-dirty {
  background: rgba(61, 139, 253, 0.08);
}

table.data td:has(.row-actions--icons) {
  text-align: right;
}

.icon-action {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--slate);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.icon-action svg {
  width: 17px;
  height: 17px;
}

.icon-action:hover {
  border-color: rgba(0, 63, 62, 0.28);
  color: var(--forest);
}

.icon-action--danger {
  color: #9b5555;
  border-color: rgba(155, 85, 85, 0.28);
}

.icon-action--danger:hover {
  background: rgba(155, 85, 85, 0.08);
  border-color: rgba(155, 85, 85, 0.45);
  color: #874848;
}

.ficha-sheet {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ficha-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0, 63, 62, 0.08) 0%, rgba(192, 161, 83, 0.14) 100%);
  border: 1px solid rgba(0, 63, 62, 0.1);
  flex-shrink: 0;
}

.ficha-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--forest);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(192, 161, 83, 0.35);
}

.ficha-hero-body {
  min-width: 0;
}

.ficha-hero-name {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--ink);
}

.ficha-hero-meta {
  margin: 4px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: rgba(0, 63, 62, 0.72);
}

.ficha-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.ficha-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--slate);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.ficha-tab:hover {
  border-color: rgba(192, 161, 83, 0.45);
  color: var(--forest);
}

.ficha-tab.is-active {
  border-color: var(--forest);
  background: rgba(0, 63, 62, 0.08);
  color: var(--forest);
  box-shadow: 0 0 0 1px rgba(0, 63, 62, 0.12);
}

.ficha-tab-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  background: rgba(0, 63, 62, 0.1);
  color: var(--forest);
}

.ficha-tab.is-active .ficha-tab-num {
  background: var(--gold);
  color: var(--forest);
}

.ficha-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  min-height: 168px;
}

.ficha-panel[hidden] {
  display: none !important;
}

.ficha-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

.ficha-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid rgba(0, 63, 62, 0.06);
}

.ficha-item--full {
  grid-column: 1 / -1;
}

.ficha-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(0, 63, 62, 0.58);
}

.ficha-value {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.ficha-value.is-empty {
  font-weight: 500;
  color: rgba(0, 63, 62, 0.35);
}

.ficha-sheet--empresa .ficha-hero--empresa {
  margin-bottom: 2px;
}

.ficha-avatar--icon {
  border-radius: 12px;
  color: var(--forest);
}

.ficha-avatar--icon svg {
  width: 22px;
  height: 22px;
}

.ficha-sheet--empresa .ficha-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
}

.ficha-sheet--empresa .ficha-grid {
  gap: 8px 12px;
}

.ficha-sheet--empresa .ficha-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 63, 62, 0.08);
}

.modal.is-ficha {
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  overflow: hidden;
}

.modal.is-vecinos {
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  max-height: min(88vh, 820px);
  overflow: hidden;
}

.modal.is-vecinos .modal-body {
  flex: 1 1 auto;
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 8px;
}

.modal.is-vecinos .modal-foot-nav {
  display: none;
}

.vecinos-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.vecinos-modal.is-loading .vecinos-table-wrap {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.vecinos-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.vecinos-search-box {
  flex: 1 1 280px;
  min-width: 0;
  max-width: 420px;
  height: 40px;
  box-shadow: none;
}

.vecinos-search-box input {
  font-size: 0.86rem;
}

.vecinos-count {
  white-space: nowrap;
}

.vecinos-table-wrap {
  flex: 1 1 auto;
  min-height: 180px;
  max-height: min(52vh, 480px);
}

.vecinos-pager {
  justify-content: flex-end;
  padding-top: 0;
  border-top: 0;
}

.modal.is-ficha .modal-head,
.modal.is-ficha .modal-foot {
  flex-shrink: 0;
}

.modal.is-ficha .modal-head h2 {
  font-size: 1.28rem;
}

.modal.is-ficha .modal-body {
  flex: 0 0 auto;
  max-height: none;
  overflow: hidden;
  padding: 10px 16px 14px;
}

.modal.is-ficha .modal-foot {
  justify-content: flex-end;
}

.modal.is-ficha .modal-foot-nav {
  display: none;
}

.modal.is-ficha.is-acta-view .modal-foot {
  justify-content: space-between;
  gap: 10px;
}

.modal.is-ficha.is-acta-view .modal-foot-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.modal.is-ficha.is-acta-view #modal-download {
  display: inline-flex;
}

.acta-download-hint {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--slate);
  line-height: 1.45;
}

@media (max-width: 520px) {
  .ficha-grid {
    grid-template-columns: 1fr;
  }

  .ficha-item--full {
    grid-column: auto;
  }
}

.empty {
  text-align: center;
  padding: 42px 20px;
  color: var(--slate);
}

.empty strong {
  display: block;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 400;
  margin-bottom: 6px;
}

/* ??? Rail ??? */
.rail .panel {
  animation: fadeUp 0.5s var(--ease) both;
}

.rail .panel:nth-child(2) { animation-delay: 0.06s; }
.rail .panel:nth-child(3) { animation-delay: 0.12s; }

.rail-logs-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 120px);
}

.rail-logs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.rail-logs-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.rail-logs-link {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.rail-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  max-height: calc(100vh - 200px);
}

.rail-log-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.rail-log-action {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}

.rail-log-meta {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
}

.rail-log-user {
  color: var(--forest);
  font-weight: 600;
}

.rail-log-empresa,
.rail-log-app {
  display: inline-block;
}

.rail-log-empty {
  padding: 20px 8px;
}

.reminder-list,
.type-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reminder-item,
.type-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.reminder-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1.5px solid var(--gold);
  display: grid;
  place-items: center;
  color: var(--forest);
}

.reminder-icon svg {
  width: 15px;
  height: 15px;
}

.reminder-item p {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
}

.reminder-item small {
  color: var(--steel);
  font-size: 0.72rem;
}

.type-item {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.type-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.type-meta span {
  font-size: 0.82rem;
  font-weight: 650;
}

.bar {
  height: 7px;
  border-radius: 999px;
  background: var(--sand);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--forest-soft));
  width: 0;
  transition: width 0.8s var(--ease);
}

.type-item strong {
  font-size: 0.8rem;
  color: var(--slate);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--slate);
  letter-spacing: 0.02em;
}

.field input,
.field select,
.field textarea {
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  padding: 0 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  background: var(--surface);
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(0, 63, 62, 0.14);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ??? Modal ??? */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 90, 112, 0.48);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
  animation: fade 0.2s ease;
}

.modal-backdrop[hidden] {
  display: none;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  overflow: visible;
  animation: fadeUp 0.3s var(--ease);
}

.modal.is-stepped {
  width: min(540px, 100%);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal.is-stepped .modal-head,
.modal.is-stepped .modal-foot {
  padding: 12px 16px;
}

.modal-foot {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: space-between;
  gap: 8px;
}

.modal-foot-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.45rem;
}

.modal.is-stepped .modal-head h2 {
  font-size: 1.28rem;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(70vh, 560px);
  overflow: visible;
}

.modal.is-stepped .modal-body {
  max-height: none;
  overflow: visible;
  padding: 12px 16px 14px;
  gap: 10px;
}

.modal-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
  justify-content: center;
}

.modal-step-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--slate);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.modal-step-tab:hover {
  border-color: rgba(0, 63, 62, 0.28);
  color: var(--forest);
}

.modal-step-tab.is-active {
  background: rgba(0, 63, 62, 0.08);
  border-color: var(--forest);
  color: var(--forest);
}

.modal-step-num {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(192, 161, 83, 0.22);
  color: #8A7340;
  font-size: 0.64rem;
  font-weight: 800;
  flex-shrink: 0;
}

.modal-step-tab.is-active .modal-step-num {
  background: var(--gold);
  color: var(--ink);
}

.modal-step-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.modal-step-panel .field {
  gap: 4px;
}

.modal-step-panel .field--full {
  grid-column: 1 / -1;
}

.modal-step-panel .field label {
  font-size: 0.7rem;
}

.modal-step-panel .field input,
.modal-step-panel .field select,
.modal-step-panel .field textarea {
  height: 36px;
  border-radius: 10px;
  padding: 0 10px;
  font-size: 0.88rem;
}

.modal-step-panel .field input:focus,
.modal-step-panel .field select:focus,
.modal-step-panel .field textarea:focus {
  box-shadow: 0 0 0 3px rgba(0, 63, 62, 0.12);
}

.modal-step-panel[hidden] {
  display: none !important;
}

.modal-confirm {
  width: min(440px, 100%);
}

.modal-confirm .modal-head {
  border-bottom: 0;
  padding-bottom: 0;
}

.modal-confirm .modal-body {
  padding-top: 8px;
}

.confirm-message {
  margin: 0;
  color: var(--slate);
  line-height: 1.55;
  font-size: 0.92rem;
}

.modal-confirm .modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 10px;
}

.modal-confirm .confirm-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.modal-confirm.is-unsaved .modal-head {
  justify-content: center;
  text-align: center;
}

.modal-confirm.is-unsaved .modal-head h2 {
  width: 100%;
  text-align: center;
}

.modal-confirm.is-unsaved .modal-body {
  text-align: center;
}

.modal-confirm.is-unsaved .confirm-message {
  text-align: center;
  max-width: 32ch;
  margin: 0 auto;
}

.modal-confirm.is-unsaved .modal-foot {
  justify-content: center;
}

.modal-confirm.is-unsaved .confirm-actions {
  margin-left: 0;
  justify-content: center;
  width: 100%;
}

.modal-confirm.is-unsaved #confirm-cancel {
  display: none;
}

.modal-confirm .modal-foot .btn.danger {
  background: #9b5555;
  color: #fff;
  border-color: #9b5555;
}

.modal-confirm .modal-foot .btn.danger:hover {
  background: #8a4a4a;
  border-color: #8a4a4a;
}

#confirm-discard:not([hidden]) {
  color: #8a4a4a;
  border-color: rgba(138, 74, 74, 0.35);
}

#confirm-discard:not([hidden]):hover {
  background: rgba(138, 74, 74, 0.08);
}

@media (max-width: 520px) {
  .modal-step-panel {
    grid-template-columns: 1fr;
  }
}

/* ??? Toast ??? */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  background: var(--forest);
  color: var(--white);
  border: 1px solid rgba(192, 161, 83, 0.35);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.84rem;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.3s var(--ease);
  min-width: 220px;
}

.toast.error {
  background: #8A7340;
}

.mobile-only {
  display: none;
}

.loading {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--slate);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(0, 63, 62, 0.12);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1200px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
  .log-filters-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .list-actions {
    margin-left: 0;
    width: 100%;
  }
  .list-actions .btn {
    width: 100%;
  }
  .rail {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .rail .panel {
    margin-bottom: 0;
  }
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi-item {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .kpi-item:nth-child(odd) {
    border-right: 1px solid var(--line);
  }
  .kpi-item:nth-child(n + 3) {
    border-bottom: 0;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    transform: translateX(-105%);
    transition: transform 0.3s var(--ease);
  }
  .sidebar.open {
    transform: none;
  }
  .mobile-only {
    display: grid;
  }
  .panel-grid-2,
  .rail,
  .field-row {
    grid-template-columns: 1fr;
  }
  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }
  .search-box {
    min-width: 0;
    width: 140px;
  }
  .profile-meta {
    display: none;
  }
  .log-filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .log-card-grid {
    grid-template-columns: 1fr;
  }
  .log-filters-bar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Import Excel (Actalia-compatible) */
.create-chooser {
  display: grid;
  gap: 1rem;
  padding: 0.35rem 0 0.15rem;
}

.create-chooser-lead {
  margin: 0;
  text-align: center;
  color: var(--slate);
  font-size: 0.95rem;
  line-height: 1.4;
}

.create-chooser-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.create-chooser-grid--3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.create-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 7.5rem;
  padding: 1.1rem 1.15rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.create-choice:hover {
  border-color: rgba(0, 63, 62, 0.35);
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 63, 62, 0.08);
  transform: translateY(-1px);
}

.create-choice:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.create-choice.is-active {
  border-color: var(--forest);
  background: rgba(0, 63, 62, 0.06);
}

.create-choice-num {
  display: inline-grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.create-choice-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--forest);
  line-height: 1.2;
}

.create-choice-desc {
  color: var(--slate);
  font-size: 0.86rem;
  line-height: 1.35;
}

@media (max-width: 560px) {
  .create-chooser-grid,
  .create-chooser-grid--3 {
    grid-template-columns: 1fr;
  }
}

.create-tabs {
  margin-bottom: 0.75rem;
}

.import-panel {
  display: grid;
  gap: 0.85rem;
  padding-top: 0.25rem;
}

.import-hint {
  margin: 0;
  color: var(--muted, #64748b);
  font-size: 0.92rem;
  line-height: 1.45;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.import-status {
  border: 1px dashed color-mix(in srgb, var(--border, #cbd5e1) 80%, transparent);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  background: color-mix(in srgb, var(--surface-2, #f8fafc) 88%, white);
  font-size: 0.9rem;
  color: var(--text, #0f172a);
}

.import-panel input[type="file"] {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 10px;
  background: #fff;
}
