/* ============================================================ base */
:root {
  --bg: #f5f3ef; --card: #fff; --ink: #26231f; --muted: #7a736b; --line: #e6e1da; --line2: #d4cdc3;
  --brand: #3b3733; --brand-2: #57504a; --accent: #9b7b55; --accent-bg: #f4ede4;
  --red: #c0262d; --ok: #2f7d4f; --ok-bg: #e5f2e9; --ag: #2c5d9b; --ag-bg: #e6eef9;
  --pend: #a2620c; --pend-bg: #fbf0dc; --cx: #847e78; --cx-bg: #eeebe7;
  --radius: 12px; --shadow: 0 1px 2px rgba(40, 30, 20, .05), 0 6px 20px rgba(40, 30, 20, .06);
  --field: #fff; --hover: #faf8f5; --head: #fcfbf9; --out: #faf9f7; --glass: rgba(255, 255, 255, .94);
  --on-brand: #fff; --brand-hover: #24211e; --note-bg: #fffbe9; --note-line: #f1e3a6;
  --err-bg: #fdecec; --err-line: #f3b9bb; --err-ink: #8e1b20; --demo-ink: #7a4a08; --modal-bg: #fff;
  color-scheme: light;
  --script: 'Great Vibes', cursive;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* ---------- versão escura (tema do aparelho ou escolhido em "Minha conta") */
:root[data-theme="dark"] {
  --bg: #161412; --card: #201d1a; --ink: #ece6de; --muted: #a59c91; --line: #332e29; --line2: #4a433c;
  --brand: #e6ddd1; --brand-2: #cfc5b8; --accent: #c9a77f; --accent-bg: #2e2620;
  --ok: #6fcf97; --ok-bg: #1d3326; --ag: #8db8f2; --ag-bg: #1c2a3f;
  --pend: #f0b45a; --pend-bg: #3a2c16; --cx: #a59c91; --cx-bg: #2a2622;
  --field: #1a1816; --hover: #26221e; --head: #1d1a17; --out: #1a1815; --glass: rgba(26, 23, 20, .92);
  --on-brand: #1a1714; --brand-hover: #fff; --note-bg: #332c17; --note-line: #5a4b1f;
  --err-bg: #3a1c1d; --err-line: #6b2b2e; --err-ink: #f3b4b6; --demo-ink: #f0c98a; --modal-bg: #221f1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
:root[data-theme="dark"] .btn.wa { color: #5fd18d; }
:root[data-theme="dark"] .sheet { box-shadow: 0 0 0 1px #3a342e; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); }
h1 { font-size: 26px; margin: 0 0 2px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h3 { font-size: 16px; margin: 0 0 12px; }
small { display: block; color: var(--muted); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; }
.boot, .loading { padding: 60px; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }
.mono-num { font-variant-numeric: tabular-nums; letter-spacing: .03em; }

/* ============================================================ botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-family: inherit; font-weight: 600; font-size: 14.5px; line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--card); color: var(--ink); transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: var(--card); border-color: var(--line2); }
.btn.ghost:hover { border-color: var(--brand-2); }
.btn.link { background: none; border: 0; color: var(--accent); padding: 0 6px; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 13.5px; border-radius: 8px; }
.btn.lg { min-height: 50px; padding: 0 24px; font-size: 16px; }
.btn.xl { min-height: 56px; padding: 0 28px; font-size: 17px; border-radius: 14px; box-shadow: 0 6px 18px rgba(59, 55, 51, .25); }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 42px; }
.btn.sm.icon { width: 34px; }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.btn.wa { color: #1f8f4e; }
.danger-txt { color: var(--red) !important; }

.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.fld > span { font-size: 13px; font-weight: 600; color: var(--brand-2); }
.fld small { margin-top: 1px; }
input, select, textarea { font: inherit; color: inherit; }
.fld input, .fld select, .fld textarea, .search {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line2); border-radius: 10px; background: var(--field); outline: none;
}
.fld textarea { resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus, .search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(155, 123, 85, .18); }
.fld.sm { margin: 0; }
.fld.sm input, .fld.sm select { min-height: 40px; padding: 7px 10px; }
.chk { display: flex; gap: 8px; align-items: center; margin: 4px 0 14px; font-weight: 500; }
.chk input { width: 20px; height: 20px; }
.err { color: var(--red); font-size: 14px; min-height: 0; margin: 4px 0 8px; }
.err:empty { display: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.st-pend { background: var(--pend-bg); color: var(--pend); }
.st-ag { background: var(--ag-bg); color: var(--ag); }
.st-ok { background: var(--ok-bg); color: var(--ok); }
.st-cx { background: var(--cx-bg); color: var(--cx); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line); }

/* ============================================================ logo */
.logo { display: flex; justify-content: center; }
.logo img { max-width: 100%; display: block; }
.logo-ui img { height: 30px; width: auto; }
.logo-login img { max-height: 150px; width: auto; }
.logo-sheet img { max-height: 96px; width: auto; }
.only-dark { display: none !important; }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
.login-theme { position: fixed; top: 14px; right: 14px; }
:root[data-theme="dark"] .only-dark { display: block !important; }
:root[data-theme="dark"] .only-light { display: none !important; }
:root[data-theme="dark"] .logo-login img.only-dark { max-height: 54px; margin: 18px 0 8px; }

/* ============================================================ topo */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--glass); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-sub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); border-left: 1px solid var(--line2); padding-left: 10px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { padding: 10px 14px; border-radius: 9px; text-decoration: none; font-weight: 600; color: var(--brand-2); white-space: nowrap; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--accent-bg); color: var(--brand); }
.top-right { display: flex; align-items: center; gap: 10px; }
.me { display: flex; align-items: center; gap: 9px; background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 10px; text-align: left; font: inherit; color: inherit; }
.me:hover { background: var(--bg); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-weight: 700; }
.me-txt b { display: block; font-size: 14px; }
.me-txt small { font-size: 12px; }
.demo-bar { background: var(--pend-bg); color: var(--demo-ink); text-align: center; padding: 7px 16px; font-size: 13.5px; }

.main { max-width: 1400px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; text-decoration: none; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.back:hover { color: var(--ink); }

/* ============================================================ login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 30% 10%, var(--card) 0, var(--bg) 60%); }
.login { width: 100%; max-width: 410px; padding: 30px 28px; }
.login h1 { justify-content: center; font-size: 15px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 4px 0 22px; }
.login-logo { display: flex; justify-content: center; }
.demo-users { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line2); }
.demo-users p { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-align: center; }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-grid .btn { flex-direction: column; align-items: flex-start; height: auto; padding: 8px 12px; gap: 2px; }
.demo-grid small { font-weight: 400; font-size: 11.5px; }

/* ============================================================ listas */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { display: block; color: var(--muted); font-size: 13px; }
.kpi b { font-size: 22px; font-variant-numeric: tabular-nums; }
.kpi.alt { background: var(--accent-bg); }
.kpi a { text-decoration: none; color: inherit; display: block; }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 280px; width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line2); background: var(--field); border-radius: 99px; padding: 8px 14px; font-family: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--brand-2); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--head); }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover, .tbl th.on { color: var(--ink); }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr[data-href] { cursor: pointer; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tr.inactive td { opacity: .55; }
.tbl .c-total { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.tbl .c-act { text-align: right; }
.row-acts { display: flex; gap: 6px; justify-content: flex-end; }
.empty { background: var(--card); border: 1px dashed var(--line2); border-radius: var(--radius); padding: 40px 20px; text-align: center; color: var(--muted); }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tab { border: 1px solid var(--line2); background: var(--field); border-radius: 10px; padding: 10px 14px; font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--brand-2); }
.tab span { background: var(--bg); border-radius: 99px; padding: 2px 8px; font-size: 12.5px; }
.tab.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.tab.on span { background: rgba(128, 128, 128, .25); }
.tab-a_entregar:not(.on) span { background: var(--pend-bg); color: var(--pend); }
.tab-agendado:not(.on) span { background: var(--ag-bg); color: var(--ag); }

.filters { padding: 12px; margin-bottom: 14px; }
.filters-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters-top .search { flex: 1 1 300px; width: auto; }
.fcount:not(:empty) { background: var(--accent); color: #fff; border-radius: 99px; padding: 1px 7px; font-size: 12px; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ============================================================ detalhe */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 76px; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.big-date { background: var(--ag-bg); color: var(--ag); border-radius: 10px; padding: 12px 14px; }
.big-date.entregue { background: var(--ok-bg); color: var(--ok); }
.big-date span { display: block; font-size: 13px; text-transform: capitalize; }
.big-date b { font-size: 24px; display: block; }
.big-date em { font-style: normal; font-weight: 600; font-size: 13.5px; }
.note { background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 6px; font-size: 14px; }
.timeline li::before { content: ''; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline p { margin: 2px 0; color: var(--brand-2); font-size: 13.5px; }
.sheet-scroll { overflow-x: auto; }

/* ============================================================ formulário */
.draft-bar { background: var(--accent-bg); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.form-errors { background: var(--err-bg); border: 1px solid var(--err-line); color: var(--err-ink); border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; scroll-margin-top: 90px; }
.form-errors ul { margin: 6px 0 0; padding-left: 20px; }
.req-star { color: var(--red); }
.form-actions {
  position: sticky; bottom: 0; z-index: 10; display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap;
  margin: 16px auto 0; max-width: 1000px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--glass); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -6px 20px rgba(0, 0, 0, .06);
}
.fa-total { margin-right: auto; color: var(--muted); }
.fa-total b { display: block; font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ============================================================ FOLHA DO PEDIDO (réplica do bloco) */
.sheet {
  --sl: #2b2b2b;
  background: #fff; color: #1e1e1e; max-width: 1000px; margin: 0 auto; padding: 22px 22px 18px;
  border-radius: 6px; box-shadow: var(--shadow); font-size: 13px;
}
.sheet .lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; color: #333; letter-spacing: .01em; }

.sh-head { display: grid; grid-template-columns: minmax(170px, 250px) 1fr minmax(140px, 210px); align-items: center; border: 1.5px solid var(--sl); padding: 10px 14px; gap: 14px; }
.sh-logo { display: flex; justify-content: center; border-right: 2px solid var(--sl); padding-right: 14px; min-height: 100px; align-items: center; }
.sh-contacts { font-size: 13.5px; display: flex; flex-direction: column; gap: 3px; }
.sh-contacts div { display: flex; align-items: center; gap: 7px; }
.sh-contacts .addr { font-size: 12px; }
.ico svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; display: block; }
.ico { flex: none; }
.sh-num-wrap { display: flex; justify-content: center; }
.sh-num { border: 1.5px solid var(--sl); border-radius: 12px; width: 100%; max-width: 190px; height: 64px; display: grid; place-items: center; color: var(--red); font: 500 30px/1 'Courier New', monospace; letter-spacing: .08em; text-align: center; }
.sh-num small { font: 500 12px Inter, sans-serif; color: #888; letter-spacing: 0; }

.sh-box { border: 1.5px solid var(--sl); margin-top: 6px; }
.sh-row { display: grid; border-bottom: 1px solid var(--sl); }
.sh-row:last-child { border-bottom: 0; }
.r-nome { grid-template-columns: 1fr 260px 190px; }
.r-1 { grid-template-columns: 1fr; }
.r-bairro { grid-template-columns: 1fr 1fr 150px; }
.r-fone { grid-template-columns: 1fr 1fr; }
.f { display: flex; flex-direction: column; justify-content: flex-start; padding: 3px 7px 4px; border-right: 1px solid var(--sl); min-height: 38px; position: relative; }
.f:last-child { border-right: 0; }
.f .val { font-size: 14px; padding: 1px 0; min-height: 18px; }
.sheet-edit .f input { border: 0; border-bottom: 1px dashed transparent; background: #fbf9f5; padding: 7px 6px; margin-top: 2px; border-radius: 4px; outline: none; width: 100%; font-size: 15px; min-height: 38px; }
.sheet-edit .f input:focus { background: #fff6e8; box-shadow: inset 0 -2px 0 var(--accent); }
.sheet-edit .req > .lbl::after, .sheet-edit th.req::after, .sheet-edit .pl-title.req::after { content: ' *'; color: var(--red); }
.sheet .invalid { background: #fdecec !important; box-shadow: inset 0 0 0 2px #e66 !important; }
.f.loading::after { content: 'Buscando…'; position: absolute; right: 8px; top: 4px; font-size: 11px; color: var(--accent); }

.sh-bar { background: #3a3735; color: #fff; font-weight: 600; font-size: 12.5px; text-align: center; padding: 7px 10px; margin: 8px 0; letter-spacing: .01em; }

.sh-items { width: 100%; border-collapse: collapse; border: 1.5px solid var(--sl); table-layout: fixed; }
.sh-items th { font-size: 12px; font-weight: 700; padding: 6px; border: 1px solid var(--sl); text-align: center; }
.sh-items td { border: 1px solid var(--sl); padding: 0 6px; height: 28px; font-size: 13.5px; }
.sh-items .c-q { width: 90px; text-align: center; }
.sh-items .c-u, .sh-items .c-t { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.sh-items .c-x { width: 40px; }
.sheet-edit .sh-items td { padding: 2px; height: 44px; }
.sheet-edit .sh-items input { width: 100%; height: 40px; border: 0; background: #fbf9f5; padding: 0 8px; border-radius: 4px; outline: none; font-size: 15px; }
.sheet-edit .sh-items input:focus { background: #fff6e8; }
.sheet-edit .sh-items .c-q input { text-align: center; }
.sheet-edit .sh-items .c-u input { text-align: right; }
.sheet-edit .sh-items .c-t { padding-right: 8px; color: #555; }
.rm-item { width: 34px; height: 34px; border: 0; background: none; color: #b33; font-size: 22px; cursor: pointer; border-radius: 6px; }
.rm-item:hover { background: #fdecec; }
.add-item { margin-top: 8px; }

.sh-pay { display: grid; grid-template-columns: 1fr 260px; margin-top: 10px; }
.pay-left { border: 1.5px solid var(--sl); border-right: 0; display: flex; flex-direction: column; }
.pl-row { display: grid; grid-template-columns: 250px 1fr; border-bottom: 1px solid var(--sl); min-height: 38px; }
.pl-row:last-child { border-bottom: 0; }
.pl-title { font-weight: 700; font-size: 13px; padding: 10px 10px; border-right: 1px solid var(--sl); display: flex; align-items: center; }
.pl-prazo { display: flex; align-items: center; gap: 8px; padding: 4px 10px; }
.pl-prazo input { flex: 1; border: 0; background: #fbf9f5; min-height: 34px; padding: 0 8px; border-radius: 4px; outline: none; font-size: 15px; }
.pay-opts { display: flex !important; flex-wrap: wrap; align-items: center; gap: 4px 22px; padding: 6px 10px; }
.pay-opt { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-height: 30px; }
.pay-opt small { display: inline; color: #444; font-weight: 500; }
.pay-chk { display: flex; align-items: center; gap: 7px; cursor: pointer; padding: 4px 0; }
.pay-chk input { width: 22px; height: 22px; accent-color: var(--brand); }
.pay-chk .paren { font-weight: 600; }
.parc input { width: 46px; min-height: 34px; border: 0; background: #fbf9f5; border-radius: 4px; padding: 0 8px; text-align: right; outline: none; font-size: 15px; }
.parc input { width: 46px; text-align: center; }
.parc input:disabled { background: #eee; }
.pay-right { border: 1.5px solid var(--sl); display: flex; flex-direction: column; }
.pay-right .tr { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 10px; border-bottom: 1px solid var(--sl); min-height: 34px; }
.pay-right .tr:last-child { border-bottom: 0; }
.pay-right b { font-variant-numeric: tabular-nums; font-size: 14px; }
.tr-total b { font-size: 17px; }
.desc-in { display: flex; align-items: center; gap: 4px; }
.desc-in input { width: 110px; min-height: 32px; border: 0; background: #fbf9f5; border-radius: 4px; padding: 0 8px; text-align: right; outline: none; font-size: 15px; }

.sh-mostruario { font-weight: 700; text-decoration: underline; font-size: 14px; margin: 10px 0 4px; }
.sh-termo h3 { font-size: 17px; margin: 6px 0 4px 30px; font-weight: 800; letter-spacing: .01em; }
.sh-termo ol { margin: 0; padding: 6px 10px 6px 28px; border-top: 1.5px solid var(--sl); font-size: 10.5px; line-height: 1.35; }
.sh-termo li { margin-bottom: 1px; }

.sh-sign { display: grid; grid-template-columns: 240px 1fr 1fr; border: 1.5px solid var(--sl); margin-top: 8px; min-height: 110px; }
.sg-vend { padding: 8px 10px; border-right: 1px solid var(--sl); }
.sg-vend .lbl { font-size: 13px; font-weight: 700; display: block; }
.sg-vend .val { font-size: 15px; font-weight: 600; display: block; margin-top: 4px; }
.sg-box { padding: 6px 12px 6px; border-right: 1px solid var(--sl); display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.sg-box:last-child { border-right: 0; }
.sg-box .line { border-top: 1px solid var(--sl); text-align: center; font-size: 12.5px; padding-top: 3px; margin-top: 2px; }
.sg-data { position: absolute; top: 6px; left: 12px; font-size: 13px; font-weight: 600; }
.sig-area { height: 64px; display: flex; align-items: flex-end; justify-content: center; }
.sig-img { max-height: 64px; max-width: 100%; }
.sig { display: flex; flex-direction: column; align-items: center; gap: 4px; border-radius: 6px; padding-top: 22px; }
.sig .sig-empty { color: #aaa; font-size: 13px; padding-bottom: 6px; }
.sig-btn { background: var(--accent-bg); }

/* modal de assinatura */
.sig-pad { position: relative; border: 2px dashed var(--line2); border-radius: 12px; background: #fff; margin-bottom: 14px; }
.sig-canvas { display: block; width: 100%; height: 280px; touch-action: none; cursor: crosshair; }
.sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #b9b2a8; pointer-events: none; transition: opacity .2s; font-size: 15px; }
.sig-baseline { position: absolute; left: 8%; right: 8%; bottom: 60px; border-top: 1px solid #ddd; pointer-events: none; }

/* ============================================================ modais e toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(30, 25, 20, .42); display: grid; place-items: center; padding: 16px; z-index: 100; animation: fade .15s; overflow-y: auto; }
.modal { background: var(--modal-bg); border-radius: 16px; padding: 22px; width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: pop .18s; }
.modal.wide { max-width: 760px; }
.modal h3 { font-size: 19px; }
.mbody p { margin: 0 0 10px; }
.mactions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.mactions.center { justify-content: center; }
.sum-items { margin: 0 0 10px; padding-left: 18px; font-size: 14px; }
.sum-items b { white-space: nowrap; }
.big { font-size: 20px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; border: 1px solid var(--line2); border-radius: 9px; padding: 9px 13px; font-size: 14px; font-weight: 500; color: var(--ink); }
.seg input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.day-load { background: var(--bg); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; margin-bottom: 8px; }
.day-load:empty { display: none; }
.success { text-align: center; }
.success .check { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 34px; display: grid; place-items: center; margin: 0 auto 12px; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; width: min(92vw, 440px); }
.toast { background: #2b2825; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-size: 14.5px; animation: up .2s; transition: opacity .4s, transform .4s; }
.toast.ok { background: #245f3d; }
.toast.err { background: #a3242a; }
.toast.warn { background: #8a5a12; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* ============================================================ calendário */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-title { min-width: 150px; text-align: center; font-size: 18px; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.cal { padding: 12px; }
.cal-wd { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; padding-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cday { min-height: 108px; border: 1px solid var(--line); border-radius: 9px; padding: 5px; cursor: pointer; position: relative; background: var(--field); overflow: hidden; transition: border-color .12s; }
.cday:hover { border-color: var(--line2); }
.cday.out { background: var(--out); }
.cday.out .dn { color: #bbb; }
.cday.sun { background: var(--head); }
.cday.today .dn { background: var(--red); color: #fff; }
.cday.sel { border: 2px solid var(--brand); padding: 4px; }
.cday.drop { background: var(--accent-bg); border-color: var(--accent); }
.dn { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 99px; font-weight: 600; font-size: 13.5px; }
.dcount { position: absolute; top: 6px; right: 7px; font-size: 11px; font-weight: 700; color: var(--muted); }
.chips-day { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.cchip { font-size: 11.5px; padding: 2px 6px; border-radius: 5px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.cchip i { font-style: normal; font-weight: 700; margin-right: 4px; }
.cchip.agendado { background: var(--ag-bg); color: var(--ag); }
.cchip.entregue { background: var(--ok-bg); color: var(--ok); }
.more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.legend { display: flex; gap: 8px; align-items: center; font-size: 12.5px; margin-top: 10px; flex-wrap: wrap; }
.lgd { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lgd.agendado { background: var(--ag-bg); border: 1px solid var(--ag); }
.lgd.entregue { background: var(--ok-bg); border: 1px solid var(--ok); margin-left: 8px; }
.side-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.side-head h3 { margin: 0; text-transform: capitalize; }
.route-group h4 { margin: 10px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dl-item { border: 1px solid var(--line); border-left: 4px solid var(--ag); border-radius: 9px; padding: 9px 11px; margin-bottom: 8px; cursor: pointer; }
.dl-item.entregue { border-left-color: var(--ok); }
.dl-item:hover { background: var(--hover); }
.dl-top { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.dl-sub { font-size: 13px; }
.dl-acts { display: flex; gap: 6px; margin-top: 8px; }
.dl-acts:empty { display: none; }
.count { background: var(--pend-bg); color: var(--pend); border-radius: 99px; padding: 1px 9px; font-size: 13px; margin-left: 4px; }
.pend-list { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; }
.pend-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-left: 4px solid var(--pend); border-radius: 9px; padding: 9px 11px; cursor: grab; background: var(--field); }
.pend-item small { font-size: 12px; }

/* ============================================================ painel */
.period { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.period input { min-height: 38px; border: 1px solid var(--line2); border-radius: 9px; padding: 0 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 190px) 1fr 150px; gap: 10px; align-items: center; }
.bn { font-weight: 600; font-size: 14px; line-height: 1.25; }
.bt { height: 12px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bf { height: 100%; background: linear-gradient(90deg, var(--accent), var(--brand-2)); border-radius: 99px; }
.bv { text-align: right; font-variant-numeric: tabular-nums; }
.bv small { font-size: 11.5px; }

/* ============================================================ responsivo */
@media screen and (max-width: 1100px) {
  .detail-grid, .cal-layout { grid-template-columns: 1fr; }
  .side { position: static; }
}
@media screen and (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .me-txt { display: none; }
  .brand-sub { display: none; }
}
@media screen and (max-width: 760px) {
  h1 { font-size: 22px; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .nav-cta { padding: 0 12px; }
  .main { padding-top: 16px; }

  /* tabela vira cartões */
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: 10px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .tbl td { border: 0; padding: 0; }
  .tbl td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
  .tbl .c-act { grid-column: 1 / -1; }
  .row-acts { justify-content: flex-start; }

  /* folha empilha */
  .sheet { padding: 12px; }
  .sh-head { grid-template-columns: 1fr; text-align: left; }
  .sh-logo { border-right: 0; border-bottom: 2px solid var(--sl); padding: 0 0 10px; min-height: 0; }
  .r-nome, .r-bairro, .r-fone { grid-template-columns: 1fr; }
  .f { border-right: 0; border-bottom: 1px solid var(--sl); }
  .f:last-child { border-bottom: 0; }
  .sh-items .c-q { width: 64px; }
  .sh-items .c-u, .sh-items .c-t { width: 96px; }
  .sh-pay { grid-template-columns: 1fr; }
  .pay-left { border-right: 1.5px solid var(--sl); border-bottom: 0; }
  .pl-row { grid-template-columns: 1fr; }
  .pl-title { border-right: 0; border-bottom: 1px solid var(--sl); }
  .sh-sign { grid-template-columns: 1fr; }
  .sg-vend, .sg-box { border-right: 0; border-bottom: 1px solid var(--sl); }
  .sg-box { min-height: 130px; }

  .cday { min-height: 62px; }
  .chips-day { display: none; }
  .dcount { position: static; display: block; text-align: center; margin-top: 4px; background: var(--ag-bg); color: var(--ag); border-radius: 99px; font-size: 12px; }
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .bv { text-align: left; }
}

/* ============================================================ impressão */
#print-root { display: none; }
@page { size: A4 portrait; margin: 7mm; }
@media print {
  html, body { background: #fff !important; color: #1e1e1e !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root .only-dark { display: none !important; }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
.login-theme { position: fixed; top: 14px; right: 14px; }
  #print-root .only-light { display: block !important; }

  .sheet-print { box-shadow: none; border-radius: 0; padding: 0; max-width: none; font-size: 10.5px; }
  .sheet-print .sh-head { grid-template-columns: 52mm 1fr 46mm; padding: 6px 10px; }
  .sheet-print .sh-logo { min-height: 0; }
  .sheet-print .logo-sheet img { max-height: 76px; }
  .rp-head .logo-ui img { height: 26px; }
  .sheet-print .sh-contacts { font-size: 11px; gap: 1px; }
  .sheet-print .sh-contacts .addr { font-size: 9.5px; }
  .sheet-print .sh-num { width: 42mm; height: 15mm; font-size: 24px; }
  .sheet-print .lbl { font-size: 9px; }
  .sheet-print .f { min-height: 30px; padding: 2px 6px; }
  .sheet-print .f .val { font-size: 11.5px; }
  .sheet-print .sh-bar { font-size: 10px; padding: 4px; margin: 5px 0; }
  .sheet-print .sh-items th { font-size: 10px; padding: 3px; }
  .sheet-print .sh-items td { height: 21px; font-size: 11px; }
  .sheet-print .sh-items .c-q { width: 18mm; }
  .sheet-print .sh-items .c-u, .sheet-print .sh-items .c-t { width: 25mm; }
  .sheet-print .sh-pay { grid-template-columns: 1fr 58mm; margin-top: 6px; }
  .sheet-print .pl-row { grid-template-columns: 55mm 1fr; min-height: 28px; }
  .sheet-print .pl-title { font-size: 10.5px; padding: 4px 8px; }
  .sheet-print .pay-opt { font-size: 10.5px; min-height: 22px; }
  .sheet-print .pay-right .tr { min-height: 26px; }
  .sheet-print .tr-total b { font-size: 13px; }
  .sheet-print .sh-mostruario { font-size: 11.5px; margin: 6px 0 2px; }
  .sheet-print .sh-termo h3 { font-size: 13.5px; margin: 3px 0 2px 22px; }
  .sheet-print .sh-termo ol { font-size: 8.4px; line-height: 1.28; padding: 4px 6px 4px 22px; }
  .sheet-print .sh-sign { grid-template-columns: 52mm 1fr 1fr; min-height: 26mm; margin-top: 5px; }
  .sheet-print .sig-area { height: 15mm; }
  .sheet-print .sig-img { max-height: 15mm; }
  .sheet-print .sg-box .line { font-size: 10.5px; }
  .sheet-print .sg-data { font-size: 10.5px; }
  .sheet-print .sh-items, .sheet-print .sh-pay, .sheet-print .sh-sign { break-inside: avoid; }

  .route-print { font-size: 11px; }
  .rp-head { display: flex; align-items: center; gap: 16px; border-bottom: 2px solid #333; padding-bottom: 8px; margin-bottom: 10px; }
  .rp-head h2 { margin: 0; font-size: 18px; }
  .rp-head p { margin: 2px 0 0; text-transform: capitalize; }
  .route-print table { width: 100%; border-collapse: collapse; }
  .route-print th, .route-print td { border: 1px solid #555; padding: 5px 6px; vertical-align: top; text-align: left; }
  .route-print th { background: #eee; font-size: 10px; }
  .route-print tr { break-inside: avoid; }
  .route-print .sigcol { width: 40mm; }
}
