/* =========================================================================
   Minhas Contas — v2 : visual enxuto, moderno, tipografia com hierarquia.
   ========================================================================= */

:root {
  font-size: 16px;

  --bg: #f5f6f9;
  --surface: #ffffff;
  --hair: #eef0f4;
  --line: #dfe3ea;

  --ink: #14171f;
  --ink-2: #3c434f;
  --muted: #8b93a3;

  --accent: #0e7d70;
  --accent-ink: #0a5f55;
  --accent-tint: #e3f2ef;

  --pos: #0f7a54;
  --pos-tint: #e6f4ed;
  --neg: #d0473f;
  --neg-tint: #fceceb;
  --warn: #a06a12;

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --sh-1: 0 1px 2px rgba(18, 28, 45, 0.05), 0 6px 20px rgba(18, 28, 45, 0.05);
  --sh-2: 0 8px 40px rgba(12, 20, 34, 0.18);

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter',
    'Helvetica Neue', Arial, sans-serif;
}
.ts-lg {
  font-size: 17px;
}
.ts-xl {
  font-size: 18.5px;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1,
h2,
h3,
p {
  margin: 0;
}
b {
  font-weight: 600;
}

.money,
.hero__val,
.card__sum,
.row__amt,
.stat__t b,
.dl__r b {
  font-variant-numeric: tabular-nums;
}

:where(button, input, select, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.loading {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.ic {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  display: block;
}

/* ------------------------------- layout ------------------------------- */

.app {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 0 0.9rem calc(2rem + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* ------------------------------- header ------------------------------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -0.9rem;
  padding: calc(0.55rem + var(--sat)) 0.9rem 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
.top__side {
  flex: 1;
  display: flex;
}
.top__side--r {
  justify-content: flex-end;
}

.mo {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.mo__arw {
  width: 2.1rem;
  height: 2.1rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.mo__arw:active {
  background: var(--hair);
}
.mo__lbl {
  position: relative;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  padding: 0.35rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--ink);
}
.mo__lbl:active {
  background: var(--hair);
}
.mo__in {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
}

.iconbtn {
  width: 2.3rem;
  height: 2.3rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.iconbtn:active {
  background: var(--hair);
}
.iconbtn--sm {
  width: 2rem;
  height: 2rem;
}
.iconbtn--danger {
  color: var(--neg);
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}

/* -------------------------------- hero -------------------------------- */

.hero {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: 1.15rem 1.15rem 1rem;
}
.hero__lbl {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero__val {
  margin-top: 0.15rem;
  font-size: 2.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hero__val.is-pos {
  color: var(--pos);
}
.hero__val.is-neg {
  color: var(--neg);
}

.hero__stats {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  min-width: 0;
}
.stat--tap {
  cursor: pointer;
}
.stat--tap:active {
  background: var(--hair);
}
.stat__ic {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: none;
}
.stat__ic .ic {
  width: 1rem;
  height: 1rem;
}
.stat__ic.up {
  color: var(--pos);
  background: var(--pos-tint);
}
.stat__ic.down {
  color: var(--neg);
  background: var(--neg-tint);
}
.stat__t {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
}
.stat__t small {
  font-size: 0.7rem;
  color: var(--muted);
}
.stat__t b {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}
.stat__chev {
  margin-left: 0.1rem;
  color: var(--line);
  flex: none;
}
.stat__chev .ic {
  width: 1rem;
  height: 1rem;
}

.hero__prog {
  margin-top: 0.85rem;
}
.prog {
  height: 6px;
  border-radius: 999px;
  background: var(--hair);
  overflow: hidden;
}
.prog > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--pos));
  border-radius: inherit;
  transition: width 0.35s ease;
}
.hero__note {
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.hero__note .warn {
  color: var(--warn);
  font-weight: 600;
}

/* -------------------------------- list -------------------------------- */

.list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.card--open {
  border-color: color-mix(in srgb, var(--g) 22%, var(--hair));
}
.card__hd {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.15rem 0.35rem 0.15rem 0.55rem;
}
.card__hdmain {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  padding: 0.75rem 0.3rem;
  cursor: pointer;
  min-width: 0;
}
.card__hdmain:active {
  background: var(--hair);
  border-radius: 10px;
}
.card__chev {
  color: var(--g);
  display: flex;
  flex: none;
  transition: transform 0.18s ease;
}
.card--open .card__chev {
  transform: rotate(90deg);
}
.gdot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--g);
  flex: none;
}
.card__nm {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--g);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card__sum {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink);
}
.card__mini {
  padding: 0 1rem 0.85rem 2.5rem;
  margin-top: -0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.card__more {
  width: 2rem;
  height: 2rem;
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.card__more:active {
  background: var(--hair);
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rows__empty {
  padding: 0.5rem 1rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.row {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--hair);
}
.row__ck {
  flex: none;
  width: 2.9rem;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.row__ck::before {
  content: '';
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  border: 2px solid var(--line);
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.row__ck .ic {
  position: absolute;
  width: 1rem;
  height: 1rem;
  color: #fff;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.12s, transform 0.12s;
}
.row__ck {
  position: relative;
}
.row__ck:active::before {
  transform: scale(0.9);
}
.row--paid .row__ck::before {
  background: var(--g, var(--accent));
  border-color: var(--g, var(--accent));
}
.row--paid .row__ck .ic {
  opacity: 1;
  transform: scale(1);
}

.row__mid {
  flex: 1;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.7rem 0.85rem 0.7rem 0.1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  min-width: 0;
}
.row__mid:active {
  background: var(--hair);
}
.row__mid--static {
  cursor: default;
  padding-left: 1rem;
}
.row__mid--static:active {
  background: transparent;
}
.row__txt {
  flex: 1;
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}
.row__nm {
  font-size: 0.93rem;
  font-weight: 550;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.row__nm > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__meta {
  font-size: 0.75rem;
  color: var(--muted);
}
.rtag {
  flex: none;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--g, var(--accent-ink));
  background: var(--g-tint, var(--accent-tint));
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}
.row--paid .row__nm,
.row--paid .row__amt {
  color: var(--muted);
}

.row__amt {
  flex: none;
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.row__amt--todo {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--warn);
}
.row__chev {
  color: var(--line);
  flex: none;
  margin-right: -0.25rem;
}

.row__ib {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding-right: 0.6rem;
}

.card__add {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--hair);
  background: transparent;
  color: var(--g);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
}
.card__add:active {
  background: var(--g-tint);
}
.card__add .ic {
  width: 1rem;
  height: 1rem;
}

/* ------------------------------- footer ------------------------------- */

.foot {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.3rem;
}
.foot__note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ------------------------------- botões ------------------------------- */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 2.85rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn:active {
  transform: translateY(0.5px);
}
.btn .ic {
  width: 1.05rem;
  height: 1.05rem;
}
.btn--block {
  width: 100%;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:active {
  background: var(--accent-ink);
}
.btn--ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn--plain {
  background: transparent;
  color: var(--accent-ink);
}
.btn--danger {
  background: var(--neg);
  color: #fff;
}

/* -------------------------------- sheet ------------------------------- */

.sheet {
  border: none;
  padding: 0;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  margin: auto auto 0;
  background: transparent;
}
@media (min-width: 620px) {
  .sheet {
    margin: auto;
  }
}
.sheet::backdrop {
  background: rgba(15, 22, 34, 0.42);
  backdrop-filter: blur(2px);
}

.sh {
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--sh-2);
  max-height: 92vh;
  overflow-y: auto;
  padding: 0 1.1rem calc(1.4rem + var(--sab));
  animation: shUp 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (min-width: 620px) {
  .sh {
    border-radius: 22px;
  }
}
@keyframes shUp {
  from {
    transform: translateY(14px);
    opacity: 0.5;
  }
}

.sh__grab {
  width: 2.4rem;
  height: 0.28rem;
  border-radius: 999px;
  background: var(--line);
  margin: 0.55rem auto 0.35rem;
}
.sh__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.35rem 0 0.7rem;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.sh__bar h3 {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sh__bd {
  padding-bottom: 0.4rem;
}

.sh__msg {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
}
.sh__msg b {
  color: var(--ink);
}
.sh__acts {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}
.sh__err {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--neg);
  background: var(--neg-tint);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.7rem;
}

/* detalhe (chave/valor) */
.dl {
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 0.9rem;
}
.dl__r {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.88rem;
}
.dl__r + .dl__r {
  border-top: 1px solid var(--hair);
}
.dl__r span {
  color: var(--muted);
}
.dl__r b.ok {
  color: var(--pos);
}
.dl__r b.warn {
  color: var(--warn);
}

/* lista de ações (menu) */
.menu {
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  overflow: hidden;
}
.mi {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 0.85rem;
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.mi + .mi {
  border-top: 1px solid var(--hair);
}
.mi:active {
  background: var(--hair);
}
.mi:disabled {
  opacity: 0.5;
  cursor: default;
}
.mi__ic {
  color: var(--muted);
  flex: none;
}
.mi__lb {
  flex: 1;
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}
.mi__lb small {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}
.mi__cv {
  color: var(--line);
  flex: none;
}
.mi--accent {
  color: var(--accent-ink);
  font-weight: 600;
}
.mi--accent .mi__ic {
  color: var(--accent);
}
.mi--danger {
  color: var(--neg);
}
.mi--danger .mi__ic {
  color: var(--neg);
}

.menu + .menu,
.dl + .menu,
.field + .menu {
  margin-top: 0.9rem;
}

/* campos */
.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}
.field > span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
}
.field input,
.field select {
  font: inherit;
  min-height: 2.85rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
  outline: none;
}
.field__hint {
  font-size: 0.78rem;
  color: var(--muted);
}

/* campo de valor com R$ */
.amt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.35rem 0.9rem;
  background: var(--surface);
}
.amt:focus-within {
  border-color: var(--accent);
}
.amt__c {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}
.amt__in {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 1.6rem;
  font-weight: 650;
  color: var(--ink);
  min-height: 2.6rem;
  min-width: 0;
}
.amt--sm .amt__in {
  font-size: 1.15rem;
  min-height: 2.2rem;
}

/* segmented control */
.seg {
  display: flex;
  gap: 0.2rem;
  padding: 0.22rem;
  background: var(--hair);
  border-radius: var(--r-md);
}
.seg__b {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.5rem 0.4rem;
  border-radius: calc(var(--r-md) - 0.22rem);
  cursor: pointer;
}
.seg__b.is-on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(18, 28, 45, 0.12);
}

/* parcelas por mês */
.pmlist {
  display: grid;
  gap: 0.4rem;
  max-height: 52vh;
  overflow-y: auto;
  padding: 0.1rem;
}
.pm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.7rem;
}
.pm--now {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.pm__l {
  font-weight: 600;
  font-size: 0.85rem;
  display: grid;
  line-height: 1.2;
}
.pm__l small {
  font-weight: 400;
  color: var(--muted);
  text-transform: capitalize;
}
.pm__f {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.15rem 0.55rem;
  background: var(--surface);
}
.pm__f i {
  font-style: normal;
  font-size: 0.8rem;
  color: var(--muted);
}
.pm__in {
  width: 5rem;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  text-align: right;
  color: var(--ink);
  min-height: 2rem;
}

.rows--flat .row {
  border-top: 1px solid var(--hair);
}
.rows--flat .row:first-child {
  border-top: 0;
}

/* --------------------------- preferências --------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  .sh {
    animation: none !important;
    transition: none !important;
  }
}
@media (prefers-contrast: more) {
  :root {
    --hair: #c9cfda;
    --line: #aab2c0;
    --muted: #5a6472;
  }
}
