/* ===== Tokens / tema ===== */
:root {
  --brand: #d81e2c;
  --brand-600: #b8141f;
  --brand-50: #fdecee;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #1b1f2a;
  --muted: #6b7280;
  --border: #e5e7ee;
  --ok: #138a4b;      --ok-bg: #e3f6ec;
  --warn: #b26a00;    --warn-bg: #fff3dc;
  --info: #1d5fd1;    --info-bg: #e5eefc;
  --danger: #c62828;  --danger-bg: #fde8e8;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --radius: 14px;
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 76px;
  color-scheme: light;
}
[data-theme="dark"] {
  --brand: #ff4655;
  --brand-600: #ff6b77;
  --brand-50: #3a1c20;
  --bg: #0f1218;
  --surface: #171b24;
  --surface-2: #1d222d;
  --text: #e8eaf0;
  --muted: #98a2b3;
  --border: #272d3a;
  --ok: #4ade80;      --ok-bg: #12301f;
  --warn: #fbbf24;    --warn-bg: #33270b;
  --info: #7aa7ff;    --info-bg: #14233f;
  --danger: #ff7b7b;  --danger-bg: #3a1717;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.1rem; } h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }

/* ===== Botões ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1.05rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; transition: .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
[data-theme="dark"] .btn-ok { color: #06220f; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: .4rem .7rem; font-size: .85rem; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 1.1rem;
}
.icon-btn:hover { background: var(--surface-2); }

/* ===== Formulários ===== */
.field { display: grid; gap: .35rem; margin-bottom: .9rem; }
.field label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: .7rem .85rem; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); transition: border-color .15s;
}
.input:focus { outline: none; border-color: var(--brand); }
textarea.input { resize: vertical; min-height: 70px; }

/* ===== Cartões, badges, tabela ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; }
.card h2 { margin-bottom: .7rem; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-pendente { background: var(--warn-bg); color: var(--warn); }
.badge-ajustado { background: var(--ok-bg); color: var(--ok); }
.badge-substituido { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--surface-2); color: var(--muted); }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .7rem .85rem; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--surface-2); }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ===== Toast / modal ===== */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 100; }
.toast { padding: .75rem 1rem; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); max-width: 340px; animation: pop .2s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
[data-theme="dark"] .toast.ok { color: #06220f; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.modal-back { position: fixed; inset: 0; background: rgba(8,10,16,.55); display: grid; place-items: center; padding: 1rem; z-index: 90; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 1.3rem; width: 100%; max-width: 440px; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.modal h2 { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }

.spinner { width: 18px; height: 18px; border: 3px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand-logo { display: block; height: 40px; width: auto; max-width: 100%; }
[data-theme="dark"] .brand-logo.on-light-only { filter: brightness(0) invert(1); }
