/* ==========================================================
   FRIOTEC GESTÃO — tema "painel técnico / gelo"
   ========================================================== */
:root {
  --ink: #0b1b2b;
  --ink-2: #13283d;
  --ink-3: #1d3954;
  --ice: #19a7e0;
  --ice-deep: #0c7fb0;
  --ice-soft: #e3f4fc;
  --frost: #f2f6f9;
  --paper: #ffffff;
  --line: #dbe4ec;
  --line-2: #e9eff4;
  --text: #0e1c2a;
  --muted: #5d7183;
  --faint: #8fa1b1;
  --ok: #0f9d6a;
  --ok-soft: #dff5ec;
  --warn: #c98100;
  --warn-soft: #fff1d6;
  --bad: #d23c3c;
  --bad-soft: #fde4e4;
  --violet: #5b5bd6;
  --violet-soft: #e8e8fb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(11, 27, 43, .06), 0 8px 24px -12px rgba(11, 27, 43, .18);
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Figtree', 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body);
  color: var(--text);
  background: var(--frost);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.rail { display: none; }
.main { min-width: 0; padding-bottom: calc(84px + var(--safe-b)); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #fff;
}
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background: linear-gradient(180deg, rgba(11,27,43,.12), transparent);
  pointer-events: none;
}
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar h1 {
  font-family: var(--display); font-weight: 700; font-size: 28px; letter-spacing: .3px;
  margin: 0; line-height: 1; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eyebrow { margin: 0 0 4px; font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--ice); font-weight: 600; }
.eyebrow:empty { display: none; }
.back {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.topbar-actions { display: flex; gap: 8px; flex: none; }
.topbar-actions .btn { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.18); }
.topbar-actions .btn.primary { background: var(--ice); border-color: var(--ice); color: #fff; }

.view { padding: 18px 16px 24px; max-width: 1180px; margin: 0 auto; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Tab bar (celular) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(11,27,43,.97); backdrop-filter: blur(10px);
  padding: 6px 6px calc(6px + var(--safe-b));
  border-top: 1px solid rgba(255,255,255,.06);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px 5px; border-radius: 12px; color: #8ea6bb; font-size: 11px; font-weight: 600;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: #fff; }
.tabbar a.on svg { color: var(--ice); }
.tabbar a.fab {
  margin-top: -22px; color: #fff;
}
.tabbar a.fab span.f {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: var(--ice); box-shadow: 0 8px 20px -6px rgba(25,167,224,.7); border: 3px solid var(--ink);
}
.tabbar a.fab svg { color: #fff; width: 26px; height: 26px; }

/* ---------- Rail (desktop) ---------- */
@media (min-width: 960px) {
  .app { grid-template-columns: 248px 1fr; }
  .rail {
    display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh;
    background: var(--ink); color: #c9d6e2; padding: 22px 16px;
    background-image: radial-gradient(circle at 0% 100%, rgba(25,167,224,.18), transparent 55%);
  }
  .tabbar { display: none; }
  .main { padding-bottom: 32px; }
  .topbar { padding: 26px 32px 20px; }
  .topbar h1 { font-size: 34px; }
  .view { padding: 26px 32px 40px; }
}
.brand { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.brand-mark {
  display: grid; place-items: center; background: #fff; border-radius: 14px; padding: 10px 14px;
  box-shadow: 0 10px 24px -14px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.4);
}
.brand-mark img { width: 100%; max-width: 170px; max-height: 70px; object-fit: contain; display: block; }
.brand-text { text-align: center; }
.brand-text small { font-size: 10.5px; color: #7f97ab; letter-spacing: 1.8px; text-transform: uppercase; font-weight: 600; }
.mais-logo { display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.mais-logo img { max-width: 220px; max-height: 90px; object-fit: contain; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .sep { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.6px; color: #5f7a91; padding: 16px 12px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  font-weight: 500; font-size: 14.5px; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.on { background: linear-gradient(90deg, rgba(25,167,224,.22), rgba(25,167,224,.04)); color: #fff; box-shadow: inset 3px 0 0 var(--ice); }
.nav a.on svg { color: var(--ice); }
.nav a .count { margin-left: auto; font-size: 11px; background: var(--ice); color: #fff; border-radius: 99px; padding: 1px 8px; font-weight: 700; }
.install-btn {
  margin-top: auto; display: flex; align-items: center; gap: 10px; justify-content: center;
  background: rgba(25,167,224,.14); color: #fff; border: 1px dashed rgba(25,167,224,.6);
  padding: 11px; border-radius: 12px; cursor: pointer; font-weight: 600;
}

/* ---------- Componentes ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--paper); color: var(--text); font-weight: 600; font-size: 14.5px; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:hover { border-color: #c4d2de; }
.btn.primary { background: var(--ice); border-color: var(--ice); color: #fff; }
.btn.primary:hover { background: var(--ice-deep); border-color: var(--ice-deep); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.btn.icon { width: 42px; padding: 0; }
.btn.sm.icon { width: 34px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 14px; }
.card h2, .section-title {
  font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  font-size: 19px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px;
}
.section-title { margin: 26px 0 12px; font-size: 18px; color: var(--ink-3); }
.section-title .more { margin-left: auto; font-family: var(--body); text-transform: none; letter-spacing: 0; font-size: 13.5px; font-weight: 600; color: var(--ice-deep); }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .g4 { grid-template-columns: repeat(4, 1fr); } .md-g2 { grid-template-columns: 1fr 1fr; } .md-g3 { grid-template-columns: repeat(3, 1fr);} }
@media (max-width: 719px) { .g4 { grid-template-columns: repeat(2, 1fr); } }

/* KPI */
.kpi {
  position: relative; overflow: hidden; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px 16px; box-shadow: var(--shadow);
}
.kpi .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .lbl i { width: 8px; height: 8px; border-radius: 3px; background: var(--ice); display: inline-block; }
.kpi .val { font-family: var(--display); font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: .2px; line-height: 1; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.kpi.hero {
  background: var(--ink); color: #fff; border-color: var(--ink);
  background-image: radial-gradient(120% 140% at 100% 0%, rgba(25,167,224,.45), transparent 55%);
}
.kpi.hero .lbl { color: #9fc2da; }
.kpi.hero .sub { color: #9fb4c6; }
.kpi .val.neg { color: var(--bad); }
.kpi.hero .val.neg { color: #ff9b9b; }

/* Chart */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart .bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.chart .bar { width: 38%; max-width: 22px; border-radius: 6px 6px 2px 2px; min-height: 3px; transition: height .5s cubic-bezier(.2,.8,.2,1); position: relative; }
.chart .bar.r { background: var(--ice); }
.chart .bar.g { background: #f0a0a0; }
.chart .m { font-size: 11.5px; color: var(--muted); text-transform: uppercase; font-weight: 600; letter-spacing: .6px; }
.chart .col.cur .m { color: var(--ink); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Listas */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--shadow); cursor: pointer; transition: border-color .15s, transform .15s;
}
.item:hover { border-color: #b9cbda; }
.item:active { transform: scale(.995); }
.item .ico {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--ice-soft); color: var(--ice-deep);
}
.item .ico.dark { background: var(--ink); color: var(--ice); }
.item .ico.red { background: var(--bad-soft); color: var(--bad); }
.item .ico.green { background: var(--ok-soft); color: var(--ok); }
.item .ico.amber { background: var(--warn-soft); color: var(--warn); }
.item .t { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 8px; align-items: center; }
.item .r { text-align: right; }
.item .v { font-family: var(--display); font-weight: 700; font-size: 20px; white-space: nowrap; }
.item .v.neg { color: var(--bad); }
.item > div { min-width: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: var(--line-2); color: var(--muted); white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.pendente, .pill.agendado { background: var(--warn-soft); color: var(--warn); }
.pill.aprovado, .pill.concluido, .pill.pago { background: var(--ok-soft); color: var(--ok); }
.pill.recusado, .pill.cancelado, .pill.areceber { background: var(--bad-soft); color: var(--bad); }
.pill.andamento { background: var(--violet-soft); color: var(--violet); }
.pill.rascunho { background: var(--line-2); color: var(--muted); }

.empty {
  text-align: center; padding: 40px 20px; color: var(--muted); border: 1.5px dashed var(--line);
  border-radius: var(--radius); background: rgba(255,255,255,.5);
}
.empty > svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: 8px; stroke-width: 1.5; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* Filtros */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.search {
  flex: 1 1 220px; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
}
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 15px; }
.search svg { color: var(--faint); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--paper);
  font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--muted);
}
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Formulários */
.form { display: grid; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }
.input, .field input, .field select, .field textarea {
  width: 100%; height: 46px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--line);
  background: #fbfdfe; outline: none; font-size: 15.5px; transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 90px; padding: 11px 13px; resize: vertical; line-height: 1.45; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--ice); box-shadow: 0 0 0 4px rgba(25,167,224,.15); background: #fff;
}
.field .hint { font-size: 12px; color: var(--faint); }
.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .form-row.three { grid-template-columns: 1fr 1fr; } .form-row.stack { grid-template-columns: 1fr; } }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14.5px; }
.switch input { width: 20px; height: 20px; accent-color: var(--ok); }
.seg { display: flex; background: var(--line-2); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button {
  flex: 1; height: 36px; border: 0; background: transparent; border-radius: 9px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; padding: 0 8px; white-space: nowrap;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(11,27,43,.12); }

/* Itens do orçamento (editor) */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line {
  display: grid; grid-template-columns: 70px 1fr 130px 40px; gap: 8px; align-items: start;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfe;
}
.line > [data-del] { margin-top: 22px; }
.line .tot { grid-column: 2 / 4; font-size: 13px; color: var(--muted); text-align: right; }
.line .tot b { color: var(--text); font-family: var(--display); font-size: 17px; }
@media (max-width: 560px) {
  .line { grid-template-columns: 64px 1fr 40px; }
  .line .f-desc { grid-column: 1 / 4; order: -1; }
  .line .f-qtd { grid-column: 1; }
  .line .f-val { grid-column: 2; }
  .line .tot { grid-column: 1 / 4; }
}
.totals-box {
  margin-top: 14px; background: var(--ink); color: #fff; border-radius: 14px; padding: 16px 18px;
  display: grid; gap: 8px;
  background-image: radial-gradient(100% 160% at 100% 0%, rgba(25,167,224,.35), transparent 60%);
}
.totals-box .r { display: flex; justify-content: space-between; color: #a9bfd1; font-size: 14px; }
.totals-box .r.big { color: #fff; font-family: var(--display); font-size: 30px; font-weight: 700; align-items: baseline; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.12); }
.totals-box .r.big span:first-child { font-size: 16px; letter-spacing: 1.4px; color: var(--ice); }
.totals-box .ext { font-size: 12.5px; color: #8aa3b8; font-style: italic; text-align: right; }

.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.quick button {
  border: 1px dashed #b5c7d6; background: transparent; color: var(--ink-3); border-radius: 99px;
  padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.quick button:hover { border-color: var(--ice); color: var(--ice-deep); background: var(--ice-soft); }

.sticky-actions {
  position: sticky; bottom: calc(76px + var(--safe-b)); z-index: 10; margin-top: 18px;
  display: flex; gap: 8px; padding: 10px; background: rgba(242,246,249,.92); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 16px;
}
.sticky-actions .btn { flex: 1; }
@media (min-width: 960px) { .sticky-actions { bottom: 16px; } }

/* Detalhe */
.detail-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.mini-table th { text-align: left; font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); }
.mini-table td { padding: 10px 6px; border-bottom: 1px solid var(--line-2); }
.mini-table .r { text-align: right; }

/* Histórico: timeline */
.month-group { margin-top: 22px; }
.month-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.month-head h3 { margin: 0; font-family: var(--display); font-size: 22px; text-transform: uppercase; letter-spacing: .6px; }
.month-head span { font-size: 13px; color: var(--muted); }
.month-head span b { color: var(--text); font-family: var(--display); font-size: 17px; }
.timeline { position: relative; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--ice), var(--line)); border-radius: 2px; }
.timeline .item { position: relative; }
.timeline .item::before {
  content: ''; position: absolute; left: -22px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border-radius: 50%; background: #fff; border: 3px solid var(--ice);
}

/* Sheet (modal) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(6,16,26,.55); z-index: 60; animation: fade .2s; }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto;
  background: var(--frost); border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + var(--safe-b));
  animation: up .28s cubic-bezier(.2,.8,.2,1);
}
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: #c3d0db; margin: 4px auto 12px; }
.sheet h3 { font-family: var(--display); font-size: 24px; text-transform: uppercase; margin: 0 0 14px; letter-spacing: .4px; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; transform: translate(-50%, -50%); border-radius: 20px; animation: pop .22s ease; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%); } }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list button, .menu-list a {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; font-weight: 600; cursor: pointer; text-align: left; font-size: 15px;
}
.menu-list .danger { color: var(--bad); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 80; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  display: flex; gap: 8px; align-items: center; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { color: var(--ice); }

/* Prévia do documento */
.doc-stage {
  background: #cfd9e2; border-radius: var(--radius); padding: 18px; overflow: auto;
  background-image: linear-gradient(45deg, rgba(255,255,255,.12) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.12) 75%),
                    linear-gradient(45deg, rgba(255,255,255,.12) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.12) 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px;
}
.doc-scale { transform-origin: top left; }
.doc-stage .doc { box-shadow: 0 20px 50px -20px rgba(11,27,43,.5); }

/* ==========================================================
   DOCUMENTO DO ORÇAMENTO (A4)
   ========================================================== */
.doc {
  --d-ink: #0b1b2b; --d-ice: #19a7e0; --d-line: #d9e3eb; --d-muted: #5b6f80;
  width: 210mm; min-height: 297mm; background: #fff; color: #142433; position: relative;
  font-family: var(--body); font-size: 10.5pt; line-height: 1.45; display: flex; flex-direction: column;
  overflow: hidden;
}
.doc-top {
  display: grid; grid-template-columns: 1fr auto; gap: 10mm; align-items: center;
  padding: 11mm 14mm 8mm; position: relative;
}
.doc-top::after {
  content: ''; position: absolute; left: 14mm; right: 14mm; bottom: 0; height: 1.2mm;
  background: linear-gradient(90deg, var(--d-ink) 0 62%, var(--d-ice) 62% 100%); border-radius: 1mm;
}
.doc-logo img { max-height: 24mm; max-width: 70mm; display: block; }
.doc-logo .ph { font-family: var(--display); font-size: 26pt; font-weight: 800; color: var(--d-ink); letter-spacing: 1px; }
.doc-company { text-align: right; font-size: 9pt; color: var(--d-muted); line-height: 1.5; }
.doc-company b { display: block; font-family: var(--display); font-size: 15pt; color: var(--d-ink); letter-spacing: .6px; text-transform: uppercase; line-height: 1.1; margin-bottom: 1mm; }

.doc-body { padding: 6mm 14mm 0; flex: 1; display: flex; flex-direction: column; }
.doc-titlebar { display: flex; align-items: flex-end; justify-content: space-between; gap: 8mm; }
.doc-title small { display: block; font-size: 8.5pt; letter-spacing: 2.5px; text-transform: uppercase; color: var(--d-ice); font-weight: 700; }
.doc-title h2 { margin: 1mm 0 0; font-family: var(--display); font-size: 25pt; line-height: 1; text-transform: uppercase; color: var(--d-ink); letter-spacing: .4px; font-weight: 800; }
.doc-meta { display: grid; grid-template-columns: repeat(3, auto); border: 1px solid var(--d-line); border-radius: 2.5mm; overflow: hidden; }
.doc-meta div { padding: 2mm 4mm; border-left: 1px solid var(--d-line); }
.doc-meta div:first-child { border-left: 0; background: var(--d-ink); color: #fff; }
.doc-meta span { display: block; font-size: 7pt; letter-spacing: 1.2px; text-transform: uppercase; color: var(--d-muted); font-weight: 700; }
.doc-meta div:first-child span { color: #8fc9e6; }
.doc-meta b { font-family: var(--display); font-size: 13pt; letter-spacing: .3px; }

.doc-client {
  margin-top: 6mm; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5mm 8mm;
  background: #f3f8fb; border-left: 1.2mm solid var(--d-ice); border-radius: 0 2.5mm 2.5mm 0; padding: 4mm 5mm;
}
.doc-client .h { grid-column: 1 / -1; font-size: 7.5pt; letter-spacing: 1.8px; text-transform: uppercase; color: var(--d-muted); font-weight: 700; margin-bottom: 1mm; }
.doc-client .name { grid-column: 1 / -1; font-weight: 700; font-size: 12.5pt; color: var(--d-ink); }
.doc-client .f span { color: var(--d-muted); font-size: 8.5pt; display: block; line-height: 1.2; }
.doc-client .f { font-size: 9.5pt; }
.doc-client .wide { grid-column: 1 / -1; }

.doc-intro { margin: 5mm 0 0; color: var(--d-muted); font-size: 9.5pt; }

.doc-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 4mm; font-size: 10pt; }
.doc-table thead th {
  background: var(--d-ink); color: #fff; font-weight: 600; font-size: 8pt; letter-spacing: 1.2px; text-transform: uppercase;
  padding: 2.6mm 3mm; text-align: left;
}
.doc-table thead th:first-child { border-radius: 2mm 0 0 0; }
.doc-table thead th:last-child { border-radius: 0 2mm 0 0; }
.doc-table td { padding: 2.8mm 3mm; border-bottom: 1px solid var(--d-line); vertical-align: top; }
.doc-table tbody tr:nth-child(even) td { background: #f8fbfd; }
.doc-table .c { text-align: center; }
.doc-table .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-table .n { color: var(--d-muted); font-variant-numeric: tabular-nums; width: 9mm; }
.doc-table td.desc b { display: block; color: var(--d-ink); }
.doc-table td.desc small { color: var(--d-muted); font-size: 8.5pt; display: block; line-height: 1.35; margin-top: .4mm; }
.doc-table .per { color: var(--d-muted); font-size: 7.5pt; margin-left: .5mm; }

/* ---------- Catálogo ---------- */
.notice {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--warn-soft); color: #6b4800;
  border: 1px solid #f1d49a; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: 14px; line-height: 1.4;
}
.notice > svg { color: var(--warn); }
.notice > div { flex: 1 1 220px; }
.cat-group { margin-bottom: 22px; }
.cat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--ink-3); }
.cat-head h3 { margin: 0; font-family: var(--display); text-transform: uppercase; letter-spacing: .6px; font-size: 19px; }
.cat-head span { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--muted); background: var(--line-2); border-radius: 99px; padding: 2px 9px; }
.cat-item { width: 100%; text-align: left; font: inherit; color: inherit; }
.cat-item .s { flex-wrap: wrap; }
.cat-item .cat-det { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.cat-item .per { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cat-item .r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
@media (min-width: 900px) { .cat-group .list { display: grid; grid-template-columns: 1fr 1fr; } }
.pick-list { max-height: 52vh; overflow: auto; padding: 2px; }
.pick-list .item { box-shadow: none; }
.pick-list .add-dot {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--ice-soft); color: var(--ice-deep);
  font-family: var(--display); font-size: 15px;
}
.pick-list .add-dot svg { width: 16px; height: 16px; }
.pick-list .picked { border-color: var(--ice); background: #f2fbff; }
.pick-list .picked .add-dot { background: var(--ice); color: #fff; }
.pick-list .picked .add-dot svg { display: none; }
.pick-foot { display: flex; gap: 8px; margin-top: 12px; }
.line .det { height: 36px !important; font-size: 13.5px !important; margin-top: 6px; color: var(--muted); }

.doc-sum { display: grid; grid-template-columns: 1fr 72mm; gap: 8mm; margin-top: 4mm; align-items: start; }
.doc-words { font-size: 9pt; color: var(--d-muted); padding-top: 2mm; }
.doc-words b { color: var(--d-ink); font-style: italic; font-weight: 600; }
.doc-totals { display: grid; gap: 1.2mm; font-size: 10pt; }
.doc-totals .row { display: flex; justify-content: space-between; padding: 0 3mm; color: var(--d-muted); }
.doc-totals .row b { color: #142433; font-weight: 600; font-variant-numeric: tabular-nums; }
.doc-totals .grand {
  display: flex; justify-content: space-between; align-items: center; margin-top: 1mm;
  background: var(--d-ice); color: #fff; border-radius: 2.5mm; padding: 3mm 4mm;
}
.doc-totals .grand span { font-size: 8.5pt; letter-spacing: 1.8px; font-weight: 700; text-transform: uppercase; }
.doc-totals .grand b { font-family: var(--display); font-size: 19pt; font-weight: 800; letter-spacing: .3px; font-variant-numeric: tabular-nums; }

.doc-boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm; margin-top: 5mm; break-inside: avoid; }
.doc-box { border: 1px solid var(--d-line); border-radius: 2.5mm; padding: 3.5mm 4mm; font-size: 9pt; }
.doc-box h4 { margin: 0 0 2mm; font-size: 7.5pt; letter-spacing: 1.8px; text-transform: uppercase; color: var(--d-ice); font-weight: 800; }
.doc-box ul { margin: 0; padding-left: 4mm; }
.doc-box li { margin: .6mm 0; }
.doc-box .pix { margin-top: 2mm; padding: 2mm 3mm; background: #f3f8fb; border-radius: 1.5mm; font-size: 9pt; }
.doc-box .pix b { color: var(--d-ink); }
.doc-pay-tags { display: flex; flex-wrap: wrap; gap: 1.5mm; }
.doc-pay-tags span { border: 1px solid var(--d-line); border-radius: 99px; padding: .6mm 2.6mm; font-size: 8.5pt; font-weight: 600; color: var(--d-ink); }
.doc-obs { margin-top: 5mm; font-size: 9pt; color: #2b3d4e; border-top: 1px dashed var(--d-line); padding-top: 3mm; white-space: pre-wrap; }
.doc-obs b { font-size: 7.5pt; letter-spacing: 1.8px; text-transform: uppercase; color: var(--d-muted); display: block; margin-bottom: 1mm; }

.doc-sign { margin-top: auto; padding-top: 6mm; break-inside: avoid; }
.doc-place { text-align: right; font-size: 9.5pt; color: var(--d-muted); margin-bottom: 11mm; }
.doc-sign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14mm; text-align: center; font-size: 9.5pt; }
.doc-sign-grid div { border-top: 1px solid #142433; padding-top: 2mm; }
.doc-sign-grid b { display: block; color: var(--d-ink); }
.doc-sign-grid span { color: var(--d-muted); font-size: 8.5pt; }

.doc-foot {
  margin-top: 6mm; background: var(--d-ink); color: #a9c0d3; font-size: 8pt;
  display: flex; justify-content: space-between; gap: 6mm; padding: 3.5mm 14mm; position: relative;
}
.doc-foot::before { content: ''; position: absolute; left: 0; right: 0; top: -1.2mm; height: 1.2mm; background: var(--d-ice); }
.doc-foot b { color: #fff; }
.doc-stamp {
  position: absolute; top: 46mm; right: 16mm; transform: rotate(-12deg);
  border: 2px solid currentColor; border-radius: 2mm; padding: 1.5mm 4mm; font-family: var(--display);
  font-size: 16pt; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; opacity: .8;
}
.doc-stamp.aprovado { color: var(--ok); }
.doc-stamp.recusado { color: var(--bad); }

/* ---------- Impressão ---------- */
#printRoot { display: none; }
@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff !important; height: auto; }
  .app, .sheet, .sheet-backdrop, .toast { display: none !important; }
  #printRoot { display: block !important; }
  #printRoot .doc { box-shadow: none; width: 210mm; height: auto; min-height: 296mm; }
  .doc-table tr { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* ---------- Sugestões do catálogo (descrição do item) ---------- */
.line { position: relative; }
.suggest {
  position: absolute; left: 10px; right: 10px; z-index: 25; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 18px 40px -16px rgba(11,27,43,.35), 0 2px 6px rgba(11,27,43,.06);
  padding: 6px; max-height: 340px; overflow: auto; animation: sgIn .14s ease;
}
@keyframes sgIn { from { opacity: 0; transform: translateY(-4px); } }
.suggest button {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; width: 100%;
  border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 9px; cursor: pointer; color: var(--text);
}
.suggest button.on, .suggest button:hover { background: var(--ice-soft); }
.suggest .sg-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--line-2); color: var(--ice-deep); }
.suggest button.on .sg-ic { background: #fff; }
.suggest .sg-ic svg { width: 16px; height: 16px; }
.suggest .sg-t { min-width: 0; }
.suggest .sg-t b { display: block; font-size: 14px; font-weight: 600; line-height: 1.3; }
.suggest .sg-t small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest .sg-p { font-family: var(--display); font-weight: 700; font-size: 16px; white-space: nowrap; }
.suggest .sg-p small { font-family: var(--body); font-weight: 500; font-size: 11px; color: var(--muted); }
.suggest .sg-foot { font-size: 11px; color: var(--faint); padding: 6px 10px 2px; border-top: 1px solid var(--line-2); margin-top: 4px; }
@media (hover: none) { .suggest .sg-foot { display: none; } }

/* ---------- Unidades / locais ---------- */
.item .s.loc-tag { color: var(--ice-deep); font-weight: 600; gap: 4px; }
.item .s.loc-tag svg { width: 13px; height: 13px; }
.section-title > svg { width: 18px; height: 18px; color: var(--ice-deep); }
.btn-link { background: none; border: 0; cursor: pointer; padding: 0; }
.doc-client .doc-loc { background: #fff; border: 1px dashed var(--d-line); border-radius: 1.5mm; padding: 1.8mm 2.5mm; margin-top: 1mm; }
.doc-client .doc-loc b { color: var(--d-ink); }

/* ---------- Sincronização ---------- */
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.sync-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 99px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06); color: #cfe0ec; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.sync-pill svg { width: 17px; height: 17px; }
.sync-pill.ok svg { color: #45d6a0; }
.sync-pill.syncing svg { color: var(--ice); animation: spin 1s linear infinite; }
.sync-pill.offline svg, .sync-pill.pend svg { color: #ffc35a; }
.sync-pill.error, .sync-pill.login, .sync-pill.config { border-color: rgba(255,120,120,.5); }
.sync-pill.error svg, .sync-pill.login svg, .sync-pill.config svg { color: #ff8e8e; }
.sync-pill.off svg { color: #8ea6bb; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 560px) { .sync-pill span { display: none; } .sync-pill { width: 34px; padding: 0; justify-content: center; } }
.sync-box { display: grid; gap: 10px; }
.sync-box .row { display: flex; justify-content: space-between; gap: 12px; font-size: 14.5px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.sync-box .row span:first-child { color: var(--muted); }
.sync-box .row b { text-align: right; overflow-wrap: anywhere; }
.choice { display: grid; gap: 10px; }
.choice button { text-align: left; display: grid; gap: 4px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; color: inherit; }
.choice button b { font-size: 15.5px; }
.choice button span { font-size: 13.5px; color: var(--muted); line-height: 1.4; }
.choice button.rec { border-color: var(--ice); box-shadow: 0 0 0 3px rgba(25,167,224,.15); }

/* ---------- Tela de login ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px 16px; overflow-y: auto;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(25,167,224,.28), transparent 60%), var(--ink);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--paper); border-radius: 20px; padding: 28px 24px 24px;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.6);
}
.login-card .login-logo { display: grid; place-items: center; height: 84px; margin-bottom: 10px; }
.login-card .login-logo img { max-width: 200px; max-height: 84px; }
.login-card h1 { font-family: var(--display); font-weight: 700; font-size: 26px; text-align: center; margin: 4px 0 2px; color: var(--ink); letter-spacing: .01em; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.login-card .form { gap: 14px; }
.login-card .btn { width: 100%; height: 48px; font-size: 16px; justify-content: center; }
.login-err { min-height: 20px; color: var(--bad); font-size: 14px; text-align: center; margin: 2px 0 0; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 76px; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--ice-deep); font: inherit; font-size: 13px; font-weight: 600; padding: 8px; cursor: pointer; }
.login-foot { text-align: center; color: rgba(255,255,255,.5); font-size: 12px; margin-top: 16px; }
.user-list { display: grid; gap: 8px; margin-bottom: 14px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.user-row .t { font-weight: 600; }
.user-row .s { color: var(--muted); font-size: 13px; }
.user-row .tag { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--ice-deep); background: var(--ice-soft); padding: 3px 8px; border-radius: 99px; }
