/* ROSA COSTUREIRA — visual no padrão do iPhone, em rosa, lilás e branco. */
:root {
  --rosa: #E0528C;
  --rosa-strong: #C93F78;
  --rosa-soft: #FCE6F0;
  --lilas: #9466CF;
  --lilas-soft: #EFE6FA;
  --bg: #FFF8FB;
  --card: #FFFFFF;
  --fill: #F6EEF4;
  --text: #1F1A22;
  --text2: #847887;
  --text3: #B3A8B5;
  --sep: rgba(110, 70, 110, .14);
  --danger: #E5484D;
  --danger-soft: #FDE8E9;
  --warn: #D9822B;
  --bar: rgba(255, 250, 253, .86);
  --shadow: 0 1px 2px rgba(120, 50, 100, .05), 0 6px 20px rgba(120, 50, 100, .06);
  --grad: linear-gradient(135deg, #EE6A9F 0%, #B07BE0 100%);
  --s-recebido: #B79BE0;
  --s-costurando: var(--rosa);
  --s-pronto: var(--lilas);
  --s-entregue: #A9A1AC;
  --radius: 14px;
  --tabbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --rosa: #FF79AE; --rosa-strong: #FF5C9A; --rosa-soft: rgba(255, 121, 174, .16);
    --lilas: #BE97F2; --lilas-soft: rgba(190, 151, 242, .16);
    --bg: #16111A; --card: #221B27; --fill: #2C2432;
    --text: #F7F0F8; --text2: #A99DAD; --text3: #6F6474; --sep: rgba(255, 220, 255, .10);
    --danger: #FF6369; --danger-soft: rgba(255, 99, 105, .15);
    --bar: rgba(28, 22, 33, .86);
    --shadow: none;
    --grad: linear-gradient(135deg, #D9518A 0%, #8E5CCB 100%);
    --s-recebido: #9F86C9; --s-entregue: #6F6474;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
body.locked #app, body.locked .fab { visibility: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }
.muted { color: var(--text2); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- estrutura ---------- */
.screen { min-height: 100vh; padding: calc(var(--safe-t) + 8px) 0 calc(var(--tabbar-h) + var(--safe-b) + 96px); }
.page { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 8px; }
.topbar .back { display: flex; align-items: center; gap: 2px; color: var(--rosa); font-size: 17px; min-height: 44px; padding-right: 12px; }
.topbar .actions { display: flex; gap: 4px; margin-left: auto; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--rosa); border-radius: 22px; }
.icon-btn:active { background: var(--rosa-soft); }
.text-btn { color: var(--rosa); font-size: 17px; min-height: 44px; padding: 0 6px; }
.large-title { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 2px; }
.subtitle { color: var(--text2); font-size: 15px; margin: 0 0 14px; }

.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 24px 4px 8px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.section-title small { font-size: 15px; font-weight: 400; color: var(--text2); }
.section-title.late { color: var(--danger); }
.group-label { margin: 22px 16px 6px; font-size: 13px; color: var(--text2); text-transform: uppercase; letter-spacing: .02em; }
.group-foot { margin: 6px 16px 0; font-size: 13px; color: var(--text2); }

/* ---------- listas agrupadas (estilo Ajustes) ---------- */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list + .list { margin-top: 12px; }
.row { position: relative; overflow: hidden; background: var(--card); }
.row + .row::before, .cell + .cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--sep); z-index: 2; }
.row-main {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 16px;
  background: var(--card); transition: transform .25s cubic-bezier(.2, .8, .2, 1); z-index: 1; width: 100%; text-align: left;
}
.row-main:active { background: var(--fill); }
.row-body { flex: 1; min-width: 0; }
.row-body > span, .kcard-open > span { display: block; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--text2); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-trail { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.amount { font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text2); }
.amount.owe { color: var(--rosa-strong); }
.chev { color: var(--text3); flex-shrink: 0; }
.row-actions { position: absolute; inset: 0 0 0 auto; display: flex; z-index: 0; }
.row-actions button { width: 84px; color: #fff; font-size: 15px; font-weight: 600; display: grid; place-items: center; }
.row-actions .edit { background: var(--lilas); }
.row-actions .del { background: var(--danger); }

.cell { position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 16px; width: 100%; text-align: left; background: var(--card); }
button.cell:active { background: var(--fill); }
.cell .label { flex: 1; }
.cell .value { color: var(--text2); text-align: right; font-variant-numeric: tabular-nums; }
.cell .value.strong { color: var(--text); font-weight: 600; }
.cell.link-cell .label { color: var(--rosa); }
.cell.danger .label { color: var(--danger); }
.cell-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.ic-rosa { background: var(--rosa); } .ic-lilas { background: var(--lilas); } .ic-grad { background: var(--grad); } .ic-gray { background: #A39AA6; }

.status-dot { width: 10px; height: 10px; border-radius: 5px; flex-shrink: 0; background: var(--s-recebido); }
.s-recebido { --c: var(--s-recebido); } .s-costurando { --c: var(--s-costurando); } .s-pronto { --c: var(--s-pronto); } .s-entregue { --c: var(--s-entregue); }
.status-dot.s-recebido, .status-dot.s-costurando, .status-dot.s-pronto, .status-dot.s-entregue { background: var(--c); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.status { background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.due { font-size: 13px; font-weight: 600; color: var(--text2); white-space: nowrap; }
.due.today { color: var(--rosa); }
.due.soon { color: var(--lilas); }
.due.late { color: var(--danger); }

.empty { text-align: center; color: var(--text2); padding: 28px 20px; font-size: 15px; }
.empty .empty-icon { width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 26px; display: grid; place-items: center; background: var(--rosa-soft); color: var(--rosa); }

/* ---------- cartões do Início ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-align: left; }
.card .k { font-size: 13px; color: var(--text2); font-weight: 600; }
.card .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card .v.small { font-size: 22px; }
.card.hero { background: var(--grad); color: #fff; box-shadow: 0 8px 24px rgba(200, 70, 140, .25); }
.card.hero .k { color: rgba(255, 255, 255, .85); }
.card.wide { grid-column: 1 / -1; }
.card.alert .v { color: var(--danger); }
.banner { display: flex; gap: 12px; align-items: center; background: var(--lilas-soft); border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; text-align: left; width: 100%; }
.banner .b-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--lilas); color: #fff; flex-shrink: 0; }
.banner b { display: block; font-size: 15px; }
.banner span { font-size: 13px; color: var(--text2); }
.sync-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); padding: 4px 10px; border-radius: 99px; background: var(--fill); }
.sync-chip::before { content: ""; width: 7px; height: 7px; border-radius: 4px; background: #6CC08E; }
.sync-chip[data-state="offline"]::before { background: var(--warn); }
.sync-chip[data-state="saving"]::before { background: var(--lilas); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- busca e segmentos ---------- */
.search { display: flex; align-items: center; gap: 6px; background: var(--fill); border-radius: 11px; padding: 0 10px; height: 38px; margin: 6px 0 12px; color: var(--text2); }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 17px; color: var(--text); min-width: 0; }
.segmented { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; margin: 0 0 14px; }
.segmented button { flex: 1 1 auto; min-height: 34px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; padding: 0 4px; letter-spacing: -.01em; }
.segmented button.on { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); color: var(--rosa-strong); }
.segmented .count { color: var(--text2); font-weight: 400; margin-left: 2px; font-size: 12px; }

/* ---------- barra de abas ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  padding: 6px 4px calc(var(--safe-b) + 4px); background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--sep);
}
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 500; color: var(--text3); min-height: 46px; }
.tabbar button.on { color: var(--rosa); }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); z-index: 21;
  width: 60px; height: 60px; border-radius: 30px; background: var(--grad); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 22px rgba(200, 70, 140, .38); transition: transform .15s;
}
.fab:active { transform: scale(.92); }

/* ---------- quadro ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 16px 12px; margin: 0 -16px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.board::-webkit-scrollbar { display: none; }
.col { flex: 0 0 84%; max-width: 340px; scroll-snap-align: center; background: var(--fill); border-radius: 18px; padding: 10px; align-self: flex-start; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 700; }
.col-head .n { margin-left: auto; font-weight: 600; color: var(--text2); font-size: 15px; }
.kcard { background: var(--card); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); margin-bottom: 8px; }
.kcard-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.kcard-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard .row-sub { margin: 2px 0 10px; }
.advance { width: 100%; min-height: 40px; border-radius: 10px; background: var(--rosa-soft); color: var(--rosa-strong); font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.advance:active { filter: brightness(.95); }
.advance.to-entregue { background: var(--lilas-soft); color: var(--lilas); }
.board-dots { display: flex; justify-content: center; gap: 6px; margin-top: 2px; }
.board-dots span { width: 7px; height: 7px; border-radius: 4px; background: var(--text3); opacity: .5; }
.board-dots span.on { background: var(--rosa); opacity: 1; }

/* ---------- agenda ---------- */
.cal { background: var(--card); border-radius: var(--radius); padding: 10px 8px 12px; box-shadow: var(--shadow); }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 6px; }
.cal-head b { font-size: 17px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; row-gap: 2px; }
.cal-grid .wd { font-size: 12px; color: var(--text3); font-weight: 600; padding: 4px 0; }
.day { min-height: 46px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 4px; font-size: 17px; font-variant-numeric: tabular-nums; }
.day span.n { width: 32px; height: 32px; border-radius: 16px; display: grid; place-items: center; }
.day.out { color: var(--text3); }
.day.today span.n { color: var(--rosa); font-weight: 700; }
.day.sel span.n { background: var(--rosa); color: #fff; font-weight: 600; }
.day .dots { display: flex; gap: 3px; height: 6px; }
.day .dots i { width: 5px; height: 5px; border-radius: 3px; background: var(--lilas); }
.day .dots i.late { background: var(--danger); }
.day .dots i.done { background: var(--s-entregue); }

/* ---------- janelas que sobem de baixo ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(30, 10, 30, .32); opacity: 0; transition: opacity .3s; }
.sheet-back.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: calc(100% - var(--safe-t) - 12px);
  background: var(--bg); border-radius: 14px 14px 0 0; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .38s cubic-bezier(.2, .9, .25, 1); max-width: 680px; margin: 0 auto;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .15);
}
.sheet.open { transform: translateY(0); }
.sheet-grab { width: 36px; height: 5px; border-radius: 3px; background: var(--text3); opacity: .6; margin: 6px auto 0; flex-shrink: 0; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 2px 8px; min-height: 48px; flex-shrink: 0; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.sheet-head .left { justify-self: start; } .sheet-head .right { justify-self: end; }
.sheet-head .text-btn.bold { font-weight: 600; }
.sheet-head .text-btn:disabled { color: var(--text3); }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px calc(var(--safe-b) + 28px); overscroll-behavior: contain; }

/* ---------- formulários ---------- */
.form-list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.field { position: relative; display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 16px; background: var(--card); }
.field + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--sep); }
.field > label { flex: 0 0 auto; min-width: 104px; color: var(--text); }
.field input, .field select, .field textarea {
  flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 17px; text-align: right; color: var(--text); padding: 13px 0;
  -webkit-appearance: none; appearance: none;
}
.field select { color: var(--rosa-strong); text-align-last: right; text-overflow: ellipsis; }
.field input::placeholder, .field textarea::placeholder { color: var(--text3); }
.field input[type="date"] { color: var(--rosa-strong); min-height: 24px; }
.field input[type="date"]::-webkit-date-and-time-value { text-align: right; }
.field.stack { flex-direction: column; align-items: stretch; gap: 0; padding: 10px 16px; }
.field.stack > label { font-size: 13px; color: var(--text2); }
.field.stack textarea { text-align: left; padding: 6px 0 2px; min-height: 64px; resize: none; }
.field .suffix { color: var(--text2); }
.field.total { min-height: 56px; }
.field.total .big { margin-left: auto; font-size: 22px; font-weight: 700; color: var(--rosa-strong); font-variant-numeric: tabular-nums; }
.field .seg-inline { display: flex; gap: 6px; margin-left: auto; padding: 8px 0; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 17px; background: var(--fill); font-size: 15px; font-weight: 500; }
.chip.on { background: var(--rosa); color: #fff; }
.stepper { display: flex; align-items: center; gap: 0; margin-left: auto; background: var(--fill); border-radius: 9px; }
.stepper button { width: 44px; height: 34px; font-size: 20px; color: var(--rosa-strong); }
.stepper b { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.hint { font-size: 13px; color: var(--text2); margin: 6px 16px 0; }
.status-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.status-picker button { min-height: 58px; border-radius: 12px; background: var(--card); font-size: 13px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text2); border: 1.5px solid transparent; }
.status-picker button.on { border-color: var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--card)); }
.status-picker button .status-dot { background: var(--c); }

.btn-primary { width: 100%; min-height: 50px; border-radius: 13px; background: var(--grad); color: #fff; font-weight: 600; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary:active { filter: brightness(.95); }
.btn-secondary { width: 100%; min-height: 50px; border-radius: 13px; background: var(--rosa-soft); color: var(--rosa-strong); font-weight: 600; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.detail-head { text-align: center; padding: 6px 0 14px; }
.detail-head .who { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.detail-head .what { color: var(--text2); margin: 2px 0 8px; }
.detail-total { font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.progress { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin: 8px auto 0; max-width: 240px; }
.progress i { display: block; height: 100%; background: var(--grad); border-radius: 3px; }

/* ---------- confirmação (folha de ações) ---------- */
.action-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(var(--safe-b) + 8px); z-index: 51; max-width: 520px; margin: 0 auto; transform: translateY(120%); transition: transform .3s cubic-bezier(.2, .9, .25, 1); }
.action-sheet.open { transform: none; }
.action-sheet .as-group { background: var(--card); border-radius: 14px; overflow: hidden; margin-top: 8px; }
.action-sheet .as-msg { padding: 14px 16px; text-align: center; color: var(--text2); font-size: 13px; }
.action-sheet button { display: block; width: 100%; min-height: 56px; font-size: 20px; color: var(--rosa); border-top: .5px solid var(--sep); }
.action-sheet button.destructive { color: var(--danger); }
.action-sheet button.cancel { font-weight: 600; border: 0; }

/* ---------- aviso rápido ---------- */
#toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 10px); transform: translate(-50%, -140%); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 15px; font-weight: 500; transition: transform .35s cubic-bezier(.2, .9, .25, 1); max-width: 90vw; text-align: center; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); }

/* ---------- tela de acesso (PIN) ---------- */
.lock { position: fixed; inset: 0; z-index: 100; display: none; background: var(--bg); overflow-y: auto; }
.lock.open { display: block; }
.lock::before { content: ""; position: fixed; inset: -20% -20% auto; height: 60%; background: radial-gradient(closest-side, var(--rosa-soft), transparent), radial-gradient(closest-side at 80% 40%, var(--lilas-soft), transparent); pointer-events: none; }
.lock-inner { position: relative; max-width: 360px; margin: 0 auto; padding: calc(var(--safe-t) + 40px) 24px calc(var(--safe-b) + 24px); display: flex; flex-direction: column; align-items: center; text-align: center; min-height: 100%; }
.lock-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 10px 30px rgba(200, 70, 140, .3); }
.lock h1 { font-size: 26px; margin: 18px 0 4px; letter-spacing: -.01em; }
.lock-sub { color: var(--text2); margin: 0 0 18px; font-size: 15px; }
.lock-msg { min-height: 20px; font-size: 15px; color: var(--text2); margin: 6px 0 4px; }
.lock-msg.error { color: var(--danger); }
.lock-form { width: 100%; display: grid; gap: 12px; }
.lock-input { width: 100%; height: 52px; border-radius: 13px; border: 0; background: var(--card); box-shadow: var(--shadow); padding: 0 16px; font-size: 19px; text-align: center; outline: none; }
.lock-input:focus { box-shadow: 0 0 0 2px var(--rosa); }
.pin-dots { display: flex; gap: 18px; margin: 4px 0 6px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 7px; border: 1.5px solid var(--rosa); transition: background .1s; }
.pin-dots span.on { background: var(--rosa); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 78px); gap: 16px 26px; margin: 18px 0 18px; }
.key { width: 78px; height: 78px; border-radius: 39px; background: var(--card); box-shadow: var(--shadow); font-size: 32px; font-weight: 400; font-variant-numeric: tabular-nums; display: grid; place-items: center; }
.key:active { background: var(--rosa-soft); }
.key-del { background: none; box-shadow: none; color: var(--text2); }
.link { color: var(--rosa); font-size: 15px; min-height: 44px; margin-top: 4px; }

@media (min-width: 700px) { .col { flex-basis: 300px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
