/* ============================================================
   JR Lira Tech — Design v2 (jr-design.css)
   Importar DEPOIS do CSS base e DEPOIS de geist-fontface.css.
   WOFF2 servidos em /_shared/fonts/ (express.static publica public/ na raiz).
   ============================================================ */

:root {
  /* Motion */
  --motion-instant: 80ms;
  --motion-fast: 150ms;
  --motion-base: 200ms;
  --motion-modal: 260ms;
  --motion-page: 220ms;
  --motion-overshoot: 320ms;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-overshoot: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-shake: cubic-bezier(0.36, 0.07, 0.19, 0.97);

  /* Focus rings */
  --focus-ring-sky: rgba(56, 189, 248, 0.18);
  --focus-ring-danger: rgba(248, 113, 113, 0.18);
  --focus-ring-warn: rgba(251, 191, 36, 0.18);

  /* Hovers tonais */
  --row-hover-sky: rgba(56, 189, 248, 0.06);
  --row-active-sky: rgba(56, 189, 248, 0.10);
}

/* ===== Tipografia ===== */
body, .app, .login-shell, .modal, table.dense, .nota-card,
input, select, textarea, button, .topbar, .filtros-padrao,
.empty-state, .empty-zero, .toast, .error-banner, .field-error-msg {
  font-family: 'Geist', system-ui, -apple-system, sans-serif;
}
.dash-brand, .login-title, nav.topbar .brand {
  font-family: 'Geist', system-ui, sans-serif;
  letter-spacing: -0.03em;
}
h1, h2, h3, .modal-title, .nota-header h2 { letter-spacing: -0.02em; font-weight: 600; }
table.dense, .kpi .kpi-value, .nh-field span, .nota-card .nc-info {
  font-variant-numeric: tabular-nums;
}

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

/* ===== Cards do dashboard — lift forte (escopo: .grupo .card pra não vazar pra painéis genéricos) ===== */
.grupo .card {
  border: 1px solid rgba(255,255,255,0.04);
  transition:
    transform var(--motion-base) var(--ease),
    background var(--motion-base) var(--ease),
    border-color var(--motion-base) var(--ease),
    box-shadow var(--motion-base) var(--ease);
}
.grupo .card:hover {
  background: #2a3a52;
  border-color: rgba(56,189,248,0.55);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45), 0 2px 6px rgba(56,189,248,0.15);
}
.grupo .card:hover .ic { transform: scale(1.12); transition: transform var(--motion-base) var(--ease); }
.grupo .card:active { transform: translateY(-1px); transition-duration: var(--motion-instant); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.grupo .card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring-sky); }

/* ===== Cards — default (lift médio) ===== */
.nota-card, .kpi, .upload-item {
  transition:
    transform var(--motion-base) var(--ease),
    background var(--motion-base) var(--ease),
    border-color var(--motion-base) var(--ease),
    box-shadow var(--motion-base) var(--ease);
}
.nota-card:hover, .kpi:hover, .upload-item:hover {
  background: #273549;
  border-color: rgba(56,189,248,0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.nota-card:active, .upload-item:active { transform: translateY(-1px); transition-duration: var(--motion-instant); }

/* ===== Badges com inset shadow ===== */
.badge {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
  letter-spacing: 0.01em;
  font-weight: 600;
}
.b-pendente   { background: rgba(59,130,246,0.15); color: #60a5fa; box-shadow: inset 0 0 0 1px rgba(59,130,246,0.25); }
.b-validada,
.b-aprovado   { background: rgba(34,197,94,0.15); color: #4ade80; box-shadow: inset 0 0 0 1px rgba(34,197,94,0.25); }
.b-divergente { background: rgba(249,115,22,0.15); color: #fb923c; box-shadow: inset 0 0 0 1px rgba(249,115,22,0.3); }
.b-maior      { background: rgba(220,38,38,0.2); color: #fff; box-shadow: inset 0 0 0 1px rgba(248,113,113,0.4); }
.b-menor      { background: rgba(34,197,94,0.15); color: #4ade80; box-shadow: inset 0 0 0 1px rgba(34,197,94,0.25); }
.b-cd         { background: rgba(14,116,144,0.2); color: #7dd3fc; box-shadow: inset 0 0 0 1px rgba(56,189,248,0.3); }
.b-novo       { background: rgba(124,58,237,0.18); color: #a78bfa; box-shadow: inset 0 0 0 1px rgba(167,139,250,0.3); }
.b-auditagem  { background: rgba(146,64,14,0.3); color: #fef3c7; box-shadow: inset 0 0 0 1px rgba(251,191,36,0.3); }
.b-em_conferencia { background: rgba(34,197,94,0.15); color: #34d399; box-shadow: inset 0 0 0 1px rgba(34,197,94,0.25); }
.b-em_auditoria { background: rgba(146,64,14,0.3); color: #fbbf24; box-shadow: inset 0 0 0 1px rgba(251,191,36,0.3); }
.b-fechada    { background: rgba(30,41,59,0.6); color: #64748b; box-shadow: inset 0 0 0 1px rgba(100,116,139,0.25); }

/* ===== Badge pulse (crítico) ===== */
.grupo .card .badge-pulse, .card .badge-pulse {
  position: absolute; top: -6px; right: -6px;
  background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 22px; height: 22px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; padding: 0 6px;
  box-shadow: 0 2px 6px rgba(239,68,68,.5);
  animation: jrPulse 1.8s infinite;
}
@keyframes jrPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ===== Badge ripple (acumulativo) ===== */
.grupo .card .badge-ripple, .card .badge-ripple {
  position: absolute; top: -6px; right: -6px;
  background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 22px; height: 22px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; padding: 0 6px;
}
.card .badge-ripple::before {
  content: ''; position: absolute; inset: 0;
  border-radius: 50%; background: #ef4444; opacity: 0.45;
  animation: jrPing 2.2s var(--ease) infinite; z-index: -1;
}
@keyframes jrPing { 0% { transform: scale(1); opacity: 0.45; } 80%, 100% { transform: scale(2.2); opacity: 0; } }

/* ===== Tabelas — hover translúcido ===== */
table.dense tbody tr { transition: background var(--motion-fast) ease; }
table.dense tbody tr:hover { background: var(--row-hover-sky); }
table.dense tbody tr:hover td { color: #f1f5f9; transition: color var(--motion-fast) ease; }
table.dense tbody tr.clickable { cursor: pointer; }
table.dense tbody tr.clickable:active { background: var(--row-active-sky); transition-duration: var(--motion-instant); }

/* ===== Inputs / selects / focus ===== */
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) {
  border-color: #475569;
  transition: border-color var(--motion-fast) ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand, #38bdf8); box-shadow: 0 0 0 3px var(--focus-ring-sky); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring-sky); }

/* ===== Botões — estados completos ===== */
.btn-primary, .btn-ok, .btn-danger, .btn-warn, .btn-ghost, .btn-nav, nav.topbar .btn-nav {
  transition: background var(--motion-fast) var(--ease), transform var(--motion-instant) var(--ease), box-shadow var(--motion-fast) var(--ease);
  letter-spacing: -0.005em;
}
.btn-primary:hover, nav.topbar .btn-nav:hover { background: #0284c7; }
.btn-ok:hover { background: #166534; }
.btn-danger:hover { background: #991b1b; }
.btn-warn:hover { background: #7c2d12; }
.btn-ghost:hover { background: #475569; color: #e2e8f0; }
.btn-primary:active, .btn-ok:active, .btn-danger:active, .btn-warn:active, .btn-ghost:active, .btn-nav:active { transform: scale(0.96); }
.btn-primary:disabled, .btn-ok:disabled, .btn-danger:disabled, .btn-warn:disabled, .btn-ghost:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ===== Modal — entrada com lift + blur ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(2, 6, 17, 0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--motion-modal) var(--ease);
  z-index: 100;
}
.modal-overlay { pointer-events: none; }
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-overlay .modal {
  transform: translateY(12px) scale(0.97); opacity: 0;
  transition: transform var(--motion-modal) var(--ease-out), opacity var(--motion-modal) ease;
}
.modal-overlay.show .modal { transform: translateY(0) scale(1); opacity: 1; }
.modal.destructive { border-left: 3px solid #ef4444; }

/* ===== Empty inicial ===== */
.empty-state {
  background: var(--surface, #1e293b);
  border-radius: 10px;
  padding: 56px 24px;
  text-align: center;
  border: 1px dashed #334155;
}
.empty-state .icon-wrap {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  background: #0c2a3f; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand, #38bdf8);
}
.empty-state .icon-wrap svg, .empty-state .icon-wrap i { width: 26px; height: 26px; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: #e2e8f0; margin-bottom: 6px; letter-spacing: -0.01em; }
.empty-state p { font-size: 13px; color: #94a3b8; margin-bottom: 18px; line-height: 1.5; max-width: 360px; margin-left: auto; margin-right: auto; }
.empty-state .actions { display: flex; gap: 8px; justify-content: center; }

/* ===== Empty zero result ===== */
.empty-zero {
  background: var(--surface, #1e293b);
  border-radius: 10px;
  padding: 40px 24px;
  text-align: center;
}
.empty-zero .small-icon { color: #64748b; margin-bottom: 10px; display: flex; justify-content: center; }
.empty-zero .small-icon svg, .empty-zero .small-icon i { width: 24px; height: 24px; }
.empty-zero h4 { font-size: 13px; color: #e2e8f0; margin-bottom: 4px; font-weight: 600; }
.empty-zero p { font-size: 12px; color: #94a3b8; margin-bottom: 14px; }
.empty-zero .clear-filter {
  background: transparent;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 6px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all var(--motion-fast) ease;
}
.empty-zero .clear-filter:hover { background: #1e293b; color: #e2e8f0; border-color: #475569; }

/* ===== Erro de campo ===== */
/* Visual permanente enquanto inválido. Shake é classe à parte (.shake) que
   o jr-components.js adiciona só na primeira aparição (design.md §11). */
.field input.invalid, .field select.invalid, .field textarea.invalid {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.12);
}
.field input.shake, .field select.shake, .field textarea.shake {
  animation: jrShake 0.4s var(--ease-shake);
}
@keyframes jrShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.field-error-msg {
  font-size: 11.5px; color: #f87171; margin-top: 5px;
  display: flex; align-items: center; gap: 5px;
  opacity: 0; transform: translateY(-4px); max-height: 0; overflow: hidden;
  transition: opacity var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease), max-height var(--motion-fast) var(--ease);
}
.field.invalid .field-error-msg { opacity: 1; transform: translateY(0); max-height: 40px; }
.field-error-msg .x {
  width: 14px; height: 14px;
  background: rgba(248, 113, 113, 0.18); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; flex-shrink: 0;
}

/* ===== Banner de erro de operação ===== */
.error-banner {
  background: rgba(127, 29, 29, 0.4);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-left: 3px solid #f87171;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 14px;
  opacity: 0; transform: translateY(-6px); max-height: 0; overflow: hidden;
  transition: opacity var(--motion-modal) var(--ease), transform var(--motion-modal) var(--ease), max-height var(--motion-modal) var(--ease);
}
.error-banner.show { opacity: 1; transform: translateY(0); max-height: 120px; }
.error-banner .x-icon {
  width: 18px; height: 18px;
  background: rgba(248, 113, 113, 0.25); color: #f87171;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; flex-shrink: 0; margin-top: 1px;
}
.error-banner .msg { flex: 1; }
.error-banner .msg .title { font-size: 12.5px; font-weight: 600; color: #fca5a5; margin-bottom: 2px; }
.error-banner .msg .detail { font-size: 11.5px; color: #fca5a5; opacity: 0.8; line-height: 1.4; }
.error-banner .close {
  background: none; border: none; color: #fca5a5;
  font-size: 16px; cursor: pointer; padding: 0;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.6; transition: opacity var(--motion-fast) ease;
}
.error-banner .close:hover { opacity: 1; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; right: 20px;
  background: var(--surface, #1e293b);
  border: 1px solid #334155;
  border-left: 3px solid var(--brand, #38bdf8);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  font-family: 'Geist', sans-serif;
  font-size: 12.5px; color: #e2e8f0;
  min-width: 240px;
  transform: translateX(120%); opacity: 0;
  transition: transform var(--motion-overshoot) var(--ease-overshoot), opacity var(--motion-base) ease;
  z-index: 200;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast .icon {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 900; flex-shrink: 0;
}
.toast.success { border-left-color: #4ade80; }
.toast.success .icon { background: rgba(74,222,128,0.18); color: #4ade80; }
.toast.error { border-left-color: #f87171; }
.toast.error .icon { background: rgba(248,113,113,0.18); color: #f87171; }
.toast.warn { border-left-color: #fbbf24; }
.toast.warn .icon { background: rgba(251,191,36,0.18); color: #fbbf24; }

/* ===== Skeleton ===== */
.skel {
  background: linear-gradient(90deg, #334155 0%, #475569 50%, #334155 100%);
  background-size: 200% 100%;
  border-radius: 4px;
  height: 12px;
  animation: jrShimmer 1.4s infinite linear;
}
@keyframes jrShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Botão loading ===== */
.btn.loading, .btn-primary.loading, .btn-ok.loading, .btn-danger.loading {
  cursor: wait; opacity: 0.85; pointer-events: none;
}
.btn.loading::after, .btn-primary.loading::after, .btn-ok.loading::after, .btn-danger.loading::after {
  content: ''; display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; margin-left: 8px;
  animation: jrSpin 0.6s linear infinite; vertical-align: -2px;
}
@keyframes jrSpin { to { transform: rotate(360deg); } }

/* ===== Upload area ===== */
.upload-area {
  transition: border-color var(--motion-base) var(--ease), background var(--motion-base) var(--ease);
}
.upload-area:hover, .upload-area.dragging {
  border-color: var(--brand, #38bdf8); border-style: solid;
  background: rgba(56, 189, 248, 0.05);
}
.upload-area.error {
  border-color: #f87171;
  background: rgba(127, 29, 29, 0.15);
  animation: jrShake 0.4s var(--ease-shake);
}

/* ===== Transição entre rotas ===== */
main.page, .page-main {
  animation: jrPageIn var(--motion-page) var(--ease-out);
}
@keyframes jrPageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Onboarding tooltip ===== */
.hint-tooltip {
  position: absolute;
  background: #0c2a3f;
  border: 1px solid #38bdf8;
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Geist', sans-serif;
  max-width: 240px;
  cursor: pointer;
  z-index: 50;
  animation: jrPageIn var(--motion-modal) var(--ease-out);
}
.hint-tooltip::after {
  content: '× clique pra fechar';
  display: block;
  font-size: 10px;
  color: #64748b;
  margin-top: 4px;
}

/* ===== Copyright global (canto sup-esq, acima do nav) ===== */
.jr-copyright {
  position: fixed;
  top: 2px; left: 8px;
  font-size: 9px;
  color: #475569;
  letter-spacing: 0.02em;
  pointer-events: none;
  user-select: none;
  z-index: 9999;
  font-family: 'Geist', system-ui, sans-serif;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
@media print { .jr-copyright { display: none !important; } }
@media (max-width: 768px) { .jr-copyright { font-size: 8px; top: 1px; left: 6px; } }
