/* Visual aprovado do sistema atual (verde Darsley), adaptado para Mac e iPad. */
:root {
  --canvas: #122221; --panel: #1e302f; --emphasis: #2a4541; --field: #38564f;
  --text: #f0f5f1; --muted: #cedbd4; --border: #7b9b8f; --outline: #62c9aa;
  --gold: #e1b96d; --value: #79d8b5; --negative: #edaaa3; --warning: #efdab5; --warning-panel: #332f23;
  --radius: 12px; --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --heading: Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--canvas); color: var(--text); font: 16px/1.45 var(--font); }
h1, h2, h3 { font-family: var(--heading); font-weight: 600; margin: 0 0 .6rem; }
h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; color: var(--gold); }
a { color: var(--value); }
small, .muted { color: var(--muted); }

.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 1.2rem;
  border-bottom: 2px solid var(--outline); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.brand small { letter-spacing: .18em; color: var(--gold); font-size: .72rem; }
.brand strong { font-family: var(--heading); font-size: 1.3rem; }
.top-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }
.dev-note { margin: 0; padding: .35rem 1.2rem; background: var(--warning-panel); color: var(--warning); font-size: .85rem; }

main { max-width: 1180px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
section, .card { background: var(--emphasis); border: 2px solid var(--outline); border-top-width: 3px;
  border-radius: var(--radius); padding: 1rem; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
input, select, textarea, button { font: inherit; }
input, select, textarea { background: var(--field); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .7rem; min-height: 44px; width: 100%; }
input[type=checkbox] { width: 22px; min-height: 22px; accent-color: var(--outline); }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.form { display: grid; gap: .7rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; align-items: end; }

button { background: var(--outline); color: #0d1d1b; border: 0; border-radius: 8px; padding: .6rem 1rem;
  min-height: 44px; font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.small { min-height: 36px; padding: .35rem .7rem; font-size: .88rem; }
button.danger { background: transparent; color: var(--negative); border: 1px solid var(--negative); }
button:disabled { opacity: .5; cursor: progress; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: .4rem; border-bottom: 1px solid var(--border); }
td { padding: .55rem .4rem; border-bottom: 1px solid #3c5650; vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.cancelled td, tr.voided td { opacity: .45; text-decoration: line-through; }
tr.cancelled td.acts, tr.voided td.acts { text-decoration: none; }
.tag { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; border: 1px solid var(--border);
  color: var(--muted); margin: .15rem .2rem 0 0; white-space: nowrap; }
.tag.gold { border-color: var(--gold); color: var(--gold); }
.tag.ok { border-color: var(--value); color: var(--value); }
.table-wrap { overflow-x: auto; }

.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; position: sticky; top: 64px; z-index: 4;
  background: var(--canvas); padding: .4rem 0; margin: -.4rem 0; }
.metric { background: var(--panel); border: 2px solid var(--outline); border-radius: var(--radius); padding: .6rem .8rem; }
.metric small { display: block; }
.metric strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.metric.balance strong { color: var(--gold); }
.list-item { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem .2rem; border-bottom: 1px solid #3c5650;
  text-decoration: none; color: var(--text); align-items: center; }
.list-item:hover { background: #ffffff0a; }
.hint { font-size: .85rem; color: var(--muted); margin: .2rem 0 .6rem; }
.calc { background: var(--panel); border-radius: 8px; padding: .5rem .7rem; font-size: .9rem; color: var(--value); }
details > summary { cursor: pointer; color: var(--gold); font-weight: 600; margin: .3rem 0; }

#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); max-width: min(92vw, 560px);
  background: var(--panel); border: 2px solid var(--gold); color: var(--text); padding: .7rem 1rem; border-radius: 10px;
  display: none; z-index: 20; }
#toast.show { display: block; } #toast.error { border-color: var(--negative); color: var(--negative); }
dialog { background: var(--panel); color: var(--text); border: 2px solid var(--outline); border-radius: var(--radius);
  padding: 1.2rem; width: min(92vw, 520px); }
dialog::backdrop { background: #000a; }

@media (max-width: 760px) {
  .totals { grid-template-columns: repeat(2, 1fr); top: 60px; }
  main { padding: .6rem; }
}

/* Invoice: papel branco, para imprimir */
.invoice { background: #fff; color: #1b2b29; border-radius: 6px; padding: 2rem; max-width: 820px; margin: 0 auto; }
.invoice h1 { font-family: var(--heading); color: #193d40; }
.invoice table td, .invoice table th { border-color: #d5dfdb; color: #1b2b29; }
.invoice .note { margin-top: 1rem; font-size: .9rem; border-top: 1px solid #d5dfdb; padding-top: .6rem; }
.invoice .right { text-align: right; }
@media print {
  .top, .dev-note, .no-print, #toast { display: none !important; }
  html, body { background: #fff; }
  main { padding: 0; max-width: none; }
  .invoice { padding: 0; }
}

/* Quadro recolhível: o título funciona como botão de abrir/fechar */
.section-toggle > summary { list-style: none; display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; color: var(--text); margin: 0; }
.section-toggle > summary::-webkit-details-marker { display: none; }
.section-toggle > summary h2 { margin: 0; }
.section-toggle > summary h2::before { content: '▸ '; color: var(--gold); }
.section-toggle[open] > summary h2::before { content: '▾ '; }
.section-toggle[open] > summary { margin-bottom: .6rem; }
.section-toggle[open] > summary small { display: none; }

/* Navegação e quadro da oficina */
.nav { display: flex; gap: .3rem; }
.navlink { padding: .45rem .9rem; border-radius: 8px; color: var(--muted); text-decoration: none; border: 1px solid transparent; }
.navlink.active { color: var(--text); border-color: var(--outline); background: var(--emphasis); }
.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: .6rem; }
.stage { background: var(--panel); color: var(--text); border: 2px solid var(--border); border-radius: var(--radius);
  padding: .7rem; text-align: left; display: grid; gap: .2rem; min-height: 86px; }
.stage strong { font-size: 1.6rem; }
.stage small { color: var(--muted); }
.stage.active { border-color: var(--gold); background: var(--emphasis); }
.tag.late { border-color: var(--negative); color: var(--negative); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #ffffff0a; }
@media (max-width: 900px) { .stages { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .stages { grid-template-columns: repeat(2, 1fr); } .nav { order: 3; width: 100%; } .top { flex-wrap: wrap; } }
.brand, .navlink { white-space: nowrap; }
.stage .tag { justify-self: start; }
.top-actions, .who { white-space: nowrap; }
@media (max-width: 980px) { .who-label { display: none; } .top { padding: .6rem .8rem; gap: .6rem; } }

/* Celular: topo compacto, cartões de estágio baixos, tabelas "stack" viram cartões empilhados */
@media (max-width: 600px) {
  .top { position: static; padding: .5rem .7rem; }
  .brand small { display: none; }
  .brand strong { font-size: 1.15rem; }
  .top-actions button, .navlink { padding: .35rem .6rem; min-height: 36px; font-size: .9rem; }
  .dev-note { padding: .25rem .7rem; font-size: .78rem; }
  .totals { top: 0; }
  .stages { grid-template-columns: repeat(2, 1fr); gap: .4rem; }
  .stage { min-height: 0; padding: .45rem .6rem; grid-template-columns: 1fr auto; align-items: center; }
  .stage strong { font-size: 1.25rem; grid-row: 1 / span 2; grid-column: 2; }
  .stage small { font-size: .8rem; }
  section, .card { padding: .8rem; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; padding: .7rem .2rem;
    border-bottom: 1px solid #3c5650; }
  table.stack td { display: block; border: 0; padding: 0; }
  table.stack td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  table.stack td:nth-child(3) { grid-row: 3; }
  table.stack td:nth-child(4) { grid-row: 1; grid-column: 2; text-align: right; }
  table.stack td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); font-size: .8rem; }
}
