@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --navy: #10173a;
  --navy-2: #1a2456;
  --navy-3: #232f6e;
  --red: #e2372b;
  --red-2: #c4281e;
  --white: #ffffff;
  --bg: #f4f5fb;
  --card: #ffffff;
  --ink: #161a33;
  --mist: #7a8099;
  --mist-2: #a4a9bd;
  --success: #16875a;
  --success-bg: #e6f7ef;
  --danger-bg: #fdecea;
  --border: #e7e8f2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 23, 58, 0.05);
  --shadow: 0 2px 8px rgba(16, 23, 58, 0.05), 0 10px 30px rgba(16, 23, 58, 0.06);
  --shadow-lg: 0 20px 60px rgba(16, 23, 58, 0.16);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .wordmark { font-family: 'Sora', 'Inter', sans-serif; }
.tab-nums { font-family: 'IBM Plex Mono', 'Inter', monospace; font-variant-numeric: tabular-nums; }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 9px;
  font-weight: 600;
  transition: filter 0.15s var(--ease), transform 0.08s var(--ease), box-shadow 0.15s var(--ease);
}
button:active { transform: translateY(1px) scale(0.99); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--red);
  color: var(--white);
  padding: 11px 18px;
  font-size: 14.5px;
  box-shadow: 0 1px 2px rgba(226, 55, 43, 0.15), 0 6px 16px rgba(226, 55, 43, 0.22);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); box-shadow: 0 1px 2px rgba(226, 55, 43, 0.2), 0 10px 22px rgba(226, 55, 43, 0.3); }

.btn-secondary {
  background: var(--white);
  color: var(--navy);
  border: 1.5px solid var(--border);
  padding: 10px 16px;
  font-size: 14.5px;
}
.btn-secondary:hover:not(:disabled) { border-color: var(--navy-3); background: #fafbff; }

.btn-ghost {
  background: transparent;
  color: var(--mist);
  padding: 8px 12px;
  font-size: 14px;
}
.btn-ghost:hover { color: var(--ink); }

input, select {
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--ink);
  width: 100%;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--navy-3);
  box-shadow: 0 0 0 4px rgba(35, 47, 110, 0.1);
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--navy-3);
  outline-offset: 2px;
}
label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mist);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.campo { margin-bottom: 14px; }

/* ---------- Wordmark (sem logo, só tipografia) ---------- */
.wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 3px;
}
.wordmark .linha1 {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--mist-2);
  text-transform: uppercase;
  animation: fadeInUp 0.5s var(--ease) both;
}
.wordmark .linha2 {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--navy);
  position: relative;
  animation: fadeInUp 0.5s var(--ease) 0.06s both;
}
.wordmark .linha2 .accent { color: var(--red); }
.wordmark .barra {
  width: 30px; height: 3px; border-radius: 3px;
  background: var(--red);
  margin-top: 2px;
  animation: growBar 0.6s var(--ease) 0.25s both;
}
.sidebar .wordmark .linha1 { color: rgba(255,255,255,0.5); }
.sidebar .wordmark .linha2 { color: var(--white); }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes growBar { from { width: 0; opacity: 0; } to { width: 30px; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes shimmer { 0% { background-position: -300px 0; } 100% { background-position: 300px 0; } }
@keyframes auroraDrift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-4%, 3%) scale(1.08); }
  100% { transform: translate(0, 0) scale(1); }
}
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(43, 214, 140, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(43, 214, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(43, 214, 140, 0); }
}

/* ---------- Tela de login / cadastro ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-wrap::before, .auth-wrap::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: auroraDrift 14s ease-in-out infinite;
}
.auth-wrap::before {
  width: 560px; height: 560px;
  background: radial-gradient(circle, var(--navy-3), transparent 70%);
  top: -180px; left: -160px;
}
.auth-wrap::after {
  width: 460px; height: 460px;
  background: radial-gradient(circle, rgba(226, 55, 43, 0.35), transparent 70%);
  bottom: -160px; right: -120px;
  animation-delay: -6s;
}
.auth-card {
  background: var(--white);
  border-radius: 18px;
  padding: 38px 34px;
  width: 100%;
  max-width: 390px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: scaleIn 0.5s var(--ease) both;
}
.auth-card .wordmark { margin-bottom: 26px; }
.auth-card h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -0.01em; }
.auth-card p.sub { color: var(--mist); font-size: 13.5px; margin: 0 0 24px; }
.auth-error {
  background: var(--danger-bg); color: var(--red-2);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px;
  display: none;
  animation: fadeIn 0.2s var(--ease);
}
.auth-switch { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--mist); }
.auth-switch a { color: var(--navy); font-weight: 600; text-decoration: none; border-bottom: 1.5px solid transparent; transition: border-color 0.15s; }
.auth-switch a:hover { border-color: var(--navy); }

/* ---------- Layout do app ---------- */
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 232px; background: var(--navy); color: var(--white);
  padding: 22px 16px; display: flex; flex-direction: column; flex-shrink: 0;
  position: relative; overflow: hidden;
}
.sidebar::before {
  content: '';
  position: absolute; top: -140px; left: -100px;
  width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle, var(--navy-3), transparent 70%);
  filter: blur(50px);
  animation: auroraDrift 16s ease-in-out infinite;
  pointer-events: none;
}
.sidebar > * { position: relative; z-index: 1; }
.sidebar nav { margin-top: 30px; display: flex; flex-direction: column; gap: 3px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm); text-decoration: none;
  color: rgba(255,255,255,0.68); font-size: 14px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.1s var(--ease);
}
.sidebar nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: var(--white); transform: translateX(1px); }
.sidebar nav a.ativo { background: rgba(255,255,255,0.1); color: var(--white); border-left-color: var(--red); }
.sidebar .user-box {
  margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.13);
  font-size: 13px;
}
.sidebar .user-box .status-linha { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; font-size: 12px; color: rgba(255,255,255,0.55); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: #2bd68c; animation: pulseDot 2.2s infinite; flex-shrink: 0; }
.sidebar .user-box .nome { font-weight: 600; color: var(--white); }
.sidebar .user-box .perfil { color: rgba(255,255,255,0.55); text-transform: capitalize; }
.sidebar .user-box button { margin-top: 10px; width: 100%; }
.sidebar .user-box .btn-ghost { color: rgba(255,255,255,0.6); }
.sidebar .user-box .btn-ghost:hover { color: var(--white); }

.main { flex: 1; padding: 28px 34px; max-width: 1200px; }
.main header.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.main header.page-head h1 { font-size: 23px; margin: 0; letter-spacing: -0.01em; }
.main header.page-head p { color: var(--mist); font-size: 13.5px; margin: 3px 0 0; }

.unidade-picker {
  display: flex; align-items: center; gap: 8px;
  background: var(--white); border: 1.5px solid var(--border);
  padding: 6px 6px 6px 13px; border-radius: var(--radius-sm); font-size: 13.5px;
  box-shadow: var(--shadow-sm);
}
.unidade-picker select { border: none; padding: 4px; width: auto; }

.view { animation: fadeInUp 0.35s var(--ease) both; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 20px;
  border: 1px solid rgba(16, 23, 58, 0.03);
}
.card h2 { font-size: 14.5px; margin: 0 0 14px; letter-spacing: -0.005em; }

.search-row { display: flex; gap: 10px; }
.search-row input { font-size: 16px; padding: 14px 16px; }
.hint { font-size: 12.5px; color: var(--mist); margin-top: 9px; display: flex; align-items: center; gap: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--mist); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 9px 10px; border-bottom: 1.5px solid var(--border); }
td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.tab-nums, th.tab-nums { text-align: right; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.entrada { background: var(--success-bg); color: var(--success); }
.badge.saida { background: var(--danger-bg); color: var(--red-2); }
.badge.estoque-baixo { background: var(--danger-bg); color: var(--red-2); }
.badge.estoque-ok { background: var(--success-bg); color: var(--success); }

.produto-row { animation: fadeInUp 0.3s var(--ease) both; transition: background 0.12s; }
.produto-row:hover { background: #fafbff; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.kpi-card { transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease); }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-label { font-size: 12.5px; color: var(--mist); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 20, 45, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 20px; overflow-y: auto; z-index: 50;
  animation: fadeIn 0.18s var(--ease);
  backdrop-filter: blur(2px);
}
.modal { background: var(--white); border-radius: 16px; width: 100%; max-width: 460px; padding: 28px; box-shadow: var(--shadow-lg); animation: scaleIn 0.25s var(--ease) both; }
.modal h2 { margin-top: 0; font-size: 18px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.hidden { display: none !important; }

.toast {
  position: fixed; bottom: 22px; right: 22px; background: var(--navy); color: var(--white);
  padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg);
  z-index: 100; max-width: 320px;
  animation: slideInRight 0.3s var(--ease) both;
}
.toast.erro { background: var(--red-2); }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filtros > * { min-width: 150px; }

.empty { text-align: center; color: var(--mist); padding: 44px 20px; font-size: 14px; animation: fadeIn 0.3s var(--ease); }
.empty svg { opacity: 0.35; margin-bottom: 10px; }

.skeleton-row td {
  padding: 12px 10px;
}
.skeleton-bar {
  height: 14px; border-radius: 4px; width: 70%;
  background: linear-gradient(90deg, #eef0f8 25%, #f7f8fc 37%, #eef0f8 63%);
  background-size: 600px 100%;
  animation: shimmer 1.4s ease infinite;
}

@media (max-width: 780px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 14px 16px; }
  .sidebar::before { display: none; }
  .sidebar nav { flex-direction: row; margin-top: 0; margin-left: 20px; overflow-x: auto; }
  .sidebar nav a { border-left: none; border-bottom: 3px solid transparent; }
  .sidebar nav a.ativo { border-bottom-color: var(--red); }
  .sidebar .user-box { display: none; }
  .main { padding: 20px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
