/* favo_3d — mobile-first, sem build step (constitution.md §4) */
:root {
  /* Tipografia da marca (docs/marca/tipografia.md) */
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --fs-display: 3.8125rem; --fs-h1: 3.0625rem; --fs-h2: 2.4375rem;
  --fs-h3: 1.9375rem; --fs-h4: 1.5625rem; --fs-h5: 1.25rem;
  --fs-body-lg: 1.125rem; --fs-body: 1rem; --fs-body-sm: 0.875rem;
  --fs-label: 0.875rem; --fs-caption: 0.75rem;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-extrabold: 800;

  /* Cores da marca */
  --color-text: #2A2118;        /* Própolis */
  --color-text-2: #6B5E4F;
  --color-accent-text: #B86E00; /* só ≥ 20px ou peso 600+ */
  --color-on-dark: #FBF3E4;     /* Cera */
  --color-accent: #F2A71B;      /* Mel: nunca como texto em fundo claro */
  --color-bg: #FBF7EF;

  /* Tokens de interface derivados */
  --bg: var(--color-bg);
  --surface: #ffffff;
  --surface-2: #f4ecdc;
  --border: #e6dac3;
  --text: var(--color-text);
  --muted: var(--color-text-2);
  --link: var(--color-accent-text);
  --brand: var(--color-accent);
  --brand-strong: #dc9410;
  --brand-ink: var(--color-text);
  --ok: #2f7a45;
  --ok-bg: #e7f4ea;
  --warn: #8a5600;
  --warn-bg: #fdf0d5;
  --danger: #a8352b;
  --danger-bg: #fbe8e5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(42, 33, 24, .06), 0 4px 16px rgba(42, 33, 24, .05);
  color-scheme: light;
}
@media (max-width: 600px) {
  :root { --fs-display: 2.4375rem; --fs-h1: 1.9375rem; --fs-h2: 1.5625rem; --fs-h3: 1.25rem; }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120c;
    --surface: #211a12;
    --surface-2: #2b2318;
    --border: #3b3123;
    --text: var(--color-on-dark);
    --muted: #c2b39b;
    --link: var(--color-accent);   /* accent-on-dark */
    --brand-strong: #ffbb3d;
    --ok: #6cc489;
    --ok-bg: #1e3326;
    --warn: #f1bf5b;
    --warn-bg: #3a2f14;
    --danger: #f08b80;
    --danger-bg: #3d1f1b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: 1.6;
}
a { color: var(--link); text-decoration: none; font-weight: var(--fw-semibold); }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5 { font-family: var(--font-display); margin: 0 0 .5rem; }
h1 { font-size: var(--fs-h1); font-weight: var(--fw-extrabold); line-height: 1.05; letter-spacing: -0.03em; }
h2 { font-size: var(--fs-h2); font-weight: var(--fw-extrabold); line-height: 1.1; letter-spacing: -0.02em; }
h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: 1.2; letter-spacing: -0.01em; }
/* Títulos de card usam a escala h4; títulos pequenos, h5 */
.card h2, .empty h2 { font-size: var(--fs-h4); font-weight: var(--fw-semibold); line-height: 1.25; letter-spacing: 0; }
.card h3 { font-size: var(--fs-h5); font-weight: var(--fw-semibold); line-height: 1.3; letter-spacing: 0; }
p { margin: 0 0 .75rem; max-width: 680px; }
small, .muted { color: var(--muted); }
small { font-size: var(--fs-body-sm); line-height: 1.5; }
.caption { font-size: var(--fs-caption); font-weight: var(--fw-medium); line-height: 1.4; letter-spacing: .02em; color: var(--muted); }
.overline { font-size: var(--fs-caption); font-weight: var(--fw-semibold); line-height: 1.2; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.price { font-family: var(--font-display); font-size: var(--fs-h4); font-weight: var(--fw-extrabold); line-height: 1; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
code { font-size: .85em; background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; }

/* --- topo -------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: .55rem 16px;
  display: flex; align-items: center; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-size: var(--fs-label); font-weight: var(--fw-semibold); }
.brand:hover { text-decoration: none; }
.brand img { height: 32px; width: auto; display: block; }
.brand small { font-weight: var(--fw-regular); display: none; padding-left: .6rem; border-left: 1px solid var(--border); color: var(--muted); }
/* O wordmark é escuro: no tema escuro ele fica sobre uma placa Cera em vez de ser recolorido */
@media (prefers-color-scheme: dark) {
  .brand img { background: var(--color-on-dark); padding: 4px 10px; border-radius: 8px; box-sizing: content-box; }
}
.nav { margin-left: auto; }
.nav summary {
  list-style: none; cursor: pointer; padding: .45rem .7rem; border-radius: 8px;
  border: 1px solid var(--border); font-size: var(--fs-label); font-weight: var(--fw-semibold); letter-spacing: .01em;
}
.nav summary::-webkit-details-marker { display: none; }
.nav-links {
  position: absolute; left: 0; right: 0; top: 100%;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .5rem 16px 1rem; display: flex; flex-direction: column; gap: .15rem;
  box-shadow: var(--shadow);
}
.nav-links a, .nav-links button {
  color: var(--text); padding: .6rem .7rem; border-radius: 8px; text-align: left;
  font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 1.2; letter-spacing: .01em;
}
.nav-links a.active { background: var(--surface-2); color: var(--link); }
.nav-links a:hover { background: var(--surface-2); text-decoration: none; }
.nav-links form { margin: 0; }
.nav-links .nav-user { color: var(--muted); padding: .6rem .7rem; font-size: var(--fs-body-sm); font-weight: var(--fw-regular); border-top: 1px solid var(--border); margin-top: .35rem; }
.nav-links button { background: none; border: 0; cursor: pointer; width: 100%; font-family: var(--font-body); }

.nav-desktop { display: none; }
@media (min-width: 960px) {
  .brand small { display: inline; }
  .nav { display: none; }
  .nav-desktop { display: flex; align-items: center; gap: .1rem; margin-left: auto; }
  .nav-desktop a, .nav-desktop button {
    color: var(--text); padding: .45rem .65rem; border-radius: 8px; background: none; border: 0; cursor: pointer;
    font-family: var(--font-body); font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 1.2; letter-spacing: .01em;
  }
  .nav-desktop a:hover, .nav-desktop button:hover { background: var(--surface-2); text-decoration: none; }
  .nav-desktop a.active { background: var(--surface-2); color: var(--link); }
  .nav-desktop form { margin: 0; }
  .nav-desktop .nav-user { color: var(--muted); font-size: var(--fs-body-sm); margin-left: .5rem; padding-left: .75rem; border-left: 1px solid var(--border); }
}

/* --- página -------------------------------------------------------------------------- */
main { max-width: 1180px; margin: 0 auto; padding: 1rem 16px 3rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.crumbs { font-size: var(--fs-body-sm); color: var(--muted); margin-bottom: .35rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; min-width: 0;
}
.card > h2:first-child { margin-bottom: .75rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 1rem; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
}
/* Painel: a tabela de arquivos precisa de largura; lado a lado só em tela grande */
@media (min-width: 720px) and (max-width: 1023px) { .grid-dash { grid-template-columns: minmax(0, 1fr); } }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; min-width: 0; }
.stat span { display: block; color: var(--muted); font-size: var(--fs-caption); font-weight: var(--fw-medium); letter-spacing: .02em; line-height: 1.4; margin-bottom: .35rem; }
.stat strong { display: block; font-family: var(--font-display); font-size: var(--fs-h4); font-weight: var(--fw-extrabold); line-height: 1; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* --- botões e formulários ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 40px; padding: .45rem .95rem; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-family: var(--font-body); font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 1.2; letter-spacing: .01em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { min-height: 32px; padding: .25rem .65rem; }
.btn-block { width: 100%; }
.inline { display: inline; margin: 0; }

.form-grid { display: grid; gap: .85rem; }
@media (min-width: 720px) { .form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span-2 { grid-column: 1 / -1; } }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field > span { font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 1.2; letter-spacing: .01em; }
.field small { font-size: var(--fs-caption); font-weight: var(--fw-medium); letter-spacing: .02em; line-height: 1.4; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], select, textarea {
  width: 100%; min-height: 42px; padding: .5rem .7rem; font-family: var(--font-body); font-size: var(--fs-body); /* 16px evita zoom no iOS */
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type=color] { width: 56px; height: 42px; padding: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
input[type=file] { width: 100%; font: inherit; padding: .6rem; border: 1px dashed var(--border); border-radius: 9px; background: var(--surface-2); }
.input-affix { display: flex; align-items: stretch; }
.input-affix input { border-radius: 9px 0 0 9px; }
.input-affix em { font-style: normal; display: flex; align-items: center; padding: 0 .65rem; border: 1px solid var(--border); border-left: 0; border-radius: 0 9px 9px 0; background: var(--surface-2); color: var(--muted); font-size: var(--fs-body-sm); white-space: nowrap; }
.input-affix.prefix em { order: -1; border-left: 1px solid var(--border); border-right: 0; border-radius: 9px 0 0 9px; }
.input-affix.prefix input { border-radius: 0 9px 9px 0; }
.has-error input, .has-error select { border-color: var(--danger); }
.error { color: var(--danger); font-style: normal; font-size: var(--fs-body-sm); }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters > * { flex: 1 1 160px; }
.filters .btn { flex: 0 0 auto; }
.filters.align-end { align-items: flex-end; }
.presets { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.btn.active { border-color: var(--brand); background: var(--surface-2); }
.sale-box { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem 1rem 1rem; margin: 1rem 0 0; min-width: 0; }
.sale-box legend { font-weight: var(--fw-semibold); padding: 0 .4rem; }
.sale-profit { margin: 0; }
.sale-profit strong { font-family: var(--font-display); font-size: var(--fs-h5); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* --- mensagens ----------------------------------------------------------------------- */
.flash { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .6rem; background: var(--ok-bg); color: var(--ok); font-size: var(--fs-body-sm); font-weight: var(--fw-medium); }
.flash.error { background: var(--danger-bg); color: var(--danger); }
.flash.warn, .alert { background: var(--warn-bg); color: var(--warn); }
.alert { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; }
.alert ul { margin: .35rem 0 0; padding-left: 1.1rem; }

/* --- tabelas: viram cartões no celular ------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
/* Cabeçalho de tabela = overline (único lugar com caixa alta) */
table.list th { text-align: left; font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .2em; line-height: 1.2; color: var(--muted); font-weight: var(--fw-semibold); padding: .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list td { padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list .num { text-align: right; white-space: nowrap; }
table.list tr.inactive td { opacity: .55; }
@media (max-width: 719px) {
  table.list.stack thead { display: none; }
  table.list.stack, table.list.stack tbody, table.list.stack tr, table.list.stack td { display: block; width: 100%; }
  table.list.stack tr { padding: .65rem 0; border-bottom: 1px solid var(--border); }
  table.list.stack tr:last-child { border-bottom: 0; }
  table.list.stack td { border: 0; padding: .12rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.list.stack td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-body-sm); text-align: left; flex: 0 0 auto; }
  table.list.stack td.title { display: block; text-align: left; font-weight: var(--fw-semibold); padding-bottom: .25rem; }
  table.list.stack td.title::before { content: none; }
  table.list.stack td.num { text-align: right; }
  table.list.stack td:empty { display: none; }
}

/* --- peças --------------------------------------------------------------------------- */
.swatches { display: inline-flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.swatch { display: inline-block; width: 1.05em; height: 1.05em; border-radius: 50%; background: var(--c); border: 1px solid rgba(0,0,0,.25); vertical-align: -.18em; flex: 0 0 auto; }
.with-swatch { display: inline-flex; align-items: center; gap: .45rem; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: var(--fs-caption); font-weight: var(--fw-medium); letter-spacing: .02em; line-height: 1.4; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.quote { background: #e8eefc; color: #3156a8; }
.badge.production { background: var(--warn-bg); color: var(--warn); }
.badge.done { background: var(--ok-bg); color: var(--ok); }
@media (prefers-color-scheme: dark) { .badge.quote { background: #1f2a44; color: #9db7f5; } }
/* Status trocável na lista de projetos, com as cores do badge (US-03.6) */
.status-form { display: inline-flex; gap: .3rem; align-items: center; margin: 0; }
select.status-select { width: auto; min-height: 32px; padding: .15rem .5rem; border-radius: 999px; border-color: transparent; background: var(--surface-2); color: var(--muted); font-weight: var(--fw-medium); cursor: pointer; }
select.status-select.quote { background: #e8eefc; color: #3156a8; }
select.status-select.production { background: var(--warn-bg); color: var(--warn); }
select.status-select.done { background: var(--ok-bg); color: var(--ok); }
@media (prefers-color-scheme: dark) { select.status-select.quote { background: #1f2a44; color: #9db7f5; } }
.thumb { width: 64px; height: 64px; border-radius: 8px; background: var(--surface-2); object-fit: contain; border: 1px solid var(--border); flex: 0 0 auto; }
.thumb.lg { width: 100%; height: auto; max-height: 260px; aspect-ratio: auto; }
.thumb-placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.thumb-placeholder svg { width: 28px; height: 28px; opacity: .5; }
.file-row { display: flex; gap: .75rem; align-items: center; min-width: 0; }
/* min-width: sem ela a coluna encolhe até uma letra por linha quando a tabela aperta */
.file-row .name { font-weight: var(--fw-semibold); overflow-wrap: anywhere; min-width: 10rem; }
.file-row .file-meta { display: block; font-weight: var(--fw-regular); }
.file-row .file-meta a { font-weight: var(--fw-medium); }
/* Miniatura do fatiador tem fundo transparente: no escuro vai sobre placa clara, como o logo */
@media (prefers-color-scheme: dark) {
  img.thumb { background: #E9E0CF; border-color: transparent; }
}

.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cost-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cost-table td { padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.cost-table td:last-child { text-align: right; white-space: nowrap; }
.cost-table tr.total td { border-bottom: 0; border-top: 2px solid var(--text); font-weight: var(--fw-semibold); padding-top: .55rem; }
.cost-table tr.price-row td { border: 0; padding-top: .6rem; font-weight: var(--fw-semibold); }
.cost-table tr.price-row td:last-child { font-family: var(--font-display); font-size: var(--fs-h4); font-weight: var(--fw-extrabold); line-height: 1; letter-spacing: -0.01em; color: var(--link); }
.cost-table tr.sub td { border: 0; color: var(--muted); font-size: var(--fs-body-sm); padding-top: 0; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.usage-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: .25rem; }
.usage-bar i { display: block; height: 100%; background: var(--c, var(--brand)); }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty h2 { color: var(--text); }
.steps { margin: 0; padding-left: 1.2rem; }
.steps li { margin-bottom: .35rem; }
.steps li.done { color: var(--muted); text-decoration: line-through; }

.progress { display: none; margin-top: .75rem; }
.progress.show { display: block; }
.progress-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

.auth { max-width: 420px; margin: 2.5rem auto; }
.auth .brand { justify-content: center; margin-bottom: 1.25rem; }
.auth .brand img { height: 56px; }
.auth h1 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: 1.2; letter-spacing: -0.01em; }
.pagination { display: flex; gap: .5rem; justify-content: center; align-items: center; margin-top: 1rem; }
details.more summary { cursor: pointer; color: var(--link); font-weight: var(--fw-semibold); }
.hide-sm { display: none; }
@media (min-width: 720px) { .hide-sm { display: initial; } }
