:root {
  --paper: #f5f4f2;
  --card: #ebebe9;
  --ink: #22332B;
  --ink-soft: #5B6B60;
  --green: #3F7D5C;
  --stamp: #C1443D;
  --gold: #C99A3E;
  --line: #C9C2AC;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Work Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 28px 18px 80px;
}

/* ---------- Cabecera ---------- */

header {
  margin-bottom: 30px;

  .title-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
  }

  .subtitle {
    font-size: 13px;
    color: var(--ink-soft);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
}

#tripName {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 32px;
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 0;
  flex: 1;
  min-width: 160px;

  &:focus {
    outline: none;
    border-bottom: 2px dashed var(--line);
  }
}

.sync-btn,
.copy-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  cursor: pointer;

  &:hover {
    border-color: var(--ink-soft);
  }
}

.share-banner {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;

  code {
    font-family: 'IBM Plex Mono', monospace;
    color: var(--ink);
  }
}

/* ---------- Secciones ---------- */

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

section {
  margin-bottom: 34px;
}

/* ---------- Participantes ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 8px 6px 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;

  button {
    border: none;
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 2px 4px;

    &:hover {
      color: var(--stamp);
    }
  }
}

/* ---------- Formularios genéricos ---------- */

.inline-form {
  display: flex;
  gap: 8px;
}

input[type="text"],
input[type="number"],
select {
  font-family: 'Work Sans', sans-serif;
  font-size: 15px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  width: 100%;

  &:focus {
    outline: 2px solid var(--green);
    outline-offset: 1px;
  }
}

button.action {
  font-family: 'Work Sans', sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  white-space: nowrap;

  &:hover {
    background: var(--green);
  }

  &:disabled {
    background: var(--line);
    cursor: not-allowed;
  }
}

/* ---------- Formulario de gasto ---------- */

.expense-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;

  .row2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .small-label {
    font-size: 12px;
    color: var(--ink-soft);
    margin-bottom: -4px;
  }
}

.share-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;

  .share-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
  }
}

/* ---------- Ticket de gasto ---------- */

.ticket {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 1fr auto;
  margin-bottom: 10px;

  .ticket-info {
    padding: 13px 16px;

    .ticket-desc {
      font-weight: 600;
      font-size: 15px;
    }

    .ticket-meta {
      font-size: 12.5px;
      color: var(--ink-soft);
      margin-top: 3px;
    }
  }

  .ticket-amount {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: 17px;
    padding: 13px 16px;
    border-left: 2px dashed var(--line);
    display: flex;
    align-items: center;
    position: relative;
    min-width: 96px;
    justify-content: flex-end;

    &::before,
    &::after {
      content: "";
      position: absolute;
      left: -6px;
      width: 11px;
      height: 11px;
      background: var(--paper);
      border-radius: 50%;
      border: 1px solid var(--line);
    }

    &::before {
      top: -6px;
    }

    &::after {
      bottom: -6px;
    }
  }

  .ticket-del {
    position: absolute;
    top: 4px;
    right: 4px;
    border: none;
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 5px;

    &:hover {
      color: var(--stamp);
    }
  }
}

/* ---------- Balances ---------- */

.balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;

  &:last-child {
    border-bottom: none;
  }
}

.balance-amt {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;

  &.pos {
    color: var(--green);
  }

  &.neg {
    color: var(--stamp);
  }
}

/* ---------- Liquidación ---------- */

.settle {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 9px;

  .stamp-badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--stamp);
    border: 1.5px solid var(--stamp);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transform: rotate(-8deg);
    flex-shrink: 0;
    line-height: 1.1;
  }

  .settle-text {
    font-size: 14.5px;

    b {
      font-weight: 600;
    }
  }

  .settle-amt {
    margin-left: auto;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
  }
}

/* ---------- Estados vacíos ---------- */

.empty {
  color: var(--ink-soft);
  font-size: 14px;
  font-style: italic;
  padding: 6px 2px;
}

.all-settled {
  color: var(--green);
  font-weight: 600;
  font-size: 14.5px;
}

/* ---------- Footer ---------- */

footer {
  text-align: center;
  margin-top: 40px;

  .reset-btn {
    border: none;
    background: none;
    color: var(--ink-soft);
    font-size: 12.5px;
    text-decoration: underline;
    cursor: pointer;

    &:hover {
      color: var(--stamp);
    }
  }
}

/* ---------- Carga / landing ---------- */

.loading,
.center-box {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
}

.landing {
  max-width: 420px;
  margin: 60px auto;
  text-align: center;

  h1 {
    font-family: 'Fraunces', serif;
    font-size: 30px;
    margin-bottom: 6px;
  }

  p {
    color: var(--ink-soft);
    font-size: 14px;
    margin-bottom: 24px;
  }

  .inline-form {
    text-align: left;
  }
}

body.landing-bg {
  min-height: 100vh;
  background-image: url('images/franquette.png');
  background-size: max(60vw, 400px);
  background-position: center 80%;
  background-repeat: no-repeat;

  .landing {
    background: var(--card);
    padding: 36px 28px;
    border-radius: 8px;
    border: 1px solid var(--line);
    box-shadow: 0 12px 34px rgba(34, 51, 43, 0.18);
  }
}

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

@media (max-width: 460px) {
  .row2 {
    grid-template-columns: 1fr;
  }

  #tripName {
    font-size: 26px;
  }
}
