/* meufin — "A régua do mês" */

@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url("fonts/schibsted-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url("fonts/schibsted-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #EDF0F4;
  --surface: #FFFFFF;
  --ink: #18233A;
  --ink-2: #5B6478;
  --ink-3: #8A92A3;
  --line: #D5DAE3;
  --essencial: #2D4F8A;
  --nao: #8A6FB0;
  --gordura: #1F8A65;
  --alerta: #C23B22;
  --sobra: #C9D0DC;
  --focus: #2D4F8A;

  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* escala modular 1.25 */
  --t-xs: 0.8rem;
  --t-sm: 0.875rem;
  --t-md: 1rem;
  --t-lg: 1.25rem;
  --t-xl: 1.563rem;
  --t-2xl: 2.441rem;
  --t-hero: clamp(2.75rem, 7vw, 4.75rem);

  --gutter: clamp(16px, 4vw, 40px);
  --radius-s: 6px;
  --radius-l: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121826;
    --surface: #1A2233;
    --ink: #E6EAF2;
    --ink-2: #A3ABBC;
    --ink-3: #6F7889;
    --line: #2A3447;
    --essencial: #6E95D8;
    --nao: #B19AD6;
    --gordura: #4CC79A;
    --alerta: #FF7A5C;
    --sobra: #344058;
    --focus: #8FB0EA;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121826; --surface: #1A2233; --ink: #E6EAF2; --ink-2: #A3ABBC; --ink-3: #6F7889;
  --line: #2A3447; --essencial: #6E95D8; --nao: #B19AD6; --gordura: #4CC79A;
  --alerta: #FF7A5C; --sobra: #344058; --focus: #8FB0EA; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg[viewBox="0 0 24 24"] { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Topo ---------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px var(--gutter) 0;
}
.wordmark { font-weight: 800; letter-spacing: -0.02em; font-size: var(--t-lg); }
.topbar > a.icon-btn { justify-self: end; }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-title {
  font-size: var(--t-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  min-width: 9.5ch;
  text-align: center;
}
.month-year { font-weight: 400; color: var(--ink-3); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; background: transparent; border-radius: 50%;
  color: var(--ink-2);
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }

main { max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter) 120px; }

/* ---------- Resumo + régua ---------- */
.summary { padding: 40px 0 36px; }
.summary-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.sobra-label { color: var(--ink-2); font-size: var(--t-md); }
.sobra-valor {
  font-size: var(--t-hero);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
}
.sobra-valor.is-negativo { color: var(--alerta); }
.falta-pagar { color: var(--ink-2); text-align: right; }
.falta-pagar strong { color: var(--ink); font-weight: 700; }

.regua { display: block; overflow: visible; }
.regua-fundo { fill: var(--sobra); }
.seg-essencial { fill: var(--essencial); }
.seg-nao { fill: var(--nao); }
.seg-gordura { fill: var(--gordura); }
.seg-excesso { fill: var(--alerta); }
.seg-sep { fill: var(--bg); }
.listra-traco { fill: color-mix(in srgb, var(--bg) 55%, transparent); }
.regua-linha { stroke: var(--ink); stroke-width: 2; }
.regua-rotulo { fill: var(--ink-2); font-size: 12.8px; font-family: var(--font); }
.regua-segs { animation: grow .7s cubic-bezier(.2, .7, .2, 1) both; }
.sem-animacao .regua-segs { animation: none; }
@keyframes grow { from { transform: scaleX(0); } }

.legenda {
  list-style: none; margin: 16px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 8px 28px;
  font-size: var(--t-sm); color: var(--ink-2);
}
.legenda li { display: flex; align-items: baseline; gap: 8px; }
.legenda strong { color: var(--ink); font-weight: 600; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; transform: translateY(1px); }
.swatch-essencial { background: var(--essencial); }
.swatch-nao { background: var(--nao); }
.swatch-gordura { background: var(--gordura); }
.texto-alerta { color: var(--alerta) !important; }
.swatch-pend { background: repeating-linear-gradient(135deg, var(--ink-3) 0 2px, transparent 2px 4px); outline: 1px solid var(--ink-3); }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 10px; flex: none; }
.dot-essencial { background: var(--essencial); }
.dot-nao { background: var(--nao); }
.dot-gordura { background: var(--gordura); }

/* ---------- Colunas ---------- */
.columns {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
.side { display: grid; gap: 32px; }
.panel { background: var(--surface); border-radius: var(--radius-l); padding: 24px 24px 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel h2 { font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; }
.panel-hint { color: var(--ink-2); font-size: var(--t-sm); margin-bottom: 8px; }
.panel-total {
  display: flex; justify-content: space-between;
  border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px;
  color: var(--ink-2);
}
.panel-total span { color: var(--ink); font-weight: 700; }

.group + .group { margin-top: 28px; }
.group h3 {
  display: flex; align-items: center;
  font-size: var(--t-md); font-weight: 600; color: var(--ink);
  padding: 12px 0 6px;
}
.group-total { margin-left: auto; font-weight: 600; color: var(--ink-2); }

.text-btn {
  border: 0; background: transparent; color: var(--essencial);
  font-weight: 600; font-size: var(--t-sm);
  padding: 10px 4px; border-radius: 6px;
}
.text-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Linhas ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  border-top: 1px solid var(--line);
}
.rows > .row:first-child { border-top-color: transparent; }
.row-main {
  grid-column: 2 / 4;
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 0;
  border: 0; background: transparent; text-align: left;
}
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main:hover .row-desc { text-decoration: underline; text-decoration-color: var(--ink-3); text-underline-offset: 3px; }
.row-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-obs { font-size: var(--t-xs); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-valor { flex: none; font-weight: 600; text-align: right; }
.row.is-pago .row-desc, .row.is-pago .row-valor { color: var(--ink-3); }
.row.is-pago .row-valor { font-weight: 500; }
.row.is-zero .row-valor { color: var(--ink-3); font-weight: 400; }
.row-entrada { grid-template-columns: minmax(0, 1fr); }
.row-entrada .row-main { grid-column: 1; }

.check {
  width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: transparent; padding: 0;
  display: grid; place-items: center;
}
.check::before {
  content: ""; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--ink-3);
  transition: background-color .15s, border-color .15s;
}
.check[aria-checked="true"]::before {
  border-color: var(--c, var(--essencial));
  background: var(--c, var(--essencial)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.check:hover::before { border-color: var(--c, var(--essencial)); }
.grupo-nao .check { --c: var(--nao); }
.rows-meta .check { --c: var(--gordura); }

/* Gordura: barra de meta por item */
.meta-bar { display: block; margin-top: 6px; }
.meta-fundo { fill: var(--line); }
.meta-fill { fill: var(--gordura); }
.meta-txt { font-size: var(--t-xs); color: var(--ink-3); }

.reserva-ideal { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: var(--t-sm); }
.reserva-valor { font-size: var(--t-xl); font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.reserva-hint { color: var(--ink-3); font-size: var(--t-xs); }

/* ---------- Tabs (só celular) ---------- */
.tabs { display: none; }

/* ---------- Botões ---------- */
.primary-btn {
  border: 0; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-weight: 700; padding: 14px 28px; min-height: 48px;
}
.primary-btn:hover { background: color-mix(in srgb, var(--ink) 85%, var(--essencial)); }
.danger-btn {
  border: 0; background: transparent; color: var(--alerta);
  font-weight: 600; padding: 14px 8px; min-height: 48px;
}
.fab {
  position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--ink); color: var(--bg);
  display: grid; place-items: center;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--ink) 30%, transparent);
}
.fab svg { width: 28px; height: 28px; stroke-width: 2.2; }

/* ---------- Mês vazio ---------- */
.empty { padding: 96px 0; max-width: 34rem; }
.empty-title { font-size: var(--t-2xl); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin-bottom: 16px; }
.empty-text { color: var(--ink-2); margin-bottom: 28px; max-width: 30rem; }

/* ---------- Sheet / dialog ---------- */
.sheet {
  border: 0; padding: 0; width: min(440px, calc(100vw - 32px));
  border-radius: var(--radius-l); background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 64px rgba(10, 16, 30, .28);
}
.sheet::backdrop { background: rgba(10, 16, 30, .45); }
.sheet[open] { animation: sheet-in .18s ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px); } }
.sheet form { padding: 20px 24px 24px; display: grid; gap: 18px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-right: -10px; }
.sheet-head h2 { font-size: var(--t-lg); font-weight: 700; }

.tipo-chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tipo-chips label { position: relative; }
.tipo-chips input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.tipo-chips span {
  display: inline-block; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); font-size: var(--t-sm); font-weight: 500; cursor: pointer;
}
.tipo-chips input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tipo-chips input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.field em { font-style: normal; font-weight: 400; color: var(--ink-3); }
.field input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.field input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.valor-wrap { position: relative; display: block; }
.valor-wrap .moeda { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: var(--t-lg); }
.field-valor input { font-size: var(--t-2xl); font-weight: 800; letter-spacing: -0.03em; padding-left: 52px; min-height: 64px; }
.field-help { color: var(--ink-3); font-size: var(--t-xs); }
.field-help.is-erro { color: var(--alerta); }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; }
.switch-ui { width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked ~ .switch-ui { background: var(--gordura); }
.switch input:checked ~ .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible ~ .switch-ui { outline: 2px solid var(--focus); outline-offset: 2px; }

.sheet-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 4px; }
.sheet-actions .primary-btn { margin-left: auto; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
  background: var(--ink); color: var(--bg);
  padding: 6px 8px 6px 18px; border-radius: 999px;
  font-size: var(--t-sm); max-width: calc(100vw - 120px);
}
.toast[hidden] { display: none; }
.toast .text-btn { color: var(--bg); text-decoration: underline; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .regua-segs, .sheet[open] { animation: none; }
  .check::before, .switch-ui, .switch-ui::after { transition: none; }
}

/* ---------- Celular ---------- */
@media (max-width: 820px) {
  .topbar { grid-template-columns: auto 1fr auto; padding-top: 12px; }
  .wordmark { display: none; }
  .month-nav { justify-self: center; grid-column: 2; }
  .topbar > a.icon-btn { grid-column: 3; }
  .month-title { font-size: var(--t-lg); }

  .summary { padding: 20px 0 24px; }
  .summary-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .falta-pagar { text-align: left; }
  .legenda { gap: 6px 18px; }

  .tabs {
    display: flex; gap: 4px; padding: 4px;
    background: color-mix(in srgb, var(--ink) 6%, transparent);
    border-radius: 999px; margin-bottom: 16px;
    position: sticky; top: 8px; z-index: 2;
    backdrop-filter: blur(8px);
  }
  .tabs button {
    flex: 1; border: 0; background: transparent; border-radius: 999px;
    padding: 10px 6px; font-weight: 600; font-size: var(--t-sm); color: var(--ink-2); min-height: 44px;
  }
  .tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); }

  .columns, .side { display: block; }
  .panel { display: none; padding: 16px 16px 12px; border-radius: 12px; }
  .panel.is-active { display: block; }
  .panel-head { display: none; }

  .sheet {
    width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92vh;
    border-radius: 20px 20px 0 0;
  }
  .sheet form { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  .toast { bottom: 96px; max-width: calc(100vw - 32px); }
}
@media (min-width: 821px) {
  .fab { display: none; }
}

/* ---------- Login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(360px, 100%); }
.login-regua { display: block; margin-bottom: 32px; }
.login-title { font-size: var(--t-2xl); font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.login-sub { color: var(--ink-2); margin: 8px 0 32px; }
.login-form { display: grid; gap: 20px; }
.login-form .primary-btn { width: 100%; }
.login-erro { color: var(--alerta); font-size: var(--t-sm); }

/* ---------- Menu ---------- */
.menu-wrap { position: relative; justify-self: end; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10;
  min-width: 240px; padding: 8px;
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(10, 16, 30, .18), 0 0 0 1px var(--line);
  display: grid;
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-weight: 500;
}
a.menu-item:hover, .menu-item.switch:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.menu .switch-ui { margin-left: auto; }
.menu-versao { padding: 10px 12px 4px; margin-top: 4px; border-top: 1px solid var(--line); font-size: var(--t-xs); color: var(--ink-3); }

.reserva-hint .text-btn { padding: 4px 2px; font-size: var(--t-xs); }
.reserva-preview { color: var(--ink-2); }
.reserva-preview strong { color: var(--ink); }

@media (max-width: 820px) {
  .topbar > .menu-wrap { grid-column: 3; }
}

/* ---------- Sobre ---------- */
.sobre { max-width: 40rem; padding-top: 48px; }
.sobre-voltar { color: var(--essencial); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; }
.sobre-voltar svg { width: 18px; height: 18px; }
.sobre h1 { font-size: var(--t-2xl); font-weight: 800; letter-spacing: -0.035em; line-height: 1.1; margin: 24px 0 16px; }
.sobre-lead { font-size: var(--t-lg); color: var(--ink-2); line-height: 1.45; }
.sobre h2 { font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.01em; margin: 48px 0 12px; }
.sobre p + p { margin-top: 12px; }
.sobre ul { padding-left: 1.2em; margin: 12px 0 0; }
.sobre li + li { margin-top: 8px; }
.sobre-regua { margin: 20px 0 8px; }
.sobre-legenda { font-size: var(--t-sm); color: var(--ink-2); }
.sobre-versao {
  margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 4px 24px; color: var(--ink-3); font-size: var(--t-sm);
}
.sobre-versao strong { color: var(--ink); font-weight: 600; }

/* ---------- Ajustes da aplicação ---------- */
.check-form { display: grid; place-items: center; }
button.menu-item { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
button.menu-item:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.row-vazia { color: var(--ink-3); font-size: var(--t-sm); padding: 12px 0; }
.login-erro code { font-size: var(--t-xs); background: color-mix(in srgb, var(--ink) 8%, transparent); padding: 1px 4px; border-radius: 4px; }
.toast form { display: contents; }
.sheet .switch[hidden] { display: none; }
