/* Painel da oficina */
:root {
  --bg: #f5f2ee;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e2dc;
  --accent: #c2410c;
  --accent-soft: #fff1e8;
  --accent-ink: #9a3412;
  --ok: #15803d; --ok-soft: #e8f6ed;
  --warn: #b45309; --warn-soft: #fef5e4;
  --bad: #b91c1c; --bad-soft: #fdecec;
  --info: #1d4ed8; --info-soft: #eaf0fe;
  --side: #1c1917;
  --side-ink: #e7e5e4;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 8px 24px -12px rgb(0 0 0 / .15);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100e; --surface: #1c1917; --surface-2: #231f1c; --ink: #f5f5f4; --muted: #a8a29e; --line: #34302c;
    --accent: #f07a45; --accent-soft: #3a2015; --accent-ink: #fdba8c;
    --ok: #4ade80; --ok-soft: #12291b; --warn: #fbbf24; --warn-soft: #2e2410; --bad: #f87171; --bad-soft: #321616; --info: #93b4fd; --info-soft: #172240;
    --side: #0c0a09; --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12100e; --surface: #1c1917; --surface-2: #231f1c; --ink: #f5f5f4; --muted: #a8a29e; --line: #34302c;
  --accent: #f07a45; --accent-soft: #3a2015; --accent-ink: #fdba8c;
  --ok: #4ade80; --ok-soft: #12291b; --warn: #fbbf24; --warn-soft: #2e2410; --bad: #f87171; --bad-soft: #321616; --info: #93b4fd; --info-soft: #172240;
  --side: #0c0a09; --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 'Plus Jakarta Sans', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, black); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-wa { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn svg { width: 17px; height: 17px; flex: none; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 700; }
.field small { color: var(--muted); font-size: 12px; }
.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; font-size: 15px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea.input { resize: vertical; min-height: 84px; }
.input-color { display: flex; gap: 8px; align-items: center; }
.input-color input[type=color] { width: 46px; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface); cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgb(0 0 0 / .3); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(18px); }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.msg-err { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; }

/* telas de acesso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg); }
.auth-card { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px 24px; box-shadow: var(--shadow); display: grid; gap: 18px; }
.auth-logo { width: 54px; height: 54px; }
.auth-card h1 { font-family: 'Fraunces', serif; font-size: 28px; }
.auth-card fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; }
.auth-card legend { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }

/* estrutura */
.shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 960px) { .shell { grid-template-columns: 240px 1fr; } }
.side { display: none; background: var(--side); color: var(--side-ink); padding: 20px 14px; position: sticky; top: 0; height: 100vh; flex-direction: column; gap: 6px; }
@media (min-width: 960px) { .side { display: flex; } }
.side-brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.side-brand img { width: 36px; height: 36px; }
.side-brand b { display: block; font-size: 15px; line-height: 1.2; color: #fff; }
.side-brand small { color: #a8a29e; font-size: 12px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #d6d3d1; text-decoration: none; font-weight: 600; font-size: 14.5px; border: 0; background: none; cursor: pointer; width: 100%; text-align: left; }
.nav-item:hover { background: rgb(255 255 255 / .06); color: #fff; }
.nav-item.active { background: rgb(255 255 255 / .1); color: #fff; box-shadow: inset 3px 0 0 #f07a45; }
.nav-item svg { width: 19px; height: 19px; }
.nav-count { margin-left: auto; background: #f07a45; color: #1c1917; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; }
.side-foot { margin-top: auto; display: grid; gap: 6px; }

.main { min-width: 0; padding-bottom: 84px; }
@media (min-width: 960px) { .main { padding-bottom: 0; } }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20; }
@media (min-width: 640px) { .topbar { padding: 14px 28px; } }
.topbar h1 { font-size: 19px; font-weight: 800; }
.content { padding: 16px; max-width: 1200px; }
@media (min-width: 640px) { .content { padding: 28px; } }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
@media (min-width: 960px) { .bottom-nav { display: none; } }
.bottom-nav button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 6px 0; cursor: pointer; position: relative; }
.bottom-nav button.active { color: var(--accent); }
.bottom-nav svg { width: 22px; height: 22px; }
.bottom-nav .dot { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 10px; display: grid; place-items: center; }

/* cartões */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 16px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.kpi b { display: block; font-size: clamp(22px, 3vw, 28px); font-weight: 800; margin-top: 4px; letter-spacing: -.01em; }
.kpi.hl { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.kpi.hl span { color: color-mix(in srgb, var(--bg) 70%, var(--ink)); }
.home-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .home-grid { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.todo { display: grid; gap: 4px; }
.todo-item { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; }
.todo-item:hover { background: var(--surface-2); }
.todo-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 2px dashed var(--line); font-size: 13px; font-weight: 800; }
.todo-item.done .todo-mark { background: var(--ok); border: 0; color: #fff; }
.todo-item.done .todo-text { color: var(--muted); text-decoration: line-through; }
.todo-text { flex: 1; font-weight: 600; font-size: 14px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.progress div { height: 100%; background: var(--ok); border-radius: 99px; transition: width .4s; }
.share-box { display: flex; gap: 8px; }
.share-box .input { font-size: 13px; }

/* pedidos */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 14px; font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip i { font-style: normal; opacity: .65; font-weight: 600; }
.leads { display: grid; gap: 12px; }
@media (min-width: 1100px) { .leads { grid-template-columns: 1fr 1fr; } }
.lead { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; border-left: 4px solid var(--line); }
.lead.st-novo { border-left-color: var(--accent); }
.lead.st-contatado { border-left-color: var(--info); }
.lead.st-visita { border-left-color: var(--warn); }
.lead.st-fechado { border-left-color: var(--ok); }
.lead-top { display: flex; gap: 10px; align-items: flex-start; }
.lead-top h4 { font-size: 16px; }
.lead-top small { color: var(--muted); font-size: 12.5px; }
.lead-price { margin-left: auto; text-align: right; font-weight: 800; font-size: 17px; white-space: nowrap; }
.lead-price small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.lead-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.fact { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; font-size: 12.5px; font-weight: 600; }
.lead-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lead-actions select { width: auto; padding: 7px 10px; font-size: 13px; font-weight: 700; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

/* editor da página */
.editor { display: grid; gap: 16px; }
@media (min-width: 1280px) { .editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; } .content.wide { max-width: none; } }
.ed-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 6px; margin-bottom: 14px; }
.ed-tab { border: 1px solid var(--line); background: var(--surface); padding: 8px 13px; border-radius: 10px; font-weight: 700; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.ed-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ed-panel { display: grid; gap: 16px; }
.ed-hint { background: var(--accent-soft); color: var(--accent-ink); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; font-weight: 500; }
.savebar { position: sticky; bottom: 76px; z-index: 15; display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: 14px; box-shadow: 0 12px 32px -8px rgb(0 0 0 / .35); margin-top: 18px; }
@media (min-width: 960px) { .savebar { bottom: 16px; } }
.savebar span { font-weight: 700; font-size: 14px; }
.savebar .btn { border: 0; }
.preview { position: sticky; top: 76px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: none; flex-direction: column; height: calc(100vh - 100px); }
@media (min-width: 1280px) { .preview { display: flex; } }
.preview.open { display: flex; position: fixed; inset: 0; top: 0; z-index: 60; border-radius: 0; height: 100%; }
.preview-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.preview-bar b { font-size: 13px; }
.preview-stage { flex: 1; display: grid; place-items: start center; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--bg) 0 50%) 0 0 / 18px 18px; overflow: auto; }
.preview-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; transition: width .25s; }
.preview-stage.mobile iframe { width: 390px; max-width: 100%; border-inline: 1px solid var(--line); }
.preview-fab { position: fixed; right: 16px; bottom: 150px; z-index: 25; border-radius: 99px; box-shadow: var(--shadow); }
@media (min-width: 1280px) { .preview-fab { display: none; } }
@media (min-width: 960px) { .preview-fab { bottom: 90px; } }

/* listas editáveis */
.items { display: grid; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.item-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; cursor: pointer; background: var(--surface-2); }
.item-head b { flex: 1; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-head .thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.item-body { padding: 14px; display: grid; gap: 12px; border-top: 1px solid var(--line); }
.item.off .item-head b { color: var(--muted); }
.item-tools { display: flex; gap: 4px; }

.img-field { display: flex; gap: 12px; align-items: center; }
.img-prev { width: 84px; height: 84px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line); overflow: hidden; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }
.img-prev img { width: 100%; height: 100%; object-fit: cover; }
.img-actions { display: grid; gap: 6px; flex: 1; min-width: 0; }
.upbar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.upbar div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); animation: tin .25s ease; }
.toast.err { background: var(--bad); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
