/* =========================================================
   Portal de clientes · Property Title and Escrow
   Sistema de diseño propio, independiente del landing page.
   ========================================================= */

:root {
	/* Superficies */
	--bg: #f5f6f8;
	--surface: #ffffff;
	--surface-2: #f9fafb;
	--border: #e4e7ec;
	--border-strong: #d0d5dd;

	/* Texto */
	--text: #101828;
	--text-2: #344054;
	--muted: #667085;
	--subtle: #7b8494; /* íconos decorativos: contraste ≥ 3:1 sobre blanco */

	/* Marca */
	--primary: #1e3a5f;
	--primary-hover: #152c49;
	--primary-soft: #eef2f7;
	--gold: #b8913a;
	--gold-strong: #9a7429; /* íconos dorados sobre fondo claro (≥ 3:1) */

	/* Estados */
	--positive: #067647;
	--positive-soft: #ecfdf3;
	--negative: #b42318;
	--negative-soft: #fef3f2;
	--warning: #b54708;
	--warning-soft: #fffaeb;
	--neutral-soft: #f2f4f7;

	--radius: 12px;
	--radius-sm: 8px;
	--shadow: 0 1px 2px rgba(16, 24, 40, .05);
	--shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);
	--focus: 0 0 0 4px rgba(30, 58, 95, .14);

	--font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html[data-theme="dark"] {
	color-scheme: dark;
	--bg: #0d1117;
	--surface: #141a23;
	--surface-2: #101720;
	--border: #263242;
	--border-strong: #35445a;
	--text: #eef2f7;
	--text-2: #d0d7e2;
	--muted: #9aa6b6;
	--subtle: #8793a4;
	--primary: #d9b45c;
	--primary-hover: #f1cc75;
	--primary-soft: #24202b;
	--gold: #d9b45c;
	--gold-strong: #f1cc75;
	--positive: #6ee7a8;
	--positive-soft: #0f2a21;
	--negative: #ff8a80;
	--negative-soft: #301a1a;
	--warning: #fdbb74;
	--warning-soft: #2d2112;
	--neutral-soft: #202938;
	--shadow: 0 1px 2px rgba(0, 0, 0, .28);
	--shadow-lg: 0 18px 48px -16px rgba(0, 0, 0, .62);
	--focus: 0 0 0 4px rgba(217, 180, 92, .18);
}

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

/* El atributo hidden siempre oculta, aunque la clase defina display (flex, grid…) */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	transition: background-color .18s ease, color .18s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
p { margin: 0; }

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* Textos capturados (nombres, usuarios, cuentas) pueden venir sin espacios: se parten donde haga falta */
h1, .page-header p, .breadcrumb, .preview-banner, .dialog, .card__title, .details dd, .activity__main, .auth__card { overflow-wrap: anywhere; }
/* En tablas: el texto conserva su ancho natural y solo se parte si excede el máximo de la celda */
.table td { overflow-wrap: break-word; }
.table td > .strong, .table td > .sub, .table td > .tabular { display: block; max-width: 220px; }
.table td > .tabular, .table td > .sub.tabular { max-width: 180px; }
.table td > .strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.table td > .strong + .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-header > div, .card__title > div { min-width: 0; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estructura ---------- */

.topbar {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}
.topbar__inner {
	max-width: 1120px;
	margin: 0 auto;
	padding: 0 24px;
	height: 64px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.brand {
	display: flex;
	align-items: center;
	gap: 12px;
	color: var(--text);
	min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand__logo { width: 36px; height: 36px; flex-shrink: 0; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(16, 24, 40, .18)); }
html[data-theme="dark"] .brand__logo { filter: drop-shadow(0 1px 5px rgba(217, 180, 92, .18)); }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand__name { font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand__area { font-size: 12px; color: var(--muted); }

.usermenu { display: flex; align-items: center; gap: 12px; }
.usermenu__name { font-size: 14px; color: var(--text-2); text-align: right; line-height: 1.25; max-width: 220px; min-width: 0; }
.usermenu__name span, .usermenu__name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu__name small { color: var(--muted); font-size: 12px; }
.usermenu { min-width: 0; }

.theme-toggle {
	height: 34px;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 0 10px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text-2);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: border-color .15s, background-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text); }
.theme-toggle:focus-visible { outline: none; box-shadow: var(--focus); }
.theme-toggle__icon {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--text-2);
	box-shadow: inset -5px -5px 0 var(--surface);
	transition: box-shadow .18s, background-color .18s;
}
html[data-theme="dark"] .theme-toggle__icon {
	background: var(--gold);
	box-shadow: 0 0 0 3px rgba(217, 180, 92, .18);
}

.tabs {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}
.tabs__inner {
	max-width: 1120px;
	margin: 0 auto;
	padding: 0 24px;
	display: flex;
	gap: 24px;
	overflow-x: auto;
}
.tabs a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 0;
	color: var(--muted);
	font-size: 14px;
	font-weight: 500;
	border-bottom: 2px solid transparent;
	white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }

.page {
	flex: 1 0 auto;
	width: 100%;
	max-width: 1120px;
	margin: 0 auto;
	padding: 32px 24px 48px;
}

.page-header {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 24px;
	flex-wrap: wrap;
}
.page-header p { color: var(--muted); margin-top: 4px; }
.page-header__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }

.footer {
	width: 100%;
	max-width: 1120px;
	margin: 0 auto;
	padding: 24px;
	border-top: 1px solid var(--border);
	font-size: 13px;
	color: var(--muted);
	display: flex;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
}
.footer a { color: var(--muted); }

/* ---------- Tarjetas y rejillas ---------- */

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}
.card__header {
	padding: 18px 24px;
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
}
.card__header p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card__body { padding: 24px; }
.card__footer {
	padding: 16px 24px;
	border-top: 1px solid var(--border);
	background: var(--surface-2);
	border-radius: 0 0 var(--radius) var(--radius);
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
}

.stack > * + * { margin-top: 24px; }

.grid { display: grid; gap: 24px; }
.grid > * { min-width: 0; }
.grid--balance { grid-template-columns: 1.3fr 1fr; }
.grid--stats { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--detail { grid-template-columns: 340px 1fr; align-items: start; }

/* Saldo principal */
.balance {
	padding: 28px;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 24px;
}
.balance__split {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	padding-top: 20px;
	border-top: 1px solid var(--border);
}
.balance__split span:not(.icon-box) { display: block; font-size: 13px; color: var(--muted); }
.balance__split strong { display: block; font-size: 17px; font-weight: 600; margin-top: 2px; }
.balance__label { font-size: 13px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.balance__amount { font-size: 40px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.balance__amount--l { font-size: 32px; }
.balance__amount--xl { font-size: 26px; }
.grid--detail .balance__amount { font-size: 34px; }
.grid--detail .balance__amount--l { font-size: 27px; }
.grid--detail .balance__amount--xl { font-size: 22px; }
.balance__amount small { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.balance__meta { font-size: 13px; color: var(--muted); }

/* Indicadores */
.stat { padding: 20px 24px; }
.stat__label { font-size: 13px; color: var(--muted); }
.stat__value { font-size: 22px; font-weight: 600; margin-top: 4px; }

/* Lista de datos (definición) */
.details { margin: 0; }
.details__row {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	padding: 12px 0;
	border-bottom: 1px solid var(--border);
	font-size: 14px;
}
.details__row:first-child { padding-top: 0; }
.details__row:last-child { border-bottom: 0; padding-bottom: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.details--compact { margin-bottom: 18px; }

/* ---------- Tablas ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
	text-align: left;
	font-size: 12px;
	font-weight: 500;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: .04em;
	padding: 12px 24px;
	background: var(--surface-2);
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
.table td {
	padding: 14px 24px;
	border-bottom: 1px solid var(--border);
	color: var(--text-2);
	vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .right { text-align: right; }
.table .strong { color: var(--text); font-weight: 500; }
.table .sub { display: block; font-size: 13px; color: var(--muted); }

.amount--pos, .table td.amount--pos { color: var(--positive); }
.amount--neg, .table td.amount--neg { color: var(--negative); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.empty {
	padding: 48px 24px;
	text-align: center;
	color: var(--muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.empty .icon-box { width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 12px; }
.empty .icon-box .icon { width: 24px; height: 24px; }

/* ---------- Íconos ---------- */

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.btn .icon { width: 16px; height: 16px; }

.icon-box {
	display: inline-grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border-radius: 10px;
	background: var(--primary-soft);
	color: var(--primary);
	flex-shrink: 0;
}
.icon-box .icon { width: 20px; height: 20px; }
.icon-box--positive { background: var(--positive-soft); color: var(--positive); }
.icon-box--negative { background: var(--negative-soft); color: var(--negative); }
.icon-box--warning { background: var(--warning-soft); color: var(--warning); }
.icon-box--gold { background: #faf5ea; color: var(--gold-strong); }

/* Encabezado de tarjeta con ícono */
.card__title { display: flex; align-items: center; gap: 14px; }

/* Indicador con ícono */
.stat { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
/* Indicadores que filtran la lista */
.stat--link { color: inherit; transition: border-color .15s, box-shadow .15s; }
.stat--link:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: 0 4px 12px -4px rgba(16, 24, 40, .12); }
.stat--link:focus-visible { outline: none; box-shadow: var(--focus); }
.stat--link[aria-current="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

/* Movimiento: ícono de entrada / salida + descripción */
.tx { display: flex; align-items: center; gap: 12px; }
/* Descripciones largas: se parten aunque no tengan espacios y se limitan a 2 líneas (el texto completo va en title) */
.tx > div { min-width: 0; max-width: 360px; }
.tx .strong, .activity__main .strong {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	overflow-wrap: anywhere;
}
.table .strong, .table .sub, .details dd { overflow-wrap: anywhere; }
.tx .icon-box { width: 34px; height: 34px; border-radius: 50%; }
.tx .icon-box .icon { width: 16px; height: 16px; }

/* Etiqueta con ícono (saldo, datos) */
.with-icon { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Ayuda / contacto ---------- */

.help { padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.help p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.help__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.help__actions .btn { height: auto; min-height: 48px; padding: 6px 16px; justify-content: flex-start; text-align: left; }
.help__actions .btn span { display: flex; flex-direction: column; line-height: 1.3; }
.help__actions small { font-size: 12px; font-weight: 400; color: var(--muted); }
.help__actions .btn { white-space: normal; }
.help__actions small { overflow-wrap: anywhere; }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; }

/* ---------- Bancos ---------- */

.banks {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 12px;
}
.bank {
	display: grid;
	place-items: center;
	height: 76px;
	padding: 12px 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: #fff;
	transition: border-color .15s, box-shadow .15s;
}
.bank:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.bank img { max-width: 100%; height: auto; object-fit: contain; } /* ancho y alto vienen de medidas_logo() */

/* ---------- Insignias ---------- */

.badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 500;
	white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--positive { background: var(--positive-soft); color: var(--positive); }
.badge--negative { background: var(--negative-soft); color: var(--negative); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--neutral { background: var(--neutral-soft); color: var(--muted); }

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

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 40px;
	padding: 0 16px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border-strong);
	background: var(--surface);
	color: var(--text-2);
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:disabled, .btn:disabled:hover { opacity: .45; cursor: not-allowed; }
.btn--primary:disabled:hover { background: var(--primary); border-color: var(--primary); }
.btn--danger { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn--danger:hover { background: #912018; border-color: #912018; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--neutral-soft); color: var(--text); }
.btn--link-danger { border-color: transparent; background: transparent; color: var(--negative); }
.btn--link-danger:hover { background: var(--negative-soft); }
.btn--sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn--block { width: 100%; }

/* ---------- Formularios ---------- */

.form-section { padding: 24px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 240px 1fr; gap: 24px; }
.form-section:last-of-type { border-bottom: 0; }
.form-section__intro h2 { font-size: 15px; }
.form-section__intro p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }

.field label { display: block; font-size: 14px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.field .hint:empty { display: none; }
.field__action { margin-top: 8px; margin-left: -10px; }
.field--spaced { margin-top: 18px; }

/* Errores por campo */
.field-error { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; font-weight: 500; color: var(--negative); margin-top: 6px; }
.field-error::before { content: "!"; flex-shrink: 0; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; background: var(--negative); color: #fff; font-size: 11px; font-weight: 700; }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--negative); }
.input[aria-invalid="true"]:focus, .select[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(180, 35, 24, .14); }
.input, .select {
	width: 100%;
	height: 42px;
	padding: 0 12px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 15px;
	transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); opacity: .85; }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input--amount { font-variant-numeric: tabular-nums; }
/* Descripciones del catálogo: se guardan en mayúsculas, así se ven desde que se escriben */
.input--mayus { text-transform: uppercase; }
.input--mayus::placeholder { text-transform: none; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-prefix .input { padding-left: 28px; }

.select-filter {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 8px 10px;
	margin-bottom: 8px;
}
.select-filter__input { height: 38px; font-size: 14px; }
.select-filter__meta {
	min-width: 24px;
	color: var(--muted);
	font-size: 13px;
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.password-field { position: relative; }
.password-field .input { padding-right: 72px; }
.password-field button {
	position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
	height: 30px; padding: 0 10px; border: 0; border-radius: 6px;
	background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.password-field button:hover { background: var(--neutral-soft); color: var(--text); }

/* Selector segmentado (depósito / retiro) */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
	display: flex; align-items: center; justify-content: center; gap: 8px;
	height: 42px; margin: 0;
	border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
	font-size: 14px; font-weight: 500; color: var(--text-2); cursor: pointer;
	transition: all .15s;
}
.segmented input:focus-visible + label { box-shadow: var(--focus); }
.segmented input[value="deposito"]:checked + label { border-color: var(--positive); background: var(--positive-soft); color: var(--positive); }
.segmented input[value="retiro"]:checked + label { border-color: var(--negative); background: var(--negative-soft); color: var(--negative); }

.form-actions {
	padding: 16px 24px;
	border-top: 1px solid var(--border);
	background: var(--surface-2);
	border-radius: 0 0 var(--radius) var(--radius);
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

/* ---------- Avisos ---------- */

.alert {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 14px 16px;
	border-radius: var(--radius-sm);
	border: 1px solid;
	font-size: 14px;
	margin-bottom: 24px;
}
.alert strong { display: block; font-weight: 600; }
.alert--success { background: var(--positive-soft); border-color: #abefc6; color: #085d3a; }
.alert--error { background: var(--negative-soft); border-color: #fecdca; color: #912018; }
.alert--warning { background: var(--warning-soft); border-color: #fedf89; color: #93370d; }
.alert__icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }

/* ---------- Buscador ---------- */

.search { position: relative; width: 280px; max-width: 100%; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--subtle); }
.search .input { height: 38px; padding-left: 36px; font-size: 14px; }
.link-count {
	display: inline-flex;
	align-items: center;
	justify-content: flex-end;
	min-width: 24px;
	font-weight: 600;
	color: var(--primary);
	text-decoration: underline;
	text-underline-offset: 3px;
}
.link-count:hover { color: var(--primary-hover); }

/* ---------- Diálogo de confirmación ---------- */

.dialog {
	border: 0;
	border-radius: var(--radius);
	padding: 0;
	width: min(440px, calc(100% - 32px));
	box-shadow: var(--shadow-lg);
	color: var(--text);
}
.dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dialog__body { padding: 24px; }
.dialog__body h2 { font-size: 17px; }
.dialog__body p { color: var(--muted); margin-top: 8px; font-size: 14px; }
.dialog__actions { padding: 0 24px 24px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Login ---------- */

.auth {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 32px 16px;
}
.auth__card { width: 100%; max-width: 400px; }
.auth__brand { text-align: center; margin-bottom: 28px; }
.auth__brand img { width: 56px; height: 56px; object-fit: contain; }
.auth__brand h1 { font-size: 20px; margin-top: 14px; }
.auth__brand p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.auth__form { padding: 28px; }
.auth__form .field + .field { margin-top: 16px; }
.auth__form .btn { margin-top: 24px; height: 44px; }
.auth__note { margin-top: 24px; text-align: center; font-size: 13px; color: var(--muted); }
.auth__note a { color: var(--muted); }
.auth__rule { width: 32px; height: 2px; background: var(--gold); margin: 14px auto 0; border-radius: 2px; }

/* ---------- Selector de idioma ---------- */

.lang {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	padding: 3px;
	border: 1px solid var(--border);
	border-radius: 999px;
	color: var(--muted);
}
.lang .icon { width: 16px; height: 16px; margin: 0 4px 0 6px; }
.lang a {
	padding: 2px 9px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	color: var(--muted);
	letter-spacing: .02em;
}
.lang a:hover { color: var(--text); text-decoration: none; }
.lang a[aria-current="true"] { background: var(--primary); color: #fff; }
.auth__lang { display: flex; justify-content: flex-end; margin-bottom: 16px; }

/* ---------- Filtros de la lista ---------- */

.filters {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 12px 16px;
	padding: 16px 24px;
	border-bottom: 1px solid var(--border);
	background: var(--surface-2);
}
.filters .search { width: 300px; }
.filters__field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.filters__field .select { height: 38px; font-size: 14px; min-width: 180px; }
.filters[aria-busy="true"] ~ [data-swap="resultados"] { opacity: .55; transition: opacity .15s; }
.filters__field--sm .select { min-width: 88px; }

/* ---------- Paginación de la lista ---------- */

.pagination { flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pagination__nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pagination__pages { display: flex; align-items: center; gap: 2px; }
.pagination__num { min-width: 32px; justify-content: center; padding: 0 8px; }
.pagination__num[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination__gap { padding: 0 4px; }
.pagination__prev .icon { transform: rotate(180deg); }
.pagination__compact { display: none; padding: 0 8px; white-space: nowrap; }

/* ---------- Actividad reciente ---------- */

.activity { list-style: none; margin: 0; padding: 0; }
.activity li + li { border-top: 1px solid var(--border); }
.activity__item {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 24px;
	color: inherit;
}
.activity__item:hover { background: var(--surface-2); text-decoration: none; }
.activity__item .icon-box { width: 34px; height: 34px; border-radius: 50%; }
.activity__item .icon-box .icon { width: 16px; height: 16px; }
.activity__main, .activity__side { display: flex; flex-direction: column; min-width: 0; }
.activity__main { flex: 1; }
.activity__main .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity__side { align-items: flex-end; text-align: right; flex-shrink: 0; }
.activity .strong { color: var(--text); font-weight: 500; font-size: 14px; }
.activity .sub { font-size: 13px; color: var(--muted); }
.activity .amount--pos { color: var(--positive); }
.activity .amount--neg { color: var(--negative); }

/* ---------- Saldo resultante al registrar un movimiento ---------- */

.preview {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin-top: 20px;
	padding: 12px 16px;
	border-radius: var(--radius-sm);
	background: var(--primary-soft);
	font-size: 14px;
	color: var(--text-2);
}
.preview__values { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; }
.preview__values strong { font-size: 17px; color: var(--text); }
.preview__alert { display: inline-flex; align-items: center; gap: 6px; flex-basis: 100%; color: var(--negative); font-weight: 500; }
.preview__alert .icon { width: 16px; height: 16px; }
.preview--negativo { background: var(--negative-soft); }
.preview--negativo .preview__values strong { color: var(--negative); }

/* ---------- Aviso de vista previa como cliente ---------- */

.preview-banner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	padding: 14px 18px;
	margin-bottom: 24px;
	border: 1px solid #ecdcb8;
	border-radius: var(--radius);
	background: #fdf9f0;
	font-size: 14px;
}
.preview-banner strong { display: block; color: var(--text); }
.preview-banner span { color: var(--muted); }

/* ---------- Responsivo ---------- */

@media (max-width: 1100px) {
	.grid--detail { grid-template-columns: 1fr; }
	.hide-lg { display: none; }
	.btn__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

@media (max-width: 900px) {
	.grid--balance, .grid--detail { grid-template-columns: 1fr; }
	.form-section { grid-template-columns: 1fr; gap: 16px; }
}

/* Tablet: se ocultan columnas secundarias para que la tabla quepa sin desplazamiento */
@media (min-width: 641px) and (max-width: 960px) {
	.table th, .table td { padding-left: 14px; padding-right: 14px; }
	.hide-md { display: none; }
}

@media (max-width: 640px) {
	.hide-sm { display: none; }
	.btn__label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
	.topbar__inner { gap: 8px; }
	.usermenu { flex-shrink: 0; }
	.brand { min-width: 0; }
	.lang a { padding: 2px 7px; }
	.theme-toggle { width: 34px; padding: 0; justify-content: center; }
	.theme-toggle__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
	.form-actions { flex-wrap: wrap; }
	.form-actions .btn { flex: 1 1 auto; }
	.lang .icon { display: none; }
	.brand { flex: 1 1 auto; }
	.brand__text { overflow: hidden; }
	.brand__name { overflow: hidden; text-overflow: ellipsis; }
	.usermenu { gap: 8px; }
	.filters { padding: 12px 16px; }
	.filters .search, .filters__field { width: 100%; }
	.filters__field .select { width: 100%; }
	/* Paginación en teléfono: Anterior · Página X de Y · Siguiente */
	.pagination { padding: 12px 16px; justify-content: center; text-align: center; }
	.pagination__nav { width: 100%; justify-content: space-between; flex-wrap: nowrap; }
	.pagination__pages { display: none; }
	.pagination__compact { display: inline; padding: 0 4px; }
	.activity__item { padding: 12px 16px; }
	body { font-size: 14px; }
	.topbar__inner, .tabs__inner, .page, .footer { padding-left: 16px; padding-right: 16px; }
	.page { padding-top: 24px; }
	.brand__area, .usermenu__name { display: none; }
	/* El cliente sigue viendo su número de cuenta en el encabezado */
	.usermenu__name--cliente { display: block; max-width: 110px; }
	.usermenu__name--cliente span { display: none; }
	h1 { font-size: 21px; }
	.grid--stats { grid-template-columns: 1fr 1fr; gap: 12px; }
	.grid--stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
	.stat { padding: 14px 16px; }
	.stat__value { font-size: 19px; }
	.balance__amount { font-size: 32px; }
	.balance__amount--l { font-size: 26px; }
	.balance__amount--xl { font-size: 22px; }
	.balance__split { grid-template-columns: 1fr; }
	.form-grid { grid-template-columns: 1fr; }
	.card__header, .card__body, .form-section { padding-left: 16px; padding-right: 16px; }
	.search { width: 100%; }

	/* Las tablas se convierten en tarjetas apiladas */
	.table--stack thead { display: none; }
	.table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
	.table--stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
	.table--stack tbody tr:last-child { border-bottom: 0; }
	/* Etiqueta a la izquierda; el valor (y su dato secundario, si lo hay) apilados a la derecha */
	.table--stack td { border: 0; padding: 4px 0; display: grid; grid-template-columns: auto 1fr; column-gap: 16px; text-align: right; }
	.table--stack td::before { content: attr(data-label); grid-row: 1 / span 2; color: var(--muted); font-size: 13px; font-weight: 400; text-align: left; }
	.table--stack td:not([data-label])::before { content: none; }
	.table--stack td > * { grid-column: 2; justify-self: end; }
	.table--stack .tx .icon-box { display: none; }
	.tx > div { max-width: none; }
	.banks { grid-template-columns: repeat(2, 1fr); gap: 8px; }
	.bank { height: 64px; }
	.bank img { max-height: 32px; }	.table--stack td.right { text-align: right; }
	.table--stack .row-actions { justify-content: flex-end; }

	/* Movimientos: lista compacta. Descripción y fecha a la izquierda; monto y saldo a la derecha */
	.table--tx tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; align-items: center; padding: 12px 16px; }
	.table--tx td { display: block; padding: 0; text-align: left; }
	.table--tx td::before { content: none; }
	.table--tx td > * { justify-self: auto; }
	.table--tx .tx-desc { grid-column: 1; grid-row: 1; }
	.table--tx .tx-fecha { grid-column: 1; grid-row: 2; padding-left: 46px; font-size: 13px; color: var(--muted); }
	.table--tx .tx-monto { grid-column: 2; grid-row: 1; text-align: right; font-weight: 600; }
	.table--tx .tx-saldo { grid-column: 2; grid-row: 2; text-align: right; font-size: 13px; font-weight: 400; color: var(--muted); }
	.table--tx .tx-saldo::before { content: attr(data-label) " "; }
	.table--tx .tx .icon-box { display: inline-grid; }
	.table--tx .tx { align-items: flex-start; }
	.table--tx .tx .sub { font-size: 12px; }
	.table--tx td { width: auto; }
	.help { padding: 16px; }
	.help__actions, .help__actions .btn { width: 100%; }
	.table--stack tbody tr:hover td { background: transparent; }
}

/* ---------- Editar movimiento ---------- */

.form-narrow { max-width: 760px; }
/* Marca de movimiento corregido en el historial del admin */
.tx-editado { color: var(--warning); }
.table--tx .row-actions { flex-wrap: nowrap; }
/* Historial con acciones: celdas un poco más compactas para que quepan las 5 columnas */
.table--tx th, .table--tx td { padding-left: 16px; padding-right: 16px; }
.table--acciones td:last-child, .table--acciones th:last-child { padding-left: 4px; }

@media (max-width: 640px) {
	/* Historial del admin: editar y eliminar en una tercera línea, alineados a la derecha */
	.table--acciones td:last-child { grid-column: 1 / -1; grid-row: 3; padding: 4px 0 0; }
	.table--acciones td:last-child .row-actions { justify-content: flex-end; }
}
