/* ------------------------------------------------------------------ */
/* Tokens                                                             */
/* ------------------------------------------------------------------ */

:root {
  color-scheme: light;
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --bg: #fbfbf9;
  --surface: #ffffff;
  --surface-sunken: #f5f4f0;
  --ink: #1b1a17;
  --ink-soft: #3d3b36;
  --muted: #7a776f;
  --subtle: #a9a69d;
  --line: #e8e6e0;
  --line-soft: #f0eee9;
  --line-strong: #d9d6ce;
  --row-hover: #f6f5f1;
  --hover: rgba(27, 26, 23, 0.05);

  --accent: #1f6b55;
  --accent-hover: #185744;
  --accent-soft: #e7f1ec;
  --accent-ink: #ffffff;
  --danger: #b23a2a;
  --danger-soft: #fcebe7;

  --shadow-float: 0 1px 2px rgba(27, 26, 23, 0.04), 0 8px 24px -10px rgba(27, 26, 23, 0.14);
  --shadow-lg: 0 18px 50px -12px rgba(27, 26, 23, 0.22), 0 4px 12px rgba(27, 26, 23, 0.06);

  --tone-0: #3f9b7a;
  --tone-1: #4a78d6;
  --tone-2: #d39a2b;
  --tone-3: #d4587a;
  --tone-4: #8a6ad6;
  --tone-5: #2ea3b5;

  /* Tono propio de cada categoría (category.color) */
  --cat-0: #2f8f6f;
  --cat-1: #3b6fd8;
  --cat-2: #c98516;
  --cat-3: #cf4a6c;
  --cat-4: #7a5bd1;
  --cat-5: #1f97ab;
  --cat-6: #dc6436;
  --cat-7: #6f8a1f;

  --radius-sm: 6px;
  --radius: 10px;

  /* Lenguaje común de Bob (Finance y Passwords): paneles y filas de lista */
  --panel-radius: 14px;
  --panel-border: 1px solid rgba(27, 26, 23, 0.06);
  --panel-shadow: 0 1px 2px rgba(27, 26, 23, 0.025);
  --panel-shadow-raised: 0 1px 2px rgba(27, 26, 23, 0.03), 0 10px 30px -18px rgba(27, 26, 23, 0.16);
  --panel-padding: 32px;
  --panel-gap: 16px;
  --list-item-radius: 10px;
  --list-item-padding: 10px;
  --tile-size: 34px;
  --tile-radius: 9px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ------------------------------------------------------------------ */
/* Base                                                               */
/* ------------------------------------------------------------------ */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

/* Reserva siempre el hueco de la barra de scroll vertical: así el contenido no
   se desplaza al pasar de una categoría corta a una larga. */
html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  flex: 0 0 auto;
}

kbd {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--subtle);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
}

/* ------------------------------------------------------------------ */
/* Botones                                                            */
/* ------------------------------------------------------------------ */

.button {
  display: inline-flex;
  height: 32px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition:
    background-color 140ms var(--ease),
    border-color 140ms var(--ease),
    color 140ms var(--ease);
}

.button.small {
  height: 30px;
  padding: 0 11px;
}

.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.button.danger {
  background: var(--danger);
  color: #ffffff;
}

.button.danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 85%, var(--ink));
}

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

.button.ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--ink);
}

.icon-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--subtle);
  transition:
    background-color 140ms var(--ease),
    color 140ms var(--ease);
}

.icon-button.small {
  width: 26px;
  height: 26px;
}

.icon-button:hover {
  background: var(--hover);
  color: var(--ink);
}

.icon-button.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ------------------------------------------------------------------ */
/* Navegación de categorías (tab bar flotante)                        */
/* ------------------------------------------------------------------ */

/* Izquierda (semáforos de macOS en escritorio) · centro (categorías, centradas
   respecto a la ventana) · derecha (datos). Las columnas laterales son iguales. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 0;
  pointer-events: none;
}

.topbar-center {
  display: flex;
  min-width: 0;
  justify-content: center;
}

.topbar-end {
  display: flex;
  justify-content: flex-end;
}

.topbar-button {
  display: inline-flex;
  height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-float);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  pointer-events: auto;
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  transition:
    color 140ms var(--ease),
    border-color 140ms var(--ease);
}

.topbar-button .icon {
  color: var(--accent);
}

.topbar-button:hover,
.topbar-button[aria-expanded="true"] {
  border-color: var(--line-strong);
  color: var(--ink);
}

/* En ventanas estrechas el botón de datos se queda solo con el icono. */
@media (max-width: 1080px) {
  .topbar-button {
    width: 44px;
    justify-content: center;
    padding: 0;
  }
}

.data-menu {
  width: 272px;
}

.tabbar {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  pointer-events: auto;
}

.tabbar-tabs {
  display: flex;
  min-width: 0;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabbar-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  height: 34px;
  flex: 0 0 auto;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--muted);
  transition:
    background-color 180ms var(--ease),
    color 180ms var(--ease),
    padding 220ms var(--ease);
}

.tab:hover {
  background: var(--hover);
  color: var(--ink);
}

.tab:focus-visible {
  outline-offset: -2px;
}

.tab {
  --cat: var(--accent);
}

.tab .icon {
  color: color-mix(in srgb, var(--cat) 78%, var(--muted));
  transition: color 180ms var(--ease);
}

.tab:hover {
  background: color-mix(in srgb, var(--cat) 8%, transparent);
}

.tab.is-active {
  padding-right: 13px;
  background: color-mix(in srgb, var(--cat) 13%, var(--surface));
  color: color-mix(in srgb, var(--cat) 82%, var(--ink));
}

.tab.is-active .icon {
  color: var(--cat);
}

.cat-tone-0 { --cat: var(--cat-0); }
.cat-tone-1 { --cat: var(--cat-1); }
.cat-tone-2 { --cat: var(--cat-2); }
.cat-tone-3 { --cat: var(--cat-3); }
.cat-tone-4 { --cat: var(--cat-4); }
.cat-tone-5 { --cat: var(--cat-5); }
.cat-tone-6 { --cat: var(--cat-6); }
.cat-tone-7 { --cat: var(--cat-7); }

/* Las categorías solo muestran su icono (el nombre va en el tooltip);
   General muestra icono y nombre. La barra mide siempre lo mismo. */
.tab-icon {
  width: 34px;
  justify-content: center;
  padding: 0;
}

.tab.tab-icon.is-active {
  padding: 0;
}

.tab-overview {
  gap: 7px;
  padding: 0 13px 0 10px;
}

.tab.tab-overview.is-active {
  padding-right: 13px;
}

.tab-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

/* Tooltip discreto (components/Tooltip.js). */
.tooltip {
  position: fixed;
  z-index: 80;
  max-width: 260px;
  padding: 5px 9px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  box-shadow: 0 4px 14px rgba(20, 20, 18, 0.16);
  color: #ffffff;
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  animation: fade-in 120ms var(--ease) both;
}

.tooltip strong {
  display: block;
  font-weight: 600;
}

.tooltip.is-rich {
  padding: 7px 10px;
}

.tooltip span {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.72);
}

.tabbar-divider {
  width: 1px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0 4px;
  background: var(--line);
}

.tab-add {
  color: var(--subtle);
}

.tab-add:hover {
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Página y métricas                                                  */
/* ------------------------------------------------------------------ */

.page {
  width: 100%;
  padding: 44px 24px 96px;
}

/* Superficie blanca compartida: contenedor de tabla y lista de General. */
.surface {
  border: var(--panel-border);
  border-radius: var(--panel-radius);
  background: var(--surface);
  box-shadow: var(--panel-shadow);
}

/* ------------------------------------------------------------------ */
/* Lenguaje común: filas de lista y baldosas (components/shared/)     */
/* Lista de General (Finance) y lista de Passwords.                   */
/* ------------------------------------------------------------------ */

.bob-list-item {
  border-radius: var(--list-item-radius);
  transition: background-color 140ms var(--ease);
}

.bob-list-item:hover {
  background: var(--row-hover);
}

.bob-list-item[aria-selected="true"] {
  background: var(--accent-soft);
}

.bob-tile {
  display: inline-grid;
  width: var(--tile-size);
  height: var(--tile-size);
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--tile-radius);
  background: color-mix(in srgb, var(--cat, var(--accent)) 12%, var(--surface));
  color: var(--cat, var(--accent));
  font-size: 14px;
  font-weight: 650;
  transition: background-color 140ms var(--ease);
}

.bob-list-item:hover .bob-tile {
  background: color-mix(in srgb, var(--cat, var(--accent)) 20%, var(--surface));
}

.bob-list-text {
  display: grid;
  min-width: 0;
}

.bob-list-title,
.bob-list-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bob-list-title {
  color: var(--ink);
  font-weight: 550;
}

.bob-list-subtitle {
  color: var(--muted);
  font-size: 12.5px;
}

.boot-error {
  margin: 120px auto;
  color: var(--muted);
  text-align: center;
}

/* Cuatro huecos de ancho fijo: las cifras cambian sin mover nada. */
.metrics {
  display: grid;
  width: min(680px, 100%);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 auto 40px;
}

.metric {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 2px 12px;
}

.metric + .metric {
  border-left: 1px solid var(--line);
}

.metric-value {
  max-width: 100%;
  overflow: hidden;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------ */
/* Vista General                                                      */
/* ------------------------------------------------------------------ */

.overview {
  display: grid;
  justify-items: center;
  gap: 32px;
}

.overview-list {
  width: min(620px, 100%);
  margin: 0;
  padding: 6px;
  list-style: none;
}

.overview-list li + li {
  box-shadow: inset 0 1px 0 var(--line-soft);
}

.overview-row {
  display: grid;
  width: 100%;
  grid-template-columns: var(--tile-size) minmax(0, 1fr) auto 56px 16px;
  align-items: center;
  gap: 14px;
  padding: var(--list-item-padding) var(--list-item-padding) var(--list-item-padding) 8px;
  text-align: left;
}

.overview-row:focus-visible {
  outline-offset: -2px;
}

.overview-name {
  overflow: hidden;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.overview-amount small {
  margin-left: 4px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 500;
}

.overview-share {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.overview-chevron {
  color: var(--subtle);
  opacity: 0;
  transform: translateX(-3px);
  transition:
    opacity 140ms var(--ease),
    transform 140ms var(--ease);
}

.overview-row:hover .overview-chevron,
.overview-row:focus-visible .overview-chevron {
  opacity: 1;
  transform: none;
}

.overview-section {
  display: grid;
  width: min(620px, 100%);
  gap: 10px;
}

.overview-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.overview-section-hint {
  color: var(--subtle);
  font-size: 12px;
}

.overview-hint {
  margin: 0;
  padding: 0 4px;
  color: var(--subtle);
  font-size: 12.5px;
}

.overview-more {
  justify-self: center;
}

/* Próximos pagos */
.payments-list {
  margin: 0;
  padding: 6px;
  list-style: none;
}

.payments-list li + li {
  box-shadow: inset 0 1px 0 var(--line-soft);
}

.payment-row {
  display: grid;
  width: 100%;
  grid-template-columns: 56px minmax(0, 1fr) auto 96px;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  text-align: left;
  transition: background-color 140ms var(--ease);
}

.payment-row:hover {
  background: var(--row-hover);
}

.payment-row:focus-visible {
  outline-offset: -2px;
}

.payment-date {
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.payment-name {
  display: grid;
  min-width: 0;
}

.payment-name span {
  overflow: hidden;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payment-name small {
  overflow: hidden;
  color: var(--subtle);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payment-when {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.payment-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Próximos meses: cobros reales previstos */
.forecast {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.forecast-month {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 14px 14px 12px;
}

.forecast-month + .forecast-month {
  box-shadow: inset 1px 0 0 var(--line-soft);
}

.forecast-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.forecast-month.is-current .forecast-label {
  color: var(--accent);
}

.forecast-amount {
  overflow: hidden;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forecast-bar {
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--line-soft);
}

.forecast-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--line-strong);
}

.forecast-month.is-current .forecast-bar span {
  background: var(--accent);
}

.forecast-count {
  color: var(--subtle);
  font-size: 11.5px;
}

.text-link {
  display: inline-flex;
  height: 30px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
  transition:
    background-color 140ms var(--ease),
    color 140ms var(--ease);
}

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

.confirm-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-warning .icon {
  margin-top: 1px;
}

.confirm-warning p {
  margin: 0;
  color: color-mix(in srgb, var(--danger) 80%, var(--ink));
  font-weight: 600;
  line-height: 1.45;
}

.confirm-details {
  display: grid;
  gap: 3px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

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

.import-confirm {
  display: grid;
  gap: 16px;
}

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

/* ------------------------------------------------------------------ */
/* Contenedor de la tabla                                             */
/* ------------------------------------------------------------------ */

.table-stage {
  display: flex;
  justify-content: center;
}

/* Anchura entre la mínima y la máxima de Configuración (--table-min-width y
   --table-max-width). Mientras se arrastran las asas (web), --table-width. Si la
   ventana es más estrecha que la mínima, la página se desplaza en horizontal. */
.table-surface {
  position: relative;
  width: min(var(--table-width, var(--table-max-width, 1500px)), 100%);
  min-width: var(--table-min-width, 600px);
  padding: 14px 20px 10px;
  transition: width 220ms var(--ease);
}

.table-surface.is-resizing {
  transition: none;
  user-select: none;
}

.table-host {
  min-width: 0;
}

.width-handle {
  position: absolute;
  top: 12px;
  bottom: 12px;
  z-index: 2;
  width: 16px;
  cursor: ew-resize;
  touch-action: none;
}

.width-handle.left {
  left: -8px;
}

.width-handle.right {
  right: -8px;
}

/* Línea sutil en el borde y un asa que sigue a la vista en tablas largas. */
.width-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 7px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 140ms var(--ease);
}

.width-grip {
  position: sticky;
  top: calc(50vh - 14px);
  display: block;
  width: 6px;
  height: 28px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-float);
  opacity: 0;
  transition:
    opacity 140ms var(--ease),
    border-color 140ms var(--ease),
    background-color 140ms var(--ease);
}

.table-surface:hover .width-grip,
.width-handle:focus-visible .width-grip,
.table-surface.is-resizing .width-grip {
  opacity: 1;
}

.width-handle:hover::before,
.width-handle:focus-visible::before,
.table-surface.is-resizing .width-handle::before {
  opacity: 0.35;
}

.width-handle:hover .width-grip,
.width-handle:focus-visible .width-grip,
.table-surface.is-resizing .width-grip {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.width-handle:focus-visible {
  outline: none;
}

.width-badge {
  position: absolute;
  top: -34px;
  left: 50%;
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--surface);
  font-size: 12px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition:
    opacity 140ms var(--ease),
    transform 140ms var(--ease);
}

.table-surface.is-resizing .width-badge {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------ */
/* Tabla                                                              */
/* ------------------------------------------------------------------ */

.expense-grid {
  width: 100%;
}

/* Sin filas, el grid no reserva hueco: el aviso va justo debajo. */
.expense-grid .ag-layout-auto-height .ag-grid-scrolling-rows,
.expense-grid .ag-layout-auto-height .ag-grid-pinned-right-rows,
.expense-grid .ag-layout-auto-height .ag-grid-pinned-left-rows {
  min-height: 0 !important;
}

.expense-grid .ag-cell {
  display: flex;
  align-items: center;
}

.expense-grid .ag-cell.is-numeric {
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
}

.expense-grid .ag-cell.is-calculated {
  font-weight: 600;
}

.expense-grid .ag-header-cell {
  padding-inline: 6px;
}

/* Los separadores de redimensionado solo aparecen al pasar por la cabecera. */
.expense-grid .ag-header-cell-resize::after {
  background: var(--line-strong);
  opacity: 0;
  transition: opacity 140ms var(--ease);
}

.expense-grid .ag-header:hover .ag-header-cell-resize::after {
  opacity: 1;
}

.column-header-button {
  display: flex;
  width: 100%;
  height: 28px;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  transition:
    background-color 140ms var(--ease),
    color 140ms var(--ease);
}

.column-header-button:hover,
.column-header-button[aria-expanded="true"] {
  background: var(--hover);
  color: var(--ink);
}

.column-type-icon {
  color: var(--subtle);
}

.column-type-icon.type-currency,
.column-type-icon.type-checkbox { color: color-mix(in srgb, var(--cat-0) 80%, var(--subtle)); }
.column-type-icon.type-date { color: color-mix(in srgb, var(--cat-1) 80%, var(--subtle)); }
.column-type-icon.type-tags { color: color-mix(in srgb, var(--cat-2) 80%, var(--subtle)); }
.column-type-icon.type-select { color: color-mix(in srgb, var(--cat-4) 80%, var(--subtle)); }
.column-type-icon.type-link { color: color-mix(in srgb, var(--cat-5) 80%, var(--subtle)); }
.column-type-icon.type-usage { color: color-mix(in srgb, var(--cat-6) 80%, var(--subtle)); }
.column-type-icon.type-formula { color: var(--accent); }

.column-header-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* El chevron solo aparece al pasar por encima y no ocupa sitio: así el
   título dispone de todo el ancho de la columna. */
.column-header-button {
  position: relative;
}

.column-chevron {
  position: absolute;
  top: 50%;
  right: 4px;
  box-sizing: content-box;
  padding: 2px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--ink) 5%, var(--surface));
  color: var(--subtle);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 140ms var(--ease);
}

.column-header-button:hover .column-chevron,
.column-header-button:focus-visible .column-chevron,
.column-header-button[aria-expanded="true"] .column-chevron {
  opacity: 1;
}

.ag-header-cell.is-numeric .column-header-button {
  flex-direction: row-reverse;
}

.ag-header-cell.is-numeric .column-chevron {
  right: auto;
  left: 4px;
}

.currency-cell {
  font-variant-numeric: tabular-nums;
}

.currency-cell.is-zero,
.cell-empty {
  color: var(--subtle);
}

.editable-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Valor de Dropdown/Etiquetas: badge neutra por defecto. Las variantes
   "dot" y "color" quedan preparadas (column.optionStyle). */
.pill {
  display: inline-flex;
  max-width: 100%;
  height: 22px;
  flex: 0 1 auto;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--surface-sunken);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 500;
}

.pill-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--tone);
}

.pill--color {
  font-weight: 550;
  background: color-mix(in srgb, var(--tone) 14%, transparent);
  color: color-mix(in srgb, var(--tone) 70%, var(--ink));
}

.pill-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tone-0 { --tone: var(--tone-0); }
.tone-1 { --tone: var(--tone-1); }
.tone-2 { --tone: var(--tone-2); }
.tone-3 { --tone: var(--tone-3); }
.tone-4 { --tone: var(--tone-4); }
.tone-5 { --tone: var(--tone-5); }

.link-cell {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  text-decoration: none;
}

.link-label {
  overflow: hidden;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: text-decoration-color 140ms var(--ease);
}

.link-icon {
  color: var(--subtle);
  transition: color 140ms var(--ease);
}

.link-cell:hover .link-label {
  text-decoration-color: var(--accent);
}

.link-cell:hover,
.link-cell:hover .link-icon {
  color: var(--accent);
}

.link-editor {
  display: grid;
  width: 280px;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 120ms var(--ease) both;
}

.link-editor .menu-footer {
  margin-top: 2px;
}

.link-editor [data-action="remove"] {
  margin-right: auto;
}

.field-error {
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.tags-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

/* Columna fija de acciones: siempre visible y discreta. */
.expense-grid .actions-cell {
  justify-content: center;
  padding-inline: 4px;
}

.actions-header {
  display: flex;
  width: 100%;
  justify-content: center;
}

.row-actions .icon-button {
  color: color-mix(in srgb, var(--cat-1) 55%, var(--subtle));
}

.row-actions .icon-button:hover {
  background: color-mix(in srgb, var(--cat-1) 12%, transparent);
  color: var(--cat-1);
}

.row-actions .icon-button.danger {
  color: color-mix(in srgb, var(--cat-3) 45%, var(--subtle));
}

.row-actions .icon-button.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ------------------------------------------------------------------ */
/* Pie de la tabla                                                    */
/* ------------------------------------------------------------------ */

.table-footer {
  display: flex;
  align-items: center;
  padding: 6px 0 0;
}

.table-footer.is-empty {
  flex-direction: column;
  gap: 10px;
  padding: 32px 0 22px;
}

.empty-message {
  margin: 0;
  color: var(--muted);
}

.add-row-button {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 8px;
  border-radius: 8px;
  color: var(--muted);
  transition:
    background-color 140ms var(--ease),
    color 140ms var(--ease);
}

.add-row-button kbd {
  opacity: 0;
  transition: opacity 140ms var(--ease);
}

.add-row-button .icon {
  color: var(--accent);
}

.add-row-button:hover:not(:disabled) {
  background: var(--hover);
  color: var(--ink);
}

.add-row-button:hover kbd,
.add-row-button:focus-visible kbd {
  opacity: 1;
}

/* ------------------------------------------------------------------ */
/* Popovers y menús                                                   */
/* ------------------------------------------------------------------ */

.popover {
  position: fixed;
  z-index: 50;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 120ms var(--ease) both;
  transform-origin: top left;
}

.popover[data-side="top"] {
  transform-origin: bottom left;
}

.column-menu {
  width: 284px;
}

.category-menu {
  width: 324px;
}

.column-menu-body {
  display: grid;
  gap: 4px;
}

.menu-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  transition:
    border-color 140ms var(--ease),
    box-shadow 140ms var(--ease);
}

.menu-name:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.menu-name input {
  min-width: 0;
  height: 34px;
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 550;
  outline: none;
}

.menu-divider {
  height: 1px;
  margin: 2px -6px;
  background: var(--line-soft);
}

.menu-list {
  display: grid;
  gap: 1px;
}

.menu-item {
  display: flex;
  width: 100%;
  min-height: 32px;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 13.5px;
  text-align: left;
  transition:
    background-color 120ms var(--ease),
    color 120ms var(--ease);
}

.menu-item:hover:not(:disabled):not([aria-disabled="true"]),
.menu-item:focus-visible {
  background: var(--hover);
  color: var(--ink);
}

.menu-item:focus-visible {
  outline: none;
}

.menu-item[aria-disabled="true"] {
  cursor: default;
  color: var(--muted);
}

.menu-item .icon {
  color: var(--muted);
}

.menu-value {
  margin-left: auto;
  color: var(--subtle);
  font-size: 12.5px;
}

.menu-trailing {
  color: var(--subtle) !important;
}

.menu-value + .menu-trailing {
  margin-left: -4px;
}

.menu-item span + .menu-trailing {
  margin-left: auto;
}

.menu-item[aria-checked="true"] {
  color: var(--ink);
  font-weight: 600;
}

.menu-item[aria-checked="true"] .icon {
  color: var(--accent) !important;
}

.menu-item.danger,
.menu-item.danger .icon {
  color: var(--danger);
}

.menu-item.danger:hover:not(:disabled),
.menu-item.is-confirming {
  background: var(--danger-soft);
}

.menu-item.is-confirming {
  font-weight: 600;
}

.menu-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 8px 4px;
  color: var(--subtle);
  font-size: 12px;
}

.menu-back {
  display: flex;
  height: 32px;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 4px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.menu-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
}

.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
  padding-left: 4px;
  color: var(--subtle);
  font-size: 12px;
}

/* Editor de opciones */
.option-columns {
  display: flex;
  justify-content: space-between;
  padding: 0 40px 2px 34px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.option-list {
  display: grid;
  max-height: 264px;
  gap: 2px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 7px;
}

.option-row.is-dragging {
  background: var(--surface-sunken);
  opacity: 0.6;
}

.drag-handle {
  display: inline-grid;
  width: 22px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--subtle);
  cursor: grab;
}

.option-row:hover .drag-handle {
  color: var(--muted);
}

.option-input,
.option-months {
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  outline: none;
  transition:
    background-color 120ms var(--ease),
    border-color 120ms var(--ease);
}

.option-input {
  min-width: 0;
  flex: 1;
  padding: 0 8px;
}

.option-months {
  width: 52px;
  flex: 0 0 auto;
  padding: 0 6px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.option-row:hover .option-input,
.option-row:hover .option-months {
  background: var(--surface-sunken);
}

.option-input:focus,
.option-months:focus {
  border-color: var(--accent);
  background: var(--surface) !important;
  color: var(--ink);
}

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

/* Formularios en popover (nueva columna / categoría) */
.menu-form {
  display: grid;
  gap: 12px;
  padding: 6px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-label {
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field-label small {
  margin-left: 4px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  outline: none;
  resize: vertical;
  transition:
    border-color 140ms var(--ease),
    box-shadow 140ms var(--ease);
}

.field input[type="text"]:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.menu-heading {
  font-size: 13.5px;
  font-weight: 650;
}

.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.type-option {
  position: relative;
  display: flex;
  height: 32px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  transition:
    background-color 120ms var(--ease),
    border-color 120ms var(--ease),
    color 120ms var(--ease);
}

.type-option:hover {
  background: var(--hover);
  color: var(--ink);
}

.type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.type-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.type-option .icon {
  color: var(--muted);
}

.type-option:has(input:checked) .icon {
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Nombre + icono (menú de categoría y nueva categoría)               */
/* ------------------------------------------------------------------ */

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

.name-row input {
  min-width: 0;
  height: 38px;
  flex: 1;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  font-weight: 550;
  outline: none;
  transition:
    border-color 140ms var(--ease),
    box-shadow 140ms var(--ease);
}

.name-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.name-row input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.icon-trigger {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-sunken);
  color: var(--ink-soft);
  transition:
    background-color 140ms var(--ease),
    border-color 140ms var(--ease);
}

.icon-trigger:hover,
.icon-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.save-template {
  display: flex;
  gap: 6px;
  padding: 2px;
}

.save-template input {
  min-width: 0;
  height: 30px;
  flex: 1;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
}

.save-template input:focus {
  border-color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Selector de iconos                                                 */
/* ------------------------------------------------------------------ */

.icon-picker {
  display: grid;
  gap: 6px;
}

.icon-search,
.select-search {
  display: flex;
  height: 32px;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-sunken);
  color: var(--subtle);
}

.icon-search:focus-within,
.select-search:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}

.icon-search input,
.select-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  outline: none;
}

.icon-scroll {
  max-height: 216px;
  margin: 0 -4px;
  padding: 0 4px 4px;
  overflow-y: auto;
}

.icon-group-title {
  padding: 8px 2px 4px;
  color: var(--subtle);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
}

.icon-option {
  display: inline-grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  transition:
    background-color 120ms var(--ease),
    color 120ms var(--ease);
}

.icon-option:hover,
.icon-option:focus-visible {
  background: var(--hover);
  color: var(--ink);
  outline: none;
}

.icon-option[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-empty {
  margin: 14px 0;
  color: var(--subtle);
  font-size: 13px;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Modal                                                              */
/* ------------------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: rgba(27, 26, 23, 0.18);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fade-in 140ms var(--ease) both;
}

.modal-backdrop.is-leaving {
  animation: fade-out 120ms var(--ease) both;
}

.modal {
  display: grid;
  width: min(440px, 100%);
  max-height: calc(100vh - 48px);
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modal-in 160ms var(--ease) both;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 6px 20px;
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.modal-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-body {
  padding: 10px 20px 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Nueva categoría */
.new-category {
  display: grid;
  gap: 14px;
}

.template-list {
  display: grid;
  gap: 2px;
  max-height: 300px;
  margin: 0 -6px;
  padding: 0 6px;
  overflow-y: auto;
}

.template-group {
  padding: 8px 2px 3px;
  color: var(--subtle);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.template-option {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition:
    background-color 120ms var(--ease),
    border-color 120ms var(--ease);
}

.template-option:hover {
  background: var(--row-hover);
}

.template-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.template-option[aria-checked="true"] {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
}

.template-icon {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-sunken);
  color: var(--ink-soft);
}

.template-option[aria-checked="true"] .template-icon {
  background: var(--surface);
  color: var(--accent);
}

.template-text {
  display: grid;
  min-width: 0;
}

.template-name {
  font-weight: 550;
}

.template-columns {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 120ms var(--ease);
}

.template-option:hover .template-actions,
.template-option:focus-within .template-actions {
  opacity: 1;
}

.template-actions .is-confirming {
  background: var(--danger-soft);
  color: var(--danger);
}

.template-check {
  color: var(--accent);
  opacity: 0;
}

.template-option[aria-checked="true"] .template-check {
  opacity: 1;
}

/* Menú de columna: elementos con descripción (vista "Función") */
.menu-item-rich {
  align-items: flex-start;
  padding-block: 7px;
}

.menu-item-text {
  display: grid;
  gap: 1px;
}

.menu-item-text small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
}

/* ------------------------------------------------------------------ */
/* Editores flotantes de celda: dropdown, fecha                       */
/* ------------------------------------------------------------------ */

.select-editor,
.date-editor {
  margin-top: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 120ms var(--ease) both;
}

.select-editor {
  display: grid;
  width: max(220px, 100%);
  max-width: 300px;
  gap: 4px;
}

.select-list {
  display: grid;
  max-height: min(520px, calc(100vh - 160px));
  gap: 1px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  outline: none;
}

.select-option {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--ink-soft);
  cursor: pointer;
}

.select-option.is-active {
  background: var(--hover);
  color: var(--ink);
}

.select-option[aria-selected="true"] {
  font-weight: 600;
}

.select-option.is-empty,
.select-option.is-action {
  color: var(--muted);
}

.select-option.is-action {
  margin-top: 3px;
  border-top: 1px solid var(--line-soft);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.select-check {
  color: var(--accent);
}

.select-none {
  padding: 8px 10px;
  color: var(--subtle);
  font-size: 13px;
}

.select-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px 2px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 13px;
}

.select-custom input {
  width: 56px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  text-align: right;
  outline: none;
}

.select-custom input:focus {
  border-color: var(--accent);
}

.select-custom .button {
  margin-left: auto;
}

/* Calendario */
.date-editor {
  width: 260px;
}

.calendar {
  display: grid;
  gap: 4px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 2px;
}

.calendar-title {
  font-size: 13px;
  font-weight: 600;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.calendar-weekdays span {
  padding: 2px 0;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.calendar-day {
  height: 32px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: background-color 100ms var(--ease);
}

.calendar-day:hover,
.calendar-day:focus-visible {
  background: var(--hover);
  outline: none;
}

.calendar-day:focus-visible {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.calendar-day.is-outside {
  color: var(--subtle);
}

.calendar-day.is-today {
  font-weight: 700;
  color: var(--accent);
}

.calendar-day[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.calendar-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 4px;
  border-top: 1px solid var(--line-soft);
}

.calendar-popover {
  width: 268px;
}

.date-field {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: border-color 140ms var(--ease);
}

.date-field .icon {
  color: var(--muted);
}

.date-field:hover,
.date-field[aria-expanded="true"] {
  border-color: var(--accent);
}

.date-field.is-empty {
  color: var(--subtle);
}

.date-rolled {
  margin-left: 5px;
  color: var(--subtle);
  vertical-align: -1px;
}

/* ------------------------------------------------------------------ */
/* Seguimiento de uso                                                 */
/* ------------------------------------------------------------------ */

.usage-cell {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  cursor: pointer;
}

.usage-cell.is-idle {
  height: 24px;
  padding: 0 9px 0 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12.5px;
  transition:
    border-color 140ms var(--ease),
    color 140ms var(--ease);
}

.ag-row-hover .usage-cell.is-idle {
  border-color: var(--accent);
  color: var(--accent);
}

.usage-cell.is-active {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.usage-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.usage-days {
  font-variant-numeric: tabular-nums;
}

.usage-meta {
  color: var(--subtle);
  font-size: 12px;
}

.usage-modal {
  display: grid;
  gap: 16px;
}

.usage-status {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-sunken);
}

.usage-status-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}

.usage-status-days {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.usage-status-meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12.5px;
}

.usage-action {
  display: grid;
  gap: 10px;
}

.usage-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.usage-primary {
  width: 100%;
  height: 36px;
}

.usage-history ul {
  display: grid;
  gap: 1px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.usage-cycle {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  padding: 0 4px 0 10px;
  border-radius: 8px;
  font-size: 13px;
}

.usage-cycle:hover {
  background: var(--row-hover);
}

.usage-cycle-dates {
  flex: 1;
  color: var(--ink-soft);
}

.usage-cycle-days {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.usage-cycle-actions {
  display: flex;
  opacity: 0;
  transition: opacity 120ms var(--ease);
}

.usage-cycle:hover .usage-cycle-actions,
.usage-cycle:focus-within .usage-cycle-actions {
  opacity: 1;
}

.usage-cycle-actions .is-confirming {
  background: var(--danger-soft);
  color: var(--danger);
}

.usage-cycle.is-editing {
  flex-wrap: wrap;
  padding: 6px 4px;
  background: var(--row-hover);
}

.usage-cycle-arrow {
  color: var(--subtle);
}

.usage-cycle.is-editing .button {
  margin-left: auto;
}

/* ------------------------------------------------------------------ */
/* Toasts                                                             */
/* ------------------------------------------------------------------ */

.toast-region {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  z-index: 60;
  display: grid;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 7px 7px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: auto;
  animation: toast-in 200ms var(--ease) both;
}

.toast:not(:has(.toast-action)) {
  padding-right: 16px;
}

.toast.is-leaving {
  animation: toast-out 160ms var(--ease) both;
}

.toast-action {
  display: inline-flex;
  height: 30px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font-weight: 600;
}

.toast-action:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ------------------------------------------------------------------ */
/* Editores flotantes: una sola superficie                             */
/* ------------------------------------------------------------------ */

/* AG Grid envuelve cada editor flotante en un contenedor con sombra
   rectangular. Nuestros editores ya son la superficie (radio, borde, sombra):
   el contenedor debe ser transparente para que no asome por las esquinas. */
.ag-popup-child:has(> .select-editor, > .date-editor, > .link-editor),
.ag-popup-editor:has(> .select-editor, > .date-editor, > .link-editor) {
  border: 0 !important;
  border-radius: 12px;
  background: transparent !important;
  box-shadow: none !important;
}

.select-editor,
.date-editor,
.link-editor {
  margin-top: 6px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(27, 26, 23, 0.05), 0 12px 32px -12px rgba(27, 26, 23, 0.22);
}

/* ------------------------------------------------------------------ */
/* Scrollbars finas y redondeadas                                     */
/* ------------------------------------------------------------------ */

.expense-grid ::-webkit-scrollbar,
.select-list::-webkit-scrollbar,
.icon-scroll::-webkit-scrollbar,
.template-list::-webkit-scrollbar,
.option-list::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.pw-list::-webkit-scrollbar,
.pw-detail-pane::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.expense-grid ::-webkit-scrollbar-track,
.select-list::-webkit-scrollbar-track,
.icon-scroll::-webkit-scrollbar-track,
.template-list::-webkit-scrollbar-track,
.option-list::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.pw-list::-webkit-scrollbar-track,
.pw-detail-pane::-webkit-scrollbar-track {
  background: transparent;
}

/* El borde transparente deja la barra en 4-6 px y separada del canto. */
.expense-grid ::-webkit-scrollbar-thumb,
.select-list::-webkit-scrollbar-thumb,
.icon-scroll::-webkit-scrollbar-thumb,
.template-list::-webkit-scrollbar-thumb,
.option-list::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.pw-list::-webkit-scrollbar-thumb,
.pw-detail-pane::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 16%, transparent);
  background-clip: padding-box;
}

.expense-grid ::-webkit-scrollbar-thumb:hover,
.select-list::-webkit-scrollbar-thumb:hover {
  border-width: 2px;
  background-color: color-mix(in srgb, var(--ink) 28%, transparent);
}

.expense-grid ::-webkit-scrollbar-corner {
  background: transparent;
}

/* ------------------------------------------------------------------ */
/* Escritorio (Electron): ventana de macOS                            */
/* ------------------------------------------------------------------ */

/* Scroll general sin barra visible (trackpad, rueda y gestos siguen funcionando).
   Sin barra, tampoco hace falta reservar su hueco: los márgenes quedan iguales. */
html.is-desktop {
  scrollbar-gutter: auto;
  scrollbar-width: none;
}

html.is-desktop::-webkit-scrollbar {
  display: none;
}

/* La barra superior es la barra de título: mismo fondo que la app, sin
   divisor, y se puede arrastrar para mover la ventana. */
html.is-desktop .topbar {
  padding: 8px 20px 12px;
  background: var(--bg);
  pointer-events: auto;
  -webkit-app-region: drag;
  user-select: none;
}

html.is-desktop .tabbar,
html.is-desktop .topbar-button {
  -webkit-app-region: no-drag;
}

/* Hueco para los semáforos de macOS (posición fijada en electron/main.js). */
html.is-mac .topbar-start {
  min-width: 72px;
}

/* La tabla ocupa el ancho de la ventana hasta la anchura máxima; por encima,
   centrada con márgenes iguales. Sin asas de ancho manual. */
html.is-desktop .page {
  padding: 20px 20px 64px;
}

html.is-desktop .width-handle,
html.is-desktop .width-badge {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Animaciones                                                        */
/* ------------------------------------------------------------------ */

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes fade-out {
  to { opacity: 0; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.98) translateY(-2px); }
  to { opacity: 1; transform: none; }
}

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

@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 720px) {
  .page {
    padding: 28px 12px 96px;
  }

  .table-surface {
    width: 100%;
    min-width: 0;
    padding: 10px 12px 8px;
  }

  .width-handle {
    display: none;
  }

  .overview-row {
    grid-template-columns: 32px minmax(0, 1fr) auto 48px;
    gap: 10px;
  }

  .overview-chevron {
    display: none;
  }

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

  .forecast-month:nth-child(4) {
    box-shadow: inset 0 1px 0 var(--line-soft);
  }

  .forecast-month:nth-child(n + 5) {
    box-shadow: inset 1px 0 0 var(--line-soft), inset 0 1px 0 var(--line-soft);
  }

  .payment-row {
    grid-template-columns: 48px minmax(0, 1fr) 84px;
  }

  .payment-when {
    display: none;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
    row-gap: 18px;
    margin-bottom: 28px;
  }

  .metric {
    padding: 0 12px;
  }

  .metric:nth-child(3) {
    border-left: 0;
  }

  .metric-value {
    font-size: 19px;
  }

  .add-row-button kbd {
    display: none;
  }
}

/* ------------------------------------------------------------------ */
/* Configuración, selector de iconos flotante y constructor de plantillas */
/* ------------------------------------------------------------------ */

.topbar-icon-button {
  width: 44px;
  justify-content: center;
  padding: 0;
}

.settings-menu {
  width: 300px;
}

.menu-section-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 4px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.menu-section-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Selector de iconos: panel flotante sobre la interfaz (sin mover nada). */
.floating-panel {
  position: fixed;
  z-index: 60;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 120ms var(--ease) both;
}

.icon-popover {
  width: 344px;
  padding: 10px;
}

.icon-popover .icon-scroll {
  max-height: 264px;
}

.template-header,
.builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.template-builder-modal {
  width: min(640px, 100%);
}

.template-builder {
  display: grid;
  gap: 12px;
}

.builder-columns {
  display: grid;
  max-height: min(52vh, 460px);
  gap: 6px;
  margin: 0;
  padding: 0 2px 2px;
  overflow-y: auto;
  list-style: none;
}

.builder-column {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.builder-column.is-dragging {
  opacity: 0.55;
}

.builder-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 210px 28px;
  align-items: center;
  gap: 6px;
}

.builder-name,
.builder-kind {
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  outline: none;
  transition:
    border-color 140ms var(--ease),
    box-shadow 140ms var(--ease);
}

.builder-name {
  min-width: 0;
  padding: 0 10px;
  font-weight: 550;
}

.builder-kind {
  width: 100%;
  padding: 0 8px;
  background: var(--surface-sunken);
  color: var(--ink-soft);
}

.builder-name:focus,
.builder-kind:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.builder-options {
  display: grid;
  gap: 4px;
  margin: 6px 34px 0 28px;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-sunken);
}

.builder-options-head {
  display: flex;
  justify-content: space-between;
  padding: 0 34px 0 8px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.builder-options ul {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.builder-options li {
  display: flex;
  align-items: center;
  gap: 4px;
}

.builder-options .option-input,
.builder-options .option-months {
  background: var(--surface);
}

.builder-add-option {
  justify-self: start;
}

.builder-add {
  justify-self: start;
}

.builder-error {
  margin: 0;
}

@media (max-width: 720px) {
  .builder-row {
    grid-template-columns: 22px minmax(0, 1fr) 28px;
  }

  .builder-kind {
    grid-column: 2 / 3;
  }
}

/* ------------------------------------------------------------------ */
/* Columnas inteligentes                                              */
/* ------------------------------------------------------------------ */

.smart-indicator {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: -2px;
  border-radius: 5px;
  color: color-mix(in srgb, var(--accent) 70%, var(--subtle));
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.smart-indicator:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.smart-indicator.is-warning {
  color: var(--cat-2);
}

.smart-indicator.is-warning:hover {
  background: color-mix(in srgb, var(--cat-2) 14%, transparent);
}

.dependency-warning {
  display: flex;
  gap: 9px;
  margin: 2px 2px 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--cat-2) 11%, var(--surface));
  color: color-mix(in srgb, var(--cat-2) 85%, var(--ink));
}

.dependency-warning .icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

.dependency-warning p {
  margin: 0 0 8px;
  color: color-mix(in srgb, var(--cat-2) 55%, var(--ink));
  font-size: 13px;
  font-weight: 550;
  line-height: 1.4;
}

.currency-cell.is-pending {
  color: var(--subtle);
  font-weight: 400;
}

.add-column-form .menu-heading {
  display: flex;
  align-items: center;
  gap: 6px;
}

.add-column-form .menu-heading .icon {
  color: var(--accent);
}

.smart-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.smart-choice {
  display: inline-flex;
  height: 30px;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 550;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease), color 140ms var(--ease);
}

.smart-choice .icon {
  color: var(--accent);
}

.smart-choice:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: var(--accent-soft);
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Mover filas, selección y secciones                                 */
/* ------------------------------------------------------------------ */

.expense-grid .drag-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
}

.expense-grid .ag-row-drag {
  color: var(--subtle);
  opacity: 0;
  cursor: grab;
  transition: opacity 140ms var(--ease), color 140ms var(--ease);
}

.expense-grid .ag-row-hover .ag-row-drag,
.expense-grid .ag-row-focus .ag-row-drag,
.expense-grid .ag-row-drag:focus-visible {
  opacity: 1;
}

.expense-grid .ag-row-drag:hover {
  color: var(--ink-soft);
}

.expense-grid .ag-row-dragging,
.expense-grid .ag-row-dragging .ag-cell {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.ag-dnd-ghost {
  border: 1px solid var(--line) !important;
  border-radius: 9px !important;
  background: var(--surface) !important;
  box-shadow: var(--shadow-float) !important;
  color: var(--ink) !important;
  font-family: var(--font-sans) !important;
  font-size: 13px !important;
}

/* La columna del asa y la de selección no llevan separador vertical
   (la de acciones, a la derecha, sí). */
.expense-grid .ag-cell-last-left-pinned:not(.ag-cell-focus),
.expense-grid .ag-header-row .ag-grid-pinned-left-cells .ag-header-cell {
  border-right-color: transparent !important;
}

.expense-grid .selection-cell,
.expense-grid .selection-header {
  justify-content: center;
  padding: 0 !important;
}

.expense-grid .ag-row-selected {
  --ag-row-hover-color: color-mix(in srgb, var(--accent) 9%, var(--surface));
}

/* Secciones: bloques dentro de la tabla, con las mismas columnas.
   La cabecera de sección lleva arriba el hueco que separa los bloques
   (--section-gap, igual que SECTION_GAP en ExpenseTable.js). El bloque se
   dibuja con ::before de cada fila (AG Grid usa ::after como relleno):
   cabecera con fondo y bordes debajo del contenido; en las filas, solo los
   bordes laterales (y el inferior en la última), encima de las celdas fijas. */
.expense-grid {
  --section-gap: 28px;
  --section-radius: 12px;
  --section-border: var(--line);
  --section-head: color-mix(in srgb, var(--surface-sunken) 70%, var(--surface));
}

.expense-grid .ag-row.section-row,
.expense-grid .ag-row.section-row.ag-row-hover,
.expense-grid .ag-row.section-row::after,
.expense-grid .ag-row.section-row .ag-cell,
.expense-grid .ag-row.section-row .ag-grid-pinned-left-cells,
.expense-grid .ag-row.section-row .ag-grid-pinned-right-cells,
.expense-grid .ag-row.section-row .ag-grid-scrolling-cells {
  background: transparent !important;
  border-bottom-color: transparent;
}

.expense-grid .ag-row.section-row::before,
.expense-grid .ag-row.in-group::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--frame-left, 0px);
  width: var(--frame-width, 100%);
  border: 1px solid var(--section-border);
  border-top: 0;
  border-bottom: 0;
  content: "";
  pointer-events: none;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}

/* AG Grid pinta el hover y la selección con ::before en cada grupo de celdas
   (toda la fila, hueco incluido): en las cabeceras de sección no se usa. */
.expense-grid .ag-row.section-row .ag-grid-pinned-left-cells::before,
.expense-grid .ag-row.section-row .ag-grid-pinned-right-cells::before,
.expense-grid .ag-row.section-row .ag-grid-scrolling-cells::before {
  background: transparent !important;
  background-image: none !important;
}

/* Cabecera: fondo y borde superior redondeado, debajo del contenido */
.expense-grid .ag-row.section-row::before {
  z-index: 0;
  top: var(--section-gap);
  border-top: 1px solid var(--section-border);
  border-bottom: 1px solid var(--line-soft);
  border-radius: var(--section-radius) var(--section-radius) 0 0;
  background: var(--section-head);
}

.expense-grid .ag-row.section-row.ag-row-hover::before {
  background: color-mix(in srgb, var(--surface-sunken) 100%, var(--ink) 2%);
}

.expense-grid .ag-row.section-row.section-empty::before {
  border-bottom-color: var(--section-border);
  border-radius: var(--section-radius);
}

/* Filas del bloque: bordes laterales por encima de las celdas fijas */
.expense-grid .ag-row.in-group::before {
  z-index: 3;
}

.expense-grid .ag-row.group-last {
  border-bottom-color: transparent;
  clip-path: inset(0 calc(100% - var(--frame-left, 0px) - var(--frame-width, 100%)) 0 var(--frame-left, 0px) round 0 0 var(--section-radius) var(--section-radius));
}

.expense-grid .ag-row.group-last::before {
  border-bottom: 1px solid var(--section-border);
  border-radius: 0 0 var(--section-radius) var(--section-radius);
}

/* Contenido de la cabecera, centrado en su franja (debajo del hueco) */
.expense-grid .ag-row.section-row .ag-cell {
  display: flex;
  align-items: center;
  padding-top: var(--section-gap);
  border-right-color: transparent !important;
  cursor: default;
}

/* Sin separadores verticales de las columnas fijas en la cabecera ni en el hueco */
.expense-grid .ag-row.section-row .ag-cell,
.expense-grid .ag-row.section-row .drag-cell {
  border-left-color: transparent !important;
  border-right-color: transparent !important;
}

.expense-grid .ag-row.section-row .drag-cell,
.expense-grid .ag-row.section-row .selection-cell {
  padding-top: var(--section-gap) !important;
}

.expense-grid .ag-row.section-row .ag-cell-focus,
.expense-grid .ag-row.section-row .ag-cell:focus-within {
  border-color: transparent !important;
  outline: none;
}

.section-cell {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: baseline;
  gap: 10px;
}

.section-title {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.005em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.section-cell.is-empty .section-count {
  color: var(--subtle);
}

.section-input {
  width: min(320px, 70%);
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
  font-size: 14px;
  font-weight: 650;
  outline: none;
}

/* Asa para mover la sección: visible siempre, pero discreta */
.expense-grid .ag-row.section-row .ag-row-drag {
  opacity: 0.7;
}

.expense-grid .ag-row.section-row .ag-row-drag:hover {
  opacity: 1;
}

/* + y ⋯ de la cabecera */
.expense-grid .section-row .row-actions {
  justify-content: flex-end;
  width: 100%;
  padding-right: 6px;
}

.expense-grid .section-row .row-actions .icon-button {
  color: var(--muted);
}

.expense-grid .section-row .row-actions .section-add {
  color: var(--accent);
}

.expense-grid .section-row .row-actions .section-add:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.expense-grid .section-row .row-actions .section-more:hover {
  background: var(--hover);
  color: var(--ink);
}

/* Arrastrar: bloque que recibirá el gasto y gastos que viajan con su sección */
.expense-grid .ag-row.is-drop-group::before {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
}

.expense-grid .ag-row.section-row.is-drop-group::before {
  background: var(--accent-soft);
}

.expense-grid .ag-row.is-carried {
  opacity: 0.35;
}

.section-menu {
  width: 260px;
}

/* Insertar una sección entre dos filas */
.table-host {
  position: relative;
}

.section-inserter {
  position: absolute;
  z-index: 5;
  right: 0;
  left: 0;
  height: 0;
  pointer-events: none;
}

.section-inserter::before {
  position: absolute;
  top: 0;
  right: 24px;
  left: 24px;
  height: 1px;
  background: color-mix(in srgb, var(--accent) 40%, transparent);
  content: "";
}

.section-inserter-button {
  position: absolute;
  top: -12px;
  left: 50%;
  display: inline-flex;
  height: 24px;
  align-items: center;
  gap: 4px;
  padding: 0 10px 0 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-float);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  pointer-events: auto;
  transform: translateX(-50%);
  animation: pop-in 120ms var(--ease) both;
}

.section-inserter-button:hover,
.section-inserter.is-active .section-inserter-button {
  background: var(--accent-soft);
}

.section-popover {
  width: 300px;
}

.section-form .menu-heading {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-form input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
}

.section-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.add-section-button .icon {
  color: var(--accent);
}

.table-footer.is-empty .add-section-button {
  display: inline-flex;
}

/* Barra de acciones masivas: tapa la cabecera (sin mover la tabla) */
.bulk-bar {
  position: absolute;
  z-index: 6;
  top: 14px;
  right: 20px;
  left: calc(20px + var(--bulk-offset, 40px));
  display: flex;
  height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 0 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  animation: fade-in 120ms var(--ease) both;
}

.bulk-count {
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}

.bulk-actions {
  display: flex;
  gap: 4px;
}

.bulk-actions .button.danger {
  background: transparent;
  color: var(--danger);
}

.bulk-actions .button.danger:hover {
  background: var(--danger-soft);
}

/* ------------------------------------------------------------------ */
/* Documentos                                                         */
/* ------------------------------------------------------------------ */

.row-actions .documents-button {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
  width: auto;
  min-width: 28px;
  gap: 3px;
  padding: 0 5px;
  color: var(--subtle);
  opacity: 0.55;
}

.row-actions .documents-button.has-documents {
  color: color-mix(in srgb, var(--cat-2) 80%, var(--ink-soft));
  opacity: 1;
}

.row-actions .documents-button:hover {
  background: color-mix(in srgb, var(--cat-2) 12%, transparent);
  color: var(--cat-2);
  opacity: 1;
}

.documents-count {
  font-size: 11.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* Fila sobre la que se va a soltar un documento */
.expense-grid .ag-row.is-drop-target,
.expense-grid .ag-row.is-drop-target .ag-cell {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)) !important;
}

.expense-grid .ag-row.is-drop-target {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* Zona para soltar facturas: sobre las métricas, sin mover la tabla */
.page {
  position: relative;
}

.drop-zone {
  position: absolute;
  z-index: 20;
  display: flex;
  padding: 0;
  pointer-events: auto;
  animation: fade-in 120ms var(--ease) both;
}

.drop-zone-inner {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line-strong));
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft));
  box-shadow: var(--shadow-float);
  color: var(--ink-soft);
  pointer-events: none;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), transform 140ms var(--ease);
}

.drop-zone-inner .icon {
  color: var(--accent);
}

.drop-zone-inner strong {
  font-size: 15px;
}

.drop-zone-hint {
  color: var(--muted);
  font-size: 12.5px;
}

.drop-zone.is-over .drop-zone-inner {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.01);
}

/* Modal de documentos */
.documents-modal {
  width: min(560px, 100%);
}

.documents {
  display: grid;
  gap: 12px;
  border-radius: 12px;
  transition: box-shadow 140ms var(--ease);
}

.documents.is-drop-target {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}

.documents-list {
  display: grid;
  max-height: min(56vh, 460px);
  gap: 4px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.document-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.document-icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--cat-3) 10%, var(--surface));
  color: var(--cat-3);
}

.document-icon.is-image {
  background: color-mix(in srgb, var(--cat-1) 10%, var(--surface));
  color: var(--cat-1);
}

.document-main {
  display: grid;
  min-width: 0;
  gap: 1px;
  text-align: left;
}

.document-name {
  overflow: hidden;
  color: var(--ink);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-main:hover .document-name {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.document-meta,
.document-detected {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-detected {
  color: var(--accent);
}

.document-actions {
  display: flex;
  gap: 2px;
}

.documents-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 26px 12px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.documents-empty .icon {
  color: var(--cat-2);
}

.documents-empty p {
  margin: 0;
  line-height: 1.5;
}

.documents-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ------------------------------------------------------------------ */
/* Configuración                                                      */
/* ------------------------------------------------------------------ */

.settings-modal {
  width: min(640px, 100%);
}

.settings-modal .modal-body {
  max-height: min(72vh, 720px);
  overflow-y: auto;
}

.settings {
  display: grid;
  gap: 22px;
}

.settings-section {
  display: grid;
}

.settings-heading {
  margin: 0 0 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--subtle);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.settings-section .settings-row:last-child {
  border-bottom: 0;
}

.settings-text {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.settings-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-weight: 600;
}

.settings-title .icon {
  color: var(--accent);
}

.settings-hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

/* Acerca de Bob → Actualizaciones */
.settings-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.update-sha {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
  user-select: text;
}

.settings-row > .button {
  flex: 0 0 auto;
}

.settings-widths {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.px-field {
  display: grid;
  grid-template-columns: auto;
  gap: 3px;
}

.px-field span {
  color: var(--muted);
  font-size: 11.5px;
}

.px-field input {
  width: 96px;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.px-field {
  position: relative;
}

.px-field em {
  position: absolute;
  right: 9px;
  bottom: 8px;
  color: var(--subtle);
  font-size: 12px;
  font-style: normal;
  pointer-events: none;
}

.px-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.px-field input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.settings-subrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line-soft);
}

.settings-subrow .text-link {
  margin-left: auto;
}

.settings-error {
  margin: 0;
}

/* Interruptor */
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color 160ms var(--ease);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(27, 26, 23, 0.25);
  transition: transform 180ms var(--ease);
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"] .switch-thumb {
  transform: translateX(16px);
}

.switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .settings-row {
    flex-wrap: wrap;
  }

  .bulk-bar {
    right: 12px;
    left: calc(12px + var(--bulk-offset, 40px));
  }
}

/* ------------------------------------------------------------------ */
/* Finanzas: ingresos y KPI de ahorro                                 */
/* ------------------------------------------------------------------ */

.money-field {
  position: relative;
  flex: 0 0 auto;
}

.money-field input {
  width: 150px;
  height: 34px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
}

.money-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.money-field input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.money-field em {
  position: absolute;
  top: 50%;
  right: 11px;
  color: var(--subtle);
  font-style: normal;
  pointer-events: none;
  transform: translateY(-50%);
}

.settings-income-error {
  margin: 0 0 6px;
  text-align: right;
}

.overview-metrics {
  width: min(540px, 100%);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 36px;
}

.overview-metrics .metric {
  font: inherit;
}

.metric-savings.is-positive .metric-value {
  color: var(--accent);
}

.metric-savings.is-negative .metric-value {
  color: var(--danger);
}

.metric-savings.is-neutral .metric-value {
  color: var(--ink-soft);
}

.metric-savings.is-unset {
  cursor: pointer;
}

.metric-savings.is-unset .metric-value {
  color: var(--subtle);
}

.metric-savings.is-unset:hover .metric-action {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.metric-action {
  color: var(--accent);
  font-size: 12px;
  font-weight: 550;
}

.section-delete-modal {
  width: min(580px, 100%);
}

.section-delete-modal .modal-footer {
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ */
/* Bob: selector de producto (primer nivel)                           */
/* ------------------------------------------------------------------ */

.bob {
  --bob-bar-height: 58px;
}

.bob-bar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  height: calc(var(--bob-bar-height) + env(safe-area-inset-top, 0px));
  align-items: flex-end;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) 20px 0;
  pointer-events: none;
}

/* La navegación de cada producto queda justo debajo. */
.bob .topbar {
  top: calc(var(--bob-bar-height) + env(safe-area-inset-top, 0px));
}

/* Control segmentado: pista suave y segmento activo blanco que se desliza. */
.product-switch {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface-sunken) 82%, var(--line));
  box-shadow: inset 0 0 0 1px rgba(27, 26, 23, 0.04);
  pointer-events: auto;
}

.product-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  height: calc(100% - 6px);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(27, 26, 23, 0.1), 0 2px 8px -2px rgba(27, 26, 23, 0.12);
  transition: transform 240ms var(--ease), width 240ms var(--ease);
}

.product-switch.no-animation .product-switch-thumb {
  transition: none;
}

.product-switch-option {
  position: relative;
  z-index: 1;
  display: inline-flex;
  height: 28px;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: color 180ms var(--ease);
}

.product-switch-option .icon {
  color: var(--subtle);
  transition: color 180ms var(--ease);
}

.product-switch-option:hover {
  color: var(--ink-soft);
}

.product-switch-option[aria-selected="true"] {
  color: var(--ink);
}

.product-switch-option[aria-selected="true"] .icon {
  color: var(--accent);
}

.product-switch-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Escritorio: el selector va en la barra de título, a la altura de los
   semáforos de macOS (que quedan a la izquierda). */
html.is-desktop .bob {
  --bob-bar-height: 49px;
}

html.is-desktop .bob-bar {
  align-items: flex-start;
  padding-top: 10px;
  background: var(--bg);
  pointer-events: auto;
  -webkit-app-region: drag;
  user-select: none;
}

html.is-desktop .product-switch {
  -webkit-app-region: no-drag;
}

/* ------------------------------------------------------------------ */
/* Bob Passwords (vista previa)                                       */
/* ------------------------------------------------------------------ */

.passwords-page {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pw-preview-notice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 16px;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cat-2) 11%, var(--surface));
  color: color-mix(in srgb, var(--cat-2) 70%, var(--ink));
  font-size: 12.5px;
  font-weight: 550;
}

/* Dos paneles flotantes del mismo sistema (lista + detalle) separados por un hueco. */
.passwords {
  display: grid;
  width: min(100%, 1180px);
  height: clamp(460px, calc(100vh - 250px), 880px);
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: var(--panel-gap);
}

html.is-desktop .passwords {
  height: clamp(460px, calc(100vh - 220px), 900px);
}

.pw-pane {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--panel-shadow-raised);
}

/* Lista */
.pw-list-pane {
  background: color-mix(in srgb, var(--surface-sunken) 28%, var(--surface));
}

.pw-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 14px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.pw-list-titles {
  display: grid;
  min-width: 0;
}

.pw-list-titles strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pw-list-titles span {
  color: var(--muted);
  font-size: 12px;
}

.pw-list-head .button {
  flex: 0 0 auto;
}

.pw-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  list-style: none;
  outline: none;
}

/* Fila: estilo común .bob-list-item / .bob-tile (lenguaje común) */
.pw-list-item {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: var(--tile-size) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: var(--list-item-padding);
  cursor: pointer;
}

.pw-list-item .bob-list-trailing {
  display: inline-flex;
  color: var(--subtle);
}

.pw-list-item[aria-selected="true"] .bob-list-title {
  color: color-mix(in srgb, var(--accent) 70%, var(--ink));
}

.pw-list-item[aria-selected="true"] .bob-tile {
  background: var(--surface);
}

.pw-list:focus-visible .pw-list-item[aria-selected="true"] {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent);
}

.pw-avatar.large {
  width: 52px;
  height: 52px;
  border-radius: var(--panel-radius);
  font-size: 21px;
}

/* Estados vacíos: centrados dentro de su panel */
.pw-empty,
.pw-placeholder {
  display: grid;
  flex: 1;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: var(--panel-padding);
  color: var(--muted);
  text-align: center;
}

.pw-empty .icon,
.pw-placeholder .icon {
  color: var(--subtle);
}

.pw-empty p,
.pw-placeholder p {
  max-width: 260px;
  margin: 0;
  line-height: 1.5;
}

.pw-placeholder {
  height: 100%;
}

/* Detalle: mismo relleno en los cuatro lados */
.pw-detail-pane {
  overflow-y: auto;
}

.pw-detail {
  padding: var(--panel-padding);
}

.pw-detail-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
}

.pw-detail-titles {
  display: grid;
  min-width: 0;
  flex: 1;
  justify-items: start;
  gap: 6px;
}

.pw-detail-name {
  overflow: hidden;
  margin: 0;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pw-vault-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cat) 12%, var(--surface));
  color: color-mix(in srgb, var(--cat) 80%, var(--ink));
  font-size: 12px;
  font-weight: 600;
}

.pw-head-actions {
  display: flex;
  min-width: 180px;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 4px;
}

.button.ghost.danger {
  background: transparent;
  color: var(--danger);
}

.button.ghost.danger:hover {
  background: var(--danger-soft);
}

.pw-fields {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--line-soft);
}

.pw-field {
  display: grid;
  gap: 4px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}

.pw-field dt {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pw-field dd {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}

.pw-field.is-multiline dd {
  align-items: flex-start;
}

.pw-value {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14.5px;
}

.pw-field.is-multiline .pw-value {
  white-space: pre-wrap;
}

.pw-value.is-mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
}

.pw-value.is-masked {
  letter-spacing: 0.12em;
}

.pw-value.is-empty {
  color: var(--subtle);
  font-family: inherit;
  letter-spacing: 0;
}

.pw-field-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
}

.pw-action {
  display: inline-flex;
  height: 28px;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

.pw-action:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.pw-detail-meta {
  margin-top: 16px;
  color: var(--subtle);
  font-size: 12px;
}

/* Edición inline: los mismos elementos, ahora editables en su sitio.
   Lectura y edición reservan el mismo alto (subrayado incluido), así nada se mueve. */
.pw-detail-name,
.pw-value {
  display: block;
  min-width: 0;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  line-height: 1.45;
}

.pw-detail-name {
  width: 100%;
  line-height: 1.3;
}

.pw-inline {
  width: 100%;
  margin: 0;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  outline: none;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}

.pw-inline:hover {
  border-bottom-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong));
}

.pw-inline:focus {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 var(--accent);
}

.pw-inline::placeholder {
  color: var(--subtle);
}

input.pw-inline.pw-detail-name {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

input.pw-inline.is-mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
}

textarea.pw-inline {
  display: block;
  overflow: hidden;
  resize: none;
}

/* Bóveda: el mismo chip, ahora con un desplegable */
/* Mismo tamaño que en lectura; un aro sutil indica que se puede cambiar. */
.pw-vault-chip.is-select {
  position: relative;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cat) 35%, transparent);
  cursor: pointer;
}

.pw-vault-chip.is-select select {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  appearance: none;
  outline: none;
  cursor: pointer;
}

.pw-vault-chip.is-select:focus-within {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cat) 35%, transparent);
}

.pw-form-error {
  margin: 12px 0 0;
}

.pw-settings-warning {
  margin: 6px 0 4px;
}

@media (max-width: 860px) {
  .passwords {
    --panel-padding: 24px;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }
}

/* ------------------------------------------------------------------ */
/* Reordenar arrastrando (components/reorder.js)                      */
/* ------------------------------------------------------------------ */

[data-reorder] > [data-reorder-id] {
  transition: transform 180ms var(--ease), box-shadow 160ms var(--ease), background-color 160ms var(--ease);
}

[data-reorder] > [data-reorder-id].is-dragging {
  position: relative;
  z-index: 3;
  box-shadow: 0 6px 18px -6px rgba(27, 26, 23, 0.28), 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
  cursor: grabbing;
  transition: box-shadow 160ms var(--ease), background-color 160ms var(--ease);
}

.tabbar-tabs.is-reordering .tab.is-dragging {
  background: var(--surface);
}

html.is-reordering-any,
html.is-reordering-any * {
  cursor: grabbing !important;
  user-select: none !important;
}

/* La barra de pestañas no recorta el elemento levantado mientras se arrastra. */
.tabbar-tabs.is-reordering {
  overflow: visible;
}

/* General: asa ⠿ a la izquierda de cada categoría, al pasar por encima */
.overview-item {
  position: relative;
}

.overview-drag {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: -30px;
  display: inline-flex;
  width: 22px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--subtle);
  cursor: grab;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 140ms var(--ease), background-color 140ms var(--ease);
}

.overview-item:hover .overview-drag,
.overview-item.is-dragging .overview-drag {
  opacity: 1;
}

.overview-drag:hover {
  background: var(--hover);
  color: var(--ink-soft);
}

.overview-list .overview-item.is-dragging {
  border-radius: 10px;
  background: var(--surface);
}

.overview-list.is-reordering li + li {
  box-shadow: none;
}

/* ------------------------------------------------------------------ */
/* Seguridad: pantalla de desbloqueo / configuración inicial          */
/* ------------------------------------------------------------------ */

.bob-gate {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 48px 20px;
}

html.is-desktop .bob-gate {
  -webkit-app-region: drag;
}

.gate-card {
  width: min(100%, 440px);
  padding: 34px 36px 30px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(27, 26, 23, 0.04), 0 24px 60px -28px rgba(27, 26, 23, 0.25);
  -webkit-app-region: no-drag;
  animation: gate-in 260ms var(--ease);
}

.bob-gate.is-leaving .gate-card {
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
}

@keyframes gate-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.gate-brand {
  display: inline-flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}

.gate-title {
  margin: 0 0 8px;
  font-size: 23px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.gate-lead {
  margin: 0 0 18px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.gate-success {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--accent);
  font-weight: 560;
}

.gate-success .icon {
  flex: 0 0 auto;
  margin-top: 3px;
}

.gate-note,
.security-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 18px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: color-mix(in srgb, var(--accent) 80%, var(--ink));
  font-size: 13px;
  line-height: 1.45;
}

.gate-note .icon,
.security-status .icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

.gate-form {
  display: grid;
  gap: 12px;
}

.gate-field {
  display: grid;
  gap: 6px;
}

.gate-field > span:first-child {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 560;
}

.gate-input {
  position: relative;
  display: block;
}

.gate-field input,
.gate-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 0 40px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}

.gate-field textarea {
  padding: 10px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
}

.gate-field input:focus,
.gate-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gate-reveal {
  position: absolute;
  top: 50%;
  right: 6px;
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--subtle);
  transform: translateY(-50%);
}

.gate-reveal:hover {
  background: var(--hover);
  color: var(--ink-soft);
}

.gate-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.gate-error {
  margin: 0;
  padding: 8px 11px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.gate-submit {
  width: 100%;
  height: 40px;
  margin-top: 4px;
  font-size: 14px;
}

.gate-secondary {
  width: 100%;
  height: 38px;
}

.gate-submit:disabled {
  cursor: default;
  opacity: 0.55;
}

.gate-link {
  display: block;
  margin: 16px auto 0;
  font-size: 13px;
}

.gate-footnote {
  margin: 0;
  color: var(--subtle);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.gate-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: gate-spin 700ms linear infinite;
}

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

/* Cuenta de Bob (Configuración): QR de TOTP y formularios en línea */
.totp-qr {
  display: block;
  width: 168px;
  height: 168px;
  margin: 8px auto 12px;
  padding: 8px;
  border-radius: 12px;
  background: #fff;
}

.security-account {
  margin-top: 8px;
}

/* Recovery Key / Recovery Kit */
.recovery-label {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.recovery-key {
  margin: 4px 0 12px;
  padding: 14px 16px;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--line-strong));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.7;
  text-align: center;
  user-select: all;
  word-spacing: 0.1em;
  overflow-wrap: anywhere;
}

.gate-actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}

.gate-warning {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 14px;
  padding: 11px 13px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--cat-2) 12%, var(--surface));
  color: color-mix(in srgb, var(--cat-2) 65%, var(--ink));
  font-size: 13px;
  line-height: 1.45;
}

.gate-warning p {
  margin: 0;
}

.gate-warning .icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

.gate-check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  font-size: 13.5px;
  cursor: pointer;
}

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

/* Botón «Bloquear Bob» en la barra de productos */
.bob-lock {
  position: absolute;
  right: 20px;
  bottom: 3px;
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: var(--subtle);
  pointer-events: auto;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.bob-lock:hover {
  background: var(--hover);
  color: var(--ink-soft);
}

html.is-desktop .bob-lock {
  top: 9px;
  bottom: auto;
  -webkit-app-region: no-drag;
}

/* Seguridad de Bob (modal) */
.security-form,
.security-confirm {
  display: grid;
  gap: 10px;
  margin: 4px 0 8px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-sunken);
}

.security-form[hidden],
.security-confirm[hidden] {
  display: none;
}

.security-form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.security-recovery {
  padding: 4px 2px;
}

.security-recovery .gate-title {
  font-size: 19px;
}

/* ─── Bóvedas compartidas (Fase 7) ─────────────────────────────────────────
   Marca discreta en la pestaña, avisos de invitación, «Solo lectura» y la
   ventana de miembros. Mismos tokens que el resto de Bob. */
.tab-icon {
  position: relative;
}

.tab-shared {
  position: absolute;
  right: 2px;
  bottom: 3px;
  display: grid;
  width: 13px;
  height: 13px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--cat) 24%, transparent);
}

.tab .tab-shared .icon {
  color: color-mix(in srgb, var(--cat) 85%, var(--ink));
}

.pw-invitations {
  display: grid;
  width: min(100%, 1180px);
  gap: 8px;
  margin: 0 0 14px;
}

.pw-invitation {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 14px;
  border: var(--panel-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  color: var(--ink);
  font-size: 13px;
}

.pw-invitation > .icon {
  color: var(--accent);
}

.pw-invitation-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pw-invitation-text > span {
  color: var(--muted);
}

.pw-invitation-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  margin-left: auto;
}

.pw-readonly {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.vault-invite {
  display: flex;
  gap: 8px;
  margin: 4px 0 8px;
}

.vault-invite input,
.vault-member select,
.vault-invite select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  outline: none;
}

.vault-invite input {
  min-width: 0;
  flex: 1;
}

.vault-invite input:focus,
.vault-invite select:focus,
.vault-member select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.vault-member-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.vault-member {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
}

.vault-member .bob-list-text {
  flex: 1;
}

.vault-member .bob-list-trailing {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.vault-member.is-pending .bob-list-title {
  color: var(--muted);
}

.vault-remove-note {
  margin: 0 0 6px;
  padding: 0 10px;
}

.vault-fingerprints summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.vault-fingerprints dl {
  display: grid;
  gap: 6px;
  margin: 10px 0 4px;
}

.vault-fingerprints dl > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.vault-fingerprints dt {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
}

.vault-fingerprints dd {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.security-fingerprint {
  flex: 0 0 auto;
  max-width: 50%;
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  text-align: right;
}

/* Bloqueo automático (Configuración → Seguridad). */
.security-select {
  height: 32px;
  flex: 0 0 auto;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
}

/* Búsqueda de Bob Passwords (en el panel de la lista, bajo la cabecera). */
.pw-search {
  display: flex;
  height: 34px;
  align-items: center;
  gap: 8px;
  margin: 10px 12px 2px 12px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  transition:
    border-color 140ms var(--ease),
    box-shadow 140ms var(--ease);
}

.pw-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  color: var(--accent);
}

.pw-search input {
  min-width: 0;
  height: 100%;
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  outline: none;
}

.pw-search input::-webkit-search-cancel-button {
  cursor: pointer;
}

.pw-search kbd {
  flex: 0 0 auto;
  opacity: 0.75;
}

.pw-search:focus-within kbd {
  display: none;
}

/* Generador de contraseñas (popover junto al campo «Contraseña»). */
.pw-generator {
  display: grid;
  width: 320px;
  gap: 12px;
}

.pw-generator-output {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}

.pw-generator-value {
  min-width: 0;
  flex: 1;
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13.5px;
  overflow-wrap: anywhere;
  user-select: all;
}

.pw-generator-strength {
  margin: -6px 0 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.pw-generator-length {
  display: grid;
  grid-template-columns: auto 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.pw-generator-length input[type="range"] {
  accent-color: var(--accent);
}

.pw-generator-length input[type="number"] {
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.pw-generator-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 13px;
}

.pw-generator-footer {
  margin-top: 2px;
}

/* Importar contraseñas (CSV). */
.pw-import-note {
  margin-bottom: 12px;
}

.pw-import-mapping {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 12px;
}

.pw-import-mapping label,
.pw-import-destination {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.pw-import-destination {
  max-width: 280px;
}

.pw-import-mapping select,
.pw-import-destination select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.pw-import-summary {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 13px;
}

.pw-import-table-wrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.pw-import-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.pw-import-table th,
.pw-import-table td {
  max-width: 200px;
  padding: 7px 10px;
  overflow: hidden;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pw-import-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}

.pw-import-table tr.is-duplicate td:first-child::after {
  content: " · posible duplicado";
  color: var(--muted);
  font-size: 11.5px;
}

.pw-import-more {
  color: var(--muted);
}

/* Estado de la sincronización (barra superior, junto al candado). */
.bob-bar-status {
  position: absolute;
  right: 56px;
  bottom: 3px;
  display: flex;
  pointer-events: auto;
}

html.is-desktop .bob-bar-status {
  top: 9px;
  bottom: auto;
  -webkit-app-region: no-drag;
}

.bob-sync {
  display: inline-flex;
  height: 30px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.bob-sync:hover {
  background: var(--hover);
  color: var(--ink);
}

.bob-sync[data-tone="ok"] .icon {
  color: var(--accent);
}

.bob-sync[data-tone="warn"] {
  color: color-mix(in srgb, var(--cat-2) 75%, var(--ink));
}

.bob-sync[data-tone="error"] {
  color: var(--danger);
}

.bob-sync[data-tone="busy"] .icon {
  animation: bob-spin 1.1s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .bob-sync[data-tone="busy"] .icon {
    animation: none;
  }
}

.sync-conflict-meta {
  color: var(--muted);
  font-size: 12px;
}

/* Acción destructiva de la cuenta, separada del resto. */
.settings-danger {
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--line-soft);
}

.sync-conflicts .settings-text {
  gap: 1px;
}

/* Dispositivos de la cuenta. */
.security-subheading {
  margin: 14px 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.security-device.is-revoked .settings-title {
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Espacios de Finance: selector (arriba a la izquierda) y solo lectura */
/* ------------------------------------------------------------------ */
.topbar-start[data-region="space"] {
  display: flex;
  align-items: center;
}

.finance-space-button {
  position: relative;
  max-width: 260px;
  -webkit-app-region: no-drag;
}

.finance-space-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.finance-space-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.finance-space-menu {
  min-width: 280px;
  max-width: 380px;
}

.finance-space-invitation {
  margin: 4px 6px;
}

/* Viewer: sin botones de añadir (el almacén, el motor y el servidor ya lo impiden). */
.finance-readonly .add-row-button,
.finance-readonly .add-section-button,
.finance-readonly .bulk-bar {
  display: none !important;
}

/* ------------------------------------------------------------------ */
/* Bob Family: contexto Personal | Familia (encima de Finance | Passwords) */
/* ------------------------------------------------------------------ */
.context-switch {
  display: inline-flex;
  margin-right: 12px;
  padding: 3px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface-sunken) 82%, var(--line));
  box-shadow: inset 0 0 0 1px rgba(27, 26, 23, 0.04);
  pointer-events: auto;
  -webkit-app-region: no-drag;
}

.context-switch-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.context-switch-option span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.context-switch-option[aria-selected="true"] {
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(27, 26, 23, 0.1), 0 2px 8px -2px rgba(27, 26, 23, 0.12);
  color: var(--ink);
}

/* Configuración → Familia */
.family-members .settings-row + .settings-row {
  border-top: var(--panel-border);
}

.family-seats {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ */
/* Configuración de Bob: secciones a la izquierda, una a la vista       */
/* ------------------------------------------------------------------ */
.bob-settings-modal {
  width: min(820px, 100%);
}

.bob-settings-modal {
  overflow: hidden;
}

.bob-settings-modal .modal-body {
  padding: 0;
  overflow: hidden;
}

.bob-settings {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  height: min(620px, 72vh);
}

.bob-settings-nav {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 14px 10px;
  border-right: 1px solid var(--line);
  background: var(--surface-sunken);
}

.bob-settings-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--list-item-radius, 8px);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms var(--ease);
}

.bob-settings-tab span {
  white-space: nowrap;
}

.bob-settings-tab .icon {
  flex: 0 0 auto;
  color: var(--muted);
}

.bob-settings-tab:hover {
  background: var(--hover);
}

.bob-settings-tab[aria-selected="true"] {
  background: var(--accent-soft);
  font-weight: 600;
}

.bob-settings-tab[aria-selected="true"] .icon {
  color: var(--accent);
}

.bob-settings-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.bob-settings-panes {
  min-width: 0;
  padding: 18px 22px 22px;
  overflow-y: auto;
}

.bob-settings-pane .security-status {
  margin: 4px 0 6px;
}

/* Correos y nombres largos: se recortan con «…» y el título completo. */
.settings-email,
.security-device-name,
.bob-settings .family-name {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.bob-settings .settings-title {
  min-width: 0;
}

.security-devices-intro {
  margin: 2px 0 4px;
}

.security-devices-empty {
  margin-top: 10px;
}

/* Ventana estrecha: las secciones pasan a una fila desplazable arriba. */
@media (max-width: 720px) {
  .bob-settings {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .bob-settings-nav {
    display: flex;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .bob-settings-tab {
    flex: 0 0 auto;
  }
}
