/* Gastos compartidos · estilos (mobile first, modo claro y oscuro) */

:root {
  color-scheme: light dark;
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #f3eee7;
  --text: #1d1916;
  --muted: #6e645c;
  --border: #e6ddd3;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #fdebdd;
  --on-accent: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #a14a07;
  --warn-soft: #fef3c7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --wa: #15803d;
  --wa-hover: #166534;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(41 28 16 / 0.05), 0 6px 20px rgb(41 28 16 / 0.05);
  --focus: 0 0 0 3px rgb(194 65 12 / 0.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141110;
    --surface: #1d1917;
    --surface-2: #28221f;
    --text: #f3ede7;
    --muted: #a69b92;
    --border: #372f2b;
    --accent: #f97316;
    --accent-hover: #fb923c;
    --accent-soft: #3b2415;
    --on-accent: #1b0f07;
    --ok: #4ade80;
    --ok-soft: #10301c;
    --warn: #fbbf24;
    --warn-soft: #3a2b0b;
    --info: #93c5fd;
    --info-soft: #172947;
    --danger: #f87171;
    --danger-soft: #3d1414;
    --shadow: none;
    --focus: 0 0 0 3px rgb(249 115 22 / 0.45);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}
a:hover {
  color: var(--accent-hover);
}

h1,
h2 {
  line-height: 1.2;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 1.6rem;
}
h2 {
  font-size: 1.1rem;
}
p {
  margin: 0 0 0.75rem;
}
code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 6px;
  word-break: break-all;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: -0.15em;
}

/* ---------- Barra superior (admin) ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-inner form {
  margin: 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand .icon {
  color: var(--accent);
  width: 1.3em;
  height: 1.3em;
}
.tabs {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 8px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tabs a {
  padding: 10px 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a:hover {
  color: var(--text);
}
.tabs a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- Tarjetas y encabezados ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card > :last-child {
  margin-bottom: 0;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 16px;
}
.page-head h1 {
  margin: 0;
}

.hero {
  padding: 20px 2px 12px;
}
.hero h1 {
  font-size: 2rem;
  margin-bottom: 4px;
}
.hero-meta {
  color: var(--muted);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Estado de cada persona ---------- */

.status-warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}
.status-info {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 35%, transparent);
}
.status-ok {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
}
.status-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  font-weight: 700;
}
.amount-big {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.pay-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.pay-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.pay-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 1.05rem;
}
.pay-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 6px 6px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}
.pay-account-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.account-bank {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}
.account-text {
  font-family: var(--mono);
  font-size: 0.95rem;
  word-break: break-all;
}
.settled {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  color: var(--ok);
  font-weight: 600;
}

/* ---------- Listas ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list > li + li {
  border-top: 1px solid var(--border);
}
.card.list {
  padding: 4px 16px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.row > :first-child {
  min-width: 0;
}
.row-end {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.row-end form {
  margin: 0;
}
.row.total {
  font-weight: 700;
}
.list-links .link-row {
  color: inherit;
  text-decoration: none;
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 8px;
}
.list-links .link-row:hover {
  background: var(--surface-2);
}
.link-row .icon {
  color: var(--muted);
}

.strong {
  font-weight: 600;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875rem;
}
.center {
  text-align: center;
}
.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.arrow {
  display: inline-flex;
  vertical-align: middle;
  color: var(--muted);
}
.arrow .icon {
  width: 0.95em;
  height: 0.95em;
}

/* ---------- Chips ---------- */

.chips {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip .icon {
  width: 1em;
  height: 1em;
}
.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.chip-info {
  background: var(--info-soft);
  color: var(--info);
}
.chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.chip-muted {
  background: var(--surface-2);
  color: var(--muted);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}
.btn-sm {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.9rem;
  border-radius: 8px;
}
.btn-block {
  width: 100%;
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-wa,
.btn-wa:hover {
  color: #fff;
}
.btn-wa {
  background: var(--wa);
}
.btn-wa:hover {
  background: var(--wa-hover);
}
.btn-danger,
.btn-danger:hover {
  color: #fff;
}
.btn-danger {
  background: #b91c1c;
}
.btn-danger:hover {
  background: #991b1b;
}
.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.btn-danger-ghost:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn.is-done {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: transparent;
}
.btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}
.btn:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.actions form {
  margin: 0;
}

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

.form .field {
  margin-bottom: 16px;
}
label,
legend {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
input:not([type="checkbox"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 75%, transparent);
}
textarea {
  min-height: 88px;
  resize: vertical;
}
select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8079' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}
.input-money {
  position: relative;
}
.input-money span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.input-money input {
  padding-left: 28px !important;
  font-variant-numeric: tabular-nums;
}
.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.preset {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.preset:hover {
  background: var(--surface-2);
}
.preset:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.preset[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}
.check-tools {
  display: flex;
  gap: 4px;
  margin: -4px 0 8px;
}
.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.checks-wide {
  grid-template-columns: 1fr;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
}
.check:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
}
.check-inline,
.check-inline:has(input:checked) {
  min-height: 0;
  padding: 4px 0;
  border: 0;
  background: none;
}

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

.flash {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 500;
}
.flash-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.flash-error {
  background: var(--danger-soft);
  color: var(--danger);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: min(560px, calc(100% - 32px));
  padding: 12px 8px 12px 16px;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
  transform: translateX(-50%);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.25s, transform 0.25s;
}
.toast-ok {
  background: #166534;
}
.toast-error {
  background: #991b1b;
}
.toast.is-hiding {
  opacity: 0;
  transform: translate(-50%, 12px);
}
.toast-close {
  flex: none;
  width: 28px;
  height: 28px;
  margin: -4px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.toast-close:hover {
  background: rgb(255 255 255 / 0.15);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}
.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
}
.notice-warn {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.missing-accounts p {
  margin: 0 0 10px;
}
.account-fields {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.account-fields legend {
  float: left;
  width: 100%;
  margin-bottom: 0;
}
.account-fields > .hint {
  clear: both;
  margin: 0 0 12px;
}
.form .account-fields .field:last-child {
  margin-bottom: 0;
}
.note {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.note p:last-child {
  margin: 0;
  white-space: pre-line;
}
.note-label {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Resumen (admin) ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 16px;
}
@media (min-width: 640px) {
  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.stat {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.person-row {
  display: grid;
  gap: 10px;
  padding: 12px 0;
}
.person-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.person-head a {
  color: var(--text);
  text-decoration: none;
}
.person-head a:hover {
  text-decoration: underline;
}
.transfer {
  padding: 12px 0;
}
.transfer .row {
  align-items: flex-start;
  padding: 0 0 8px;
}
.transfer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}
.transfer-actions form {
  margin: 0;
}
details.partial > summary {
  list-style: none;
}
details.partial > summary::-webkit-details-marker {
  display: none;
}
details.partial[open] > summary {
  background: var(--surface-2);
  color: var(--text);
}
.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.inline-form input:not([type="hidden"]) {
  width: 140px;
  min-height: 36px;
  padding: 6px 10px;
}

.breakdown {
  margin-top: 10px;
  font-size: 0.9rem;
}
.breakdown summary {
  width: fit-content;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.breakdown ul {
  list-style: none;
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface-2);
}
.breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}
.breakdown li small {
  display: block;
  color: var(--muted);
}
.breakdown li.total {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-weight: 700;
}

.onboarding h1 {
  font-size: 1.5rem;
}
.steps {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}
.steps li.done {
  color: var(--muted);
  text-decoration: line-through;
}
.steps li.done::before {
  content: "✓";
  background: var(--ok-soft);
  color: var(--ok);
}

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

.auth {
  max-width: 400px;
  margin: 6vh auto 0;
}
.auth-head {
  margin-bottom: 16px;
  text-align: center;
}
.auth-mark {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
}
.auth-mark .icon {
  width: 28px;
  height: 28px;
}

/* ---------- Varios ---------- */

.empty {
  padding: 28px 16px;
  text-align: center;
}
.empty-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ok);
  font-weight: 600;
}
.link-box {
  margin: 8px 0 12px;
}
.danger-form {
  margin: 8px 0 24px;
  text-align: center;
}
.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}
.danger-zone h2 {
  color: var(--danger);
}
.bullets {
  padding-left: 1.2rem;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.copy-buffer {
  position: fixed;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
}
