/* Tiraped: tokens e componentes comuns ao ERP e ao app. Fonte da verdade das cores: replica/design/tokens.json */
@font-face { font-family: "Lora"; src: url("/fonts/Lora-Variable.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/Inter-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/Inter-Medium.otf") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/Inter-SemiBold.otf") format("opentype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/Inter-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f6f0e6; --surface: #fffcf7; --sunken: #efe6d8; --border: #e2d5c1; --border-input: #8f7d66;
  --text: #2b201d; --muted: #6b5a50; --accent: #6b1f2e; --accent-hover: #53172a; --accent-soft: #f3e4e2; --on-accent: #fbf6ee;
  --gold: #9a7442; --danger: #a8361c; --danger-soft: #f8e6dd; --success: #3d6436; --success-soft: #e6eedd;
  --warning: #845a10; --warning-soft: #f5ead2; --focus: #6b1f2e;
  --display: "Lora", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --shadow: 0 1px 2px rgba(60,35,25,.05), 0 2px 6px rgba(60,35,25,.07);
  --pop: 0 14px 36px rgba(60,35,25,.18);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -.005em; }
h1 { font-size: 28px; line-height: 34px; } h2 { font-size: 20px; line-height: 28px; } h3 { font-size: 16px; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--display); font-variant-numeric: lining-nums proportional-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* botões */
.btn { height: 44px; padding: 0 18px; border-radius: var(--r-md); border: 1px solid transparent; font: 600 14px var(--sans);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--accent); color: var(--on-accent); transition: background .12s; }
.btn:hover { background: var(--accent-hover); }
.btn.sec { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn.sec:hover { background: var(--accent-soft); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn .ico { width: 18px; height: 18px; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: inline-grid; place-items: center; cursor: pointer; }
.iconbtn:hover { background: var(--sunken); color: var(--text); }

/* ícones (traço, estilo Lucide) */
.ico { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* campos */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; height: 44px; border: 1px solid var(--border-input); border-radius: var(--r-md); padding: 0 12px;
  font: 400 14px var(--sans); color: var(--text); background: var(--surface); }
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b5a50' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[readonly], .input:disabled { background: var(--sunken); color: var(--muted); border-color: var(--border); }
.input.err { border-color: var(--danger); }
.hint { font-size: 11.5px; color: var(--muted); }
.hint.err { color: var(--danger); }
.hint.warn { color: var(--warning); }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* selos */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge .ico { width: 13px; height: 13px; }
.b-ok { background: var(--success-soft); color: var(--success); }
.b-wait { background: var(--warning-soft); color: var(--warning); }
.b-err { background: var(--danger-soft); color: var(--danger); }
.b-wine { background: var(--accent-soft); color: var(--accent); }
.b-dev { background: var(--sunken); color: var(--muted); }

/* cartões e tabelas */
.card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; }
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 10px 12px; background: var(--sunken); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fbf5ec; }
.tbl .r { text-align: right; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty .ico { width: 32px; height: 32px; margin-bottom: 6px; }

/* modal e folha */
.scrim { position: fixed; inset: 0; background: rgba(43,32,29,.42); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--pop); width: min(720px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal.wide { width: min(980px, 100%); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 18px 22px 12px; border-bottom: 1px solid var(--border); }
.modal header h2 { flex: 1; }
.modal .body { padding: 16px 22px; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 22px 18px; border-top: 1px solid var(--border); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .span4 { grid-column: 1 / -1; }

/* aviso flutuante */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--on-accent); padding: 10px 16px; border-radius: 10px; box-shadow: var(--pop); font-size: 13.5px; max-width: 90vw; animation: sobe .2s ease; }
.toast.erro { background: var(--danger); }
@keyframes sobe { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

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