@import url('../../shared/tokens.css');

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
  min-height: 100vh;
}

.muted,
.brand-tag,
label,
.field-error {
  font-family: 'Roboto', 'Segoe UI', sans-serif;
}

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

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  animation: fadeDown 0.5s ease both;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.menu-toggle {
  border: 1px solid var(--status-border);
  background: var(--panel-soft);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.brand-name {
  font-family: 'Sora', 'Segoe UI', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
}

.brand-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-menu {
  position: relative;
}

.user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 0.35rem 0.6rem 0.35rem 0.4rem;
  cursor: pointer;
  font-weight: 600;
}

.user-trigger:hover {
  border-color: var(--primary);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e8f0ff;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.user-name {
  font-size: 0.85rem;
  color: var(--text);
}

.chevron {
  font-size: 0.85rem;
  color: var(--muted);
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.5rem;
  display: none;
  z-index: 20;
}

.user-menu.is-open .user-dropdown {
  display: block;
}

.user-dropdown-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.user-dropdown-head .muted {
  font-size: 0.75rem;
  color: var(--muted);
}

.dropdown-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  display: block;
}

.dropdown-item:hover {
  background: var(--panel-soft);
}

.dropdown-item.is-disabled {
  color: var(--muted);
  pointer-events: none;
}

.dropdown-item.danger {
  color: #b42318;
}

/* Menú de cuenta: una superficie clara, compacta y con jerarquía visual. */
.user-trigger {
  gap: 0.65rem;
  min-height: 46px;
  border-color: var(--border);
  background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
  border-radius: 14px;
  padding: 0.3rem 0.65rem 0.3rem 0.35rem;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.035);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.user-trigger:hover { border-color: #c9ddff; box-shadow: 0 7px 18px rgba(13, 110, 253, 0.12); transform: translateY(-1px); }
.user-trigger:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.14); }
.user-menu.is-open .user-trigger { border-color: #b9d5ff; box-shadow: 0 7px 18px rgba(13, 110, 253, 0.12); }

.avatar { background: linear-gradient(135deg, #e7f1ff 0%, #d5e7ff 100%); color: #0759d6; box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.08); }
.user-trigger-copy { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: 1px; }
.user-name { max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { color: var(--muted); font-size: 0.67rem; font-weight: 600; line-height: 1; }
.chevron { display: inline-flex; width: 16px; height: 16px; align-items: center; justify-content: center; transition: transform 0.2s ease, color 0.2s ease; }
.chevron svg { width: 14px; height: 14px; }
.user-menu.is-open .chevron { color: var(--primary); transform: rotate(180deg); }

.user-dropdown {
  top: calc(100% + 0.75rem);
  width: min(320px, calc(100vw - 2rem));
  min-width: 0;
  background: rgba(255, 255, 255, 0.98);
  border-color: #e5edf8;
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(11, 29, 58, 0.16), 0 2px 8px rgba(11, 29, 58, 0.06);
  display: block;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 40;
}
.user-menu.is-open .user-dropdown { display: block; opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.user-dropdown-head { align-items: flex-start; gap: 0.75rem; padding: 0.9rem; border: 0; border-radius: 13px; background: linear-gradient(135deg, #f5f9ff 0%, #eef5ff 100%); }
.user-dropdown-head .avatar { width: 42px; height: 42px; font-size: 0.9rem; flex-shrink: 0; }
.user-account-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-account-copy strong { color: var(--text); font-size: 0.9rem; line-height: 1.25; }
.user-account-email { color: var(--muted); font-size: 0.73rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-account-status { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; color: #168649; font-size: 0.7rem; font-weight: 700; }
.user-account-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.13); }
.user-dropdown-section { padding: 0.6rem 0.2rem 0.35rem; }
.user-dropdown-label { margin: 0.1rem 0.5rem 0.35rem; color: var(--muted); font-size: 0.65rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.user-dropdown-footer { margin-top: 0.2rem; padding: 0.5rem 0.2rem 0.1rem; border-top: 1px solid var(--border); }
.user-dropdown form { margin: 0; }

.dropdown-item { padding: 0.65rem 0.6rem; border-radius: 11px; font-family: inherit; font-size: 0.84rem; display: flex; align-items: center; gap: 0.65rem; transition: background 0.16s ease, color 0.16s ease; }
.dropdown-item:hover { background: #f2f7ff; color: var(--primary-dark); }
.dropdown-item.danger { color: #d92d20; }
.dropdown-item.danger:hover { background: #fff1f0; color: #b42318; }
.dropdown-icon { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: #eaf3ff; color: var(--primary); }
.dropdown-icon svg { width: 16px; height: 16px; }
.dropdown-item.danger .dropdown-icon { background: #ffebe9; color: #d92d20; }
.dropdown-item-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.dropdown-item-copy strong { font-size: 0.82rem; line-height: 1.15; }
.dropdown-item-copy small { color: var(--muted); font-size: 0.7rem; line-height: 1.2; }

.app-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  flex: 1;
}

/* Estructura de escritorio: una lectura acotada, con navegación estable. */
.topbar { min-height: 68px; padding: 0.8rem 2rem; box-shadow: 0 1px 0 rgba(15, 23, 42, 0.05); }
.menu-toggle { display: none; }
.brand-name { font-size: 1rem; }
.brand-tag { font-size: 0.68rem; letter-spacing: 0.1em; }
.sidebar { background: #102a4c; border-right-color: #102a4c; padding: 1rem 0.75rem; }
.sidebar-brand { display: flex; align-items: center; gap: 0.65rem; padding: 0.45rem 0.65rem 1.2rem; margin-bottom: 0.5rem; color: #fff; }
.sidebar-brand img { width: 30px; height: 30px; object-fit: contain; }
.sidebar-brand > span { display: flex; flex-direction: column; font-size: 0.9rem; font-weight: 750; line-height: 1.2; }
.sidebar-brand small { margin-top: 2px; color: rgba(232, 240, 255, 0.62); font-size: 0.62rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.nav { gap: 0.15rem; }
.nav-section { margin: 1rem 0 0.35rem; padding: 0 0.65rem; font-size: 0.62rem; letter-spacing: 0.14em; }
.nav-item { position: relative; padding: 0.6rem 0.8rem; border-radius: 9px; font-size: 0.9rem; font-weight: 600; }
.nav-item:hover { background: rgba(255,255,255,0.09); }
.nav-group.is-open > .nav-item { background: rgba(109, 167, 255, 0.18); color: #fff; }
.nav-group.is-open > .nav-item::before { content: ''; position: absolute; left: -0.75rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 4px 4px 0; background: #72b0ff; }
.nav-item.is-active { background: rgba(109, 167, 255, 0.18); color: #fff; }
.nav-item.is-active::before { content: ''; position: absolute; left: -0.75rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 4px 4px 0; background: #72b0ff; }
.nav-submenu { gap: 0.1rem; padding-left: 0.8rem; }
.nav-subitem { padding: 0.45rem 0.7rem; font-size: 0.82rem; }
.content { width: min(100%, 1500px); margin: 0 auto; padding: 2rem 2rem 3.5rem; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1, h1 { font-size: 1.75rem; letter-spacing: -0.025em; }
.card { border-radius: 14px; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.055); }
.stats { gap: 0.85rem; margin-bottom: 1.5rem; }
.stat-card { min-height: 108px; padding: 1.15rem 1.25rem; background: #fff; border-color: var(--border); box-shadow: 0 3px 10px rgba(15, 23, 42, 0.025); }
.stat-label { font-size: 0.8rem; }
.stat-value { font-size: 1.65rem; letter-spacing: -0.02em; }
@media (max-width: 760px) {
  .menu-toggle { display: inline-flex; }
  .sidebar-brand { display: none; }
  .content { padding: 1.25rem 1rem 5.5rem; }
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-start) 0%, var(--sidebar-end) 100%);
  border-right: 1px solid var(--sidebar-border);
  padding: 1.5rem 1rem;
}

.sidebar-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  color: var(--sidebar-text);
}

.sidebar-title {
  font-weight: 600;
}

.sidebar-close {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.nav-section {
  margin: 1.4rem 0 0.65rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(248, 251, 255, 0.72);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.nav-section:first-of-type {
  margin-top: 0;
}

.nav-section::after {
  content: '';
  height: 1px;
  flex: 1;
  background: rgba(248, 251, 255, 0.18);
}

.nav-item {
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  color: var(--sidebar-text);
  transition: background 0.2s ease;
}

.nav-item:hover {
  background: var(--sidebar-hover);
}

.nav-group-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.nav-caret {
  font-size: 0.85rem;
  color: rgba(248, 251, 255, 0.85);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-group.is-open .nav-caret {
  transform: rotate(180deg);
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.15rem 0 0.15rem 1rem;
  max-height: 0;
  overflow: hidden;
}

.nav-group.is-open .nav-submenu {
  max-height: 240px;
  padding: 0.3rem 0 0.3rem 1rem;
}

.nav-subitem {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  color: rgba(248, 251, 255, 0.78);
  font-size: 0.88rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-subitem:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.content {
  padding: 2rem 2.5rem 3rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  animation: rise 0.6s ease both;
}

h1 {
  font-size: 1.75rem;
  margin: 0;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 1rem 0;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: rise 0.6s ease both;
}

.link-card {
  display: block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.link-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 28px 40px rgba(20, 20, 20, 0.15);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--panel-soft);
  border-radius: 16px;
  padding: 1.25rem;
  border: 1px solid var(--tag-border);
  animation: rise 0.6s ease both;
}

.stats .stat-card:nth-child(2) {
  animation-delay: 0.05s;
}

.stats .stat-card:nth-child(3) {
  animation-delay: 0.1s;
}

.stats .stat-card:nth-child(4) {
  animation-delay: 0.15s;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-meta {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

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

.grid .card:nth-child(2) {
  animation-delay: 0.06s;
}

.grid .card:nth-child(3) {
  animation-delay: 0.12s;
}

.grid .card:nth-child(4) {
  animation-delay: 0.18s;
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  flex: 1 1 100%;
}

.search input {
  flex: 1;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  pointer-events: none;
}

.search-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.search-field input {
  width: 100%;
  padding-left: 2.2rem;
}

.filter-advanced {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
  width: 100%;
}

.column-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.column-title {
  font-weight: 600;
  color: var(--muted);
  margin-right: 0.25rem;
}

.column-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text);
}

.filter-field {
  display: grid;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.filter-field input,
.filter-field select {
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: inherit;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.8rem;
  color: var(--muted);
}

.filter-pill.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef2ff;
}

.status-counts {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.export-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.bulk-form {
  display: grid;
  gap: 1rem;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.bulk-actions select {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.bulk-select {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 1.5rem;
  top: 1.2rem;
  background: #0f172a;
  color: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 60;
}

.toast-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.quick-pay {
  margin-bottom: 1.5rem;
}

.quick-pay .card-head {
  align-items: center;
}

.quick-pay-form .hint {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.quick-pay-form .hint-subtle {
  font-size: 0.7rem;
  opacity: 0.85;
}

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

.quick-actions.compact .btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.quick-advanced {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
}

.quick-advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  list-style: none;
}

.quick-advanced summary::-webkit-details-marker {
  display: none;
}

.quick-advanced-content {
  margin-top: 0.85rem;
}

.field-inline {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.quick-suggest {
  margin-top: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 0.35rem;
  display: grid;
  gap: 0.25rem;
  max-height: 180px;
  overflow-y: auto;
}

.quick-suggest.is-hidden {
  display: none;
}

.quick-suggest-item {
  border: 0;
  background: #f8fafc;
  color: inherit;
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.quick-suggest-item:hover {
  background: #eef2f7;
}

.quick-suggest-empty {
  padding: 0.45rem 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.quick-client-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.btn-mini {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.fab {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 18px 32px rgba(29, 78, 216, 0.3);
  z-index: 40;
}

.fab:hover {
  background: var(--primary-dark);
}

.toast.is-hidden {
  display: none;
}

.is-hidden {
  display: none;
}

.sort-link {
  color: inherit;
  font-weight: 600;
}

.sort-link.is-active {
  color: var(--primary);
}

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

.table th,
.table td {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.table tbody tr.is-hidden {
  display: none;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--table-head);
}

.preview-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.preview-metric {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.preview-metric span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.preview-metric strong {
  display: block;
  font-size: 1rem;
  margin-top: 0.35rem;
  color: var(--text);
}

.preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.75rem 0 0.5rem;
}

.preview-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.table .table-total th {
  background: #f2f5fa;
  font-weight: 700;
}

.badge.badge-mini {
  padding: 0.15rem 0.45rem;
  font-size: 0.65rem;
  margin-left: 0.4rem;
  vertical-align: middle;
}

.table tr.is-highlight {
  animation: row-highlight 0.3s ease;
}

@keyframes row-highlight {
  from {
    background-color: #e7f7ef;
  }
  to {
    background-color: transparent;
  }
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--badge-bg);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.success {
  background: #d9f5e6;
  color: #137a4a;
}

.badge.warning {
  background: #ffe9c7;
  color: #9a4f0f;
}

.badge.info {
  background: #dbeafe;
  color: var(--primary);
}

.badge.danger {
  background: #fee2e2;
  color: #b42318;
}

.badge.neutral {
  background: #e5e7eb;
  color: #374151;
}

.presence-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.25);
}

.presence-dot.is-online {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.presence-dot.is-offline {
  background: #9ca3af;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.status-filter {
  padding: 0.45rem 0.85rem;
  font-size: 0.95rem;
  border-radius: 999px;
}

.status-filter.is-active {
  border: 1px solid var(--primary);
  color: var(--primary);
}

.live-search-status {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  margin-left: 0.75rem;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
}

.status-dot.success {
  background: #22c55e;
}

.status-dot.danger {
  background: #ef4444;
}

.status-dot.neutral {
  background: #9ca3af;
}

.status-dot.warning {
  background: var(--warning);
}

.action-badge {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.btn {
  border: 1px solid var(--border);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

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

.btn.ghost {
  background: transparent;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.btn.is-disabled {
  pointer-events: none;
  opacity: 0.6;
}

.btn.is-loading {
  cursor: wait;
}

.btn.danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #b42318;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn.danger:hover {
  background: #fecaca;
}

.btn-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
}

.btn-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.action-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.action-btn:hover {
  border-color: var(--primary);
  background: #eef2ff;
}

.action-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.action-btn.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
}

.pagination-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

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

.link {
  color: var(--primary);
  font-weight: 600;
  margin-right: 0.75rem;
}

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

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

.form-section {
  padding: 1rem;
  border: 1px solid #e3e8ef;
  border-radius: 16px;
  background: #f8fafc;
}

.form-section + .form-section {
  margin-top: 1rem;
}

.form-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #495567;
}

.form-section .form-grid {
  margin-top: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}

input,
select,
textarea {
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-family: inherit;
}

input:not([type='checkbox']):not([type='radio']):not([type='submit']):not([type='button']),
select,
textarea {
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.18);
}

input.is-error,
select.is-error,
textarea.is-error {
  border-color: #fca5a5;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.detail-grid.detail-grid-wide {
  grid-template-columns: minmax(280px, 360px) minmax(520px, 1fr);
}

.detail-span {
  grid-column: 1 / -1;
}

.detail-hero {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.detail-hero-main {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: space-between;
  align-items: center;
}

.detail-hero-eyebrow {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.detail-hero-subtitle {
  color: var(--muted);
  margin-top: 0.4rem;
}

.detail-hero-dot {
  margin: 0 0.35rem;
  color: var(--muted);
}

.detail-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.detail-list {
  display: grid;
  gap: 0.75rem;
}

.detail-list.two-col {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.5rem;
}

.label {
  color: var(--muted);
  font-size: 0.8rem;
  display: block;
}

.muted {
  color: var(--muted);
  font-size: 0.75rem;
  display: block;
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Texto solo para lectores de pantalla. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: #f7e0c2;
  color: #8a4b12;
}

.field-error {
  color: #b42318;
  font-size: 0.75rem;
  font-weight: 600;
}

.profile-incomplete-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.profile-incomplete-alert p {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.setting-toggle {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.setting-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
}

.setting-toggle-row input {
  margin-top: 0.15rem;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.setting-toggle-row strong {
  display: block;
  font-size: 0.86rem;
}

.setting-toggle-row small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

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

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

.dashboard-page .content {
  padding: 2.5rem 2.75rem 3.5rem;
}

.dashboard-header {
  align-items: flex-end;
}

.dashboard-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
}

.dashboard-quick-actions {
  margin-bottom: 2.5rem;
}

.dashboard-quick-actions .card-head {
  align-items: center;
}

.quick-actions-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.quick-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
}

.quick-action {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: var(--panel-soft);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.quick-action:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-soft);
  background: var(--panel);
}

.quick-action-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--tag-border);
  background: var(--tag-bg);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.quick-action-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.quick-action-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.quick-action-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.quick-action-client .quick-action-icon {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

.quick-action-loan .quick-action-icon {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.quick-action-payment .quick-action-icon {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #15803d;
}

.quick-action-reports .quick-action-icon {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.status-pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--status-border);
  color: var(--muted);
  background: var(--status-bg);
}

.status-pill.success {
  border-color: #a7f3d0;
  color: #137a4a;
  background: #d9f5e6;
}

.status-pill.warning {
  border-color: #fecaca;
  color: #b42318;
  background: #fee2e2;
}

.status-pill.subtle {
  color: var(--muted);
}

.page-kicker {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  font-size: 0.7rem;
  margin: 0 0 0.5rem 0;
}

.page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.date-pill {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--status-border);
  font-size: 0.85rem;
  color: var(--text);
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.metric-card {
  background: var(--panel);
  border-radius: 18px;
  padding: 1.4rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: rise 0.6s ease both;
}

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.metric-icon {
  font-size: 1.4rem;
}

.metric-title {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.metric-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric-trend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.metric-trend.positive {
  color: var(--success);
}

.metric-trend.negative {
  color: var(--danger);
}

.tone-deep {
  border-color: var(--primary-soft);
  box-shadow: var(--shadow);
}

.tone-emerald {
  border-color: var(--success-soft);
}

.tone-amber {
  border-color: var(--warning-soft);
}

.tone-rose {
  border-color: var(--danger-soft);
}

.tone-sky {
  border-color: var(--primary-soft);
}

.tone-lime {
  border-color: rgba(163, 230, 53, 0.45);
}

.tone-alert {
  border-color: var(--danger-soft);
  box-shadow: var(--shadow);
}

.metric-card.is-critical {
  box-shadow: var(--shadow);
  border-color: var(--danger);
}

.metric-card.is-warning {
  border-color: #fbbf24;
}

.metric-card.has-cta {
  position: relative;
}

.metric-cta {
  align-self: flex-start;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--status-border);
  font-size: 0.75rem;
  color: var(--text);
  background: var(--panel-soft);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-cta:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.dashboard-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 1.5rem;
}

.dashboard-card {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
}

.dashboard-card .table th {
  background: var(--table-head);
  color: var(--muted);
}

.client-search-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.client-search-row input {
  flex: 1;
}

.client-search-btn {
  white-space: nowrap;
}

/* Módulo de préstamos: controles compactos y lectura financiera clara. */
.loan-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: 0.75rem; padding: 1rem; margin-bottom: 1.5rem; }
.loan-toolbar .loan-filter-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.75rem; align-items: center; }
.loan-toolbar .search { margin: 0; }
.loan-toolbar .search-field { min-width: 280px; }
.loan-filter-trigger { min-height: 42px; }
.loan-advanced-filters { grid-column: 1 / -1; margin: 0; padding-top: 0.9rem; border-top: 1px solid var(--border); grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.loan-advanced-filters[hidden] { display: none; }
.loan-clear-filters { align-self: end; padding: 0.55rem 0.2rem; color: var(--muted); font-size: 0.8rem; font-weight: 650; white-space: nowrap; }
.loan-clear-filters:hover { color: var(--primary); }
.loan-export { position: relative; }
.loan-export summary { list-style: none; }
.loan-export summary::-webkit-details-marker { display: none; }
.loan-export summary::after { content: '⌄'; margin-left: 0.35rem; }
.loan-export-menu { position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 12; min-width: 150px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12); }
.loan-export-menu a { display: block; padding: 0.65rem 0.8rem; font-size: 0.82rem; font-weight: 600; }
.loan-export-menu a:hover { background: var(--panel-soft); color: var(--primary); }
.loan-table.is-empty thead { display: none; }
.loan-empty-cell { padding: 0 !important; border: 0 !important; }
.loan-empty-state { display: flex; min-height: 255px; max-width: 440px; margin: 0 auto; padding: 2.25rem 1rem; align-items: center; flex-direction: column; justify-content: center; text-align: center; }
.loan-empty-icon { width: 48px; height: 48px; margin-bottom: 0.8rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 14px; background: #eaf3ff; color: var(--primary); }
.loan-empty-icon svg { width: 24px; height: 24px; }
.loan-empty-state strong { color: var(--text); font-size: 1rem; }
.loan-empty-state p { max-width: 360px; margin: 0.5rem 0 1rem; color: var(--muted); font-size: 0.85rem; line-height: 1.55; }

.loan-create-layout { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(330px, 0.75fr); align-items: start; gap: 1.5rem; margin-bottom: 1.5rem; }
.loan-form-card { padding: 1.6rem 1.75rem; }
.loan-form-card .form-section { margin: 0; padding: 1.65rem 0; border: 0; border-radius: 0; background: transparent; }
.loan-form-card .form-section:first-of-type { padding-top: 0; }
.loan-form-card .form-section:last-of-type { padding-bottom: 0; }
.loan-form-card .form-section + .form-section { margin: 0; border-top: 1px solid var(--border); }
.loan-section-heading { display: flex; align-items: flex-start; gap: 0.8rem; }
.loan-section-heading > div { min-width: 0; }
.loan-step-number { width: 32px; height: 32px; display: inline-flex; flex: 0 0 32px; align-items: center; justify-content: center; border: 1px solid #cfe0ff; border-radius: 10px; background: #edf5ff; color: var(--primary); font-size: 0.8rem; font-weight: 800; }
.loan-form-card .form-section-title { color: var(--text); font-size: 0.96rem; line-height: 1.25; text-transform: none; letter-spacing: 0; }
.loan-section-heading p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.loan-form-card .form-grid { margin-top: 1.15rem; gap: 1rem 1.15rem; }
.loan-basic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.loan-conditions-grid, .loan-dates-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.loan-form-card label { color: #3d4a5d; font-size: 0.8rem; font-weight: 650; }
.loan-form-card input, .loan-form-card select { min-height: 44px; padding: 0.6rem 0.75rem; border-radius: 9px; background-color: #fff; transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease; }
.loan-form-card input:focus, .loan-form-card select:focus { border-color: #8bb9ff; box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.1); }
.loan-form-card .client-search-btn { display: none; }
.loan-form-card .client-search-row { display: block; }
.loan-form-card .client-search-row input, .loan-form-card .client-search-row select { width: 100%; }
.loan-form-card [data-late-fee-value-field][hidden] { display: none !important; }

/* Selector de cliente: ficha con contexto de cartera antes de prestar. */
.client-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.client-field-label { color: #3d4a5d; font-size: 0.8rem; font-weight: 650; font-family: 'Roboto', 'Segoe UI', sans-serif; }
.client-picker { position: relative; display: flex; align-items: center; gap: 0.4rem; }
.client-picker-trigger { flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: center; padding: 0.5rem 0.75rem; border: 1px solid var(--status-border); border-radius: 9px; background: #fff; color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color 0.18s ease, box-shadow 0.18s ease; }
.client-picker-trigger:hover { border-color: #8bb9ff; }
.client-picker-trigger:focus-visible { outline: none; border-color: #8bb9ff; box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.1); }
.client-picker-trigger.is-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12); }
.client-picker-placeholder { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.85rem; }
.client-picker-search-icon { width: 15px; height: 15px; flex: 0 0 15px; border: 1.8px solid currentColor; border-radius: 50%; position: relative; opacity: 0.75; }
.client-picker-search-icon::after { content: ''; position: absolute; right: -5px; bottom: -3px; width: 7px; height: 1.8px; background: currentColor; transform: rotate(45deg); }
.client-picker-clear { width: 34px; height: 34px; flex: 0 0 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--status-border); border-radius: 9px; background: #fff; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.client-picker-clear:hover { border-color: var(--danger-soft); color: var(--danger); }

/* Se escopa al selector: mas abajo hay un .client-avatar propio del listado
   de clientes que ganaria por orden de aparicion. */
.client-chip .client-avatar,
.client-card .client-avatar { width: 34px; height: 34px; flex: 0 0 34px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: var(--panel-tint); color: var(--primary); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.02em; }
.client-chip { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.client-chip-body { display: flex; flex-direction: column; min-width: 0; }
.client-chip-name { color: var(--text); font-size: 0.87rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-chip-meta { color: var(--muted); font-size: 0.74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.client-picker-modal .modal-card { width: calc(100% - 2rem); max-width: 620px; }
/* .modal-body (display: grid) se define mas abajo: hay que escopar para ganar. */
.client-picker-modal .modal-body { display: block; }
.client-search-field { position: relative; display: flex; align-items: center; gap: 0.5rem; padding: 0 0.75rem; border: 1px solid var(--status-border); border-radius: 10px; background: #fff; }
.client-search-field:focus-within { border-color: #8bb9ff; box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.1); }
.client-search-field .client-picker-search-icon { color: var(--muted); }
.client-search-field input { flex: 1; min-width: 0; min-height: 44px; padding: 0; border: 0; background: transparent; font-size: 0.9rem; }
.client-search-field input:focus { outline: none; box-shadow: none; }
.client-search-spinner { display: block; width: 16px; height: 16px; flex: 0 0 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: clientSpin 0.7s linear infinite; }
@keyframes clientSpin { to { transform: rotate(360deg); } }
.client-picker-help { margin: 0.55rem 0 0.35rem; color: var(--muted); font-size: 0.76rem; }

.client-results { display: flex; flex-direction: column; gap: 0.4rem; max-height: 46vh; overflow-y: auto; padding: 0.15rem; }
.client-card { display: flex; align-items: flex-start; gap: 0.7rem; width: 100%; padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; text-align: left; font: inherit; cursor: pointer; transition: border-color 0.15s ease, background-color 0.15s ease; }
.client-card:hover, .client-card.is-active { border-color: #bcd6ff; background: #f7fbff; }
.client-card.is-active { box-shadow: 0 0 0 2px rgba(23, 105, 255, 0.12); }
.client-card-body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; flex: 1; }
.client-card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.client-card-name { color: var(--text); font-size: 0.88rem; font-weight: 700; }
.client-card-meta { color: var(--muted); font-size: 0.76rem; }
.client-card-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 0.5rem; margin-top: 0.15rem; }
.client-badge { display: inline-block; padding: 0.1rem 0.45rem; border-radius: 999px; font-size: 0.68rem; font-weight: 700; vertical-align: middle; }
.client-badge.is-incomplete { background: #fff3e6; color: #b45309; }
.client-badge.is-inactive { background: var(--badge-bg); color: var(--muted); }
.client-stat { color: var(--muted); font-size: 0.73rem; font-weight: 600; }
.client-stat + .client-stat::before, .client-risk + .client-stat::before { content: '·'; margin-right: 0.5rem; color: var(--border); }
.client-risk { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.73rem; font-weight: 700; }
.client-risk::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.client-risk.is-current { color: var(--success); }
.client-risk.is-due_soon { color: var(--warning); }
.client-risk.is-late { color: var(--danger); }
.client-risk.is-none { color: var(--muted); }
.client-results-empty { margin: 0; padding: 1.4rem 0.5rem; color: var(--muted); font-size: 0.82rem; text-align: center; }

.client-quick-open { display: flex; align-items: center; gap: 0.55rem; width: 100%; margin-top: 0.6rem; padding: 0.7rem 0.75rem; border: 1px dashed #bcd6ff; border-radius: 12px; background: #f7fbff; color: var(--primary); font: inherit; font-size: 0.83rem; font-weight: 700; text-align: left; cursor: pointer; }
.client-quick-open:hover { border-color: var(--primary); background: var(--panel-tint); }
.client-quick-open-icon { width: 22px; height: 22px; flex: 0 0 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--panel-tint); font-weight: 800; }
.client-quick-open-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.client-quick-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.client-quick-head strong { font-size: 0.92rem; }
.client-quick-head p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.client-quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem 1rem; }
.client-quick-grid label { display: flex; flex-direction: column; gap: 0.3rem; color: #3d4a5d; font-size: 0.8rem; font-weight: 650; }
.client-quick-grid input { min-height: 42px; padding: 0.55rem 0.7rem; border: 1px solid var(--status-border); border-radius: 9px; background: #fff; font: inherit; }
.client-quick-grid input:focus { outline: none; border-color: #8bb9ff; box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.1); }
.client-quick-grid input.is-error { border-color: var(--danger); }
.client-quick-dupes { margin-top: 1rem; padding: 0.85rem; border: 1px solid var(--warning-soft); border-radius: 12px; background: #fffaf3; }
.client-quick-dupes strong { display: block; margin-bottom: 0.55rem; font-size: 0.83rem; }
.client-quick-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 1.1rem; }

/* .is-hidden se define antes que estos bloques: con la misma especificidad
   ganaria el display de cada componente, asi que se reafirma aqui. */
.client-picker-placeholder.is-hidden,
.client-chip.is-hidden,
.client-picker-clear.is-hidden,
.client-search-spinner.is-hidden,
.client-picker-search.is-hidden,
.client-quick-view.is-hidden,
.client-quick-dupes.is-hidden,
.client-quick-open.is-hidden,
.client-results .client-card.is-hidden { display: none; }

@media (max-width: 720px) {
  .client-quick-grid { grid-template-columns: minmax(0, 1fr); }
  .client-quick-head { flex-direction: column; }
  .client-results { max-height: 52vh; }
}
.loan-summary-card { position: sticky; top: 88px; overflow: hidden; padding: 1.35rem; border-color: #dfe8f5; box-shadow: 0 18px 42px rgba(15, 42, 76, 0.1); }
.loan-summary-card::before { position: absolute; top: 0; right: 0; left: 0; height: 3px; content: ''; background: linear-gradient(90deg, #1769ff, #55a6ff); }
.loan-summary-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.loan-summary-card h2 { margin: 0.1rem 0 0; font-size: 1.12rem; letter-spacing: -0.015em; }
.loan-summary-eyebrow { color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.loan-draft-badge { display: inline-flex; align-items: center; padding: 0.3rem 0.55rem; border: 1px solid #d7e5fb; border-radius: 999px; background: #f1f6ff; color: #3a6dad; font-size: 0.69rem; font-weight: 750; }
.loan-summary-intro { margin: 0.8rem 0 1rem; color: var(--muted); font-size: 0.8rem; line-height: 1.55; }
.loan-summary-total { position: relative; overflow: hidden; padding: 1rem; border-radius: 12px; background: linear-gradient(135deg, #102a4c, #174a86); color: #fff; }
.loan-summary-total::after { position: absolute; right: -28px; bottom: -45px; width: 120px; height: 120px; border-radius: 50%; content: ''; background: rgba(95, 170, 255, 0.22); }
.loan-summary-total span { position: relative; z-index: 1; display: block; color: #c9daf1; font-size: 0.72rem; font-weight: 650; }
.loan-summary-total strong { position: relative; z-index: 1; display: block; margin-top: 0.3rem; font-size: 1.7rem; line-height: 1.15; letter-spacing: -0.03em; }
.loan-summary-card .preview-summary { grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0.75rem 0 0; }
.loan-summary-card .preview-metric { min-width: 0; padding: 0.72rem 0.75rem; border: 1px solid #e6ecf4; border-radius: 10px; background: #f8fafc; }
.loan-summary-card .preview-metric span { overflow: hidden; color: var(--muted); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.035em; text-overflow: ellipsis; white-space: nowrap; }
.loan-summary-card .preview-metric strong { overflow: hidden; margin-top: 0.3rem; font-size: 0.96rem; text-overflow: ellipsis; white-space: nowrap; }
.loan-summary-card .preview-summary.is-empty { display: grid; opacity: 0.68; }
.loan-summary-card .preview-actions { display: block; margin-top: 0.75rem; }
.loan-summary-card .preview-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }
.loan-summary-card .preview-buttons .btn { padding: 0.42rem 0.58rem; font-size: 0.71rem; }
.loan-summary-submit-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.55rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.loan-summary-submit-panel .btn { min-height: 42px; }
.loan-summary-submit { width: 100%; }
.loan-summary-cancel { min-width: 86px; }
.loan-summary-submit-panel small { grid-column: 1 / -1; color: var(--muted); font-size: 0.7rem; line-height: 1.45; text-align: center; }
.loan-summary-submit-panel small.is-ready { color: #15803d; font-weight: 650; }
.loan-summary-submit:disabled { box-shadow: none; filter: saturate(0.45); }
.loan-schedule-card { padding: 1.35rem 1.5rem; }
.loan-schedule-head { display: flex; align-items: start; justify-content: space-between; margin-bottom: 1rem; }
.loan-schedule-head h2 { margin: 0; }
.loan-schedule-head p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.82rem; }
.loan-schedule-table.is-empty thead, .loan-schedule-table.is-empty tfoot { display: none; }
.loan-schedule-table.is-empty td { padding: 2.25rem 0.5rem; color: var(--muted); text-align: center; }
.loan-simulation-empty { display: flex; max-width: 420px; margin: 0 auto; align-items: center; flex-direction: column; }
.loan-simulation-empty-icon { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 0.65rem; border-radius: 12px; background: #edf5ff; color: var(--primary); font-size: 1rem; font-weight: 800; }
.loan-simulation-empty strong { color: var(--text); font-size: 0.88rem; }
.loan-simulation-empty span { margin-top: 0.3rem; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.loan-confirm-modal .modal-card { width: calc(100% - 2rem); max-width: 520px; margin: 12vh auto; padding: 1.4rem; }
.loan-confirm-modal .modal-head { align-items: flex-start; }
.loan-confirm-modal .modal-head h2 { margin: 0.15rem 0 0; font-size: 1.2rem; }
.loan-confirm-client { padding: 1rem; border: 1px solid #dbe8fa; border-radius: 12px; background: #f3f7fd; }
.loan-confirm-client span, .loan-confirm-grid span { display: block; color: var(--muted); font-size: 0.69rem; font-weight: 700; letter-spacing: 0.035em; text-transform: uppercase; }
.loan-confirm-client strong { display: block; margin-top: 0.35rem; color: var(--text); font-size: 1rem; }
.loan-confirm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; margin-top: 0.75rem; }
.loan-confirm-grid > div { padding: 0.8rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.loan-confirm-grid strong { display: block; margin-top: 0.3rem; color: var(--text); font-size: 0.9rem; }
.loan-confirm-note { margin: 0.85rem 0 0; color: var(--muted); font-size: 0.75rem; line-height: 1.5; }
.loan-confirm-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.15rem; padding-top: 1rem; border-top: 1px solid var(--border); }

@media (max-width: 1100px) {
  .loan-create-layout { grid-template-columns: 1fr; }
  .loan-summary-card { position: static; }
  .loan-advanced-filters { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}
@media (max-width: 1380px) and (min-width: 761px) {
  .loan-conditions-grid, .loan-dates-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .loan-toolbar { grid-template-columns: 1fr; }
  .loan-toolbar .loan-filter-form { grid-template-columns: 1fr; }
  .loan-toolbar .search-field { min-width: 0; }
  .loan-toolbar .btn, .loan-toolbar .export-group { width: 100%; }
  .loan-toolbar .export-group { justify-content: stretch; }
  .loan-export { width: 100%; }
  .loan-export summary { width: 100%; text-align: center; }
  .loan-advanced-filters, .loan-basic-grid, .loan-conditions-grid, .loan-dates-grid { grid-template-columns: 1fr; }
  .loan-form-card { padding: 1.2rem; }
  .loan-summary-submit-panel { grid-template-columns: 1fr; }
  .loan-summary-submit-panel small { grid-column: 1; }
  .loan-summary-cancel { width: 100%; }
  .loan-confirm-grid { grid-template-columns: 1fr; }
  .loan-confirm-actions { align-items: stretch; flex-direction: column-reverse; }
  .loan-confirm-actions .btn { width: 100%; }
}

/* Clientes: directorio compacto, filtros progresivos y acciones claras. */
.clients-page { width: min(100%, 1400px); }
.clients-page-header { align-items: flex-end; }
.clients-title-row { display: flex; align-items: center; gap: 0.65rem; }
.clients-title-row h1 { margin: 0; }
.clients-title-count { min-width: 30px; height: 26px; display: inline-flex; align-items: center; justify-content: center; padding: 0 0.55rem; border: 1px solid #d7e5fb; border-radius: 999px; background: #edf5ff; color: var(--primary); font-size: 0.78rem; font-weight: 800; }
.clients-create-button { min-height: 42px; gap: 0.4rem; box-shadow: 0 8px 18px rgba(23, 105, 255, 0.18); }
.clients-create-button > span { font-size: 1.05rem; line-height: 1; }
.clients-toolbar-card { margin-bottom: 1.25rem; padding: 1rem; animation-delay: 0.02s; }
.clients-filter-form { position: relative; }
.clients-toolbar-main { display: grid; grid-template-columns: minmax(300px, 1fr) auto auto; align-items: center; gap: 0.65rem; }
.clients-search-field input { min-height: 44px; border-color: #dfe6ef; border-radius: 10px; background: #fbfcfe; }
.clients-search-field input:focus { border-color: #8bb9ff; background: #fff; box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.1); }
.clients-filter-toggle { min-height: 42px; gap: 0.4rem; }
.clients-filter-toggle svg { width: 17px; height: 17px; }
.clients-filter-count { min-width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; padding: 0 0.35rem; border-radius: 999px; background: #e5efff; color: var(--primary); font-size: 0.68rem; font-weight: 800; }
.clients-export-menu { position: relative; }
.clients-export-menu summary { min-height: 42px; list-style: none; cursor: pointer; }
.clients-export-menu summary::-webkit-details-marker { display: none; }
.clients-export-menu[open] summary { border-color: #bcd4f8; background: #f4f8ff; color: var(--primary); }
.clients-export-popover { position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 20; min-width: 170px; overflow: hidden; padding: 0.35rem; border: 1px solid var(--border); border-radius: 11px; background: #fff; box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14); }
.clients-export-popover a { display: block; padding: 0.65rem 0.75rem; border-radius: 8px; color: var(--text); font-size: 0.8rem; font-weight: 650; }
.clients-export-popover a:hover { background: #f1f6fd; color: var(--primary); }
.clients-live-status { margin: 0.65rem 0 0; }
.live-search-status[hidden], .clients-advanced-filters[hidden] { display: none !important; }
.clients-advanced-filters { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)) auto; align-items: end; gap: 0.75rem; margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }
.clients-advanced-filters .filter-field { color: #526075; font-size: 0.74rem; font-weight: 700; }
.clients-advanced-filters input, .clients-advanced-filters select { min-height: 40px; background: #fff; }
.clients-filter-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem; }
.clients-clear-filters { color: var(--muted); font-size: 0.75rem; font-weight: 650; white-space: nowrap; }
.clients-clear-filters:hover { color: var(--primary); }
.clients-filter-actions .btn { min-height: 40px; }
.clients-quick-filter-row { display: flex; align-items: center; gap: 0.9rem; margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }
.clients-quick-filter-label { flex: 0 0 auto; color: var(--muted); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.clients-page .status-counts { gap: 0.4rem; }
.clients-page .status-filter { min-height: 30px; padding: 0.32rem 0.62rem; border: 1px solid transparent; background: #f4f6f9; color: #5f6d81; font-size: 0.73rem; font-weight: 650; }
.clients-page .status-filter strong { color: inherit; font-size: 0.72rem; }
.clients-page .status-filter.is-active { border-color: #a9caff; background: #edf5ff; color: var(--primary); box-shadow: 0 0 0 2px rgba(23, 105, 255, 0.05); }
.clients-page .status-filter.success:not(.is-active) { background: #eef9f2; color: #16804b; }
.clients-table-card { overflow: visible; padding: 0; box-shadow: 0 12px 32px rgba(15, 42, 76, 0.075); }
.clients-table-heading { display: flex; align-items: center; justify-content: space-between; padding: 1.05rem 1.3rem; border-bottom: 1px solid var(--border); }
.clients-table-heading h2 { margin: 0; font-size: 0.98rem; }
.clients-table-heading p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.75rem; }
.clients-table-card .bulk-form { gap: 0; }
.clients-table { margin: 0; }
.clients-table th { height: 46px; padding: 0.7rem 1rem; background: #f7f9fc; color: #718096; font-size: 0.72rem; font-weight: 750; letter-spacing: 0.01em; white-space: nowrap; }
.clients-table td { height: 64px; padding: 0.8rem 1rem; vertical-align: middle; }
.clients-table th:last-child, .clients-table td:last-child { text-align: right; }
.clients-table tbody tr { transition: background-color 0.16s ease; }
.clients-table tbody tr:hover { background: #f9fbfe; }
.clients-table.is-empty thead { display: none; }
.clients-empty-cell { height: auto !important; padding: 0 !important; border: 0 !important; }
.clients-empty-state { min-height: 285px; display: flex; max-width: 450px; margin: 0 auto; padding: 2.4rem 1rem; align-items: center; flex-direction: column; justify-content: center; text-align: center; }
.clients-empty-icon { width: 54px; height: 54px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 0.9rem; border-radius: 16px; background: #edf5ff; color: var(--primary); }
.clients-empty-icon svg { width: 27px; height: 27px; }
.clients-empty-state strong { color: var(--text); font-size: 1rem; }
.clients-empty-state p { max-width: 390px; margin: 0.45rem 0 1rem; color: var(--muted); font-size: 0.82rem; line-height: 1.55; }
.client-identity { display: flex; min-width: 190px; align-items: center; gap: 0.7rem; }
.client-avatar { width: 36px; height: 36px; display: inline-flex; flex: 0 0 36px; align-items: center; justify-content: center; border: 1px solid #d5e4fb; border-radius: 11px; background: #edf5ff; color: var(--primary); font-size: 0.78rem; font-weight: 800; }
.client-identity-copy { min-width: 0; display: block; }
.client-identity-copy strong { display: block; overflow: hidden; color: var(--text); font-size: 0.82rem; text-overflow: ellipsis; white-space: nowrap; }
.client-identity-copy small { display: block; overflow: hidden; max-width: 210px; margin-top: 0.2rem; color: var(--muted); font-size: 0.7rem; text-overflow: ellipsis; white-space: nowrap; }
.client-phone-link { color: #35679e; font-weight: 600; }
.client-phone-link:hover { color: var(--primary); }
.clients-money-cell { color: var(--text); font-weight: 750; text-align: right; white-space: nowrap; }
.client-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.4rem; }
.client-view-button { min-width: 82px; color: #245e9e; }
.client-row-menu { position: relative; }
.client-row-menu summary { list-style: none; letter-spacing: 0.05em; cursor: pointer; }
.client-row-menu summary::-webkit-details-marker { display: none; }
.client-row-menu[open] summary { border-color: #bcd4f8; background: #edf5ff; color: var(--primary); }
.client-row-menu-popover { position: absolute; right: 0; top: calc(100% + 0.45rem); z-index: 25; min-width: 170px; overflow: hidden; padding: 0.35rem; border: 1px solid var(--border); border-radius: 11px; background: #fff; box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16); }
.client-row-menu-popover a, .client-row-menu-popover button { width: 100%; display: block; padding: 0.62rem 0.7rem; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 0.78rem; font-weight: 600; text-align: left; cursor: pointer; }
.client-row-menu-popover a:hover, .client-row-menu-popover button:hover { background: #f1f6fd; color: var(--primary); }
.clients-pagination { margin-top: 1rem; }
.client-detail-modal .modal-card { width: calc(100% - 2rem); max-width: 560px; }
.client-detail-modal .modal-head { align-items: flex-start; }
.client-detail-modal .modal-head h2 { margin: 0.15rem 0 0; font-size: 1.15rem; }
.client-detail-modal .detail-list { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.client-detail-modal .detail-list > div { padding: 0.8rem; border: 1px solid var(--border); border-radius: 10px; background: #f9fbfd; }

@media (max-width: 1180px) {
  .clients-advanced-filters { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .clients-filter-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
  .clients-page-header { align-items: stretch; }
  .clients-create-button { width: 100%; }
  .clients-toolbar-main { grid-template-columns: 1fr; }
  .clients-filter-toggle, .clients-export-menu, .clients-export-menu summary { width: 100%; }
  .clients-advanced-filters { grid-template-columns: 1fr; }
  .clients-filter-actions { align-items: stretch; flex-direction: column-reverse; }
  .clients-filter-actions .btn, .clients-clear-filters { width: 100%; text-align: center; }
  .clients-quick-filter-row { align-items: flex-start; flex-direction: column; }
  .clients-page .status-counts { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.2rem; }
  .clients-page .status-filter { flex: 0 0 auto; }
  .clients-table-heading { padding: 1rem; }
  .clients-money-cell { text-align: left; }
  .client-actions { justify-content: flex-start; }
  .client-row-menu-popover { right: auto; left: 0; }
  .client-detail-modal .detail-list { grid-template-columns: 1fr; }
}

.client-search-table {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-tag {
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  color: var(--tag-text);
}

.bar-chart {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.6rem;
  align-items: end;
  height: 200px;
}

.bar-chart.is-empty {
  background: linear-gradient(180deg, rgba(227, 232, 239, 0) 0%, rgba(227, 232, 239, 0.7) 100%);
  border-radius: 12px;
  padding: 0.5rem;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0 1rem;
}

.bar {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.35rem;
  min-height: 80px;
}

.bar::before {
  content: '';
  display: block;
  height: var(--bar-height);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  box-shadow: 0 10px 22px rgba(29, 78, 216, 0.25);
  transition: height 0.6s ease;
}

.bar-value {
  font-size: 0.7rem;
  color: var(--muted);
}

.bar-label {
  font-size: 0.75rem;
  color: var(--muted);
}

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

.donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--success) calc(var(--pct) * 1%), rgba(27, 31, 42, 0.08) 0);
  position: relative;
  box-shadow: inset 0 0 0 12px var(--panel);
}

.donut::after {
  content: '';
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend-pct {
  font-size: 0.75rem;
  color: var(--muted);
}

.legend-row strong {
  color: var(--text);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
}

.legend-dot.collected {
  background: var(--success);
}

.legend-dot.pending {
  background: var(--border);
}

.card-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.dashboard-page .table td {
  border-bottom: 1px solid var(--border);
}

.audit-header {
  align-items: flex-start;
  gap: 1rem;
}

.audit-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.export-group {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.audit-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-section {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-section .audit-cards {
  margin-bottom: 0;
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.summary-header h2 {
  margin: 0;
}

.summary-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.summary-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.summary-refresh {
  background: #eef2ff;
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.15);
}

.summary-refresh:hover {
  background: var(--primary);
  color: #fff;
}

.mini-card {
  background: var(--panel-soft);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.mini-meta {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.progress-track {
  width: 100%;
  height: 6px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.6rem;
}

.progress-fill {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.mini-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.mini-value {
  font-size: 1.4rem;
}

.audit-filters {
  margin-bottom: 1.5rem;
}

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

.filter-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.audit-table .table th {
  background: #f2f5fa;
}

.audit-table .table td .muted {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.audit-detail-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  margin-top: 1rem;
}

.audit-panel {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 60;
}

.audit-panel.is-open {
  display: block;
}

.audit-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
}

.audit-panel-card {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(520px, 94vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.audit-panel.is-open .audit-panel-card {
  transform: translateX(0);
}

.audit-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.audit-panel-body {
  padding: 1.25rem 1.5rem;
  overflow: auto;
  display: grid;
  gap: 1rem;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}

.modal.is-open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
}

.modal-card {
  position: relative;
  max-width: 720px;
  margin: 6vh auto;
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.2);
  padding: 1.5rem;
  z-index: 1;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-close {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
}

.modal-body {
  display: grid;
  gap: 1rem;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
}

.modal-description p {
  margin: 0.4rem 0 0;
}

.modal-meta pre {
  margin: 0.4rem 0 0;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  font-size: 0.8rem;
  max-height: 200px;
  overflow: auto;
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  font-size: 0.85rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.action-icon:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

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

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

.user-primary {
  font-weight: 600;
}

.user-secondary {
  display: none;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.users-summary {
  margin-bottom: 1.5rem;
}

.quick-filters {
  margin-bottom: 1rem;
  display: grid;
  gap: 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.quick-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.quick-filters-head h3 {
  font-size: 0.9rem;
  margin: 0;
  color: var(--text);
}

.quick-filters-head p {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.filter-chips {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid #d7e0ef;
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.filter-chip.is-active {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

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

.chip-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  color: currentColor;
}

.chip-icon svg {
  width: 16px;
  height: 16px;
}

.chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 0 0.45rem;
  height: 24px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 0.75rem;
  font-weight: 700;
  color: inherit;
}

.filter-chip.is-active .chip-count {
  background: rgba(255, 255, 255, 0.2);
}

.chip-clear {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  border-style: dashed;
}

.quick-selected {
  font-size: 0.78rem;
  color: var(--muted);
}

.installment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  grid-template-areas:
    'hero actions'
    'client summary';
  gap: 1.5rem;
  align-items: start;
}

.installment-hero {
  grid-area: hero;
  display: grid;
  gap: 0.75rem;
}

.installment-actions-card {
  grid-area: actions;
}

.installment-summary-card {
  grid-area: summary;
}

.installment-client-card {
  grid-area: client;
}

.installment-kicker {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.installment-hero-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status-band {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  background: #fff7ed;
  color: #7a3d0f;
}

.status-band--pending,
.status-band--due {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a4f0f;
}

.status-band--late {
  background: #fee2e2;
  border-color: #fecaca;
  color: #b42318;
}

.status-band--paid {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #1b7a43;
}

.installment-amount {
  font-size: 2rem;
  font-weight: 700;
}

.installment-meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.indicator-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.indicator-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid transparent;
  background: var(--panel-soft);
  color: var(--muted);
}

.indicator-chip--due {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.indicator-chip--late {
  background: #fee2e2;
  color: #b42318;
  border-color: #fecaca;
}

.indicator-chip--priority {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

.indicator-chip--repeat {
  background: #ede9fe;
  color: #5b21b6;
  border-color: #ddd6fe;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-chip--paid {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}

.status-chip--due {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.status-chip--late {
  background: #fee2e2;
  color: #b42318;
  border-color: #fecaca;
}

.status-chip--pending {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

.installment-actions {
  display: grid;
  gap: 1rem;
}

.installment-actions-primary .btn {
  width: 100%;
  justify-content: center;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  border-radius: 16px;
  gap: 0.4rem;
}

.installment-actions-secondary {
  display: grid;
  gap: 0.5rem;
}

.installment-actions-secondary .btn {
  width: 100%;
  justify-content: center;
  padding: 0.55rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 600;
}

.installment-actions-secondary .btn.is-disabled {
  background: var(--panel-soft);
  color: var(--muted);
}

.installment-actions-critical {
  display: grid;
  gap: 0.55rem;
  padding-top: 0.6rem;
  margin-top: 0.4rem;
  border-top: 1px dashed var(--border);
}

.installment-actions-critical .critical-title {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.installment-actions-critical .btn {
  width: 100%;
  justify-content: center;
}

.installment-actions-critical .action-critical {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #be123c;
  border-radius: 10px;
  font-weight: 600;
  padding: 0.55rem 0.8rem;
}

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

.summary-cards .mini-card {
  box-shadow: var(--shadow-soft);
}

.progress-card .card-head {
  margin-bottom: 1rem;
}

.client-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.client-actions .btn {
  flex: 1 1 140px;
  justify-content: center;
}

.text-success {
  color: #1b7a43;
  font-weight: 600;
}

.text-warning {
  color: #9a4f0f;
  font-weight: 600;
}

.text-info {
  color: #1d4ed8;
  font-weight: 600;
}

.collector-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 18px #14284206;
  display: none;
  z-index: 30;
  padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom));
  justify-content: space-around;
}

.collector-nav-item {
  text-decoration: none;
  color: #718199;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
}

.collector-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.collector-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.collector-title-line {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.collector-title-count {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--badge-bg);
  color: var(--muted);
}

.collector-search {
  flex: 0 0 320px;
}

.collector-filters {
  margin-top: 0.5rem;
}

.collector-filters summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.collector-stats-row {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}

.collector-stats-row .stat-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.collector-quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.quick-filters-compact .quick-filters-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}

.quick-filters-compact .filter-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.2rem;
}

.quick-filters-compact .filter-chip {
  flex: 0 0 auto;
}

.quick-filters-compact .filter-chip .chip-icon {
  display: none;
}

.quick-filters-compact .chip-clear.icon-only {
  padding: 0.25rem 0.45rem;
}

.collector-search .search-field input {
  height: 40px;
  padding-left: 2.2rem;
}

.collector-table th,
.collector-table td {
  padding: 0.4rem 0.5rem;
  font-size: 0.88rem;
}

.action-btn.icon-only {
  padding: 0.3rem 0.45rem;
  min-width: auto;
}

.action-btn.icon-only svg {
  width: 16px;
  height: 16px;
  display: block;
}

.progress-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--muted);
  margin-left: 0.4rem;
}

@media (max-width: 768px) {
  .collector-page-header {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }

  .collector-title h1 {
    font-size: 1.2rem;
  }

  .collector-title .page-subtitle {
    margin-top: 0.2rem;
    font-size: 0.85rem;
  }

  .collector-search {
    flex: 1 1 auto;
    min-width: 140px;
  }

  .collector-meta {
    font-size: 0.75rem;
  }

  .collector-search .search-field input {
    font-size: 0.88rem;
    padding: 0.35rem 0.55rem;
    padding-left: 2.2rem;
    height: 40px;
  }

  .collector-filters {
    margin-top: 0.35rem;
  }

  .collector-filters .filter-advanced {
    margin-top: 0.35rem;
  }

  .collector-stats-row {
    margin: 0.35rem 0 0.5rem;
  }

  .collector-stats-row .stat-pill {
    font-size: 0.78rem;
    padding: 0.25rem 0.5rem;
  }

  .collector-quick-filters {
    margin-bottom: 0.5rem;
  }

  .collector-quick-filters .badge {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
  }

  .content {
    padding-top: 0.75rem;
  }

  .page-header.collector-page-header {
    margin-bottom: 0.4rem;
  }
}

.collector-nav-item.is-active {
  color: #2563eb;
  background: #edf3ff;
}

.collector-bottom-spacer {
  display: none;
  height: 76px;
}

@media (max-width: 980px) {
  .collector-only .sidebar,
  .collector-only .menu-toggle {
    display: none;
  }

  .collector-only .app-shell.sidebar-open .sidebar {
    left: -100%;
  }

  .collector-bottom-nav {
    display: flex;
  }

  .collector-bottom-spacer {
    display: block;
  }
}

.installment-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem;
  margin: 0.75rem 0 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.installment-tab {
  border: 0;
  background: transparent;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

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

.installment-tab.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
}

.installment-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.notice-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #1d4ed8;
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.notice-icon {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #c7d2fe;
  color: #1d4ed8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.action-secondary {
  background: var(--panel-soft);
}

.action-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  padding: 0.55rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.action-primary:hover {
  background: var(--primary-dark);
}

.action-secondary {
  color: var(--text);
  border-color: #d7e0ef;
}

.action-cancel {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  font-weight: 600;
}

.action-cancel:hover {
  background: var(--panel-soft);
  color: var(--text);
  border-color: var(--border);
}

.action-cancel-icon {
  font-size: 0.75rem;
  line-height: 1;
}

.action-map .btn-icon {
  width: 18px;
  height: 18px;
}

.status-late {
  border-left: 4px solid #ef4444;
}

.status-soon {
  border-left: 4px solid #fbbf24;
}

.status-warn {
  border-left: 4px solid #f97316;
}

.status-ok {
  border-left: 4px solid #22c55e;
}

.status-paid {
  border-left: 4px solid #94a3b8;
}

.installment-row {
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
  border-left: 3px solid transparent;
}

.installment-row.is-paid {
  background: #f0fdf4;
  border-left-color: #22c55e;
}

.installment-row.is-paid .amount-strong {
  color: var(--text);
}

.installment-row.is-on-way {
  background: #eff6ff;
  border-left-color: #3b82f6;
}

.installment-row.is-pending {
  background: #fff7ed;
  border-left-color: #fb923c;
}

.installment-row.is-paid-today {
  background: #ecfdf3;
  border-left-color: #22c55e;
}

.installment-row.is-just-paid {
  animation: paidPulse 1.1s ease;
}

@keyframes paidPulse {
  0% {
    box-shadow: 0 0 0 rgba(34, 197, 94, 0.2);
  }
  60% {
    box-shadow: 0 14px 28px rgba(34, 197, 94, 0.25);
  }
  100% {
    box-shadow: 0 0 0 rgba(34, 197, 94, 0);
  }
}

.badge-days {
  font-weight: 700;
}

.badge-days.late {
  background: #fee2e2;
  color: #b42318;
}

.badge-days.soon {
  background: #fef3c7;
  color: #92400e;
}

.badge-days.warn {
  background: #ffedd5;
  color: #9a4f0f;
}

.badge-days.ok {
  background: #dcfce7;
  color: #137a4a;
}

.badge-days.paid {
  background: #e2e8f0;
  color: #475569;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--muted);
}

.badge-status.ok {
  background: #dcfce7;
  color: #137a4a;
  border-color: #bbf7d0;
}

.badge-status.soon {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.badge-status.warn {
  background: #ffedd5;
  color: #9a4f0f;
  border-color: #fed7aa;
}

.badge-status.late {
  background: #fee2e2;
  color: #b42318;
  border-color: #fecaca;
}

.badge-status.paid {
  background: #e2e8f0;
  color: #334155;
  border-color: #cbd5f5;
}

.installment-row.is-paid-today .badge-status.paid {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}

.paid-time {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.badge-route {
  margin-left: 0.35rem;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.arrival-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  background: var(--panel-soft);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 0.5rem 0.6rem;
}

.arrival-prompt span {
  font-size: 0.78rem;
  color: var(--muted);
}

.arrival-prompt form {
  margin: 0;
}

.arrival-prompt.is-hidden {
  display: none;
}

.modal-body select[name='reason'] {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
}

.modal-body select[name='reason'] option {
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem;
}

.installments-table .col-collector,
.installments-table .col-phone,
.installments-table .col-status,
.installments-table .col-last {
  display: none;
}

.installments-table.show-collector .col-collector,
.installments-table.show-phone .col-phone,
.installments-table.show-status .col-status,
.installments-table.show-last .col-last {
  display: table-cell;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  margin-left: 0.35rem;
}

.chip-warning {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a4f0f;
}

.chip-danger {
  border-color: #fecaca;
  background: #fee2e2;
  color: #b42318;
}

.client-name {
  font-weight: 700;
  color: var(--text);
}

.amount-strong {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.empty-state {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 0;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.35rem;
}

.empty-state p {
  margin: 0 0 0.8rem;
}

.empty-icon {
  font-size: 1.8rem;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.empty-icon svg {
  width: 24px;
  height: 24px;
  color: var(--muted);
}

.empty-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.action-menu {
  display: inline-block;
  position: relative;
}

.action-menu-btn {
  list-style: none;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}

.action-menu-btn::-webkit-details-marker {
  display: none;
}

.action-menu-content {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.35rem);
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.35rem;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  z-index: 5;
}

.action-menu-content::after {
  content: '';
  position: absolute;
  right: 14px;
  bottom: -6px;
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: var(--panel) transparent transparent transparent;
  filter: drop-shadow(0 2px 2px rgba(15, 23, 42, 0.08));
}

.action-menu-group {
  display: grid;
  gap: 0.15rem;
  padding: 0.4rem 0.25rem;
}

.action-menu-group + .action-menu-group {
  border-top: 1px solid var(--border);
}

.action-menu-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0.1rem 0 0.25rem;
}

.action-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.menu-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.menu-icon svg {
  width: 16px;
  height: 16px;
}

.menu-text {
  font-weight: 600;
}

.menu-desc {
  display: none;
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
  padding-left: 0.5rem;
  text-align: right;
}

.action-menu-item:hover .menu-desc {
  display: inline;
}

.action-menu-item.tone-warning {
  color: #9a4f0f;
}

.action-menu-item.tone-danger {
  color: #b42318;
}

.action-menu-item.tone-neutral {
  color: var(--text);
}

.action-menu-item.tone-warning .menu-icon,
.action-menu-item.tone-danger .menu-icon {
  color: currentColor;
}

.action-menu-item:hover {
  background: var(--panel-soft);
}

.action-menu-item.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

@media (max-width: 980px) {
  .menu-desc {
    display: none;
  }

  .detail-grid.detail-grid-wide {
    grid-template-columns: 1fr;
  }
}

.action-menu[open] .action-menu-list {
  display: grid;
}

.action-menu-list {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 10;
}

.balance-value {
  font-weight: 700;
  color: #b42318;
}

/* =========================================================================
   Navegación de escritorio: una superficie clara y compacta. El azul queda
   reservado para contexto, acción y selección, no como un bloque dominante.
   ========================================================================= */

.app-body {
  grid-template-columns: 232px minmax(0, 1fr);
  background: #f7f9fc;
  transition: grid-template-columns .22s ease;
}

.topbar {
  min-height: 64px;
  padding: .65rem 1.65rem;
  border-bottom-color: #e6edf6;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 6px 20px -18px rgba(15, 42, 82, .45);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
}

.topbar-context,
.topbar-actions {
  display: flex;
  align-items: center;
}

.topbar-context { min-width: 0; gap: .85rem; }
.topbar-actions { gap: .65rem; }

.sidebar-collapse-toggle,
.menu-toggle {
  display: inline-flex;
  width: 35px;
  height: 35px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid #e0e8f2;
  border-radius: 10px;
  background: #fff;
  color: #52647c;
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease, transform .18s ease;
}

.sidebar-collapse-toggle:hover,
.menu-toggle:hover {
  border-color: #bcd4f6;
  background: #f1f6fe;
  color: #0d63dc;
  transform: translateY(-1px);
}

.sidebar-collapse-toggle svg,
.menu-toggle svg { width: 17px; height: 17px; }
.menu-toggle { display: none; }

.brand { gap: .18rem; }
.topbar-crumb {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: .42rem;
  color: #7b8aa0;
  font-size: .75rem;
  font-weight: 620;
}
.topbar-crumb strong { overflow: hidden; color: #223048; font-weight: 760; text-overflow: ellipsis; white-space: nowrap; }
.topbar-crumb i { color: #b1bdcc; font-style: normal; }
.brand-tag { color: #92a0b3; font-size: .61rem; font-weight: 750; letter-spacing: .13em; }

.topbar-session-status {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  padding: .43rem .68rem;
  border: 1px solid #dceee2;
  border-radius: 999px;
  background: #f2fbf5;
  color: #25824d;
  font-size: .71rem;
  font-weight: 720;
  white-space: nowrap;
}
.topbar-session-status i { width: 6px; height: 6px; border-radius: 50%; background: #2eb468; box-shadow: 0 0 0 3px rgba(46, 180, 104, .1); }

.topbar-quick-new {
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  min-height: 35px;
  padding: .45rem .75rem;
  border-radius: 10px;
  background: #1268e8;
  color: #fff;
  font-size: .76rem;
  font-weight: 760;
  box-shadow: 0 8px 18px -12px rgba(13, 96, 220, .72);
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.topbar-quick-new span { font-size: 1rem; font-weight: 500; line-height: .6; }
.topbar-quick-new:hover { background: #0958c9; box-shadow: 0 12px 22px -13px rgba(13, 96, 220, .76); transform: translateY(-1px); }

.sidebar {
  position: sticky;
  top: 64px;
  display: flex;
  height: calc(100vh - 64px);
  min-height: 460px;
  flex-direction: column;
  overflow-x: visible;
  overflow-y: auto;
  padding: .9rem .7rem 1.1rem;
  border-right: 1px solid #e1e9f3;
  background: #fff;
  box-shadow: 8px 0 28px -28px rgba(21, 50, 94, .26);
  scrollbar-width: thin;
  scrollbar-color: #d7e2f1 transparent;
}

.sidebar-top { padding: .1rem .2rem .95rem; }
.sidebar-brand {
  display: inline-flex;
  align-items: center;
  width: 100%;
  gap: .62rem;
  padding: .55rem .6rem;
  border-radius: 12px;
  color: #10203a;
}
.sidebar-brand:hover { background: #f5f8fd; }
.sidebar-brand img { width: 31px; height: 31px; flex: 0 0 auto; border-radius: 9px; object-fit: cover; box-shadow: 0 4px 10px rgba(15, 57, 116, .11); }
.sidebar-brand-copy { display: flex; min-width: 0; flex-direction: column; color: #13223a; font-size: .78rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; }
.sidebar-brand-copy small { margin-top: .17rem; color: #8795a8; font-size: .55rem; font-weight: 720; letter-spacing: .055em; text-transform: uppercase; }

.sidebar-header { display: none; }
.nav { gap: .12rem; padding: 0 .12rem; }
.nav-section {
  display: block;
  margin: 1.05rem .5rem .42rem;
  padding: 0;
  color: #93a1b3;
  font-size: .59rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.nav-section:first-of-type { margin-top: .15rem; }
.nav-section::after { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  gap: .65rem;
  padding: .52rem .64rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #53647a;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 650;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}
.nav-item:hover { background: #f3f7fc; color: #1e4f93; }
.nav-item.is-active,
.nav-group.is-open > .nav-item { background: #eaf3ff; color: #0b60d8; box-shadow: inset 0 0 0 1px #d8e8ff; }
.nav-item.is-active::before,
.nav-group.is-open > .nav-item::before { display: none; }

.nav-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  color: #74849a;
}
.nav-icon svg { width: 18px; height: 18px; }
.nav-item:hover .nav-icon,
.nav-item.is-active .nav-icon,
.nav-group.is-open > .nav-item .nav-icon { color: #0d67e6; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item-main { display: inline-flex; min-width: 0; align-items: center; gap: .65rem; }
.nav-group-trigger { justify-content: space-between; }
.nav-caret { display: inline-flex; width: 15px; height: 15px; align-items: center; justify-content: center; color: #8d9aae; transition: transform .18s ease; }
.nav-caret svg { width: 13px; height: 13px; }
.nav-group.is-open .nav-caret { color: #0d67e6; transform: rotate(180deg); }

.nav-submenu { gap: .1rem; margin: .12rem 0 .12rem 1.15rem; padding: 0 0 0 .7rem; border-left: 1px solid #e1e9f4; }
.nav-group.is-open .nav-submenu { padding: .2rem 0 .25rem .7rem; }
.nav-subitem { padding: .4rem .5rem; border-radius: 8px; color: #75849a; font-size: .72rem; font-weight: 600; }
.nav-subitem:hover { background: #f1f6fd; color: #0c63dc; }

.app-shell.sidebar-collapsed .app-body { grid-template-columns: 72px minmax(0, 1fr); }
.app-shell.sidebar-collapsed .sidebar { padding-inline: .58rem; overflow: visible; }
.app-shell.sidebar-collapsed .sidebar-top { padding-inline: 0; }
.app-shell.sidebar-collapsed .sidebar-brand { width: 42px; padding: .42rem; }
.app-shell.sidebar-collapsed .sidebar-brand img { width: 32px; height: 32px; }
.app-shell.sidebar-collapsed .sidebar-brand-copy,
.app-shell.sidebar-collapsed .nav-section,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .nav-caret { display: none; }
.app-shell.sidebar-collapsed .nav { padding: 0; }
.app-shell.sidebar-collapsed .nav-item { position: relative; justify-content: center; width: 42px; min-height: 40px; padding: .5rem; gap: 0; }
.app-shell.sidebar-collapsed .nav-item-main { min-width: auto; gap: 0; }
.app-shell.sidebar-collapsed .nav-icon { width: 19px; height: 19px; flex-basis: 19px; }
.app-shell.sidebar-collapsed .nav-group { position: relative; }
.app-shell.sidebar-collapsed .nav-submenu { display: none; }
.app-shell.sidebar-collapsed .nav-group.is-open .nav-submenu {
  position: absolute;
  z-index: 80;
  top: 0;
  left: calc(100% + .55rem);
  display: flex;
  width: 190px;
  max-height: 260px;
  margin: 0;
  padding: .45rem;
  overflow: visible;
  border: 1px solid #dce7f3;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 32px -18px rgba(12, 43, 85, .34);
}
.app-shell.sidebar-collapsed .nav-subitem { padding: .52rem .62rem; color: #51627a; font-size: .74rem; }
.app-shell.sidebar-collapsed .nav-item[data-nav-label]::after {
  position: absolute;
  z-index: 90;
  left: calc(100% + .65rem);
  padding: .38rem .55rem;
  border-radius: 7px;
  background: #1d2b43;
  color: #fff;
  content: attr(data-nav-label);
  font-size: .68rem;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-3px);
  transition: opacity .14s ease, transform .14s ease;
  white-space: nowrap;
}
.app-shell.sidebar-collapsed .nav-item[data-nav-label]:hover::after { opacity: 1; transform: translateX(0); }

@media (max-width: 980px) {
  .sidebar-collapse-toggle { display: none; }
  .app-shell.sidebar-collapsed .app-body { grid-template-columns: 1fr; }
  .topbar { padding-inline: 1rem; }
  .menu-toggle { display: inline-flex; }
  .topbar-session-status { display: none; }
}

@media (max-width: 620px) {
  .topbar { min-height: 59px; padding: .55rem .8rem; }
  .topbar-context { gap: .55rem; }
  .topbar-crumb { font-size: .7rem; }
  .brand-tag { display: none; }
  .topbar-quick-new { min-height: 34px; padding-inline: .62rem; font-size: .72rem; }
  .user-trigger { padding-right: .35rem; }
  .user-trigger-copy,
  .user-trigger .chevron { display: none; }
}

