/* ── Botones ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius);
  font-weight: 700; font-size: .95rem; line-height: 1; white-space: nowrap;
  background: var(--surface-2); color: var(--text); border-color: var(--border);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), opacity var(--dur);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: var(--surface); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { min-height: 36px; padding: 0 var(--space-3); font-size: .85rem; border-radius: var(--radius-sm); }
.btn--block { width: 100%; }
.btn--icon { width: 40px; min-height: 40px; padding: 0; border-radius: var(--radius-sm); }
.btn--icon.btn--sm { width: 34px; min-height: 34px; }

.topbar .btn--icon { color: var(--header-text); background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); }
.topbar .btn--icon:hover { background: rgba(255, 255, 255, .24); }

/* Botón con estado (entregado / pagado) */
.toggle {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--space-3);
  border-radius: 999px; font-size: .82rem; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-muted);
  transition: all var(--dur) var(--ease);
}
.toggle svg { width: 16px; height: 16px; }
.toggle[aria-pressed="true"] { background: var(--success-soft); border-color: var(--success); color: var(--success); }

/* ── Tarjetas ─────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--space-4);
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.card__title { font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.stack { display: grid; gap: var(--space-4); }
.stack--sm { gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ── Formularios ──────────────────────────────────────────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field__label { font-size: .78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.field__hint { font-size: .8rem; color: var(--text-faint); }
.field__error { font-size: .85rem; color: var(--danger); font-weight: 600; }

.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 1rem; /* 16px: evita el zoom automático en iOS */
  transition: border-color var(--dur), box-shadow var(--dur);
}
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-faint); }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238a96ab' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.select option { background: var(--surface); color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }

.check { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.input-group { display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.input-group:focus-within { border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group .input { border: 0; background: transparent; box-shadow: none; }
.input-group__affix { padding: 0 12px; color: var(--text-muted); font-weight: 700; white-space: nowrap; }

/* ── Pestañas de cliente ──────────────────────────────────── */
.tabs { display: flex; gap: var(--space-2); overflow-x: auto; padding: 2px 2px var(--space-2); margin: 0 calc(var(--space-4) * -1); padding-left: var(--space-4); padding-right: var(--space-4); scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.tab {
  flex: none; scroll-snap-align: start; display: grid; gap: 1px; text-align: left;
  padding: 8px var(--space-4); border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: all var(--dur) var(--ease);
}
.tab__name { font-weight: 700; font-size: .92rem; }
.tab__sub { font-size: .75rem; color: var(--text-muted); }
.tab--debt .tab__sub { color: var(--danger); font-weight: 700; }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow); }
.tab[aria-selected="true"] .tab__sub { color: var(--accent-contrast); opacity: .9; }
@media (min-width: 900px) { .tabs { margin: 0; padding-left: 2px; padding-right: 2px; } }

/* ── Cifras ───────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-3) var(--space-3); text-align: center; min-width: 0; }
.tile__label { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.tile__value { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.15rem; line-height: 1.2; margin-top: 2px; overflow-wrap: anywhere; }
.tile__note { font-size: .72rem; color: var(--text-faint); margin-top: 2px; }
.tile--hero { background: var(--accent-soft); border-color: var(--accent); }
.tile--hero .tile__value { font-size: 1.3rem; }
.c-total { color: var(--c-total); }
.c-molienda { color: var(--c-molienda); }
.c-cuchara { color: var(--c-cuchara); }
.c-debt { color: var(--danger); }
.c-ok { color: var(--success); }
@media (max-width: 400px) { .tile__value { font-size: 1rem; } .tile--hero .tile__value { font-size: 1.1rem; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--space-3); }
.stat__label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.stat__value { font-family: var(--font-num); font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat__sub { font-size: .78rem; color: var(--text-muted); }

/* ── Listas ───────────────────────────────────────────────── */
.list { display: grid; gap: var(--space-2); }
.item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); background: var(--surface-2); border-radius: var(--radius-sm); min-width: 0; }
.item__main { flex: 1; min-width: 0; }
.item__title { font-weight: 700; overflow-wrap: anywhere; }
.item__sub { font-size: .82rem; color: var(--text-muted); overflow-wrap: anywhere; }
.item__end { text-align: right; flex: none; }
.item--off { opacity: .6; }

/* Tarjeta de registro */
.reg { display: grid; gap: var(--space-3); }
.reg__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.reg__date { font-weight: 800; }
.reg__who { font-size: .82rem; color: var(--text-muted); }
.reg__total { font-family: var(--font-num); font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; text-align: right; }
.reg__lines { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .84rem; font-weight: 600; }
.chip b { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.chip--special { border-color: var(--accent-text); color: var(--accent-text); }
.reg__note { font-size: .86rem; color: var(--text-muted); font-style: italic; }
.reg__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: var(--space-3); }
.reg--paid { border-left: 4px solid var(--success); }
.reg--debt { border-left: 4px solid var(--danger); }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 800; letter-spacing: .04em; background: var(--surface-3); color: var(--text-muted); }
.badge--ok { background: var(--success-soft); color: var(--success); }
.badge--warn { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--accent { background: var(--accent-soft); color: var(--accent-text); }

/* Desglose */
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent-text); border-radius: 99px; }

/* Filas de línea en el formulario de registro */
.lines { display: grid; gap: var(--space-2); }
.line { display: grid; grid-template-columns: 1fr 96px auto; gap: var(--space-2); align-items: start; }
.line__amount { grid-column: 1 / -1; font-size: .82rem; color: var(--text-muted); margin-top: -4px; padding-left: 2px; }
.preview { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--accent-soft); font-weight: 700; }
.preview__value { font-family: var(--font-num); font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Temas (selector) */
.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-3); }
.theme-opt { display: grid; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius); background: var(--surface-2); border: 2px solid var(--border); text-align: left; transition: border-color var(--dur); }
.theme-opt[aria-pressed="true"] { border-color: var(--accent-text); }
.theme-opt__sw { display: flex; height: 34px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-strong); }
.theme-opt__sw i { flex: 1; }
.theme-opt__name { font-weight: 700; font-size: .9rem; }

/* ── Diálogo (hoja inferior en móvil, centrado en escritorio) ─ */
dialog.modal {
  padding: 0; border: 0; background: var(--surface); color: var(--text);
  width: min(560px, 100%); max-width: 100%; max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin: auto auto 0; box-shadow: var(--shadow-lg); overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; animation: sheet var(--dur) var(--ease); }
dialog.modal::backdrop { background: var(--overlay); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4); border-bottom: 1px solid var(--border); }
.modal__body { padding: var(--space-4); overflow-y: auto; display: grid; gap: var(--space-4); }
.modal__foot { display: flex; gap: var(--space-3); justify-content: flex-end; padding: var(--space-4); padding-bottom: max(var(--space-4), env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.modal__foot .btn { flex: 1; }
@media (min-width: 700px) {
  dialog.modal { margin: auto; border-radius: var(--radius-lg); }
  .modal__foot .btn { flex: none; min-width: 120px; }
}
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Avisos ───────────────────────────────────────────────── */
.toasts { position: fixed; z-index: 100; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--space-4) + env(safe-area-inset-bottom)); display: grid; gap: var(--space-2); justify-items: center; padding: 0 var(--space-4); pointer-events: none; }
.toast { pointer-events: auto; max-width: 440px; padding: 12px 16px; border-radius: var(--radius); background: var(--text); color: var(--surface); font-weight: 600; font-size: .92rem; box-shadow: var(--shadow-lg); animation: sheet var(--dur) var(--ease); }
.toast--error { background: var(--danger); color: var(--surface); }
.toast--ok { background: var(--success); color: var(--surface); }
@media (min-width: 900px) { .toasts { bottom: var(--space-5); } }

.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600; background: var(--warning-soft); color: var(--warning); }
.alert--danger { background: var(--danger-soft); color: var(--danger); }

/* ── Estados ──────────────────────────────────────────────── */
.empty { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-6) var(--space-4); text-align: center; color: var(--text-muted); }
.empty svg { width: 44px; height: 44px; color: var(--text-faint); }
.empty__title { font-weight: 800; color: var(--text); }

.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.page-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Detalles específicos del tema Hacker */
[data-theme="hacker-dark"] .btn--primary { box-shadow: 0 0 14px rgba(198, 253, 14, .3); }
[data-theme="hacker-dark"] .topbar__title,
[data-theme="hacker-dark"] .auth__title { text-shadow: 0 0 14px rgba(198, 253, 14, .5); }
[data-theme="hacker-dark"] .tile__value,
[data-theme="hacker-dark"] .reg__total { text-shadow: 0 0 10px rgba(198, 253, 14, .25); }

/* Campo de precio dentro de una fila de lista */
.item .input-group { width: 150px; flex: none; }
.item .input-group .input { min-height: 40px; padding: 6px 8px; }
@media (max-width: 480px) { .item:has(.input-group) { flex-wrap: wrap; } .item .input-group { width: 100%; } }

/* ── Correcciones de la revisión visual ─────────────────── */
.item > svg { width: 20px; height: 20px; flex: none; color: var(--text-muted); }
.page-head > .grow { flex: 1 1 14rem; }
.page-head h1 { overflow-wrap: anywhere; }
.page-head__actions { flex: none; }
.stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); }
.toasts { max-height: 40vh; overflow: hidden; }
