/* VettorPrint OS — identidade: grafite + dourado da marca */
:root {
  --gold-1: #b47c38; --gold-2: #d9a948; --gold-3: #f4d860; --gold-4: #f7e9a6;
  --gold-grad: linear-gradient(100deg, #b47c38 0%, #dcae4c 30%, #f6df6d 55%, #e4bb55 78%, #b47c38 100%);
  --side: #0f0f11; --side-2: #18181b; --side-ink: #a1a1aa; --side-ink-on: #fafafa;
  --radius: 10px; --nav-w: 236px; --nav-min: 68px;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
[data-theme="light"] {
  --bg: #f5f4f0; --card: #ffffff; --ink: #18181b; --muted: #6b6b73; --line: #e7e5df; --input: #ffffff; --input-line: #d6d3cb;
  --accent: #9a6a1f; --accent-soft: #fbf3dd; --row-hover: #faf8f2; --chip: #f1eee6;
  --ok-bg: #e8f5ec; --ok: #136c35; --err-bg: #fdeceb; --err: #b42318; --warn-bg: #fff4dc; --warn: #8a5300;
  --shadow: 0 1px 2px rgba(24, 24, 27, .05), 0 4px 16px rgba(24, 24, 27, .04);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #121214; --card: #1b1b1e; --ink: #ececee; --muted: #9b9ba3; --line: #2a2a2f; --input: #151517; --input-line: #34343a;
  --accent: #e7c15e; --accent-soft: #2a2416; --row-hover: #202024; --chip: #26262b;
  --ok-bg: #12291b; --ok: #6fd99a; --err-bg: #331615; --err: #ff8a80; --warn-bg: #2f2410; --warn: #f2c26b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; }

/* Estrutura */
.shell { display: flex; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; width: var(--nav-w); flex: none;
  background: var(--side); color: var(--side-ink); display: flex; flex-direction: column;
  border-right: 1px solid #000; transition: width .18s ease; overflow: hidden; z-index: 20;
}
.side::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--gold-grad); }
.logo { display: flex; align-items: center; justify-content: center; height: 76px; padding: 14px 18px; border-bottom: 1px solid #1f1f23; }
.logo-full { width: 100%; max-width: 190px; height: auto; }
.logo-icon { display: none; width: 34px; height: 34px; }
.side nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  color: var(--side-ink); white-space: nowrap; font-weight: 500;
}
.side nav a:hover { background: var(--side-2); color: var(--side-ink-on); text-decoration: none; }
.side nav a.on { background: var(--side-2); color: var(--side-ink-on); box-shadow: inset 3px 0 0 var(--gold-3); }
.side nav a.on .ic { color: var(--gold-3); }
.sep { margin: 14px 12px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #5f5f68; white-space: nowrap; }
.collapse {
  display: flex; align-items: center; gap: 12px; margin: 10px; padding: 9px 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--side-ink); font: inherit; cursor: pointer; white-space: nowrap;
}
.collapse:hover { background: var(--side-2); color: var(--side-ink-on); }

[data-nav="min"] .side { width: var(--nav-min); }
[data-nav="min"] .side nav a span, [data-nav="min"] .collapse span, [data-nav="min"] .sep span { display: none; }
[data-nav="min"] .sep { height: 1px; background: #26262b; margin: 12px 8px; }
[data-nav="min"] .side nav a, [data-nav="min"] .collapse { justify-content: center; padding: 10px; }
[data-nav="min"] .collapse .ic { transform: rotate(180deg); }
[data-nav="min"] .logo-full { display: none; }
[data-nav="min"] .logo-icon { display: block; }
[data-nav="min"] .logo { padding: 14px 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.crumb { flex: 1; font-weight: 600; color: var(--muted); }
.who { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.who small { color: var(--muted); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--row-hover); }
[data-theme="dark"] .sun, [data-theme="light"] .moon { display: none; }
.mobile-only { display: none; }
.content { padding: 24px; max-width: 1320px; width: 100%; }

/* Login */
.guest { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--side); }
.guest-logo { width: 300px; max-width: 80vw; margin-bottom: 28px; }
.guest .card { width: 100%; max-width: 400px; }
.guest .flash { width: 100%; max-width: 400px; }
.guest-theme { position: fixed; top: 16px; right: 16px; color: #ddd; border-color: #333; }

/* Componentes */
h1 { font-size: 22px; margin: 0 0 18px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 0 auto; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.bar h1 { margin: 0; }
label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-weight: 500; font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--ink); padding: 8px 10px; border: 1px solid var(--input-line); border-radius: 8px;
  background: var(--input); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-2); outline-offset: -1px; border-color: transparent; }
textarea { width: 100%; min-height: 80px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; color: #1d1405; background: var(--gold-grad);
  background-size: 140% 100%; background-position: 0 0; transition: background-position .3s; white-space: nowrap;
}
.btn:hover { background-position: 100% 0; text-decoration: none; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.wa { background: #1f9d55; color: #fff; }
.btn.wa:hover { background: #18834a; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.danger { color: var(--err) !important; }

table { width: 100%; border-collapse: collapse; }
.card > table, .content > table { background: var(--card); }
.content > table { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
table tr:hover td { background: var(--row-hover); }
tr.off { opacity: .5; }
tr.pend td { background: var(--warn-bg); }
.actions { display: flex; gap: 12px; align-items: center; }
.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.muted { color: var(--muted); }
.code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; background: var(--chip); padding: 2px 7px; border-radius: 5px; font-weight: 600; }
.tag { display: inline-block; background: var(--chip); border-radius: 999px; padding: 2px 9px; margin: 2px; font-size: 12px; }
.tag.off { text-decoration: line-through; }
.tag.gold { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--muted); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stats div::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold-grad); }
.stats span { display: block; font-size: 26px; font-weight: 700; color: var(--ink); }
.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1; padding: 11px 14px; }
.quote { display: grid; grid-template-columns: 1fr 380px; gap: 16px; }
.sticky { position: sticky; top: 76px; align-self: start; }
.item { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.item .qty { width: 72px; }
.item .line { width: 100%; font-size: 12px; }
dl { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; margin: 0 0 12px; }
dd { margin: 0; text-align: right; }
.qr { background: #fff; padding: 10px; border-radius: 8px; width: max-content; margin: 0 auto 12px; }
.qr svg { width: 220px; height: 220px; display: block; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
details summary { cursor: pointer; color: var(--accent); margin: 6px 0; }
.wa-box { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.wa-box .note { font-size: 12px; margin: 6px 0 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--chip); }
.status.enviada, .status.entregue, .status.lida { background: var(--ok-bg); color: var(--ok); }
.status.falhou { background: var(--err-bg); color: var(--err); }
.status.aguardando_conexao { background: var(--warn-bg); color: var(--warn); }
.msg-body { white-space: pre-wrap; font-size: 13px; }

@media (max-width: 900px) {
  .grid2, .grid3, .quote, .stats { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; width: var(--nav-w) !important; }
  .nav-open .side { transform: none; }
  [data-nav="min"] .side nav a span, [data-nav="min"] .sep span { display: inline; }
  [data-nav="min"] .logo-full { display: block; }
  [data-nav="min"] .logo-icon { display: none; }
  .mobile-only { display: inline-flex; }
  .collapse { display: none; }
  .who { display: none; }
  .content { padding: 16px; }
}
select, input, textarea { max-width: 100%; }
.quote > *, .grid2 > *, .grid3 > * { min-width: 0; }
.grid3 select, .grid2 select { width: 100%; }

/* Badge do menu */
.badge { margin-left: auto; background: #1f9d55; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
[data-nav="min"] .badge { position: absolute; margin: -14px 0 0 14px; padding: 0 5px; }

/* Central de atendimento */
.content.full { max-width: none; padding: 0; }
.inbox { display: grid; grid-template-columns: 320px 1fr 300px; height: calc(100vh - 60px); }
.inbox > * { min-width: 0; min-height: 0; }
.ib-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--card); }
.ib-list .tools { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.ib-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.ib-tabs button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.ib-tabs button.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.ib-items { overflow-y: auto; flex: 1; }
.ib-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; padding: 11px 14px; cursor: pointer; }
.ib-item:hover { background: var(--row-hover); }
.ib-item.on { background: var(--accent-soft); }
.ib-item .top { display: flex; justify-content: space-between; gap: 8px; }
.ib-item .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-item .pv { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ib-item .meta { display: flex; gap: 6px; margin-top: 4px; font-size: 11px; color: var(--muted); align-items: center; }
.ib-item .un { background: #1f9d55; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; }
.pill { font-size: 11px; border-radius: 999px; padding: 1px 7px; background: var(--chip); color: var(--muted); }
.pill.bot { background: var(--accent-soft); color: var(--accent); }
.pill.new { background: var(--warn-bg); color: var(--warn); }

.ib-chat { display: flex; flex-direction: column; background: var(--bg); }
.ib-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); min-height: 58px; }
.ib-head .who2 { flex: 1; min-width: 0; }
.ib-head .who2 b { display: block; }
.ib-head small { color: var(--muted); }
.ib-msgs { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; }
.empty-state { margin: auto; color: var(--muted); text-align: center; }
.bub { max-width: 68%; padding: 8px 11px 6px; border-radius: 10px; position: relative; box-shadow: var(--shadow); white-space: pre-wrap; word-wrap: break-word; }
.bub.in { align-self: flex-start; background: var(--card); border-top-left-radius: 2px; }
.bub.out { align-self: flex-end; background: #dcf3e3; color: #0f2a19; border-top-right-radius: 2px; }
[data-theme="dark"] .bub.out { background: #18402a; color: #e5f6eb; }
.bub.bot.out { background: var(--accent-soft); color: var(--ink); }
.bub .ft { display: flex; justify-content: flex-end; gap: 6px; font-size: 11px; opacity: .7; margin-top: 3px; white-space: nowrap; }
.bub .who3 { font-size: 11px; font-weight: 700; opacity: .75; margin-bottom: 2px; }
.bub img { max-width: 260px; max-height: 260px; border-radius: 6px; display: block; margin-bottom: 4px; cursor: zoom-in; }
.bub .q { border-left: 3px solid var(--gold-2); background: rgba(127,127,127,.12); padding: 4px 8px; border-radius: 4px; font-size: 12px; margin-bottom: 4px; }
.bub .btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.bub .btns span { border: 1px solid currentColor; opacity: .7; border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.bub .acts { display: none; position: absolute; top: -10px; right: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; gap: 8px; font-size: 12px; }
.bub:hover .acts { display: flex; }
.bub.hid { opacity: .55; font-style: italic; }
.tick.lida { color: #1d8cf8; opacity: 1; }
.tick.falhou, .bub .err { color: var(--err); opacity: 1; }
.day-sep { align-self: center; font-size: 11px; color: var(--muted); background: var(--card); padding: 2px 10px; border-radius: 999px; margin: 6px 0; }

.ib-compose { background: var(--card); border-top: 1px solid var(--line); padding: 10px 14px; position: relative; }
.ib-compose.drag { outline: 2px dashed var(--gold-2); outline-offset: -6px; }
.ib-compose .row { display: flex; gap: 8px; align-items: flex-end; }
.ib-compose textarea { flex: 1; min-height: 42px; max-height: 160px; resize: none; }
.ib-compose .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ib-compose .chips span { background: var(--chip); border-radius: 6px; padding: 3px 8px; font-size: 12px; }
.replybar { display: flex; justify-content: space-between; gap: 8px; background: var(--chip); border-left: 3px solid var(--gold-2); padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; font-size: 12px; }
.qr-menu { position: absolute; bottom: 100%; left: 14px; right: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; }
.qr-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 8px 12px; cursor: pointer; }
.qr-menu button:hover, .qr-menu button.on { background: var(--row-hover); }
.window-closed { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.ib-side { border-left: 1px solid var(--line); background: var(--card); overflow-y: auto; padding: 16px; }
.ib-side h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.ib-side h3:first-child { margin-top: 0; }
.ib-side .ord { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal .card { width: min(520px, 92vw); max-height: 86vh; overflow-y: auto; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 60; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; }

/* Simulador (tela de celular) */
.sim { display: grid; grid-template-columns: 300px 400px; gap: 24px; align-items: start; }
.phone { border: 10px solid #111; border-radius: 34px; height: 720px; display: flex; flex-direction: column; overflow: hidden; background: #efe7dd; }
[data-theme="dark"] .phone { background: #0b141a; }
.phone .ph-head { background: #075e54; color: #fff; padding: 14px 16px; font-weight: 600; }
.phone .ph-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.phone .bub.in { align-self: flex-end; background: #d9fdd3; color: #111; }
.phone .bub.out { align-self: flex-start; background: #fff; color: #111; }
[data-theme="dark"] .phone .bub.in { background: #005c4b; color: #e9edef; }
[data-theme="dark"] .phone .bub.out { background: #202c33; color: #e9edef; }
.phone .btns button { display: block; width: 100%; margin-top: 4px; border: 0; border-top: 1px solid rgba(0,0,0,.1); background: transparent; color: #027eb5; font: inherit; font-weight: 600; padding: 7px; cursor: pointer; }
.phone .ph-input { display: flex; gap: 6px; padding: 8px; background: rgba(0,0,0,.04); }
.phone .ph-input input[type=text] { flex: 1; border-radius: 999px; }

@media (max-width: 1200px) { .inbox { grid-template-columns: 280px 1fr; } .ib-side { display: none; } }
@media (max-width: 900px) { .inbox { grid-template-columns: 1fr; } .ib-list.hide-m { display: none; } .sim { grid-template-columns: 1fr; } }
.bell { position: relative; }
.bell .badge { position: absolute; top: -6px; right: -6px; background: var(--err); }
.bell-menu { position: absolute; right: 0; top: 46px; width: 340px; max-height: 420px; overflow-y: auto; z-index: 30; }
.bell-item { display: block; padding: 8px 6px; border-bottom: 1px solid var(--line); color: var(--ink); }
.bell-item small { display: block; color: var(--muted); }
.bell-item.new b::before { content: "● "; color: var(--err); }
