:root {
  --green: #515B46;
  --green-2: #434c3a;
  --gold: #C4AE8A;
  --gold-dark: #8f7a52;
  --cream: #F5F1E8;
  --paper: #ffffff;
  --ink: #292B28;
  --muted: #666a60;
  --line: #DDD2C0;
  --red: #a4262c;
  --red-bg: #fbe9ea;
  --ok: #1d6b45;
  --ok-bg: #e4f3ea;
  --warn-bg: #fdf1d6;
  --blue: #1f5a8a;
  --blue-bg: #e3eef8;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(18, 55, 42, 0.1);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --serif: Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--cream);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0 0 .75em; }
a { color: var(--green-2); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 44px; padding: .55em 1.1em;
  border: 1px solid var(--green); border-radius: 10px;
  background: var(--green); color: #fff; font-weight: 600; text-decoration: none;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--green-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--green); }
.btn.secondary:hover { background: #f1ece0; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1d1608; }
.btn.gold:hover { background: #d2c09f; }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-bg); }
.btn.small { min-height: 36px; padding: .3em .8em; font-size: .9rem; }
.btn.link { background: none; border: none; color: var(--green-2); text-decoration: underline; min-height: 0; padding: .2em; font-weight: 500; }
.btn.block { width: 100%; }

label.field { display: block; margin-bottom: .9rem; }
label.field > span.lab { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .25rem; color: var(--ink); }
label.field > span.lab em { font-style: normal; font-weight: 400; color: var(--muted); }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=search], input[type=number],
input[type=date], select, textarea {
  width: 100%; min-height: 44px; padding: .5em .7em;
  border: 1px solid #cdbf9f; border-radius: 10px; background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(201, 153, 58, .55); outline-offset: 1px;
}
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--green-2); flex: none; }
.check { display: flex; align-items: center; gap: .6em; min-height: 36px; cursor: pointer; }

.row { display: grid; gap: .8rem; }
@media (min-width: 560px) { .row.two { grid-template-columns: 1fr 1fr; } .row.three { grid-template-columns: 1fr 1fr 1fr; } }

.error-box {
  background: var(--red-bg); color: var(--red); border: 1px solid #e8b9bc;
  padding: .6rem .8rem; border-radius: 10px; margin-bottom: .9rem; font-weight: 500;
}
.note-box { background: var(--warn-bg); border: 1px solid #ecd58f; padding: .6rem .8rem; border-radius: 10px; margin-bottom: .9rem; }
.ok-box { background: var(--ok-bg); border: 1px solid #b6dcc6; padding: .6rem .8rem; border-radius: 10px; margin-bottom: .9rem; }

.badge {
  display: inline-block; padding: .15em .65em; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap; background: #eee; color: #333;
}
.st-novo { background: var(--blue-bg); color: var(--blue); }
.st-confirmado { background: #ece6fa; color: #55349a; }
.st-em_producao { background: var(--warn-bg); color: #7a5a00; }
.st-pronto { background: #dff3f1; color: #14675f; }
.st-enviado { background: #e4ecfb; color: #2a4fa0; }
.st-entregue { background: var(--ok-bg); color: var(--ok); }
.st-cancelado { background: #ececec; color: #666; }
.pay-por_pagar { background: var(--red-bg); color: var(--red); }
.pay-parcial { background: var(--warn-bg); color: #7a5a00; }
.pay-pago { background: var(--ok-bg); color: var(--ok); }
.pay-excedido { background: var(--blue-bg); color: var(--blue); }
.pay-reembolsar { background: var(--red-bg); color: var(--red); }
.pay-cancelado { background: #ececec; color: #666; }

dialog {
  border: none; border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px); box-shadow: 0 10px 40px rgba(0, 0, 0, .35); background: var(--paper); color: var(--ink);
}
dialog::backdrop { background: rgba(10, 25, 18, .6); }
dialog .dlg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 1;
}
dialog .dlg-head h2 { margin: 0; font-size: 1.2rem; }
dialog .dlg-body { padding: 1.1rem; }
dialog .dlg-x { background: none; border: none; font-size: 1.8rem; line-height: 1; padding: .1em .35em; border-radius: 8px; }
dialog .dlg-x:hover { background: #f0eadb; }
@media (max-width: 600px) {
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
}

.toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 9999; display: grid; gap: .5rem; width: min(92vw, 420px); }
.toast { padding: .75rem 1rem; border-radius: 10px; color: #fff; background: var(--green); box-shadow: var(--shadow); font-weight: 600; text-align: center; }
.toast.err { background: var(--red); }

.muted { color: var(--muted); }
.small { font-size: .88rem; }
.right { text-align: right; }
.spacer { flex: 1; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -.15em; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}
