/* ============================================================================
   COPA SESI 80 ANOS — Design system (base)
   Paleta extraída do logotipo: preto + amarelo, vermelho, azul e verde.
   Todos os componentes consomem tokens; troque-os para repaginar o sistema.
   ========================================================================== */
:root {
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Oswald", "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --yellow: #ffc20e;
  --red: #e5242d;
  --blue: #0b63ce;
  --green: #2fa84f;
  --ink: #0b0d12;
  --ink-2: #151a28;

  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eceef4;
  --line: #e2e5ee;
  --line-2: #cbd1df;
  --text: #0e1220;
  --text-2: #475069;
  --text-3: #7a8299;

  --primary: #1546a8;
  --primary-2: #0f3787;
  --primary-soft: #e8eefb;
  --on-primary: #ffffff;
  --ok: #1b8a47;
  --ok-soft: #e1f4e8;
  --warn: #a8620a;
  --warn-soft: #fff0d3;
  --bad: #d11f2b;
  --bad-soft: #fde8ea;
  --gold: #f5b400;
  --silver: #9aa3b8;
  --bronze: #c47a3d;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow-1: 0 1px 2px rgba(14, 18, 32, 0.06), 0 1px 1px rgba(14, 18, 32, 0.04);
  --shadow-2: 0 14px 34px -14px rgba(14, 18, 32, 0.22), 0 2px 6px rgba(14, 18, 32, 0.05);
  --focus: 0 0 0 3px color-mix(in srgb, var(--primary) 32%, transparent);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #090b10;
  --surface: #12161f;
  --surface-2: #171c27;
  --surface-3: #1e2431;
  --line: #232a39;
  --line-2: #343d52;
  --text: #eef0f6;
  --text-2: #adb4c8;
  --text-3: #7d869e;
  --primary: #6c9bff;
  --primary-2: #8fb2ff;
  --primary-soft: #18233f;
  --on-primary: #0a0c11;
  --ok: #4cc57b;
  --ok-soft: #12301f;
  --warn: #ffbf47;
  --warn-soft: #33250e;
  --bad: #ff6b73;
  --bad-soft: #3a1519;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 18px 40px -16px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
a { color: var(--primary); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; text-decoration: none; transition: top 0.2s; }
.skip-link:focus { top: 12px; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.icon { flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* --------------------------------------------------------------- marca */
.stripe {
  height: 4px;
  background: linear-gradient(90deg, var(--yellow) 0 25%, var(--red) 25% 50%, var(--blue) 50% 75%, var(--green) 75% 100%);
}
.eyebrow {
  display: inline-block;
  font: 600 12px/1 var(--font-display);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* -------------------------------------------------------------- botões */
.btn {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 600 14px/1 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  user-select: none;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); box-shadow: 0 6px 16px -8px var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); }
.btn-secondary { --btn-bg: var(--surface); border-color: var(--line-2); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-ghost { --btn-bg: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn-danger { --btn-bg: var(--bad); --btn-fg: #fff; }
.btn-danger-text { color: var(--bad); }
.btn-danger-text:hover:not(:disabled) { background: var(--bad-soft); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; border-radius: 10px; }
.btn-lg { min-height: 52px; font-size: 16px; }
.btn-block { width: 100%; }
.btn.is-busy { color: transparent; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--btn-fg) 35%, transparent); border-top-color: var(--btn-fg);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text-2);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); background: var(--surface-2); }
.icon-btn-light { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.16); color: #e9ecf5; }
.icon-btn-light:hover { background: rgba(255, 255, 255, 0.18); color: #fff; border-color: rgba(255, 255, 255, 0.3); }

/* ------------------------------------------------------------ formulários */
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field-label { font: 600 13px/1.2 var(--font-body); color: var(--text-2); }
.field-hint { color: var(--text-3); font-size: 12px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-wide { grid-column: 1 / -1; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; min-height: 46px; padding: 11px 14px;
  border: 1.5px solid var(--line-2); border-radius: 12px; background: var(--surface);
  color: var(--text); transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
select { appearance: none; padding-right: 38px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.form-error { min-height: 20px; color: var(--bad); font-size: 13px; font-weight: 600; }
.form-error:empty { min-height: 0; }
.stack { display: grid; gap: 20px; }
.stack-sm { display: grid; gap: 16px; }

/* ------------------------------------------------------------- escudos */
.badge {
  --size: 40px;
  display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); border-radius: 30%;
  font: 700 calc(var(--size) * 0.38)/1 var(--font-display); letter-spacing: 0.02em; color: #fff;
  background: linear-gradient(145deg, hsl(var(--hue, 215) 68% 50%), hsl(calc(var(--hue, 215) + 24) 70% 34%));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 4px 10px -4px hsl(var(--hue, 215) 60% 30% / 0.6);
  overflow: hidden;
}
.badge-xs { --size: 22px; border-radius: 50%; } .badge-sm { --size: 34px; } .badge-md { --size: 42px; } .badge-lg { --size: 54px; } .badge-xl { --size: 68px; }
.badge.has-logo { background: #fff; box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1); padding: 12%; }
.badge.has-logo img { width: 100%; height: 100%; object-fit: contain; }
.badge.is-empty { background: var(--surface-3); color: var(--text-3); box-shadow: none; border: 1.5px dashed var(--line-2); }

/* campo de senha com botão de mostrar/ocultar */
.password { position: relative; display: block; }
.password input { padding-right: 54px; }
.password .icon-btn { position: absolute; right: 4px; top: 4px; width: 38px; height: 38px; border: 0; background: transparent; }

/* parceiros: logos direto sobre o fundo, sem placa. Em fundo claro ficam coloridos;
   em fundo escuro (tema escuro ou painéis sempre escuros) viram monocromáticos brancos. */
.plate { display: inline-flex; align-items: center; gap: 26px; max-width: 100%; }
.plate img { height: 28px; width: auto; object-fit: contain; transition: filter 0.2s, opacity 0.2s; }
.plate-mono img, [data-theme="dark"] .plate img { filter: brightness(0) invert(1); opacity: 0.82; }
.plate-mono img:hover, [data-theme="dark"] .plate img:hover { opacity: 1; }

/* ------------------------------------------------------ pílulas e chips */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font: 700 11px/1.2 var(--font-body); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-idle { background: var(--surface-3); color: var(--text-3); }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); font: 600 14px/1 var(--font-body); white-space: nowrap; flex: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--primary); }

/* ------------------------------------------------------------- cartões */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 24px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.card-head h2 { font: 600 22px/1.2 var(--font-display); letter-spacing: 0.03em; text-transform: uppercase; display: flex; align-items: center; gap: 10px; }
.card-sub { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 48px 24px; }
.empty h3 { font: 600 22px/1.2 var(--font-display); text-transform: uppercase; letter-spacing: 0.03em; }
.empty p { color: var(--text-2); max-width: 46ch; margin-bottom: 8px; }
.empty-inline { padding: 28px 12px; border: 1.5px dashed var(--line-2); border-radius: var(--radius-sm); }
.empty-art { width: 76px; height: 76px; display: grid; place-items: center; border-radius: 24px; color: var(--primary); background: var(--primary-soft); margin-bottom: 4px; }

/* -------------------------------------------------------------- modal */
.modal { border: 0; padding: 0; background: transparent; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); color: var(--text); overflow: visible; }
.modal.sm { width: min(420px, calc(100vw - 24px)); }
.modal.lg { width: min(720px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(6, 8, 14, 0.62); backdrop-filter: blur(5px); animation: fade 0.2s ease; }
.modal[open] .modal-card { animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.modal-card { display: grid; max-height: calc(100dvh - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-2); overflow: hidden; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.modal-head { display: flex; justify-content: space-between; gap: 16px; padding: 22px 24px 8px; }
.modal-head h2 { font: 600 24px/1.2 var(--font-display); text-transform: uppercase; letter-spacing: 0.03em; }
.modal-head p { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 14px 24px 8px; overflow: auto; }
.modal .form-error { padding: 0 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; }
.modal.sm .modal-foot .btn { flex: 1; }
.confirm-text { color: var(--text-2); line-height: 1.55; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.97); } }

/* -------------------------------------------------------------- toasts */
#toasts { position: fixed; z-index: 200; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 10px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-2); opacity: 0; transform: translateY(12px); transition: opacity 0.22s, transform 0.22s; border-left: 4px solid var(--blue); cursor: pointer; }
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--green); }
.toast-success .icon { color: #5be08a; }
.toast-error { border-left-color: var(--red); }
.toast-error .icon { color: #ff8a90; }
[data-theme="dark"] .toast { background: #222a3b; }

@media (max-width: 560px) {
  .field-grid { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
  .modal .form-error { padding: 0 18px; }
}
