/* ZenoPOS — segue o manual de marca Zeno.
   Paleta: Ardósia #3A4A5A · Tinta #12161B · Âmbar #E8A33D · Papel #F5F6F7.
   Letra: Quicksand SemiBold (títulos) e Poppins (texto). Âmbar só como acento. */

@font-face { font-family: "Poppins"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/poppins-400.9212f6f9860f.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/poppins-500.a09f2fccfee3.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/poppins-600.72993dddf88a.woff2") format("woff2"); }
@font-face { font-family: "Quicksand"; font-weight: 300 700; font-style: normal; font-display: swap; src: url("../fonts/quicksand-var.9d503278216c.woff2") format("woff2"); }

:root {
  /* Marca */
  --ardosia: #3A4A5A; --tinta: #12161B; --ambar: #E8A33D; --papel: #F5F6F7;

  /* Superfícies e texto (claro) */
  --bg: var(--papel); --surface: #fff; --sunken: #EEF0F2;
  --text: var(--tinta); --heading: var(--tinta); --section: var(--ardosia);
  --muted: #5D6976; --border: #DDE1E6; --border-strong: #C3CAD2;
  --link: var(--ardosia);
  --primary: var(--ardosia); --primary-hover: var(--tinta); --on-primary: var(--papel);
  --focus: var(--ambar);

  /* Estados — tons funcionais; o aviso usa o âmbar diluído */
  --ok: #1D6E49; --ok-bg: #E5F1EA;
  --warn: #7E5310; --warn-bg: #FBF0DC;
  --err: #A8352A; --err-bg: #FAE9E7;
  --info: var(--ardosia); --info-bg: #E7EBEF;

  --font-title: "Quicksand", Verdana, Arial, sans-serif;
  --font-text: "Poppins", Verdana, Arial, sans-serif;
  --radius: 8px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(18, 22, 27, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tinta); --surface: #1A2028; --sunken: #151A20;
    --text: #E4E8EC; --heading: var(--papel); --section: #B9C4CF;
    --muted: #96A2AE; --border: #2A3440; --border-strong: #3B4857;
    --link: #C8D3DE;
    --primary: var(--papel); --primary-hover: #fff; --on-primary: var(--tinta);
    --ok: #6FD3A2; --ok-bg: #143022;
    --warn: var(--ambar); --warn-bg: #2E2413;
    --err: #FF9488; --err-bg: #3A1A17;
    --info: #C8D3DE; --info-bg: #1F2833;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 400 14.5px/1.55 var(--font-text); background: var(--bg); color: var(--text);
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); text-decoration-color: var(--ambar); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--heading); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }

main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 32px 24px 96px; flex: 1; }
h1, h2, h3 { font-family: var(--font-title); font-weight: 600; color: var(--heading); letter-spacing: -.005em; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
h2 { font-size: 1.15rem; margin: 0 0 14px; color: var(--section); }
h3 { font-size: 1rem; margin: 22px 0 8px; color: var(--section); }
p { margin: 0 0 12px; }
code { font-size: .9em; background: var(--sunken); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
small.muted { font-size: .78rem; line-height: 1.4; }

/* Barra de topo — fundo Tinta, âmbar só no traço */
.topbar { background: var(--tinta); color: var(--papel); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 36px; }
.brand { display: block; line-height: 0; padding: 4px 0; }
.brand img { height: 32px; width: auto; display: block; }
.topbar nav { display: flex; gap: 4px; flex: 1; height: 100%; }
.topbar nav a {
  display: flex; align-items: center; padding: 0 12px; height: 100%;
  color: rgba(245, 246, 247, .68); text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent; border-top: 2px solid transparent;
}
.topbar nav a:hover { color: var(--papel); }
.topbar nav a.active { color: var(--papel); border-bottom-color: var(--ambar); }
.topbar .user { display: flex; align-items: center; gap: 14px; font-size: .85rem; color: rgba(245, 246, 247, .6); }
.topbar .user form { margin: 0; }
.topbar .user button.link { color: rgba(245, 246, 247, .8); }
.topbar .user button.link:hover { color: var(--papel); }

/* Cabeçalho de página */
.head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head .sub { width: 100%; margin: -16px 0 0; color: var(--muted); }
.back { display: inline-block; margin-bottom: 10px; font-size: .85rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--heading); }
.back::before { content: "< "; color: var(--ambar); font-weight: 600; }

/* Superfícies */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.narrow-wide { max-width: 680px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.layout-2 > .card { margin-bottom: 0; }
.stack { margin-bottom: 20px; }

/* Formulários */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
fieldset { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
fieldset:last-of-type { margin-bottom: 0; }
legend { font-family: var(--font-title); font-weight: 600; font-size: 1rem; color: var(--section); padding: 0; margin-bottom: 10px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; font-weight: 500; color: var(--muted); }
label.wide { grid-column: 1 / -1; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-size: .9rem; font-weight: 400; color: var(--text); margin: 14px 0; cursor: pointer; }
input, select, textarea {
  font: inherit; font-size: .92rem; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px; width: 100%;
  transition: border-color .12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ardosia); box-shadow: 0 0 0 3px rgba(232, 163, 61, .35); }
input:disabled { background: var(--sunken); color: var(--muted); }
textarea { resize: vertical; line-height: 1.5; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ardosia); flex: none; }
input.num { text-align: right; }
.errorlist, .error { color: var(--err); margin: 0; padding: 0; list-style: none; font-size: .8rem; font-weight: 500; }

/* Botões */
button, .button {
  font: inherit; font-weight: 500; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; min-height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
button:hover, .button:hover { border-color: var(--muted); background: var(--sunken); color: var(--text); }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.primary:hover, .button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
button:disabled { opacity: .6; cursor: progress; }
button.link { border: 0; background: none; color: var(--muted); padding: 0; min-height: 0; font-weight: 400; text-decoration: underline; text-decoration-color: transparent; }
button.link:hover { background: none; color: var(--heading); text-decoration-color: currentColor; }
button.danger, .button.danger { color: var(--err); }
button.danger:hover, .button.danger:hover { border-color: var(--err); background: var(--err-bg); color: var(--err); }
button.link.danger { color: var(--err); }
button.primary.danger-bg { background: var(--err); border-color: var(--err); color: #fff; }
button.primary.danger-bg:hover { filter: brightness(.92); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.head .actions, .card-head .actions { margin-top: 0; }
.actions form { margin: 0; }
.actions .spacer { flex: 1; }

/* Tabelas */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: .75rem; color: var(--muted); font-weight: 500; white-space: nowrap; background: var(--sunken); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
table.list td a.row-link { font-weight: 500; color: var(--heading); text-decoration: none; }
table.list tr[data-href] { cursor: pointer; }
table.list tr[data-href]:hover td { background: var(--sunken); }
table.list tr[data-href]:hover a.row-link { text-decoration: underline; text-decoration-color: var(--ambar); }
td.strong { font-weight: 500; color: var(--heading); }
.empty { text-align: center; color: var(--muted); padding: 40px 24px; }

/* Linhas editáveis do orçamento */
table.lines th { background: none; padding: 6px 4px; border-bottom: 1px solid var(--border-strong); }
table.lines td { padding: 8px 4px; vertical-align: top; }
table.lines td.num { vertical-align: top; padding-top: 16px; }
table.lines input, table.lines select { padding: 7px 8px; font-size: .88rem; }
table.lines { table-layout: fixed; min-width: 1000px; }
table.lines th:nth-of-type(1) { width: 92px; }
table.lines th:nth-of-type(3) { width: 112px; }
table.lines th:nth-of-type(4), table.lines th:nth-of-type(6) { width: 80px; }
table.lines th:nth-of-type(5) { width: 104px; }
table.lines th:nth-of-type(7) { width: 82px; }
table.lines th:nth-of-type(8) { width: 72px; }
table.lines th:nth-of-type(9) { width: 108px; }
table.lines th:nth-of-type(10) { width: 42px; }
table.lines td.line-net { font-weight: 500; color: var(--heading); }
table.lines tfoot td { border: 0; padding: 4px; }
table.lines tfoot tr:first-child td { padding-top: 14px; }
table.lines tr.grand td { font-family: var(--font-title); font-weight: 700; font-size: 1.15rem; color: var(--heading); padding-top: 8px; }
table.lines tr.grand td#sum-total { box-shadow: inset 0 -2px 0 var(--ambar); }
textarea.summary { margin-top: 4px; font-size: .8rem; color: var(--muted); min-height: 0; }
tr.deleted td { opacity: .4; }
tr.deleted td input, tr.deleted td textarea { text-decoration: line-through; }
.delete { flex-direction: row; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-sm); color: var(--muted); font-size: 1rem; }
.delete:hover { background: var(--err-bg); color: var(--err); }
tr.deleted .delete { background: var(--sunken); color: var(--heading); opacity: 1; }
.delete input { position: absolute; opacity: 0; pointer-events: none; }
.delete:has(input:focus-visible) { outline: 2px solid var(--focus); }
#add-line { margin-top: 14px; }

/* Barra de gravação fixa (orçamento) */
.savebar {
  position: sticky; bottom: 0; z-index: 5; margin: 0 0 20px; padding: 12px 0;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px);
  border-top: 1px solid var(--border);
}
.savebar .total { font-family: var(--font-title); font-weight: 700; font-size: 1.15rem; color: var(--heading); }
.savebar .total small { font-family: var(--font-text); font-weight: 400; font-size: .8rem; color: var(--muted); margin-right: 6px; }
.savebar .state { font-size: .85rem; color: var(--muted); }
.savebar .state.dirty { color: var(--warn); font-weight: 500; }
.savebar .spacer { flex: 1; }

/* Estados */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 99px;
  font-family: var(--font-text); font-size: .74rem; font-weight: 500; line-height: 1.7; letter-spacing: 0;
  background: var(--sunken); color: var(--muted); text-decoration: none; white-space: nowrap; vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.reviewed, .badge.closed { background: var(--ok-bg); color: var(--ok); }
.badge.draft { background: var(--warn-bg); color: var(--warn); }
.badge.cancelled { background: var(--err-bg); color: var(--err); }
.badge.cancelled::before { border-radius: 1px; height: 2px; width: 7px; }
a.badge:hover { filter: brightness(.96); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }

/* Mensagens */
.flash { position: relative; padding: 12px 16px 12px 18px; border-radius: var(--radius-sm); margin: 0 0 14px; background: var(--info-bg); color: var(--info); border-left: 3px solid currentColor; }
.flash.success { background: var(--ok-bg); color: var(--ok); }
.flash.warning { background: var(--warn-bg); color: var(--warn); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash ul { margin: 6px 0 0; padding-left: 18px; }
.flash a { color: inherit; }
.messages { margin-bottom: 8px; }

/* Resumos */
.summary { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.summary dt { color: var(--muted); font-size: .85rem; }
.summary dd { margin: 0; }
.figures { display: flex; gap: 0; flex-wrap: wrap; margin: 0 0 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.figures div { padding: 16px 24px; border-right: 1px solid var(--border); min-width: 150px; }
.figures div:last-child { border-right: 0; }
.figures dt { font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.figures dd { margin: 0; font-family: var(--font-title); font-weight: 700; font-size: 1.35rem; color: var(--heading); white-space: nowrap; }
.figures dd.due { box-shadow: inset 0 -2px 0 var(--ambar); display: inline-block; }
.figures dd.text { font-family: var(--font-text); font-weight: 500; font-size: 1rem; padding-top: 5px; white-space: normal; }

/* Listas com o prompt da marca */
ul.prompt { list-style: none; margin: 0; padding: 0; }
ul.prompt li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
ul.prompt li:last-child { border-bottom: 0; }
ul.prompt li::before { content: ">"; color: var(--ambar); font-weight: 600; }
ul.prompt .muted { font-size: .85rem; }

/* Progresso do orçamento (carregado → revisto → emitido) */
.steps { display: flex; gap: 0; margin: 0 0 24px; padding: 0; list-style: none; counter-reset: step; font-size: .85rem; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--muted); counter-increment: step; }
.steps li + li::before { content: ""; width: 40px; height: 1px; background: var(--border-strong); margin: 0 12px; }
.steps li span::before {
  content: counter(step); display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 8px;
  border-radius: 50%; border: 1px solid var(--border-strong); font-size: .72rem; font-weight: 600;
}
.steps li.done { color: var(--text); }
.steps li.done span::before { content: "✓"; background: var(--ardosia); border-color: var(--ardosia); color: var(--papel); }
.steps li.current { color: var(--heading); font-weight: 500; }
.steps li.current span::before { border: 2px solid var(--ambar); color: var(--heading); }

/* Emissão: escolha do tipo de documento */
.kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.kind {
  display: block; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  text-decoration: none; color: var(--text); background: var(--surface); transition: border-color .12s, background .12s;
}
.kind strong { display: block; font-family: var(--font-title); font-weight: 600; font-size: 1rem; color: var(--heading); }
.kind span { display: block; font-size: .8rem; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.kind:hover { border-color: var(--ardosia); background: var(--sunken); color: var(--text); }
.kind:hover strong::after { content: "_"; color: var(--ambar); margin-left: 2px; }

/* Zona de upload — o cursor do símbolo */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 36px 24px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; text-align: center; color: var(--muted); font-size: .85rem; font-weight: 400;
  transition: border-color .15s, background .15s;
}
.dropzone .prompt-line { font-family: var(--font-title); font-weight: 600; font-size: 1.2rem; color: var(--heading); }
.dropzone .prompt-line::before { content: "> "; color: var(--ardosia); }
.dropzone .cursor { display: inline-block; width: .7em; height: 3px; margin-left: 3px; border-radius: 2px; background: var(--ambar); vertical-align: baseline; animation: blink 1.1s steps(1) infinite; }
.dropzone:hover, .dropzone.over { border-color: var(--ardosia); background: var(--sunken); }
.dropzone.over { border-style: solid; }
.dropzone.busy { cursor: progress; border-style: solid; }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dropzone:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.upload { margin-bottom: 24px; }
@keyframes blink { 50% { opacity: 0; } }

/* Filtros */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select { width: auto; min-width: 180px; }
.filters input[type=search] { width: 270px; }
.filters label.check { margin: 0 0 0 8px; }

/* Entrar */
body.auth { background: var(--tinta); color: var(--papel); }
.auth main { display: grid; place-items: center; padding: 40px 20px; }
.auth-box { width: 100%; max-width: 360px; }
.auth-box .logo { display: block; width: 116px; margin: 0 auto 40px; }
.auth-box form, .auth-panel { background: #1A2028; border: 1px solid #2A3440; border-radius: var(--radius); padding: 26px 24px; }
.auth-panel h1 { display: block; font-size: 1.3rem; color: var(--papel); margin-bottom: 12px; }
.auth-panel h1::after { content: ""; display: block; width: 40px; height: 3px; margin-top: 12px; border-radius: 2px; background: var(--ambar); }
.auth-panel p { color: #C8D3DE; }
.auth-panel p:last-child { margin-bottom: 0; }
.auth-box label { color: #96A2AE; margin-bottom: 14px; }
.auth-box input { background: var(--tinta); border-color: #3B4857; color: var(--papel); }
.auth-box button.primary { width: 100%; justify-content: center; margin-top: 6px; background: var(--papel); border-color: var(--papel); color: var(--tinta); }
.auth-box button.primary:hover { background: #fff; }
.auth-box .error { color: #FF9488; margin-bottom: 14px; }
.auth-box .tagline { text-align: center; color: #96A2AE; font-size: .8rem; margin-top: 24px; }

@media (max-width: 860px) {
  .layout-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  main { padding: 20px 16px 80px; }
  .topbar-inner { padding: 0 16px; gap: 16px; height: auto; flex-wrap: wrap; padding-top: 10px; }
  .topbar nav { order: 3; width: 100%; flex: none; height: 44px; margin: 0 -12px; overflow-x: auto; }
  .topbar .user { margin-left: auto; }
  .topbar .user .name { display: none; }
  h1 { font-size: 1.45rem; }
  .card { padding: 18px 16px; }
  .figures div { flex: 1 1 50%; border-right: 0; border-bottom: 1px solid var(--border); }
  .savebar { padding: 10px 0; }
  .filters, .filters input[type=search] { width: 100%; }
  .steps li + li::before { width: 16px; margin: 0 6px; }
  .steps { font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .topbar, .savebar, .actions, #add-line { display: none !important; }
  body { background: #fff; }
}
input.qty { max-width: 110px; margin-left: auto; }
.gap-top { margin-top: 18px; }
.table-scroll { overflow-x: auto; }
table.list td:first-child { white-space: nowrap; }
@media (prefers-color-scheme: dark) { .topbar { border-bottom: 1px solid #232B35; } }
