/* =====================================================================
   ORÇAI — estilos base
   Tema claro por padrão; escuro ou automático escolhidos em Configurações.
   ===================================================================== */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1b1a17;
  --text-muted: #6b675f;
  --border: #dedad2;
  --border-strong: #c4bfb4;

  --accent: #f2b01e;          /* âmbar */
  --accent-hover: #e0a00f;
  --on-accent: #1b1a17;
  --accent-soft: #fdf1d3;

  --danger: #b42318;
  --danger-soft: #fdecea;
  --success: #1e7a46;
  --success-soft: #e5f4eb;
  --warning: #9a6700;

  --focus: #1b1a17;
  --radius: 6px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  color-scheme: light;
}

/* Tema escuro: escolhido em Configurações, ou "automático" com o sistema no escuro. */
:root[data-theme="escuro"] {
  --bg: #121211;
  --surface: #1b1b19;
  --surface-2: #242421;
  --text: #f1efe9;
  --text-muted: #a29e94;
  --border: #2f2e2a;
  --border-strong: #46443e;

  --accent: #f5bd3c;
  --accent-hover: #ffcb57;
  --on-accent: #161513;
  --accent-soft: #3a2f14;

  --danger: #ff8a7a;
  --danger-soft: #3a1d19;
  --success: #6fd49a;
  --success-soft: #16301f;
  --warning: #e3b341;

  --focus: #f5bd3c;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="automatico"] {
    --bg: #121211;
    --surface: #1b1b19;
    --surface-2: #242421;
    --text: #f1efe9;
    --text-muted: #a29e94;
    --border: #2f2e2a;
    --border-strong: #46443e;

    --accent: #f5bd3c;
    --accent-hover: #ffcb57;
    --on-accent: #161513;
    --accent-soft: #3a2f14;

    --danger: #ff8a7a;
    --danger-soft: #3a1d19;
    --success: #6fd49a;
    --success-soft: #16301f;
    --warning: #e3b341;

    --focus: #f5bd3c;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--text); }

h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

[hidden] { display: none !important; }

/* ---------- Marca ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--text);
}
.brand-mark {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 4px;
  position: relative;
}
.brand-mark::after {               /* "folha" de orçamento */
  content: "";
  position: absolute;
  left: 6px; right: 6px; top: 7px;
  height: 2px;
  background: var(--on-accent);
  box-shadow: 0 4px 0 var(--on-accent);
}

/* ---------- Telas de acesso (login, cadastro) ---------- */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 28px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.auth-card h1 { font-size: 1.375rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--text-muted); margin-bottom: 24px; }
.auth-footer {
  color: var(--text-muted);
  font-size: 0.9375rem;
  text-align: center;
}

/* ---------- Formulários ---------- */

.form { display: grid; gap: 18px; }

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.9375rem; }
.field .optional { font-weight: 400; color: var(--text-muted); }
.field .hint { font-size: 0.8125rem; color: var(--text-muted); }

.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.input::placeholder { color: var(--text-muted); opacity: 0.7; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea.input { min-height: 80px; resize: vertical; }

.field.has-error .input { border-color: var(--danger); }
.field-error { font-size: 0.8125rem; color: var(--danger); }

.field-row { display: grid; gap: 18px; }
@media (min-width: 640px) {
  .field-row.cols-2 { grid-template-columns: 1fr 1fr; }
}

.inline-link { font-size: 0.875rem; color: var(--text-muted); justify-self: end; }

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 700;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, border-color .15s;
}
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-muted); padding-inline: 10px; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.btn-block { width: 100%; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mensagens ---------- */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  border: 1px solid transparent;
}
.alert-error   { background: var(--danger-soft);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-info    { background: var(--accent-soft);  color: var(--text);    border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---------- Estrutura do app (após login) ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
  padding: 8px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9375rem;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.nav-links { display: flex; gap: 4px; }
.label-short { display: none; }

/* No celular, o menu vira uma barra de abas fixa embaixo, ao alcance do polegar. */
@media (max-width: 639px) {
  .nav-links {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  .nav-links a { text-align: center; padding: 10px 2px; font-size: 0.8125rem; }
  .label-long { display: none; }
  .label-short { display: inline; }
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.625rem; }
.page-header p { color: var(--text-muted); margin-top: 6px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
}
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 1.0625rem; margin-bottom: 4px; }
.panel .panel-sub { color: var(--text-muted); font-size: 0.9375rem; margin-bottom: 20px; }

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 24px;
}
@media (max-width: 639px) {
  .form-actions .btn { flex: 1 1 100%; }
}

/* ---------- Logotipo e cor ---------- */

.logo-picker { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview {
  width: 88px; height: 88px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
  overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.logo-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.color-picker { display: flex; align-items: center; gap: 12px; }
.color-picker input[type="color"] {
  width: 52px; height: 46px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

/* ---------- Carregamento de página ---------- */


.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Listas e clientes ---------- */

.page-narrow { max-width: 720px; }

.page-header-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
}
.back-link::before { content: "‹"; font-size: 1.25rem; line-height: 1; }
.back-link:hover { color: var(--text); }

.page > .alert { margin-bottom: 16px; }

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.search { flex: 1 1 280px; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  color: var(--text-muted);
  cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.list:empty { display: none; }
.list > li + li { border-top: 1px solid var(--border); }
.list-flush { border-radius: 0; border-inline: 0; border-bottom: 0; background: transparent; margin-inline: -20px; margin-bottom: -24px; }

.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  min-height: 64px;
}
a.list-item:hover { background: var(--surface-2); }
.list-flush .list-item { padding-inline: 20px; }
.list-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.list-title { font-weight: 700; overflow-wrap: anywhere; }
.list-sub {
  color: var(--text-muted);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-value { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chevron {
  width: 8px; height: 8px;
  border-right: 2px solid var(--border-strong);
  border-top: 2px solid var(--border-strong);
  transform: rotate(45deg);
  flex: none;
}

.avatar {
  width: 40px; height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 700;
  font-size: 0.875rem;
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.125rem; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: 2px;
}

.status { font-weight: 600; }
.status-aprovado { color: var(--success); }
.status-recusado, .status-cancelado, .status-expirado { color: var(--danger); }

.empty {
  text-align: center;
  padding: 48px 20px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  display: grid;
  justify-items: center;
  gap: 8px;
}
.empty h2 { font-size: 1.125rem; }
.empty p { color: var(--text-muted); margin-bottom: 12px; }
.empty-search { color: var(--text-muted); text-align: center; padding: 32px 0; }

.client-header { display: flex; align-items: center; gap: 16px; }
.client-header h1 { overflow-wrap: anywhere; }
.archived-note { margin-bottom: 16px; }

.action-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.panel .action-bar { margin-bottom: 0; }
@media (max-width: 639px) {
  .page > div > .action-bar .btn { flex: 1 1 0; }
}

.details { margin: 16px 0 0; display: grid; gap: 14px; }
.details dt { font-size: 0.8125rem; color: var(--text-muted); font-weight: 600; }
.details dd { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.details dd.muted { color: var(--text-muted); }

.panel-quiet { background: transparent; }

.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }

/* ---------- Orçamentos ---------- */

select.input { cursor: pointer; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: 0.875rem; }

.section-title { font-size: 1.0625rem; margin: 28px 0 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head a { font-weight: 600; font-size: 0.9375rem; color: var(--text-muted); }

.quote-code {
  flex: none;
  min-width: 52px;
  padding: 4px 8px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-weight: 700;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.status-enviado, .status-aguardando { color: var(--warning); }

/* Filtros da lista */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.filter:hover { color: var(--text); }
.filter[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.filter-count { opacity: 0.7; font-weight: 400; margin-left: 2px; }
.list-search { margin-bottom: 12px; }

/* Painel inicial */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.stat:hover { border-color: var(--border-strong); }
.stat-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); }
.stat-value { font-size: 1.5rem; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-sub { font-size: 0.8125rem; color: var(--text-muted); }

.steps { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 10px; counter-reset: step; }
.steps li { counter-increment: step; display: flex; gap: 12px; align-items: center; font-weight: 600; }
.steps li::before {
  content: counter(step);
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  font-size: 0.875rem;
}
.steps li.done { color: var(--text-muted); text-decoration: line-through; font-weight: 400; }
.steps li.done::before { content: "✓"; background: var(--success-soft); color: var(--success); border-color: transparent; }
.steps li.done a { pointer-events: none; color: inherit; text-decoration: none; }

/* Editor: itens */
.items { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 12px; }
.item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  background: var(--bg);
}
.item .form { gap: 12px; }
.item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.item-number { font-weight: 700; font-size: 0.875rem; color: var(--text-muted); }
.item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 640px) { .item-grid { grid-template-columns: 0.7fr 0.8fr 1.2fr 1.3fr; } }
.item-subtotal { text-align: right; font-size: 0.9375rem; color: var(--text-muted); }
.item-subtotal strong { color: var(--text); font-variant-numeric: tabular-nums; }
.input-money { text-align: right; font-variant-numeric: tabular-nums; }

.totals { margin: 0; display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals dt { color: var(--text-muted); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals .totals-final { font-weight: 800; font-size: 1.125rem; padding-top: 6px; }
.totals .totals-final dt { color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chip {
  font: inherit;
  font-size: 0.8125rem;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.chip:hover { color: var(--text); border-style: solid; }

/* Barra fixa com total e botão de salvar */
.savebar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 20px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.savebar-total { display: grid; line-height: 1.2; }
.savebar-total span { font-size: 0.8125rem; color: var(--text-muted); font-weight: 600; }
.savebar-total strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.savebar-total strong.negative { color: var(--danger); }
@media (max-width: 639px) {
  body.has-tabbar .savebar { bottom: calc(57px + env(safe-area-inset-bottom)); padding-bottom: 12px; }
}
@media (min-width: 640px) {
  .savebar { margin-inline: 0; border: 1px solid var(--border); border-radius: var(--radius); bottom: 12px; }
}

/* Tela do orçamento */
.status-panel .field { max-width: 360px; }
.send-help { margin-bottom: 16px; line-height: 1.55; }

/* Prévia do documento: sempre clara, como o papel/PDF */
.doc {
  --doc-accent: #F2B01E;
  --doc-on-accent: #1B1A17;
  background: #fff;
  color: #1B1A17;
  border: 1px solid var(--border);
  border-top: 6px solid var(--doc-accent);
  border-radius: var(--radius);
  padding: 24px 20px;
  font-size: 0.9375rem;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}
.doc p { margin: 0; }
.doc a { color: inherit; }
.doc-muted { color: #6B675F; font-size: 0.875rem; }
.doc-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #6B675F; }
.doc-strong { font-weight: 700; }
.doc-header { display: flex; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid #DEDAD2; }
.doc-business { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.doc-logo { width: auto; max-width: 96px; max-height: 56px; object-fit: contain; }
.doc-business-name { font-size: 1.125rem; font-weight: 800; }
.doc-id { text-align: right; font-size: 0.875rem; }
.doc-number { font-size: 1.25rem; font-weight: 800; }
.doc-parties { display: grid; gap: 16px; padding: 16px 0; }
@media (min-width: 640px) { .doc-parties { grid-template-columns: 1fr 1fr; } }

.doc-items { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.doc-items th {
  background: var(--doc-accent);
  color: var(--doc-on-accent);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: right;
  padding: 8px;
}
.doc-items th:first-child { text-align: left; }
.doc-items td { padding: 10px 8px; border-bottom: 1px solid #DEDAD2; text-align: right; vertical-align: top; white-space: nowrap; }
.doc-items td:first-child { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.doc-items td:last-child { font-weight: 700; }
.doc-category { display: block; font-size: 0.75rem; color: #6B675F; }
/* No celular, cada item vira um bloco em vez de colunas apertadas */
@media (max-width: 559px) {
  .doc { padding: 20px 16px; }
  .doc-id { text-align: left; }
  .doc-items thead { display: none; }
  .doc-items tr { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 10px 0; border-bottom: 1px solid #DEDAD2; }
  .doc-items td { border: 0; padding: 0; }
  .doc-items td:first-child { grid-column: 1 / -1; font-weight: 600; margin-bottom: 4px; }
  .doc-items td:nth-child(2), .doc-items td:nth-child(3) { grid-column: 1; text-align: left; font-size: 0.8125rem; color: #6B675F; }
  .doc-items td:nth-child(2)::before, .doc-items td:nth-child(3)::before { content: attr(data-label) ": "; }
  .doc-items td:last-child { grid-column: 2; grid-row: 2 / 4; align-self: center; }
}

.doc-totals { margin: 16px 0 0 auto; max-width: 320px; display: grid; gap: 6px; font-variant-numeric: tabular-nums; }
.doc-totals div { display: flex; justify-content: space-between; gap: 16px; }
.doc-totals dt { color: #6B675F; }
.doc-totals dd { margin: 0; }
.doc-total {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--doc-accent);
  color: var(--doc-on-accent);
  font-weight: 800;
  font-size: 1.125rem;
}
.doc-totals .doc-total dt { color: inherit; }
.doc-conditions { margin: 24px 0 0; display: grid; gap: 12px; }
.doc-conditions dt { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #6B675F; }
.doc-conditions dd { margin: 2px 0 0; white-space: pre-line; }
.doc-validity { margin-top: 20px !important; font-weight: 700; }

/* ---------- Avisos flutuantes ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100% - 32px));
  pointer-events: none;
}
@media (max-width: 639px) {
  body.has-tabbar .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.9375rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.22);
  cursor: pointer;
  animation: toast-in .28s cubic-bezier(.2, .9, .3, 1.2) both;
}
.toast-leave { animation: toast-out .2s ease-in both; }
.toast-icon {
  width: 22px; height: 22px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.75rem;
  font-weight: 800;
}
.toast-error .toast-icon { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Movimento ---------- */

/* Conteúdo da página entra suavemente quando termina de carregar. */
.page:not([hidden]), .auth { animation: page-in .32s ease-out both; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }

.btn { transition: background-color .15s, border-color .15s, transform .08s, box-shadow .15s; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 35%, transparent); }

.list-item, .stat, .filter, .chip, .nav a { transition: background-color .15s, border-color .15s, color .15s; }
.stat { transition: border-color .15s, transform .15s; }
.stat:hover { transform: translateY(-1px); }

/* Linhas da lista aparecem em cascata (até a 10ª). */
.list > li { animation: row-in .26s ease-out both; }
.list > li:nth-child(2) { animation-delay: 20ms; }
.list > li:nth-child(3) { animation-delay: 40ms; }
.list > li:nth-child(4) { animation-delay: 60ms; }
.list > li:nth-child(5) { animation-delay: 80ms; }
.list > li:nth-child(6) { animation-delay: 100ms; }
.list > li:nth-child(7) { animation-delay: 120ms; }
.list > li:nth-child(8) { animation-delay: 140ms; }
.list > li:nth-child(9) { animation-delay: 160ms; }
.list > li:nth-child(n+10) { animation-delay: 180ms; }
@keyframes row-in { from { opacity: 0; transform: translateY(4px); } }

/* Itens do orçamento entram e saem com movimento. */
.item { animation: item-in .24s ease-out both; }
.item.item-leave { animation: item-out .18s ease-in both; }
@keyframes item-in { from { opacity: 0; transform: translateY(-6px) scale(.99); } }
@keyframes item-out { to { opacity: 0; transform: scale(.97); } }

/* Total pulsa de leve quando muda. */
.bump { animation: bump .32s ease-out; }
@keyframes bump { 40% { transform: scale(1.06); color: var(--accent-hover); } }

.alert:not([hidden]) { animation: page-in .22s ease-out both; }

/* ---------- Carregamento (esqueleto) ---------- */

.page-loading {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 16px;
  display: grid;
  gap: 14px;
  min-height: 0;
  place-items: stretch;
  animation: page-in .2s .12s both; /* só aparece se a página demorar */
}
.sk {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface) 50%, var(--surface-2) 100%) 0 0 / 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.sk-title { height: 30px; width: 46%; }
.sk-line { height: 16px; width: 68%; margin-bottom: 10px; }
.sk-card { height: 92px; border: 1px solid var(--border); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Instalar o app ---------- */

.install-card {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.install-card:not([hidden]) { animation: page-in .3s ease-out both; }
.install-icon img { display: block; border-radius: 10px; }
.install-text { flex: 1 1 200px; min-width: 0; }
.install-text p { color: var(--text-muted); font-size: 0.875rem; margin-top: 2px; }
.install-actions { display: flex; gap: 6px; }

/* ---------- Páginas de status (offline, 404) ---------- */

.status-card { text-align: center; display: grid; justify-items: center; }
.status-card .lead { margin-bottom: 20px; }
.status-icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  margin-bottom: 14px;
}
.status-code {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

/* Quem prefere menos movimento não vê animações. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Editor: ferramentas do item e desconto ---------- */

.item-tools { display: flex; align-items: center; gap: 2px; }
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.item:first-child [data-action="up"],
.item:last-child [data-action="down"] { opacity: 0.3; pointer-events: none; }
.items:has(> .item:only-child) .icon-btn[data-action="up"],
.items:has(> .item:only-child) .icon-btn[data-action="down"] { display: none; }

.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.segmented button {
  font: inherit;
  font-weight: 700;
  font-size: 0.875rem;
  min-width: 40px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* Nas telas com barra de salvar, o aviso fica acima dela. */
body:has(.savebar) .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
@media (max-width: 639px) {
  body.has-tabbar:has(.savebar) .toasts { bottom: calc(146px + env(safe-area-inset-bottom)); }
}

/* ---------- Configurações do app ---------- */

.app-settings { margin-top: 16px; }
.segmented-lg { display: flex; width: 100%; max-width: 420px; }
.segmented-lg button { flex: 1; min-height: 40px; }
.theme-hint { margin-top: 8px; }

/* ---------- Páginas legais (privacidade, cookies) ---------- */

.legal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.legal-header-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.legal {
  max-width: 760px;
  margin: 0 auto;
  padding: 36px 16px 72px;
  line-height: 1.65;
  animation: page-in .32s ease-out both;
}
.legal-kicker {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--warning);
  margin-bottom: 6px;
}
.legal h1 { font-size: clamp(1.75rem, 5vw, 2.25rem); letter-spacing: -0.01em; }
.legal-updated { color: var(--text-muted); margin-top: 8px; font-size: 0.9375rem; }
.legal section { margin-top: 36px; scroll-margin-top: 16px; }
.legal h2 { font-size: 1.25rem; margin-bottom: 10px; }
.legal p + p { margin-top: 12px; }
.legal ul, .legal ol { padding-left: 1.25rem; margin: 10px 0; }
.legal li + li { margin-top: 6px; }
.legal a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.legal code {
  font-size: 0.8125rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

.legal-summary {
  margin-top: 28px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.legal-summary h2 { font-size: 1rem; margin-bottom: 6px; }
.legal-summary ul { margin-bottom: 0; }

.legal-toc {
  margin-top: 28px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.legal-toc-title { font-weight: 700; margin-bottom: 4px; }
.legal-toc ol { columns: 2 220px; column-gap: 28px; margin: 0; }
.legal-toc a { text-decoration: none; color: var(--text-muted); }
.legal-toc a:hover { color: var(--text); text-decoration: underline; }

.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); }
.legal-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.5; background: var(--surface); }
.legal-table th {
  text-align: left;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 10px 12px;
}
.legal-table td { padding: 12px; border-top: 1px solid var(--border); vertical-align: top; }
.legal-table td:first-child { font-weight: 600; }
@media (max-width: 559px) {
  .legal-table thead { display: none; }
  .legal-table tr { display: block; padding: 12px; border-top: 1px solid var(--border); }
  .legal-table tr:first-child { border-top: 0; }
  .legal-table td { display: block; padding: 2px 0; border: 0; }
}

/* Trechos a completar (dados do responsável). */
.fill {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  font-weight: 600;
  padding: 0 4px;
  border-radius: 4px;
}

.legal-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-weight: 600;
}

/* Links legais nas telas de acesso */
.legal-links { margin-top: 10px; font-size: 0.8125rem; color: var(--text-muted); text-align: center; }
.legal-links a { color: inherit; }
.consent { font-size: 0.8125rem; color: var(--text-muted); text-align: center; }
.consent a { color: var(--text); }

/* ---------- Aviso de armazenamento (cookies) ---------- */

.storage-notice {
  position: fixed;
  z-index: 40;
  left: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.14);
  font-size: 0.875rem;
  line-height: 1.45;
  animation: toast-in .3s ease-out both;
}
.storage-notice p { flex: 1; }
.storage-notice a { color: inherit; font-weight: 600; }
.storage-notice .btn { flex: none; }
.storage-notice-leave { animation: toast-out .2s ease-in both; }
@media (max-width: 639px) {
  .storage-notice { left: 12px; right: 12px; max-width: none; }
  body.has-tabbar .storage-notice { bottom: calc(72px + env(safe-area-inset-bottom)); }
  body.has-tabbar:has(.savebar) .storage-notice { bottom: calc(146px + env(safe-area-inset-bottom)); }
}
