/* The Witcher Jiu Jitsu — tatame preto, ouro da logo, vermelho da ponteira */
:root {
  --bg: #110d09;
  --surface: #1a1510;
  --surface-2: #251e15;
  --line: #3a2f22;
  --line-soft: #2a2218;
  --text: #f2e9d6;
  --muted: #a89c86;
  --gold: #e4b23e;
  --gold-deep: #b98a1f;
  --on-gold: #1a1204;
  --paid: #69c496;
  --open: #8aa9c8;
  --late: #e0483f;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --display: "Avenir Next Condensed", "DIN Condensed", "Barlow Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--body);
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
body.noscroll { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- estrutura ---------- */
.shell { max-width: 680px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: rgba(17, 13, 9, .86);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 40px; height: 40px; border-radius: 10px; display: block; }
.brand b { display: block; font: 700 21px/1 var(--display); letter-spacing: .02em; color: var(--gold); }
.brand small { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
main { flex: 1; padding: 18px 16px calc(104px + var(--safe-b)); }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(26, 21, 16, .94);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-b));
}
nav.tabs .inner { display: flex; max-width: 680px; margin: 0 auto; }
nav.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 0 6px; border-radius: 12px;
  font-size: 11.5px; color: var(--muted); text-decoration: none;
}
nav.tabs a.on { color: var(--gold); }
nav.tabs a.on svg { stroke-width: 2.2; }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; flex: none;
  background: transparent; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
svg.i { display: block; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- títulos e textos ---------- */
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-h h1 { font: 700 30px/1 var(--display); letter-spacing: .01em; }
.page-h p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.muted { color: var(--muted); }
.section-t { font: 700 20px/1.1 var(--display); margin: 26px 0 10px; letter-spacing: .01em; }
.section-t + .hint { margin: -4px 0 10px; }
.hint { color: var(--muted); font-size: 14px; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-weight: 600; font-size: 15px; cursor: pointer; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.primary {
  background: linear-gradient(180deg, #edc35a, #d9a52f);
  border-color: #f1cd6d; color: var(--on-gold);
}
.btn.danger { color: #ff8f88; border-color: #5a2a27; background: #2a1514; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.gap > .btn { flex: 1; }

/* ---------- faixa do mês (resumo) ---------- */
.belt { padding: 2px 0 6px; }
.belt-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.belt-top .lbl { color: var(--muted); font-size: 14px; }
.belt-top .val { font: 700 34px/1.05 var(--display); letter-spacing: .01em; }
.belt-bar {
  display: flex; height: 22px; margin: 12px 0 14px; border-radius: 6px; overflow: hidden;
  background: #0b0806; border: 1px solid #4a3b27;
  box-shadow: inset 0 0 0 2px #0b0806;
}
.belt-bar span { display: block; height: 100%; min-width: 0; transition: width .5s ease;
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,.28) 0 2px, transparent 2px 9px); }
.belt-bar .p { background-color: var(--paid); }
.belt-bar .o { background-color: var(--open); }
.belt-bar .l { background-color: var(--late); }
.belt-key { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  text-align: left; padding: 8px 10px 9px; border-radius: 12px; cursor: pointer;
  background: transparent; border: 1px solid var(--line-soft);
}
.key.on { background: var(--surface); border-color: var(--line); }
.key .k { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.key .k i { width: 9px; height: 9px; border-radius: 3px; display: block; }
.key b { display: block; font: 700 22px/1.15 var(--display); margin-top: 3px; }
.key small { color: var(--muted); font-size: 12.5px; }
.dot-p { background: var(--paid); } .dot-o { background: var(--open); } .dot-l { background: var(--late); }

/* ---------- filtros ---------- */
.tools { display: flex; gap: 10px; margin: 18px 0 6px; }
.search { flex: 1; position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 42px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- listas ---------- */
.list { border-top: 1px solid var(--line-soft); }
.item {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 14px 4px 14px 14px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.item::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--line); }
.item.a_vencer::before { background: var(--open); }
.item.inadimplente::before { background: var(--late); }
.item.paga::before { background: var(--paid); }
.item:active { background: var(--surface); }
.avatar {
  width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--gold); font: 700 20px/1 var(--display);
}
.item .main { flex: 1; min-width: 0; }
.item .main h3 { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .main p { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.item .main p.late { color: #ff9a93; }
.item .side { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.item .side strong { font: 700 20px/1 var(--display); letter-spacing: .01em; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; border: 1px solid transparent; }
.badge.ok { color: var(--paid); background: rgba(105,196,150,.12); border-color: rgba(105,196,150,.28); }
.badge.open { color: var(--open); background: rgba(138,169,200,.12); border-color: rgba(138,169,200,.28); }
.badge.bad { color: #ff9a93; background: rgba(224,72,63,.14); border-color: rgba(224,72,63,.35); }
.badge.off { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.quick {
  min-height: 30px; padding: 0 10px; border-radius: 9px; border: 1px solid #6b5420; background: rgba(228,178,62,.1);
  color: var(--gold); font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}

.empty { text-align: center; padding: 44px 12px; color: var(--muted); }
.empty svg { margin: 0 auto 12px; color: var(--gold-deep); }
.empty h3 { color: var(--text); font: 700 20px/1.2 var(--display); margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }

.fab {
  position: fixed; z-index: 25; right: max(16px, calc(50% - 340px + 16px)); bottom: calc(78px + var(--safe-b));
  height: 54px; padding: 0 20px 0 16px; border-radius: 16px; display: flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, #edc35a, #d9a52f); color: var(--on-gold); border: 1px solid #f1cd6d;
  font-weight: 700; font-size: 15.5px; box-shadow: 0 8px 24px rgba(0,0,0,.55); cursor: pointer;
}
.fab:active { transform: scale(.97); }

/* ---------- formulários ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field label, .field > span { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font: 16px/1.35 var(--body); -webkit-appearance: none; appearance: none;
}
select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23a89c86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
textarea { min-height: 150px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(228,178,62,.16); }
input::placeholder, textarea::placeholder { color: #6f6555; }
input[type=date], input[type=time] { min-height: 48px; }
input:disabled { opacity: .6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0; cursor: pointer; }
.check span:first-child { font-size: 15.5px; }
.check small { display: block; color: var(--muted); font-size: 13px; margin-top: 1px; }
.vars { display: flex; flex-wrap: wrap; gap: 8px; }
.vars button { min-height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid #6b5420; background: rgba(228,178,62,.08); color: var(--gold); font-size: 13.5px; cursor: pointer; }
.preview { background: #0b0806; border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; font-size: 15px; word-break: break-word; }
mark { background: rgba(228,178,62,.14); color: var(--gold); border-radius: 5px; padding: 0 3px; }

.switch { position: relative; width: 48px; height: 29px; flex: none; display: inline-block; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; z-index: 1; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); transition: background .2s, border-color .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #7d7360; transition: transform .2s, background .2s; }
.switch input:checked + i { background: rgba(228,178,62,.24); border-color: var(--gold-deep); }
.switch input:checked + i::after { transform: translateX(19px); background: var(--gold); }
.switch input:focus-visible + i { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- ajustes ---------- */
.group { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 16px; overflow: hidden; }
.group > .line { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.group > .line:last-child { border-bottom: 0; }
.group .line.stack { flex-direction: column; align-items: stretch; }
.group .line h3 { font-size: 16px; font-weight: 600; }
.group .line p { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.group .line input[type=number] { width: 84px; text-align: center; }
.group .line input[type=time] { width: 124px; text-align: center; }
.group .line select { max-width: 200px; }
.rule-body.off { opacity: .45; pointer-events: none; }
.wa { display: flex; align-items: center; gap: 14px; padding: 16px; }
.wa .logo { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: rgba(105,196,150,.12); color: var(--paid); border: 1px solid rgba(105,196,150,.3); flex: none; }
.wa.bad .logo { background: rgba(224,72,63,.12); color: #ff9a93; border-color: rgba(224,72,63,.3); }
.wa.wait .logo { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.wa h3 { font-size: 16.5px; font-weight: 600; }
.wa p { color: var(--muted); font-size: 13.5px; }
.savebar { position: sticky; bottom: calc(76px + var(--safe-b)); margin-top: 22px; z-index: 5; }
.savebar .btn { box-shadow: 0 8px 24px rgba(0,0,0,.55); }

/* ---------- envios ---------- */
.day { font: 700 17px/1 var(--display); color: var(--muted); margin: 20px 0 6px; letter-spacing: .02em; }
.log { display: flex; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line-soft); align-items: flex-start; }
.log time { width: 46px; flex: none; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; padding-top: 2px; }
.log .main { flex: 1; min-width: 0; }
.log h3 { font-size: 15.5px; font-weight: 600; }
.log p { color: var(--muted); font-size: 13.5px; }
.log .err { color: #ff9a93; font-size: 13px; margin-top: 3px; word-break: break-word; }

/* ---------- folhas (modais) ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.62); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease both; }
.sheet {
  width: 100%; max-width: 680px; max-height: 92dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(22px + var(--safe-b)); animation: up .24s cubic-bezier(.2,.8,.2,1) both;
}
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-h h2 { font: 700 24px/1.1 var(--display); letter-spacing: .01em; }
.sheet-h .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.actions .btn { justify-content: flex-start; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { transform: translateY(28px); opacity: .4; } to { transform: none; opacity: 1; } }
.qrbox { display: grid; place-items: center; min-height: 260px; background: #fff; border-radius: 16px; padding: 12px; margin-bottom: 14px; }
.qrbox img { width: 100%; max-width: 280px; display: block; }
.qrbox p { color: #444; }
.steps { margin: 0 0 6px; padding-left: 20px; color: var(--muted); font-size: 14.5px; }
.steps li { margin-bottom: 4px; }

/* ---------- login ---------- */
.login { max-width: 420px; margin: 0 auto; min-height: 100dvh; padding: calc(36px + var(--safe-t)) 24px 32px; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.login .logo { width: min(240px, 62vw); margin: 0 auto 6px; display: block; border-radius: 22px; }
.login h1 { font: 700 30px/1.1 var(--display); text-align: center; }
.login p.muted { text-align: center; }
.login .err { color: #ff9a93; min-height: 20px; font-size: 14px; }

/* ---------- toast e esqueleto ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translate(-50%, 16px); z-index: 80;
  max-width: min(92vw, 520px); padding: 12px 16px; border-radius: 12px; background: #2c241a; border: 1px solid var(--line);
  color: var(--text); font-size: 14.5px; box-shadow: 0 10px 30px rgba(0,0,0,.6); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: #6a2f2b; background: #2e1816; }
#toast.ok { border-color: #2d5a45; }
.sk { height: 74px; border-bottom: 1px solid var(--line-soft); background: linear-gradient(90deg, transparent, rgba(255,255,255,.035), transparent); background-size: 200% 100%; animation: sk 1.3s linear infinite; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (min-width: 700px) {
  main { padding-top: 26px; }
}
.log .tech { margin-top: 4px; }
.log .tech summary { color: var(--muted); font-size: 12.5px; cursor: pointer; }
.log .tech p { font-size: 12px; margin-top: 4px; word-break: break-word; }
a.btn { color: inherit; text-decoration: none; }
