/* ============================================================ tokens */
:root {
  --bg: #f5f3f1;
  --surface: #ffffff;
  --surface-2: #faf8f7;
  --surface-3: #f0ecea;
  --text: #1a1520;
  --text-2: #4a4350;
  --muted: #8a8290;
  --line: #ebe6e3;
  --line-2: #ddd6d2;
  --accent: #b0175a;
  --accent-2: #d9467a;
  --accent-ink: #ffffff;
  --accent-soft: #fbeef3;
  --accent-soft-2: #f6d9e4;
  --ok: #0f8a5f;
  --ok-soft: #e4f5ee;
  --warn: #b26a00;
  --warn-soft: #fff3dc;
  --err: #c62828;
  --err-soft: #fdeceb;
  --side: #17121b;
  --side-text: #c9c1cd;
  --side-hover: #241c29;
  --shadow-sm: 0 1px 2px rgba(26, 21, 32, .05);
  --shadow: 0 1px 2px rgba(26, 21, 32, .04), 0 4px 16px rgba(26, 21, 32, .06);
  --shadow-lg: 0 10px 40px rgba(26, 21, 32, .18);
  --r-sm: 8px;
  --r: 14px;
  --r-lg: 20px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0c12; --surface: #19151d; --surface-2: #1e1922; --surface-3: #27212c;
    --text: #f3eff5; --text-2: #cfc7d4; --muted: #8f8696; --line: #2a2430; --line-2: #3a3240;
    --accent: #ec5b93; --accent-2: #f47fab; --accent-ink: #1a0b12; --accent-soft: rgba(236, 91, 147, .12); --accent-soft-2: rgba(236, 91, 147, .22);
    --ok: #3ccf91; --ok-soft: rgba(60, 207, 145, .12); --warn: #f0b048; --warn-soft: rgba(240, 176, 72, .12);
    --err: #ff6b6b; --err-soft: rgba(255, 107, 107, .12);
    --side: #0b090d; --side-hover: #1b1620;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ============================================================ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; letter-spacing: -.02em; font-weight: 750; }
h2 { font-size: 1.05rem; margin: 0 0 14px; letter-spacing: -.01em; font-weight: 700; }
h3 { font-size: .95rem; margin: 0 0 10px; font-weight: 700; }
.num, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 28px; height: 28px; }
[hidden] { display: none !important; }

/* ============================================================ shell */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-text); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.logo {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #d9467a, #8e1450); box-shadow: 0 4px 14px rgba(217, 70, 122, .35);
}
.brand b { display: block; font-size: .95rem; line-height: 1.2; }
.brand small { color: var(--side-text); font-size: .75rem; opacity: .7; }
.side a.nav {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-text);
  font-weight: 550; text-decoration: none; transition: background .15s, color .15s;
}
.side a.nav:hover { background: var(--side-hover); color: #fff; }
.side a.nav.on { background: linear-gradient(135deg, rgba(217, 70, 122, .22), rgba(176, 23, 90, .12)); color: #fff; }
.side a.nav.on .icon { color: #f47fab; }
.side .kbd-hint { margin-left: auto; font-size: .7rem; opacity: .55; border: 1px solid #3a3240; border-radius: 5px; padding: 0 5px; }
.side .spacer { flex: 1; }
.side form button { width: 100%; justify-content: flex-start; color: var(--side-text); }
.side form button:hover { background: var(--side-hover); color: #fff; }

.content { min-width: 0; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px 28px 60px; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: .9rem; margin-bottom: 10px; }

.tabbar { display: none; }
@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .page { padding: 18px 16px 100px; }
  h1 { font-size: 1.35rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; font-weight: 600; color: var(--muted); padding: 4px 0; text-decoration: none; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a.main .icon { background: var(--accent); color: var(--accent-ink); border-radius: 12px; width: 40px; height: 32px; padding: 6px 10px; margin-top: -2px; }
}

/* ============================================================ componentes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-sm); }
.card + .card, .card + section, section + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; flex: 1; }
.stack > * + * { margin-top: 16px; }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2.side-r { grid-template-columns: 1fr 360px; } }

.flash { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 550; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--err-soft); color: var(--err); }
.note { background: var(--warn-soft); color: var(--warn); padding: 12px 16px; border-radius: 12px; font-size: .9rem; font-weight: 550; display: flex; gap: 10px; align-items: center; }
.note a { color: inherit; text-decoration: underline; }

label, .label { display: block; font-size: .8rem; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.input, input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=tel], input:not([type]), select, textarea {
  width: 100%; padding: 11px 14px; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 11px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 70px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field { margin-bottom: 16px; }
.row { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .row.c2 { grid-template-columns: 1fr 1fr; } .row.c3 { grid-template-columns: repeat(3, 1fr); } }
.hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > input { padding-left: 44px; }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; font: inherit; font-weight: 650;
  border-radius: 11px; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); cursor: pointer;
  text-decoration: none; transition: transform .08s, background .15s, box-shadow .15s, opacity .15s; white-space: nowrap;
}
.btn:hover, button:hover { text-decoration: none; filter: brightness(1.05); }
.btn:active, button:active { transform: scale(.98); }
button:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 4px 14px rgba(176, 23, 90, .25); }
.btn.ghost, button.ghost { background: transparent; color: var(--text-2); border-color: var(--line-2); }
.btn.ghost:hover, button.ghost:hover { background: var(--surface-3); filter: none; }
.btn.soft, button.soft { background: var(--accent-soft); color: var(--accent); }
.btn.danger, button.danger { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.btn.danger:hover, button.danger:hover { background: var(--err-soft); }
.btn.lg, button.lg { padding: 14px 22px; font-size: 1.02rem; border-radius: 13px; }
.btn.block, button.block { width: 100%; }
.btn.icon-only, button.icon-only { padding: 8px; border-radius: 10px; }
button.plain { background: none; color: var(--muted); padding: 6px 8px; border: none; font-weight: 550; }
button.plain:hover { color: var(--text); background: var(--surface-3); filter: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: .9rem; flex: none;
  background: linear-gradient(135deg, var(--accent-soft-2), var(--accent-soft)); color: var(--accent); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg button { padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: .88rem; color: var(--text-2); background: transparent; border: none; text-decoration: none; }
.seg a.on, .seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* stats */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); margin-bottom: 18px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.stat .k { font-size: .78rem; font-weight: 650; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 1.5rem; font-weight: 780; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.stat.hero { background: linear-gradient(135deg, #2a1830, #17121b); color: #fff; border: none; }
.stat.hero .k, .stat.hero .s { color: #cdb9d3; }

/* listas */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list > a, .list > .li { display: flex; align-items: center; gap: 14px; padding: 14px 18px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); transition: background .12s; }
.list > :first-child { border-top: none; }
.list > a:hover { background: var(--surface-2); text-decoration: none; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-end { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.li-end b { display: block; }
.thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; background: var(--surface-3); flex: none; display: grid; place-items: center; color: var(--muted); }
.thumb.sm { width: 44px; height: 44px; border-radius: 10px; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .icon { width: 44px; height: 44px; color: var(--line-2); margin-bottom: 8px; }
.empty p { margin: 0 0 16px; }

table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
.t th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: none; }
.t .r { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); } .neg { color: var(--err); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.kv .total { font-size: 1.2rem; font-weight: 800; color: var(--text); }

/* chips (grade de tamanhos) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { margin: 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 48px; height: 40px; padding: 0 14px; border-radius: 11px;
  border: 1.5px solid var(--line-2); background: var(--surface); cursor: pointer; user-select: none; font-weight: 650; color: var(--text-2); transition: all .12s;
}
.chip span:hover { border-color: var(--accent); }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 10px rgba(176, 23, 90, .22); }
.chip input:focus-visible + span { outline: 3px solid var(--accent-soft-2); outline-offset: 1px; }
.grp-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 10px 0 8px; display: flex; gap: 8px; align-items: center; }
.grp-label button { padding: 2px 8px; font-size: .72rem; text-transform: none; letter-spacing: 0; }
.preview { font-size: .88rem; color: var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 11px; font-weight: 600; }

.photo-drop { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.photo-drop img, .photo-drop .ph { width: 112px; height: 112px; object-fit: cover; border-radius: var(--r); background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }

/* tabela de variantes: vira cartão no celular */
table.vt { width: 100%; border-collapse: collapse; }
.vt th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--line); }
.vt td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.vt input { padding: 9px 11px; }
.vt td.n input { max-width: 120px; }
.vt td.var { font-weight: 650; }
.vt tr.hl td { background: var(--accent-soft); }
@media (max-width: 639px) {
  .vt thead { display: none; }
  .vt tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .vt td { border: none; padding: 0; }
  .vt td.var, .vt td.bc { grid-column: 1 / -1; }
  .vt td[data-l]::before { content: attr(data-l); display: block; font-size: .72rem; color: var(--muted); font-weight: 650; margin-bottom: 4px; }
  .vt td.n input { max-width: none; }
}

/* modal */
dialog.modal { border: none; padding: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog.modal::backdrop { background: rgba(15, 10, 20, .55); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
@media (max-width: 639px) {
  dialog.modal { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
}

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 100;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow-lg); transition: all .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--err); color: #fff; }
@media (max-width: 899px) { .toast { bottom: 90px; } }

/* login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .auth { grid-template-columns: 1.1fr 1fr; } }
.auth-art { display: none; position: relative; overflow: hidden; background: radial-gradient(circle at 20% 20%, #d9467a 0, transparent 45%), radial-gradient(circle at 80% 70%, #6b1d7a 0, transparent 50%), #17121b; color: #fff; padding: 48px; }
@media (min-width: 900px) { .auth-art { display: flex; flex-direction: column; justify-content: flex-end; } }
.auth-art h2 { font-size: 2.2rem; line-height: 1.1; letter-spacing: -.03em; max-width: 420px; margin: 0 0 12px; }
.auth-art p { color: #e2d4e6; max-width: 380px; margin: 0; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form .logo { width: 48px; height: 48px; border-radius: 14px; font-size: 1.3rem; margin-bottom: 22px; }
.auth-form h1 { margin-bottom: 6px; }
.auth-form p.muted { margin: 0 0 26px; }

/* relatórios */
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: center; padding: 7px 0; font-size: .9rem; }
.bar { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.cust-link { display: flex; gap: 12px; align-items: center; color: inherit; }
.cust-link:hover { text-decoration: none; }
.stat-inline b { display: block; letter-spacing: -.02em; }
details > summary { list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "›"; margin-left: auto; transition: transform .15s; font-size: 1.3rem; color: var(--muted); }
details.card[open] > summary::after { transform: rotate(90deg); }

/* taxas */
.fee-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.fee { margin: 0; display: flex; flex-direction: column; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.fee span { font-size: .75rem; font-weight: 700; color: var(--muted); }
.fee input { padding: 7px 10px; text-align: right; font-variant-numeric: tabular-nums; }

/* ajustes pós-revisão visual */
.grid2 > .card, .grid2 > section, .grid2 > .stack { margin-top: 0 !important; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
