:root {
  --navy-950: #070e22;
  --navy-900: #0c1733;
  --navy: #15254c;
  --blue: #1a66ff;
  --blue-600: #1557db;
  --sky: #1fb6ff;
  --cyan: #29e3ff;
  --bg: #f3f6fb;
  --card: #ffffff;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e4e8f0;
  --line-2: #d0d6e2;
  --soft: #f7f9fc;
  --danger: #d92d20;
  --success: #079455;
  --warn: #dc6803;
  --grad: linear-gradient(135deg, var(--sky), var(--blue));
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 50px -12px rgba(12, 23, 51, .28);
  --sidebar: 256px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: var(--blue); text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
button { font: inherit; }
input, select, textarea { font: inherit; color: inherit; }

.ic { width: 18px; height: 18px; flex: none; }

.boot { min-height: 100vh; display: grid; place-items: center; background: var(--navy-900); }
.boot img { width: 64px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .06s, box-shadow .15s, background .15s, border-color .15s, opacity .15s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { color: #fff; background: var(--grad); box-shadow: 0 6px 16px -6px rgba(26, 102, 255, .6); }
.btn-primary:hover { box-shadow: 0 8px 20px -6px rgba(26, 102, 255, .75); }
.btn-dark { color: #fff; background: var(--navy); }
.btn-dark:hover { background: var(--navy-900); }
.btn-outline { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft); color: var(--ink); }
.icon-btn.danger:hover { background: #fef3f2; color: var(--danger); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .field input:not([type=checkbox]):not([type=file]), .field select, .field textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(26, 102, 255, .12);
}
.input-money { position: relative; }
.input-money::before {
  content: 'R$';
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  pointer-events: none;
}
.input-money input { padding-left: 34px !important; text-align: right; font-variant-numeric: tabular-nums; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px !important; }
.pw-eye {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.pw-eye:hover { color: var(--ink); background: var(--soft); }
.pw-eye:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.grid { display: grid; gap: 16px; }
.phones { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr) minmax(0, 1.3fr); gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 600; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 38px; height: 22px; border-radius: 22px; background: var(--line-2); position: relative; transition: background .15s; flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s;
}
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px rgba(26, 102, 255, .2); }

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.login-art {
  position: relative;
  overflow: hidden;
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(600px 400px at 90% 10%, rgba(26, 102, 255, .55), transparent 70%),
    radial-gradient(500px 380px at 0% 100%, rgba(41, 227, 255, .25), transparent 70%),
    linear-gradient(140deg, var(--navy-950), var(--navy));
}
.login-art::after {
  content: '';
  position: absolute;
  right: -120px;
  bottom: -140px;
  width: 520px;
  height: 520px;
  background: url('/img/icon-white.png') center / contain no-repeat;
  opacity: .05;
}
.login-art img.logo { width: 200px; }
.login-art h1 { font-size: 40px; font-weight: 800; letter-spacing: -.02em; max-width: 480px; }
.login-art h1 em { font-style: normal; background: linear-gradient(90deg, var(--cyan), var(--sky)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-art p { color: rgba(255,255,255,.72); font-size: 16px; max-width: 440px; margin: 16px 0 0; }
.login-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.login-chips span {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 13px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14);
}
.login-form { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.login-card { width: 100%; max-width: 380px; }
.login-card .logo-sm { display: none; width: 150px; margin-bottom: 28px; }
.login-card h2 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.login-card > p { color: var(--muted); margin: 6px 0 28px; }
.login-card form { display: grid; gap: 16px; }
.login-card .btn { height: 46px; margin-top: 6px; }
.form-error { color: var(--danger); background: #fef3f2; border: 1px solid #fecdca; padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 13px; }
.form-error:empty { display: none; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  color: #c8d2e8;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  z-index: 30;
}
.sidebar .brand { padding: 4px 10px 22px; display: flex; align-items: center; justify-content: space-between; }
.sidebar .brand img { width: 128px; display: block; }
.sidebar .brand small { display: block; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: rgba(255,255,255,.45); margin-top: 8px; font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.35); padding: 18px 12px 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #c8d2e8;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(31, 182, 255, .14); color: #fff; box-shadow: inset 3px 0 0 var(--cyan); }
.nav a.active .ic { color: var(--cyan); }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; margin-left: 5px; margin-right: 5px; }
.sidebar .new-btn { margin: 4px 0 6px; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; }
.me:hover { background: rgba(255,255,255,.05); }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: var(--grad); font-size: 13px;
}
.me-info { min-width: 0; flex: 1; }
.me-info b { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info small { color: rgba(255,255,255,.5); font-size: 12px; }
.me .icon-btn { color: rgba(255,255,255,.55); }
.me .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; }
.topbar { display: none; }
.page { padding: 32px 36px 60px; max-width: 1380px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.back:hover { color: var(--blue); }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 22px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; font-size: 13px; font-weight: 800;
  color: var(--blue); background: rgba(26, 102, 255, .1);
}

/* Serviço */
.svc-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.svc-goto { color: #1447b8; background: #e8efff; }
.svc-chat { color: #0b7ea8; background: #e0f7ff; }
.svc-badge .ic { width: 14px; height: 14px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-rascunho { color: #475467; background: #f2f4f7; }
.st-enviada { color: #1557db; background: #eaf1ff; }
.st-aprovada { color: #067647; background: #dcfae6; }
.st-recusada { color: #b42318; background: #fee4e2; }
.role-super { color: #5925dc; background: #f4f3ff; }

/* ---------- Dashboard ---------- */
.hero-cta { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.cta {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 26px;
  border-radius: 18px;
  color: #fff;
  min-height: 190px;
  box-shadow: var(--shadow-lg);
  transition: transform .15s;
}
.cta:hover { transform: translateY(-2px); }
.cta-goto { background: radial-gradient(420px 260px at 100% 0%, rgba(26, 102, 255, .7), transparent 70%), linear-gradient(140deg, var(--navy-900), var(--navy)); }
.cta-chat { background: radial-gradient(420px 260px at 100% 0%, rgba(0, 166, 224, .65), transparent 70%), linear-gradient(140deg, #03040a, #0b1433); }
.cta .cta-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); }
.cta .cta-icon .ic { width: 22px; height: 22px; color: var(--cyan); }
.cta h3 { font-size: 21px; font-weight: 800; }
.cta p { margin: 0; color: rgba(255,255,255,.72); max-width: 360px; }
.cta .cta-go { margin-top: auto; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--cyan); }
.cta::after {
  content: ''; position: absolute; right: -40px; bottom: -50px; width: 200px; height: 200px;
  background: url('/img/icon-white.png') center / contain no-repeat; opacity: .06;
}

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { padding: 18px 20px; }
.stat span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.stat strong { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 12px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  padding: 12px 16px; background: var(--soft); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: #fafbff; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions-col { text-align: right; white-space: nowrap; }
.table .muted { color: var(--muted); }
.table .strong { font-weight: 700; }
.cell-title b { display: block; }
.cell-title small { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink-2); }
.table tr.inactive td { opacity: .5; }
.group-row td { background: #f9fafc; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--blue); padding: 8px 16px; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .ic { width: 38px; height: 38px; color: var(--line-2); margin-bottom: 8px; }
.empty b { display: block; color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.filters .search { position: relative; flex: 1; min-width: 220px; }
.filters .search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filters .search input { padding-left: 38px !important; } /* vence o padding genérico de .field input */
.filters select { width: auto; min-width: 150px; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; background: #e9edf5; border-radius: 12px; }
.tabs a, .tabs button {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 9px; font-weight: 700; color: var(--muted);
  border: 0; background: transparent; cursor: pointer;
}
.tabs a.active, .tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.editor-side { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; }
.summary {
  color: #fff; border-radius: 18px; padding: 22px; box-shadow: var(--shadow-lg);
  background: radial-gradient(300px 200px at 100% 0%, rgba(26, 102, 255, .6), transparent 70%), linear-gradient(150deg, var(--navy-900), var(--navy));
}
.summary.chat { background: radial-gradient(300px 200px at 100% 0%, rgba(0, 166, 224, .55), transparent 70%), linear-gradient(150deg, #03040a, #0b1433); }
.summary .s-label { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.6); }
.summary .s-main { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.summary .s-sub { color: rgba(255,255,255,.6); font-size: 13px; }
.summary .s-rows { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12); display: grid; gap: 8px; }
.summary .s-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; color: rgba(255,255,255,.75); }
.summary .s-row b { color: #fff; font-variant-numeric: tabular-nums; }
.summary .s-row.hl b { color: var(--cyan); }
.side-card { padding: 18px; display: grid; gap: 14px; }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side-actions .btn-primary { grid-column: 1 / -1; height: 46px; }
.dirty-flag { font-size: 12.5px; color: var(--warn); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.dirty-flag::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.saved-flag { font-size: 12.5px; color: var(--muted); }

.items { display: flex; flex-direction: column; }
.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 72px 130px 120px;
  grid-template-areas:
    'name name name name act'
    'desc bill qty price total';
  gap: 10px 12px;
  align-items: end;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.item:hover { background: #fcfdff; }
.item .i-name { grid-area: name; min-width: 0; }
.item .i-desc { grid-area: desc; min-width: 0; }
.item .i-bill { grid-area: bill; }
.item .i-qty { grid-area: qty; }
.item .i-price { grid-area: price; }
.item .i-total { grid-area: total; }
.item .i-actions { grid-area: act; align-self: center; }
.item input, .item select { height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; width: 100%; background: #fff; outline: none; }
.item input:focus, .item select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 102, 255, .12); }
.item .i-name input { font-weight: 700; font-size: 14.5px; border-color: transparent; background: transparent; padding-left: 8px; margin-left: -8px; }
.item .i-name input:hover { border-color: var(--line-2); background: #fff; }
.item .i-name input:focus { background: #fff; }
.item .i-desc input { color: var(--ink-2); font-size: 13px; }
.item .i-bill { display: flex; flex-direction: column; gap: 6px; }
.item .i-warn { display: block; font-size: 11.5px; font-weight: 600; color: var(--danger); line-height: 1.3; }
.item .i-inst { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.item .i-inst input { height: 30px; width: 64px; text-align: center; }
.item .i-qty input { text-align: center; }
.item .i-total { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; padding-bottom: 2px; }
.item .i-total small { display: block; font-weight: 600; font-size: 11.5px; color: var(--muted); }
.item .i-total .free { color: var(--success); }
.item .i-actions { display: flex; justify-content: flex-end; gap: 2px; }
.item .i-actions .icon-btn { width: 30px; height: 30px; }
.item .i-actions .icon-btn.on { color: var(--success); background: #dcfae6; }
.item.is-free .i-price input { text-decoration: line-through; color: var(--muted); }
.item .i-label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.item .i-total .i-label { text-align: right; }

.catalog-pick { padding: 18px 22px; background: var(--soft); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.catalog-pick h4 { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.chip-group { margin-bottom: 12px; }
.chip-group > span { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff;
  font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: border-color .15s, color .15s, box-shadow .15s;
}
.chip:hover { border-color: var(--blue); color: var(--blue); box-shadow: 0 2px 8px -2px rgba(26, 102, 255, .25); }
.chip .ic { width: 14px; height: 14px; }
.chip em { font-style: normal; color: var(--muted); font-weight: 600; font-size: 12px; }
.chip.chip-custom { border-style: dashed; }
.chip.in { border-color: rgba(26, 102, 255, .45); background: #f2f6ff; }

.text-block .field textarea { min-height: 110px; }
.field-row-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.link-btn { border: 0; background: none; color: var(--blue); font-weight: 700; font-size: 12px; cursor: pointer; padding: 0; display: inline-flex; gap: 4px; align-items: center; }
.link-btn .ic { width: 13px; height: 13px; }

/* Pré-visualização */
.preview-backdrop .modal { width: min(980px, 96vw); max-height: 94vh; }
.preview-backdrop .modal-body { background: #e9edf4; padding: 24px; overflow: auto; }
.paper-scale { transform-origin: top left; }
.paper-frame { margin: 0 auto; }
.paper-frame .pdoc { box-shadow: 0 10px 40px rgba(12, 23, 51, .18); }

/* Upload */
.upload {
  display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px dashed var(--line-2); border-radius: 12px; background: var(--soft);
}
.upload .thumb { width: 120px; height: 64px; border-radius: 8px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; flex: none; }
.upload .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.upload .thumb .ic { color: var(--line-2); width: 26px; height: 26px; }
.upload .u-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(7, 14, 34, .55); backdrop-filter: blur(3px); opacity: 0; transition: opacity .18s;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  width: min(620px, 100%); max-height: 92vh; display: flex; flex-direction: column; background: #fff; border-radius: 18px;
  box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.98); transition: transform .18s;
}
.modal-backdrop.show .modal { transform: none; }
.modal.modal-sm { width: min(420px, 100%); }
.modal.modal-lg { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; font-weight: 800; }
.modal-body { padding: 22px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--soft); border-radius: 0 0 18px 18px; }
.confirm-text { margin: 0; color: var(--ink-2); }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 16px; border-radius: 12px;
  background: var(--navy-900); color: #fff; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast .ic { color: var(--cyan); }
.toast-error { background: #7a271a; }
.toast-error .ic { color: #fecdca; }

.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: #eaf1ff; color: #1447b8; font-weight: 600; font-size: 13px; }
.notice.warn { background: #fffaeb; color: #93370d; }
.price-zero { color: var(--warn); font-weight: 700; }

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: 1fr; }
  .editor-side { position: static; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; position: sticky; top: 0; z-index: 20;
    background: var(--navy-900); color: #fff;
  }
  .topbar img { height: 28px; }
  .topbar .icon-btn { color: #fff; }
  .scrim { position: fixed; inset: 0; background: rgba(7,14,34,.5); z-index: 25; display: none; }
  body.nav-open .scrim { display: block; }
  .page { padding: 22px 16px 60px; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-card .logo-sm { display: block; }
  .hero-cta { grid-template-columns: 1fr; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .item {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 'name name' 'desc desc' 'bill qty' 'price total' 'act act';
    padding: 16px;
  }
  .item .i-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .stats { grid-template-columns: 1fr 1fr; }
  .page-head h1 { font-size: 22px; }
  .side-actions { grid-template-columns: 1fr; }
}

/* =====================================================================
   Celular / tablet — nada abaixo altera o layout de desktop
   ===================================================================== */
.m-savebar { display: none; }
.field.off { visibility: hidden; }

@media (max-width: 960px) {
  /* Evita o zoom automático do iPhone ao tocar em campos (fonte < 16px) */
  input:not([type=checkbox]):not([type=file]), select, textarea { font-size: 16px !important; }

  .topbar { padding-top: calc(12px + env(safe-area-inset-top)); }
  .topbar img { height: 26px; }
  .sidebar { width: min(300px, 86vw); padding-bottom: calc(22px + env(safe-area-inset-bottom)); }

  .page-head { margin-bottom: 18px; }
  .page-head .actions { width: 100%; }
  .page-head .actions > .btn { flex: 1; }
  .page-head .actions .tabs { width: 100%; }
  .page-head .actions .tabs > * { flex: 1; justify-content: center; }

  .card-head { padding: 16px; }
  .card-body { padding: 16px; }
  .filters { padding: 14px 16px; }
  .filters .search { min-width: 0; }
  .filters select { width: 100%; }

  /* Editor */
  .editor { gap: 16px; }
  .page:has(.m-savebar) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .item {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: 'name name' 'desc desc' 'bill qty' 'price total' 'act act';
    gap: 10px 12px;
    padding: 14px 16px;
  }
  .item .i-actions { justify-content: flex-end; gap: 6px; padding-top: 8px; border-top: 1px dashed var(--line); }
  .item .i-actions .icon-btn { width: 32px; height: 32px; }
  .item .i-total { text-align: right; align-self: center; }
  .item .i-total .i-label { text-align: right; }
  .catalog-pick { padding: 16px; }
  .summary .s-main { font-size: 30px; }

  .m-savebar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(12, 23, 51, .96);
    backdrop-filter: blur(8px);
    box-shadow: 0 -8px 24px rgba(7, 14, 34, .25);
    color: #fff;
  }
  .m-total { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
  .m-total small { font-size: 11px; color: rgba(255,255,255,.6); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
  .m-total b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .m-savebar .btn { height: 44px; }
  .m-savebar .m-pdf { width: 44px; padding: 0; background: rgba(255,255,255,.12); }
  .m-savebar #mSave { position: relative; padding: 0 18px; }
  .m-savebar #mSave.is-dirty::after {
    content: ''; position: absolute; top: -3px; right: -3px; width: 11px; height: 11px; border-radius: 50%;
    background: #fdb022; border: 2px solid var(--navy-900);
  }
  #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); left: 16px; right: 16px; }
  .toast { min-width: 0; max-width: none; }

  /* Pré-visualização */
  .modal-backdrop { grid-template-columns: minmax(0, 1fr); }
  .preview-backdrop .modal, .preview-backdrop .modal.modal-lg { width: 100%; max-width: 100%; }
  .preview-backdrop .modal-body { padding: 10px; }

  /* Tabelas viram cartões */
  .table.rtable, .rtable tbody { display: block; }
  .rtable thead { display: none; }
  .rtable tr { display: grid; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); align-items: center; }
  .rtable tbody tr:last-child { border-bottom: 0; }
  .rtable td { display: block; padding: 0; border: 0 !important; min-width: 0; }
  .rtable .actions-col { text-align: right; }
  .rtable .actions-col .icon-btn { width: 36px; height: 36px; }
  .rtable tr.group-row { display: block; padding: 0; }
  .rtable tr.group-row td { padding: 9px 16px; }
  .table tbody tr.clickable:hover td { background: transparent; }

  /* Propostas */
  .rt-prop tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'num status' 'client client' 'svc monthly' 'seller once' 'date actions'; }
  .rt-prop.compact tr { grid-template-areas: 'num status' 'client client' 'svc monthly' 'date actions'; }
  .rt-prop .c-num { grid-area: num; font-size: 12.5px; color: var(--muted); }
  .rt-prop .c-status { grid-area: status; justify-self: end; }
  .rt-prop .c-client { grid-area: client; font-size: 15px; }
  .rt-prop .c-svc { grid-area: svc; }
  .rt-prop .c-monthly { grid-area: monthly; text-align: right; font-size: 16px; }
  .rt-prop .c-monthly::after { content: ' /mês'; font-size: 12px; font-weight: 600; color: var(--muted); }
  .rt-prop .c-once { grid-area: once; text-align: right; font-size: 13px; color: var(--muted); }
  .rt-prop .c-once::before { content: 'Único '; }
  .rt-prop .c-seller { grid-area: seller; font-size: 13px; }
  .rt-prop .c-date { grid-area: date; font-size: 12.5px; }
  .rt-prop .c-actions { grid-area: actions; margin-right: -8px; }

  /* Catálogo */
  .rt-cat tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'name price' 'bill price' 'flags flags' 'status actions'; }
  .rt-cat .c-name { grid-area: name; }
  .rt-cat .c-bill { grid-area: bill; font-size: 13px; color: var(--muted); }
  .rt-cat .c-price { grid-area: price; text-align: right; align-self: start; font-size: 15px; }
  .rt-cat .c-qty { display: none !important; }
  .rt-cat .c-flags { grid-area: flags; display: flex; flex-wrap: wrap; gap: 6px; }
  .rt-cat .c-flags .muted { display: none; }
  .rt-cat .c-status { grid-area: status; }
  .rt-cat .c-actions { grid-area: actions; display: flex; justify-content: flex-end; gap: 2px; margin-right: -6px; }

  /* Usuários */
  .rt-users tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'name role' 'email email' 'pos status' 'date actions'; }
  .rt-users .c-name { grid-area: name; }
  .rt-users .c-role { grid-area: role; justify-self: end; }
  .rt-users .c-email { grid-area: email; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
  .rt-users .c-pos { grid-area: pos; font-size: 13px; }
  .rt-users .c-status { grid-area: status; justify-self: end; text-align: right; }
  .rt-users .c-date { grid-area: date; font-size: 12.5px; }
  .rt-users .c-actions { grid-area: actions; }
}

@media (max-width: 560px) {
  .page { padding: 18px 14px 48px; }
  .page-head h1 { font-size: 22px; }
  .cta { min-height: 0; padding: 20px; }
  .cta h3 { font-size: 19px; }
  .stat { padding: 14px 16px; }
  .stat strong { font-size: 21px; }
  .field.off { display: none; }
  .phones { grid-template-columns: minmax(0, 1.4fr) minmax(0, .8fr); }
  .phones .f-mobile { grid-column: 1 / -1; }

  /* Janelas abrem como painel de baixo para cima */
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal, .modal.modal-sm, .modal.modal-lg { width: 100%; max-width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
  .modal-backdrop .modal { transform: translateY(24px); }
  .modal-head { padding: 16px 18px; }
  .modal-body { padding: 18px; }
  .modal-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-radius: 0; }
  .modal-foot .btn { flex: 1; height: 44px; }
  .preview-backdrop .modal { max-height: 94vh; }

  .upload { flex-direction: column; align-items: stretch; }
  .upload .thumb { width: 100%; height: 90px; }
  .login-form { place-items: start center; padding: 12vh 20px 32px; }
}

/* ---------- Métricas ---------- */
.metrics-filters { margin-bottom: 20px; }
.metrics-filters .filters { flex-direction: row; border-bottom: 0; padding-bottom: 6px; align-items: center; }
.metrics-filters .m-custom { display: inline-flex; align-items: center; gap: 8px; }
.metrics-filters .m-custom[hidden] { display: none; }
.metrics-filters .m-custom input { width: 160px; }
.m-range { padding: 0 22px 14px; font-size: 12.5px; }
.metrics-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat .delta { display: block; color: var(--muted); font-weight: 600; }
.stat .delta.up { color: var(--success); }
.stat .delta.down { color: var(--danger); }
.metrics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.metrics-grid + .card, .metrics-grid ~ .card { margin-bottom: 16px; }
.metrics-grid .card { min-width: 0; }
.empty.small { padding: 28px 12px; }
.empty.small .ic { width: 30px; height: 30px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }

.chart { position: relative; min-height: 240px; }
.chart svg { display: block; overflow: visible; }
.chart-tick { font-size: 11px; fill: #667085; font-variant-numeric: tabular-nums; }
.chart-band { fill: transparent; }
.chart-band.on { fill: rgba(16, 24, 40, .045); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 170px; padding: 10px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 12.5px;
}
.chart-tip b { display: block; margin-bottom: 4px; color: var(--ink); }
.chart-tip div { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.chart-tip div i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.chart-tip div span { margin-left: auto; padding-left: 14px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-tip .tip-note { display: block; margin-top: 4px; color: var(--muted); }
.chart-data { margin-top: 10px; font-size: 13px; }
.chart-data summary { cursor: pointer; color: var(--muted); font-weight: 600; width: fit-content; }
.chart-data summary:hover { color: var(--blue); }
.chart-data .table-wrap { max-height: 280px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; }
.chart-data .table td, .chart-data .table th { padding: 7px 12px; }

.svc-row + .svc-row { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.svc-row dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 10px 16px; margin: 10px 0 0; }
.svc-row dt { font-size: 12px; font-weight: 700; color: var(--muted); }
.svc-row dd { margin: 2px 0 0; font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.hbars { display: grid; gap: 14px; }
.hbar { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.hbar-track { height: 14px; }
.hbar-fill { height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; }
.hbar-value { font-size: 13px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 1180px) {
  .metrics-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .metrics-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-filters .m-custom { width: 100%; }
  .metrics-filters .m-custom input { flex: 1; width: auto; min-width: 0; padding: 0 6px !important; }
  .m-range { padding: 0 16px 12px; }
}

/* ---------- Somente leitura (proposta de outro vendedor) ---------- */
.readonly-notice { margin-bottom: 18px; align-items: center; }
.editor input:disabled, .editor select:disabled, .editor textarea:disabled {
  background: var(--soft) !important; color: var(--ink-2); cursor: default; opacity: 1; -webkit-text-fill-color: var(--ink-2);
}
.editor .i-name input:disabled { background: transparent !important; border-color: transparent; }

/* ---------- Auditoria ---------- */
.audit-filters { flex-direction: row; align-items: center; }
.audit-filters .m-custom { display: inline-flex; align-items: center; gap: 8px; }
.audit-filters .m-custom[hidden] { display: none; }
.audit-filters .m-custom input { width: 150px; }
.rt-audit tr[hidden] { display: none !important; }
.rt-audit .c-when { white-space: nowrap; font-size: 12.5px; color: var(--ink-2); }
.rt-audit .c-who small { display: block; }
.rt-audit .c-what { min-width: 280px; }
.rt-audit tr.open td { background: var(--soft); }
.rt-audit tr.open .c-more .ic { transform: rotate(180deg); }
.cat-pill { color: #344054; background: #f2f4f7; }
.a-details td { background: var(--soft); padding: 4px 16px 16px 16px; }
.a-changes { margin: 0 0 8px; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }
.a-changes b { font-weight: 700; color: var(--ink-2); }
.a-from { color: var(--muted); text-decoration: line-through; }
.a-to { color: var(--ink); }
.a-meta { font-size: 12px; color: var(--muted); }
.a-more { padding: 14px; text-align: center; border-top: 1px solid var(--line); }
.a-more[hidden] { display: none; }

@media (max-width: 960px) {
  .audit-filters .m-custom { width: 100%; }
  .audit-filters .m-custom input { flex: 1; width: auto; min-width: 0; padding: 0 6px !important; }
  .rt-audit tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'when cat' 'who who' 'what what'; }
  .rt-audit .c-when { grid-area: when; }
  .rt-audit .c-cat { grid-area: cat; justify-self: end; }
  .rt-audit .c-who { grid-area: who; }
  .rt-audit .c-what { grid-area: what; min-width: 0; }
  .rt-audit .c-more { display: none !important; }
  .rt-audit tr.a-details { display: block; padding: 0 16px 14px; background: var(--soft); }
  .rt-audit tr.a-details td { padding: 0; }
}
