/*
 * Capa Compliance — Gestión con el mismo sistema visual que Atico34 Compliance.
 * Valores medidos en la aplicación cliente: raíl negro de 272px con texto,
 * cabecera negra de página, cifras centradas, tablas de 12px y botones de 44px.
 * Se carga después de styles.css.
 */

:root {
  --ink: #0b0b0a;
  --muted: #6b7280;
  --soft: #9ca3af;
  --label: #777771;
  --canvas: #ffffff;
  --surface: #ffffff;
  --fill: #f4f4f5;
  --paper: #f4f4f1;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --rail: 272px;
  --page: 1280px;
}

html,
body {
  background: var(--canvas);
}

body {
  color: var(--ink);
  font-size: 14px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Raíl ───────────────────────────────────────────────────────────── */

.app-shell {
  grid-template-columns: var(--rail) minmax(0, 1fr);
}

.sidebar {
  width: var(--rail);
  padding: 0;
  color: #fff;
  background: #000;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar__brand {
  display: flex;
  min-height: 52px;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar__brand img {
  display: block;
  width: 112px;
  height: auto;
}

.sidebar .nav {
  display: block;
  padding: 8px 0;
  overflow-y: auto;
}

.nav__group + .nav__group {
  position: relative;
  margin-top: 17px;
  padding-top: 17px;
}

.nav__group + .nav__group::before {
  content: '';
  position: absolute;
  inset: 0 10px auto;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar .nav__item {
  display: grid;
  width: 100%;
  min-height: 44px;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  font-size: 14px;
  font-weight: 420;
  letter-spacing: -0.015em;
  text-align: left;
  transition: color 140ms ease, background-color 140ms ease;
}

.sidebar .nav__item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar .nav__item.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #fff;
}

.sidebar .nav__item:focus-visible,
.sidebar .sidebar__account:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -3px;
}

.sidebar .nav__icon {
  width: 18px;
  font-size: 16px;
  opacity: 0;
}

.sidebar .nav__item.is-active .nav__icon {
  opacity: 1;
}

.sidebar .sidebar__profile {
  position: relative;
  margin-top: auto;
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar .sidebar__account {
  display: grid;
  width: 100%;
  min-height: 32px;
  grid-template-columns: minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: #fff;
  background: transparent;
  border: 0;
  text-align: left;
}

.sidebar .sidebar__account:hover,
.sidebar .sidebar__account.is-open {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar .sidebar__account-copy strong {
  display: block;
  overflow: hidden;
  color: #f2f2ed;
  font-size: 12px;
  font-weight: 620;
  letter-spacing: -0.015em;
  line-height: 16px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar .sidebar__account-chevron {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
}

.sidebar .profile-menu {
  position: absolute;
  inset: auto 10px calc(100% + 6px) 10px;
  z-index: 60;
  padding: 6px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
}

.profile-menu__who {
  display: grid;
  gap: 2px;
  margin: 0 0 6px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
}

.profile-menu__who strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
}

.profile-menu__who span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar .profile-menu button {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
  border: 0;
  font-size: 14px;
  font-weight: 450;
  text-align: left;
}

.sidebar .profile-menu button:hover {
  background: var(--fill);
}

.mobile-menu {
  display: none;
}

/* ── Página y cabecera negra ────────────────────────────────────────── */

.workspace {
  background: var(--canvas);
}

.main {
  width: min(100%, calc(var(--page) + 32px));
  padding: 34px 16px 64px;
}

.main > .sr-only + .page-head,
.home-hero,
.client-hero,
.client-hero.client-hero--compact {
  display: flex;
  min-height: 148px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 12px;
  padding: 31px 34px;
  color: #fff;
  background: #000;
  border: 0;
}

.client-hero::after {
  content: none;
}

.main > .sr-only + .page-head h2,
.home-hero h2,
.client-hero h2 {
  margin: 0;
  color: #fff;
  font-size: 25px;
  font-weight: 630;
  letter-spacing: -0.01em;
  line-height: 28px;
}

.main > .sr-only + .page-head p,
.home-hero__headline,
.client-hero__meta {
  margin: 7px 0 0;
  color: #a3a3a3;
  font-size: 14px;
  line-height: 19px;
}

.home-hero__top {
  display: contents;
}

.home-hero__date {
  display: none;
}

.client-hero__eyebrow {
  margin: 0 0 10px;
}

.client-hero__meta:empty {
  display: none;
}

.page-head {
  align-items: center;
  margin: 40px 0 16px;
}

.page-head h2 {
  font-size: 20px;
  font-weight: 630;
  letter-spacing: -0.01em;
}

.page-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.back-link {
  min-height: 0;
  margin: 0 0 12px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.back-link:hover {
  color: var(--ink);
}

/* ── Botones ────────────────────────────────────────────────────────── */

.button {
  min-height: 44px;
  gap: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--ink);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
}

.button--secondary {
  color: var(--ink);
  background: var(--fill);
  border-color: transparent;
}

.button--secondary:hover {
  background: #e9e9eb;
}

.button--small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.main > .sr-only + .page-head .button,
.home-hero .button,
.client-hero .button {
  color: var(--ink);
  background: #fff;
}

.main > .sr-only + .page-head .button:hover,
.home-hero .button:hover,
.client-hero .button:hover {
  background: #e9e9eb;
}

/* ── Cifras centradas ───────────────────────────────────────────────── */

.metrics-grid,
.stats-grid,
.client-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
  margin: 28px 0 36px;
  padding: 0;
  background: transparent;
  border: 0;
}

.metric,
.stats-grid .stat-card,
.client-insights article,
.client-insights article:nth-child(n) {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 24px 20px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  text-align: center;
}

.metric:first-child,
.stats-grid .stat-card:first-child,
.client-insights article:first-child {
  border-left: 0;
}

.metric strong,
.stat-card__value,
.client-insights article strong {
  order: 1;
  margin: 0;
  color: var(--ink);
  font-size: 38px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 38px;
}

.metric strong em,
.stat-card__value em {
  color: var(--soft);
  font-size: 20px;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0;
}

.metric .zero-value,
.stat-card__value .zero-value,
.client-insights .zero-value {
  font-size: inherit;
  font-weight: inherit;
}

.metric span,
.stat-card__top,
.client-insights article > span:first-child {
  order: 2;
  justify-content: center;
  margin: 13px 0 0;
  color: var(--label);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric small,
.stat-card__meta,
.client-insights article small {
  order: 3;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.client-insights article strong.client-insight-date,
.client-insights article .client-usage {
  order: 1;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 38px;
}

/* ── Secciones ──────────────────────────────────────────────────────── */

.panel,
.panel.client-card,
.client-list,
.client-tab-panel .panel.client-card,
.client-tab-panel .panel.client-disclosure {
  overflow: visible;
  background: transparent;
  border: 0;
}

.client-tab-panel .panel.client-card,
.client-tab-panel .panel.client-disclosure {
  margin-bottom: 44px;
  padding: 0;
}

.panel__head,
.client-section-heading,
.client-card .client-section-heading {
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}

.panel__head h3,
.client-section-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 630;
  letter-spacing: -0.01em;
  text-transform: none;
}

.panel__head span,
.client-section-heading span {
  color: var(--soft);
  font-size: 12px;
}

.text-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}

.text-link:hover {
  color: var(--ink);
}

.list-row {
  min-height: 68px;
  margin: 0;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.list-row--lead {
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 14px;
}

button.list-row:hover {
  background: #fbfbfb;
}

.list-row__title {
  font-size: 14px;
  font-weight: 600;
}

.list-row__meta {
  gap: 10px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.list-row__when,
.row-end,
.row-end span,
.row-end strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
}

.list-row__go {
  color: var(--soft);
  font-size: 15px;
}

.empty-state {
  min-height: 180px;
  color: var(--muted);
}

.empty-state__mark {
  width: auto;
  height: auto;
  margin-bottom: 10px;
  color: var(--soft);
  background: transparent;
  border: 0;
  font-size: 20px;
}

.empty-state strong {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

/* ── Resumen ────────────────────────────────────────────────────────── */

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: 56px;
  align-items: start;
}

.home-grid__main,
.home-grid__side {
  display: grid;
  gap: 44px;
  min-width: 0;
}

.home-grid__side {
  gap: 12px;
}

.home-grid__side .panel {
  margin-top: 32px;
}

.side-card {
  padding: 24px;
  background: var(--paper);
}

.side-card h3 {
  margin: 0 0 18px;
  font-size: 16px;
  font-weight: 630;
  letter-spacing: -0.01em;
}

.share-bar {
  display: flex;
  gap: 2px;
  height: 10px;
}

.share-bar__part {
  min-width: 4px;
  flex: 0 1 0;
}

.share-bar__part--ink {
  background: var(--ink);
}

.share-bar__part--mid {
  background: #8b8b86;
}

.share-bar__part--light {
  background: #d2d2cc;
}

.share-bar__part--empty {
  background: #e4e4df;
}

.share-legend {
  display: grid;
  gap: 9px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.share-legend li {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: #3f3f3b;
  font-size: 13px;
}

.share-legend__dot {
  width: 8px;
  height: 8px;
}

.share-legend strong,
.rank-list strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 620;
}

.rank-list {
  display: grid;
  gap: 2px;
  margin: 20px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.rank-list button {
  display: grid;
  width: 100%;
  min-height: 30px;
  grid-template-columns: minmax(0, 1fr) 88px 20px;
  align-items: center;
  gap: 12px;
  padding: 0;
  color: #3f3f3b;
  background: transparent;
  border: 0;
  font-size: 13px;
  text-align: left;
}

.rank-list button:hover {
  color: var(--ink);
}

.rank-list button > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-list__track {
  display: block;
  height: 6px;
  background: #e4e4df;
}

.rank-list__track i {
  display: block;
  height: 100%;
  background: var(--ink);
}

.rank-list strong {
  text-align: right;
}

/* ── Estados ────────────────────────────────────────────────────────── */

.badge,
.badge[class*='badge--'] {
  display: inline-flex;
  min-height: 0;
  align-items: center;
  gap: 7px;
  padding: 0;
  color: #3f3f3b;
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  background: #a1a1aa;
  border-radius: 50% !important;
}

.badge--active::before,
.badge--completed::before,
.badge--verified::before {
  background: var(--ink);
}

.badge--paused::before,
.badge--closed::before,
.badge--cancelled::before,
.badge--disabled::before,
.badge--expired::before,
.badge--revoked::before {
  background: transparent;
  border: 1.5px solid #a1a1aa;
}

.client-hero .badge {
  color: rgba(255, 255, 255, 0.72);
}

.client-hero .badge--active::before {
  background: #fff;
}

/* Solo grises: el uso se distingue por relleno, no por color. */
.client-usage {
  color: #3f3f3b;
  font-size: 12px;
}

.client-usage--recent::before {
  background: var(--ink);
}

.client-usage--inactive::before {
  background: #a1a1aa;
}

.client-usage--never::before {
  background: transparent;
  border: 1.5px solid #a1a1aa;
}

.client-systems-table td > .system-review-overdue {
  color: var(--ink);
}

/* ── Filtros y tablas ───────────────────────────────────────────────── */

.toolbar {
  gap: 8px;
  margin: 0 0 12px;
}

.toolbar .search-input,
.toolbar .filter-select {
  min-height: 44px;
  height: 44px;
  color: var(--ink);
  background-color: var(--fill);
  border: 1px solid transparent;
  font-size: 14px;
}

.toolbar .search-input:focus,
.toolbar .filter-select:focus {
  background-color: #fff;
  border-color: var(--muted);
}

.toolbar .client-sort-select {
  margin-left: auto;
}

.table-wrap {
  background: transparent;
  border: 0;
}

.data-table th {
  height: auto;
  padding: 10px 12px 16px;
  color: var(--soft);
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 550;
  letter-spacing: 0;
  line-height: 1.4;
  text-transform: none;
  white-space: nowrap;
}

.data-table td {
  height: 68px;
  padding: 16px 12px;
  color: var(--muted);
  background: #fbfbfb;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.4;
}

.data-table tbody tr:hover td {
  background: #f6f6f6;
}

.data-table td strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
}

.data-table td .cell-main strong {
  font-size: 13px;
  font-weight: 600;
}

.data-table td small {
  color: var(--soft);
  font-size: 12px;
}

.cell-main {
  gap: 12px;
}

.client-monogram,
.data-table .avatar,
.client-mobile-card .avatar,
.client-assignment-row .avatar {
  width: 36px;
  height: 36px;
  color: #3f3f3b;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
}

.list-row--lead .client-monogram {
  background: var(--paper);
  border: 0;
}

.client-pending-clear {
  color: var(--soft) !important;
  font-weight: 450 !important;
}

.client-table--usage {
  min-width: 860px;
}

.client-systems-table {
  min-width: 1120px;
}

.client-systems-table tr:not(.client-system-detail-row) td:last-child {
  width: 52px;
  min-width: 0;
}

.table-action,
.client-systems-table .button--small {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.table-action:hover,
.client-systems-table .button--small:hover {
  color: var(--ink);
  background: var(--fill);
}

.client-systems-table [aria-expanded='true'] .ui-icon {
  transform: rotate(180deg);
}

/* ── Pestañas segmentadas (ficha y formación) ───────────────────────── */

.client-tabs,
.training-tabs {
  display: inline-flex;
  width: auto;
  gap: 0;
  margin: 8px 0 28px;
  padding: 4px;
  background: #f1f1ec;
  border: 0;
}

.client-tabs .client-tab,
.training-tabs > button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 600;
}

.client-tabs .client-tab:hover,
.training-tabs > button:hover {
  color: var(--ink);
  background: transparent;
}

.client-tabs .client-tab.is-active,
.training-tabs > button.is-active {
  color: var(--ink);
  background: #fff;
}

.client-tabs .client-tab em {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  color: var(--ink);
  background: #f1f1ec;
  font-size: 12px;
  font-style: normal;
  font-weight: 650;
  line-height: 20px;
  text-align: center;
}

.client-tabs .client-tab:not(.is-active) em {
  background: #fff;
}

/* ── Ficha de cliente ───────────────────────────────────────────────── */

.client-tab-heading--actions {
  display: flex;
  justify-content: flex-end;
  margin: -72px 0 28px;
}

.client-card > .info-grid {
  gap: 24px 48px;
  padding: 22px 0 0;
}

.client-card > .notes {
  margin: 22px 0 0;
}

.client-card > .row-list,
.client-card > .invitation-list,
.client-card > .client-attention-list,
.client-card .system-review-list {
  padding: 0;
}

.client-attention-list {
  display: grid;
}

.client-card .client-attention-item {
  min-height: 68px;
  padding: 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.client-card .client-attention-item:hover {
  background: #fbfbfb;
}

.client-card .client-attention-item > span,
.client-card .client-attention-item.is-important > span {
  width: 36px;
  height: 36px;
  color: var(--muted);
  background: var(--paper);
}

.client-card .client-attention-item.is-important > span {
  color: #fff;
  background: var(--ink);
}

.client-card .client-all-clear {
  min-height: 0;
  padding: 20px 0 0;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.client-card .client-all-clear > span {
  width: auto;
  height: auto;
  color: var(--soft);
  background: transparent;
}

.client-mcp-access {
  padding: 18px 0 0;
  border: 0;
}

.client-mcp-access__icon {
  display: none;
}

.client-mcp-access__copy p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.info-item > span {
  color: var(--label);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.info-item strong,
.info-item a {
  font-size: 14px;
  font-weight: 500;
}

/* ── Configuración ──────────────────────────────────────────────────── */

.mcp-settings,
.mcp-admin-settings {
  display: grid;
  gap: 0;
  margin: 0;
}

.mcp-settings {
  margin-top: 28px;
}

.settings-section,
.mcp-admin-settings > .panel,
.api-reference {
  margin: 0 0 48px;
}

.settings-endpoint,
.api-reference__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 10px 10px 10px 18px;
  background: var(--paper);
  border: 0;
}

.settings-endpoint code {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-endpoint .button--small,
.api-reference__head .button--small {
  background: #fff;
}

.settings-note {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.settings-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 24px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.settings-steps li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  padding: 18px 24px 4px 0;
}

.settings-steps li > span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #fff;
  background: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.settings-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.settings-steps strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 620;
}

.mcp-personal-access {
  margin: 0 0 28px;
}

.mcp-panel-heading p {
  display: none;
}

.api-reference {
  background: transparent;
  border: 0;
}

.connection-list .table-wrap {
  margin-top: 24px;
}

/* ── Anchos menores ─────────────────────────────────────────────────── */

@media (max-width: 1120px) {
  .home-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 44px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-menu {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 30;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    color: #fff;
    background: #000;
    border: 0;
    font-size: 18px;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(var(--rail), 86vw);
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }

  body.nav-open .sidebar {
    transform: none;
  }

  .main {
    padding: 68px 12px 48px;
  }

  .main > .sr-only + .page-head,
  .home-hero,
  .client-hero,
  .client-hero.client-hero--compact {
    min-height: 0;
    flex-direction: column;
    padding: 24px 20px;
  }

  .metrics-grid,
  .stats-grid,
  .client-insights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric:nth-child(odd),
  .stats-grid .stat-card:nth-child(odd),
  .client-insights article:nth-child(odd) {
    border-left: 0;
  }

  .metric,
  .stats-grid .stat-card,
  .client-insights article {
    min-height: 112px;
  }

  .client-tab-heading--actions {
    margin: 0 0 20px;
    justify-content: flex-start;
  }

  .settings-steps {
    grid-template-columns: minmax(0, 1fr);
  }

  .toolbar .client-sort-select {
    margin-left: 0;
  }
}

/* ── Barra de lista: buscador desde su icono y filtros tras un botón ── */

.list-toolbar {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin: 0 0 8px;
}

.toolbar-search {
  display: flex;
  height: 44px;
  align-items: center;
  border-bottom: 1px solid transparent;
  cursor: text;
  transition: border-color 160ms ease;
}

.toolbar-search__icon,
.icon-button {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--ink);
  background: transparent;
  border: 0;
  font-size: 19px;
}

.toolbar-search__icon {
  cursor: pointer;
}

.toolbar-search__input {
  width: 0;
  min-width: 0;
  height: 44px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  font-size: 14px;
  opacity: 0;
  transition: width 220ms cubic-bezier(0.16, 1, 0.3, 1), opacity 160ms ease;
}

.toolbar-search__input::placeholder {
  color: var(--soft);
}

.toolbar-search:focus-within,
.toolbar-search:has(.toolbar-search__input:not(:placeholder-shown)) {
  border-bottom-color: var(--ink);
}

.toolbar-search:focus-within .toolbar-search__input,
.toolbar-search__input:not(:placeholder-shown) {
  width: min(320px, 52vw);
  padding-right: 8px;
  opacity: 1;
}

.icon-button:hover,
.toolbar-search__icon:hover,
.icon-button[aria-expanded='true'] {
  background: var(--fill);
}

.icon-button em {
  position: absolute;
  top: 6px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  color: #fff;
  background: var(--ink);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.toolbar-filter {
  position: relative;
}

.filter-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  width: 288px;
  gap: 16px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--line-strong);
}

.filter-popover[hidden] {
  display: none;
}

.filter-field {
  display: grid;
  gap: 7px;
}

.filter-field > span {
  color: var(--label);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.filter-field .filter-select {
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background-color: var(--fill);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 450;
}

.filter-field .filter-select:focus {
  background-color: #fff;
  border-color: var(--muted);
}

/* Las cifras no se parten en filas desiguales. */
.stats-grid,
.client-insights {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

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

  .metrics-grid .metric:nth-child(4) {
    border-left: 0;
  }
}

@media (max-width: 820px) {
  .stats-grid,
  .client-insights,
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics-grid .metric:nth-child(4) {
    border-left: 1px solid var(--line);
  }
}

.metric span,
.stat-card__top,
.client-insights article > span:first-child {
  font-size: 11px;
  line-height: 1.35;
}

/* ── Ficha de cliente por apartados ─────────────────────────────────── */

.client-mcp-access {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
}

.client-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 56px;
}

.client-profile-body {
  padding: 22px 0 0;
}

.client-profile-body .info-grid {
  gap: 24px 48px;
}

.client-profile-body .profile-summary {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.client-tabs {
  max-width: 100%;
  overflow-x: auto;
}

.client-tabs .client-tab {
  white-space: nowrap;
}

.button--danger {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
}

.button--danger:hover {
  color: #fff;
  background: var(--ink);
}

.client-tab-heading--actions .page-actions {
  gap: 8px;
}

@media (max-width: 820px) {
  .client-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── Escala única de la ficha ───────────────────────────────────────────
   Título de fila 14/600 · secundario 12 gris · etiqueta 12 versalitas ·
   valor 14/500 · filas de 68px con 16/12 de aire. Nada fuera de esto. */

.client-tab-panel .list-row,
.client-tab-panel .access-person-row,
.client-tab-panel .invitation-row,
.client-tab-panel .procedure,
.client-tab-panel .client-assignment-row,
.client-tab-panel .timeline-item {
  min-height: 68px;
  margin: 0;
  padding: 16px 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.client-tab-panel .access-person-row,
.client-tab-panel .invitation-row,
.client-tab-panel .client-assignment-row {
  align-items: center;
}

.client-tab-panel .cell-main strong,
.client-tab-panel .invitation-row strong,
.client-tab-panel .procedure__title,
.client-tab-panel .client-assignment-row__copy strong,
.client-tab-panel .timeline-item p,
.client-tab-panel .client-attention-item strong {
  display: block;
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 20px;
}

.client-tab-panel .timeline-item p {
  font-weight: 450;
}

.client-tab-panel .timeline-item p strong {
  display: inline;
}

.client-tab-panel .cell-main small,
.client-tab-panel .invitation-row span,
.client-tab-panel .procedure__description,
.client-tab-panel .procedure__meta,
.client-tab-panel .timeline-item span:not(.timeline-dot),
.client-tab-panel .client-attention-item small,
.client-tab-panel .row-end,
.client-tab-panel .row-end strong,
.client-tab-panel .row-end span,
.client-tab-panel .row-end small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
  letter-spacing: 0;
  line-height: 17px;
}

.client-tab-panel .row-end strong {
  color: var(--ink);
  font-weight: 500;
}

.client-tab-panel .client-assignment-row__copy > span,
.client-tab-panel .info-item > span,
.client-tab-panel .profile-summary > div > span,
.system-context-grid > div > span {
  display: block;
  margin: 0 0 7px;
  color: var(--label);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0.08em;
  line-height: 16px;
  text-transform: uppercase;
}

.client-tab-panel .info-item strong,
.client-tab-panel .info-item a,
.system-context-grid > div > strong {
  display: block;
  padding-left: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.client-tab-panel .compact-tags {
  gap: 6px;
  margin-top: 8px;
}

.client-tab-panel .compact-tags:empty {
  display: none;
}

.client-tab-panel .compact-tags span,
.client-tab-panel .assignment-chip {
  padding: 3px 8px;
  color: #3f3f3b;
  background: var(--paper);
  border: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

.client-tab-panel .timeline {
  padding: 0;
}

.client-tab-panel .timeline::before {
  content: none;
}

.client-tab-panel .timeline-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.client-tab-panel .timeline-dot {
  position: static;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  background: var(--ink);
  border: 0;
}

.client-tab-panel .access-person-row__end {
  gap: 20px;
}

.client-tab-panel .button--small {
  min-height: 36px;
  font-size: 13px;
}

/* Tablas de la ficha: misma rejilla que Clientes. */
.client-tab-panel .data-table td,
.client-tab-panel .data-table th {
  padding-left: 12px;
  padding-right: 12px;
}

.client-systems-table {
  min-width: 920px;
}

.client-system-row {
  cursor: pointer;
}

.client-system-row td strong {
  font-size: 13px;
  font-weight: 600;
}

.client-systems-table td:first-child {
  min-width: 220px;
}

.client-systems-table tr:not(.client-system-detail-row) td:last-child {
  width: 60px;
  text-align: right;
}

/* ── Ficha del sistema (modal) ──────────────────────────────────────── */

.modal.modal--system {
  width: min(760px, calc(100vw - 32px));
}

.modal__head h2 {
  font-size: 20px;
  font-weight: 630;
  letter-spacing: -0.01em;
}

.modal--system .client-system-detail {
  padding: 0;
  background: transparent;
  border: 0;
}

.client-system-detail__purpose {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.modal--system .system-context-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 40px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
}

.modal--system .system-context-grid > div {
  padding: 0;
  background: transparent;
  border: 0;
}

.modal--system .review-note {
  margin: 24px 0 0;
  padding: 16px 18px;
  background: var(--paper);
  border: 0;
  font-size: 14px;
}

.modal--system .review-note p {
  margin: 6px 0 0;
  color: var(--muted);
}

.modal--system .system-decision-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 28px 0 0;
  padding: 20px 0 0;
  border-top: 1px solid var(--line);
}

@media (max-width: 620px) {
  .modal--system .system-context-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.client-columns > * {
  min-width: 0;
}

.client-tab-heading--actions {
  margin: 0 0 24px;
}

@media (min-width: 1240px) {
  .client-tab-heading--actions {
    margin: -72px 0 28px;
  }
}

@media (max-width: 1239px) {
  .client-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .client-tabs {
    margin-bottom: 20px;
  }
}

/* Todo el contenido de una sección alinea con su título: sin sangrías heredadas. */
.client-tab-panel .client-card > .client-section-heading + div,
.client-tab-panel .client-assignment-list {
  padding-right: 0 !important;
  padding-left: 0 !important;
}

.client-tab-panel .client-card > .client-profile-body {
  padding: 22px 0 0 !important;
}

.client-tab-panel .client-card > .table-wrap {
  padding-top: 8px !important;
}

/* ── Ficha: menos líneas ────────────────────────────────────────────────
   Los bloques se separan por fondo y aire, no por reglas. Solo las tablas
   y las listas largas conservan un filete entre filas. */

.client-tab-panel .client-section-heading,
.client-tab-panel .client-card .client-section-heading {
  padding: 0 0 14px;
  border-bottom: 0;
}

.client-tab-panel .client-section-heading h3 {
  font-size: 15px;
  font-weight: 600;
}

.client-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 44px;
}

.client-facts article {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  background: var(--paper);
}

.client-facts article > span {
  color: var(--label);
  font-size: 12px;
  font-weight: 500;
}

.client-facts article > strong {
  color: var(--ink);
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 28px;
}

.client-facts article > small {
  margin-top: -14px;
  color: var(--muted);
  font-size: 12px;
}

.client-tab-panel .client-attention-list,
.client-tab-panel .client-assignment-list {
  display: grid;
  gap: 8px;
}

.client-tab-panel .client-card .client-attention-item,
.client-tab-panel .client-assignment-row {
  display: grid;
  min-height: 64px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px 14px 12px 20px;
  background: var(--paper);
  border: 0;
  text-align: left;
}

.client-tab-panel .client-card .client-attention-item {
  grid-template-columns: 20px minmax(0, 1fr) 20px;
  padding-right: 20px;
}

.client-tab-panel .client-card .client-attention-item:hover {
  background: #ecece7;
}

.client-tab-panel .client-card .client-attention-item > span,
.client-tab-panel .client-card .client-attention-item.is-important > span {
  width: 20px;
  height: 20px;
  color: var(--ink);
  background: transparent;
  font-size: 17px;
}

.client-attention-item__go {
  color: var(--soft);
  font-size: 16px;
  font-style: normal;
}

.client-tab-panel .client-card .client-all-clear {
  min-height: 64px;
  padding: 0 20px;
  background: var(--paper);
}

.client-tab-panel .client-assignment-row__copy > span {
  margin: 0 0 3px;
  color: var(--label);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.client-tab-panel .client-assignment-row .button--small {
  background: #fff;
}

/* Tipografía más suave: pesos medios en lugar de negritas. */
.client-tab-panel .cell-main strong,
.client-tab-panel .invitation-row strong,
.client-tab-panel .procedure__title,
.client-tab-panel .client-assignment-row__copy strong,
.client-tab-panel .client-attention-item strong {
  font-size: 14px;
  font-weight: 550;
}

.client-tab-panel .info-item > span,
.client-tab-panel .profile-summary > div > span,
.system-context-grid > div > span {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.client-tab-panel .list-row:last-child,
.client-tab-panel .access-person-row:last-child,
.client-tab-panel .timeline-item:last-child,
.client-tab-panel .data-table tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 1239px) {
  .client-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.client-facts article {
  position: relative;
}

.client-facts article > small {
  position: absolute;
  right: 22px;
  bottom: 25px;
  margin: 0;
}

/* Los datos del cliente van en una línea dentro de la cabecera, como en Compliance. */
.client-hero__facts {
  margin: 7px 0 0;
  color: #a3a3a3;
  font-size: 14px;
  line-height: 19px;
}

.client-hero__meta {
  color: rgba(255, 255, 255, 0.72);
}

.client-tabs {
  margin-bottom: 36px;
}

/* ── MCP y Configuración por apartados ──────────────────────────────── */

.settings-body {
  max-width: 920px;
}

.settings-body .mcp-settings {
  margin-top: 0;
}

.settings-body .panel__head {
  padding: 0 0 14px;
  border-bottom: 0;
}

.settings-body .panel__head h3 {
  font-size: 15px;
  font-weight: 600;
}

.settings-body .settings-endpoint {
  margin-top: 0;
  padding: 12px 12px 12px 20px;
}

.settings-body .settings-steps {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  border-top: 0;
}

.settings-body .settings-steps li {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 20px;
  background: var(--paper);
}

.settings-body .settings-steps strong {
  font-weight: 550;
}

.settings-body .connection-list .table-wrap {
  margin-top: 0;
}

.settings-body .api-reference__head {
  margin-top: 0;
}

/* Instrucciones */
.mcp-prompt-form {
  display: grid;
  gap: 12px;
  padding: 0;
}

.mcp-prompt-field textarea {
  width: 100%;
  min-height: 220px;
  padding: 16px 18px;
  color: var(--ink);
  background: var(--fill);
  border: 1px solid transparent;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}

.mcp-prompt-field textarea:focus {
  background: #fff;
  border-color: var(--muted);
}

.mcp-prompt-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
}

.mcp-prompt-meta p {
  margin: 0;
}

.mcp-security-note {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 14px;
  margin: 8px 0 0;
  padding: 18px 20px;
  background: var(--paper);
  border: 0;
}

.mcp-security-note > span {
  width: 20px;
  height: 20px;
  color: var(--ink);
  background: transparent;
  font-size: 17px;
}

.mcp-security-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.mcp-security-note strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
}

.mcp-prompt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
}

.mcp-prompt-actions p {
  display: grid;
  gap: 2px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.mcp-prompt-actions p strong {
  color: var(--label);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.mcp-access-footnote {
  margin: 16px 0 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 12px;
}

.settings-body:has(.mcp-access-panel),
.settings-body:has(.connection-list) {
  max-width: none;
}

.mcp-users-table {
  min-width: 860px;
}

@media (max-width: 820px) {
  .settings-body .settings-steps {
    grid-template-columns: minmax(0, 1fr);
  }
}

.mcp-prompt-meta p,
.mcp-prompt-meta span,
.mcp-prompt-actions p span {
  font-size: 12px;
}

/* ── Facturas del cliente ─────────────────────────────────────────────── */
.invoice-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: -8px 0 26px;
  color: var(--muted);
  font-size: 13px;
}

.invoice-summary span + span::before {
  content: '·';
  margin-right: 22px;
  color: var(--soft);
}

.invoice-table th.is-amount,
.invoice-table td.is-amount {
  text-align: right;
}

.invoice-table td.invoice-actions {
  white-space: nowrap;
  text-align: right;
}

.invoice-table td.invoice-actions > * {
  vertical-align: middle;
  margin-left: 8px;
}

.invoice-delivery {
  display: grid;
  gap: 2px;
}

.invoice-delivery small {
  color: var(--soft);
}

.modal--invoice {
  width: min(720px, calc(100vw - 32px));
}

/* Nueva remesa: la lista de facturas con empresa, CIF, IBAN y estado en una línea. */
.modal--remittance {
  width: min(1040px, calc(100vw - 32px));
}

.invoice-lines {
  display: grid;
  gap: 10px;
  margin: 6px 0 12px;
}

.invoice-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 132px 32px;
  gap: 10px;
  align-items: end;
}

.invoice-line .field {
  margin: 0;
}

.invoice-line__remove {
  margin-bottom: 6px;
}

.invoice-tax-row {
  align-items: end;
  margin-top: 18px;
}

.invoice-tax-row .field {
  flex: 0 0 150px;
  max-width: 150px;
}

.invoice-tax-row .invoice-total-preview {
  flex: 1 1 auto;
}

.invoice-total-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  justify-content: flex-end;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.invoice-total-preview strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--soft);
  font-size: 12px;
}

@media (max-width: 640px) {
  .invoice-line {
    grid-template-columns: minmax(0, 1fr) 80px;
  }
  .invoice-line__price {
    grid-column: 1;
  }
}

/* ── Facturación ────────────────────────────────────────────────────── */

.billing-tabs {
  max-width: 100%;
  overflow-x: auto;
}

.billing-tabs .client-tab {
  white-space: nowrap;
}

.billing-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 8px 0 24px;
}

.billing-bar .client-tabs {
  margin: 0;
}

.billing-bar__tools {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.billing-bar__tools .toolbar {
  flex-direction: row;
  margin: 0;
}

.billing-bar__tools > .billing-year {
  flex: 0 0 104px;
}

.billing-bar__tools > .billing-year--month {
  flex-basis: 160px;
}

.billing-bar__tools .billing-year .filter-select {
  width: 100%;
  min-height: 44px;
  height: 44px;
  color: var(--ink);
  background-color: var(--fill);
  border: 1px solid transparent;
  font-size: 14px;
}

.billing-bar__tools > .button {
  flex: 0 0 auto;
}

/* Estado de la lectura del CRM. */
.billing-sync {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -8px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.billing-sync__dot {
  width: 7px;
  height: 7px;
  background: var(--ink);
  border-radius: 50%;
}

.billing-sync__dot.is-running {
  animation: billing-pulse 1s ease-in-out infinite alternate;
}

@keyframes billing-pulse {
  to { opacity: 0.25; }
}

.billing-link {
  padding: 0;
  color: var(--ink);
  background: none;
  border: 0;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Contiene el texto sr-only (absoluto) de las cabeceras dentro del desplazamiento. */
.billing .table-wrap {
  position: relative;
  overflow-x: auto;
}

.billing-table {
  min-width: 760px;
}

.billing-table th.is-amount,
.billing-table td.is-amount {
  text-align: right;
}

.billing-table td {
  vertical-align: middle;
}

.billing-table td > strong,
.billing-table td > .table-note {
  display: block;
}

.billing-table .table-note {
  margin-top: 3px;
  color: var(--soft);
  font-size: 12px;
}

.billing-row {
  cursor: pointer;
}

.billing-row:focus-visible td {
  background: #f1f1ec;
  outline: none;
}

/* Tabla común: filas de una línea, cabeceras ordenables y total al pie. */
.billing-table td {
  height: 48px;
  padding-top: 10px;
  padding-bottom: 10px;
  background: #fff;
  border-bottom-color: #f0f0ee;
}

.billing-table tbody tr.billing-row:hover td {
  background: #f7f7f5;
}

.billing-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.billing-sort .ui-icon {
  color: #c4c4bf;
  font-size: 12px;
}

.billing-sort:hover,
.billing-sort.is-active,
.billing-sort.is-active .ui-icon {
  color: var(--ink);
}

.billing-table th.is-amount .billing-sort {
  flex-direction: row-reverse;
}

.billing-table tfoot td {
  height: 44px;
  color: var(--muted);
  background: #fff;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  font-size: 13px;
}

.billing-table tfoot td.is-amount strong {
  color: var(--ink);
}

.billing-table td.billing-col-company {
  min-width: 200px;
}

.billing-company {
  color: var(--ink);
  font-size: 13px;
  font-weight: 560;
  text-decoration: none;
}

a.billing-company:hover,
a.billing-company:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.billing-table tbody tr.is-selected td {
  background: #f7f7f5;
}

.billing-cell-note {
  display: block;
  margin-top: 2px;
  color: var(--soft);
  font-size: 12px;
}

.billing-link--soft {
  color: var(--muted);
  font-weight: 500;
}

/* Estados: solo lo que pide atención lleva color (amarillo pendiente, rojo devuelto o vencido). */
.billing-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  color: var(--muted);
  background: #f4f4f2;
  font-size: 12px;
  font-weight: 560;
  white-space: nowrap;
}

.billing-pill--warning {
  color: #854d0e;
  background: #fef3c7;
}

.billing-pill--danger {
  color: #b42318;
  background: #fee4e2;
}

.billing-pill--muted {
  color: var(--soft);
  background: transparent;
  padding: 0;
}

.billing-amount--danger {
  color: #b42318;
}

.modal .billing-hero-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.modal .billing-hero-figures strong {
  color: var(--ink);
}

.page-head .billing-hero-figures .billing-amount--danger {
  color: #fda29b;
}

.remittance-actions {
  margin-top: 0;
}

.remittance-actions__date {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.remittance-actions__date input {
  height: 44px;
  min-height: 44px;
  color: var(--ink);
  background-color: var(--fill);
  border: 1px solid transparent;
  font-size: 14px;
}

.billing-iban {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.billing-soft {
  color: var(--soft);
}

/* Territorio sin IVA (Canarias, Ceuta y Melilla), como etiqueta delante del importe. */
.billing-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-right: 8px;
  padding: 0 6px;
  color: var(--muted);
  background: #f4f4f2;
  font-size: 12px;
  font-weight: 560;
  white-space: nowrap;
  vertical-align: 1px;
}

.billing-table td.is-amount > strong {
  display: inline;
}

/* Cifras del año dentro de la cabecera negra, bajo el estado de la emisión. */
.page-head .billing-hero-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 14px 0 0;
  color: #a3a3a3;
  font-size: 14px;
}

.page-head .billing-hero-figures strong,
.page-head .billing-hero-figures span:first-child {
  color: #fff;
  font-weight: 620;
}

.billing-nowrap,
.billing-table td.billing-nowrap,
.billing-table td.is-amount,
.billing-table td .table-note {
  white-space: nowrap;
}

.billing-table td.billing-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.billing-table tr.is-cancelled td {
  color: var(--soft);
}

.billing-table tr.is-cancelled strong {
  color: var(--soft);
  text-decoration: line-through;
}

.billing-check {
  width: 44px;
}

.billing-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--ink);
}

.billing-modal-lead {
  margin: 0 0 20px;
}

.billing-modal-table {
  max-height: 52vh;
  overflow: auto;
}

.billing-modal-table .billing-table {
  min-width: 560px;
}

.billing-modal-actions {
  align-items: center;
}

.billing-modal-actions .invoice-total-preview {
  margin: 0 auto 0 0;
}

.badge--returned {
  color: var(--ink);
  font-weight: 600;
}

.billing-table .badge,
.invoice-viewer__bar .badge {
  gap: 0;
}

.billing-table .badge::before,
.invoice-viewer__bar .badge::before {
  content: none;
}

/* Visor de factura: la hoja como en el PDF sobre fondo gris. */
/* Visor pequeño: la hoja entera cabe en pantalla. */
.modal--invoice-viewer {
  width: min(560px, calc(100vw - 32px));
}

.invoice-viewer__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
}

.invoice-viewer__bar > span {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}

.invoice-viewer__bar small {
  color: var(--muted);
  font-size: 12px;
}

.invoice-viewer__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.invoice-viewer__mat {
  padding: 16px;
  background: #ededea;
}

.invoice-viewer__mat .invoice-sheet {
  zoom: 0.64;
}

.invoice-sheet {
  display: flex;
  flex-direction: column;
  max-width: 720px;
  min-height: 900px;
  margin: 0 auto;
  padding: 44px 40px 24px;
  color: #1f1f1f;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
  font-size: 13px;
  line-height: 1.45;
}

.invoice-sheet address {
  display: grid;
  font-style: normal;
}

.invoice-sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

/* El logotipo del raíl es blanco: en la hoja se invierte a tinta. */
.invoice-sheet__logo {
  width: 170px;
  height: auto;
  margin-top: 4px;
  filter: invert(1);
}

.invoice-sheet__issuer {
  text-align: right;
}

.invoice-sheet strong {
  color: #111;
  font-weight: 650;
}

.invoice-sheet__meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  margin: 44px 0 72px;
}

.invoice-sheet__customer em {
  color: #6b6b6b;
  font-style: normal;
  font-weight: 550;
}

.invoice-sheet__facts,
.invoice-sheet__totals {
  display: grid;
  gap: 2px;
  margin: 0;
}

.invoice-sheet__facts div,
.invoice-sheet__totals div {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.invoice-sheet__facts dt {
  color: #111;
  font-weight: 650;
}

.invoice-sheet__facts dd,
.invoice-sheet__totals dd {
  margin: 0;
}

.invoice-sheet__lines {
  width: 100%;
  border-collapse: collapse;
}

.invoice-sheet__lines th {
  padding: 9px 12px;
  color: #fff;
  background: #111;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-align: left;
  text-transform: uppercase;
}

.invoice-sheet__lines th:last-child,
.invoice-sheet__lines td:last-child {
  width: 130px;
  text-align: right;
  white-space: nowrap;
}

.invoice-sheet__lines td {
  padding: 10px 12px 4px;
  vertical-align: top;
}

/* Totales en la parte baja de la hoja, encima de la forma de pago. */
.invoice-sheet__totals {
  gap: 10px;
  margin: auto 12px 0 auto;
  padding-top: 40px;
}

.invoice-sheet__totals dt {
  min-width: 160px;
  color: #111;
  font-weight: 650;
  text-align: right;
}

.invoice-sheet__totals dd {
  min-width: 110px;
  color: #111;
  font-weight: 650;
  text-align: right;
}

.invoice-sheet__total dt,
.invoice-sheet__total dd {
  font-size: 15px;
}

.invoice-sheet__notes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 40px;
  color: #6b6b6b;
  font-size: 12px;
}

.invoice-sheet__notes div {
  display: grid;
  align-content: start;
}

.invoice-sheet__notes strong {
  font-size: 12px;
}

.invoice-sheet__foot {
  padding-top: 40px;
  color: #6b6b6b;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 1020px) {
  .billing .table-wrap {
    display: block;
  }
}

@media (max-width: 720px) {

  .invoice-viewer__mat {
    padding: 0;
  }

  .invoice-sheet {
    min-height: 0;
    padding: 24px 18px;
  }

  .invoice-sheet__head,
  .invoice-sheet__meta {
    flex-direction: column;
    gap: 16px;
  }

  .invoice-sheet__issuer {
    text-align: left;
  }

  .invoice-sheet__meta {
    margin: 24px 0 32px;
  }

  .invoice-sheet__facts div {
    justify-content: flex-start;
  }

  .invoice-sheet__notes {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .invoice-sheet__logo {
    width: 120px;
  }

}

.billing-sync--note {
  margin-top: 0;
}

@media (max-width: 620px) {
  .billing-bar__tools {
    flex-basis: 100%;
    justify-content: flex-start;
  }
}

.billing-bar__tools .icon-button {
  flex: 0 0 auto;
}

.billing-row--draft td {
  background: #fff;
}

.billing-list--files {
  margin-top: 40px;
}

.billing-list__title {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 620;
}

/* Detalle de una remesa. */
.remittance-detail__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin: 8px 0 20px;
}

.remittance-detail__top .back-link {
  margin: 0;
}

.remittance-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--soft);
  font-size: 13px;
}

.remittance-progress li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.remittance-progress li span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid #d4d4d0;
  font-size: 12px;
  font-weight: 650;
}

.remittance-progress li span .ui-icon {
  font-size: 13px;
}

.remittance-progress .is-done {
  color: var(--muted);
}

.remittance-progress .is-done span {
  color: #fff;
  background: var(--muted);
  border-color: var(--muted);
}

.remittance-progress .is-current {
  color: var(--ink);
  font-weight: 600;
}

.remittance-progress .is-current span {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.remittance-detail__hash {
  margin: 10px 0 0;
  color: var(--soft);
  font-size: 12px;
}

@media (max-width: 720px) {

  .remittance-actions__buttons {
    justify-content: flex-start;
  }
}

.field small.billing-issue__hint,
.modal .field small.billing-issue__hint {
  margin-top: 6px;
  color: var(--soft);
  font-size: 12px;
}
