:root {
  color-scheme: light;
  --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-subtle: #f8f9fc;
  --surface-hover: #f0f3f9;
  --border: #dfe4ed;
  --border-strong: #cbd3df;
  --text: #172033;
  --muted: #5c687c;
  --primary: #3157d5;
  --primary-hover: #2849b8;
  --primary-soft: #eaf0ff;
  --primary-soft-text: #2447b5;
  --on-primary: #ffffff;
  --focus: rgba(49, 87, 213, .28);
  --ok-bg: #e7f6ed;
  --ok-fg: #17633b;
  --warn-bg: #fff3d8;
  --warn-fg: #82510a;
  --bad-bg: #fdebec;
  --bad-fg: #a42a32;
  --neutral-bg: #edf0f5;
  --neutral-fg: #46536a;
  --shadow-sm: 0 1px 2px rgba(20, 30, 55, .05), 0 8px 24px rgba(20, 30, 55, .05);
  --shadow-md: 0 4px 10px rgba(20, 30, 55, .06), 0 24px 56px rgba(20, 30, 55, .08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --nav: 264px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #10141c;
    --surface: #181e29;
    --surface-subtle: #1d2431;
    --surface-hover: #222b3a;
    --border: #2d3748;
    --border-strong: #3b485d;
    --text: #eef2f8;
    --muted: #a5b0c2;
    --primary: #89a7ff;
    --primary-hover: #a8bdff;
    --primary-soft: #24345e;
    --primary-soft-text: #c3d1ff;
    --on-primary: #11192c;
    --focus: rgba(137, 167, 255, .34);
    --ok-bg: #173625;
    --ok-fg: #8de1ad;
    --warn-bg: #3d3012;
    --warn-fg: #f4ce78;
    --bad-bg: #421d22;
    --bad-fg: #ffadb2;
    --neutral-bg: #273142;
    --neutral-fg: #ced6e3;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .22), 0 10px 28px rgba(0, 0, 0, .18);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .28), 0 26px 64px rgba(0, 0, 0, .26);
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scrollbar-color: var(--border-strong) var(--bg); }
[hidden] { display: none !important; }
::selection { background: var(--primary-soft); color: var(--primary-soft-text); }

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.55 var(--font-sans);
  letter-spacing: -.006em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -.025em;
  text-wrap: balance;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.25rem); font-weight: 720; }
h2 { margin-bottom: 24px; font-size: clamp(1.65rem, 3vw, 2.05rem); font-weight: 700; }
h3 { margin-bottom: 8px; font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 16px; }
.muted { color: var(--muted); }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 12% 12%, var(--primary-soft), transparent 34rem), var(--bg);
}
.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 10px;
  padding: clamp(24px, 6vw, 38px);
  box-shadow: var(--shadow-md);
}
.login-card h1::before {
  content: "";
  display: block;
  width: 36px;
  height: 8px;
  margin-bottom: 22px;
  border-radius: 99px;
  background: var(--primary);
}
.login-card .muted { margin: 0 0 10px; max-width: 36ch; }
.login-card .primary { width: 100%; margin-top: 8px; }

.card {
  margin-bottom: 18px;
  padding: clamp(18px, 3vw, 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

label { margin-top: 2px; font-size: .875rem; font-weight: 650; color: var(--text); }
input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text);
  caret-color: var(--primary);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
input:hover { border-color: var(--muted); }
input:focus { background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); outline: 0; }

input:focus-visible, .btn:focus-visible, .nav-item:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

.btn {
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 640;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: transform 120ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--muted); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); box-shadow: 0 6px 18px var(--focus); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:disabled { opacity: .46; cursor: not-allowed; box-shadow: none; }
.perigo-btn { background: var(--bad-bg); color: var(--bad-fg); border-color: color-mix(in srgb, var(--bad-fg) 45%, transparent); }
.perigo-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--bad-bg) 78%, var(--bad-fg)); border-color: var(--bad-fg); }
.perigo { border-color: color-mix(in srgb, var(--bad-fg) 34%, var(--border)); box-shadow: none; }
.erro { margin: 2px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bad-bg); color: var(--bad-fg); font-weight: 560; }

.app { display: grid; grid-template-columns: var(--nav) minmax(0, 1fr); min-height: 100vh; }
.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.marca {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -.03em;
}
.marca::before {
  content: "S";
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 1rem;
  box-shadow: 0 7px 18px var(--focus);
}
.marca span { margin-left: -4px; color: var(--muted); font-size: .75rem; font-weight: 560; letter-spacing: .01em; }
.nav nav { display: grid; gap: 5px; }
.nav-item {
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 590;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.ativo { background: var(--primary-soft); color: var(--primary-soft-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 14%, transparent); }
.rodape-nav { margin-top: auto; display: grid; gap: 10px; padding: 16px 8px 0; border-top: 1px solid var(--border); }
.rodape-nav .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }

.conteudo { width: 100%; max-width: 1120px; padding: clamp(26px, 5vw, 52px); }
.aba { animation: aba-entrada 240ms cubic-bezier(.22, 1, .36, 1); }
@keyframes aba-entrada {
  from { opacity: .55; transform: translateY(5px); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: none; }
}
.aviso {
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--neutral-fg) 18%, transparent);
  border-radius: var(--radius-md);
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  font-weight: 560;
}
.aviso.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: color-mix(in srgb, var(--ok-fg) 20%, transparent); }
.aviso.falha { background: var(--bad-bg); color: var(--bad-fg); border-color: color-mix(in srgb, var(--bad-fg) 20%, transparent); }

.linha { display: flex; justify-content: space-between; align-items: center; gap: 18px; min-height: 52px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.linha:first-child { padding-top: 0; }
.linha > span:first-child { color: var(--muted); font-weight: 560; }
.botoes { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.selo { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 999px; background: var(--neutral-bg); color: var(--neutral-fg); font-size: .8rem; font-weight: 700; letter-spacing: .005em; }
.selo::before { content: ""; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: currentColor; opacity: .68; }
.selo.ok { background: var(--ok-bg); color: var(--ok-fg); }
.selo.warn { background: var(--warn-bg); color: var(--warn-fg); }
.selo.bad { background: var(--bad-bg); color: var(--bad-fg); }

.grade { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.cartao {
  grid-column: span 2;
  min-height: 130px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.cartao:nth-child(-n+2) { grid-column: span 3; }
.cartao:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.cartao .num { font-variant-numeric: tabular-nums; font-size: clamp(2rem, 5vw, 2.65rem); font-weight: 740; line-height: 1; letter-spacing: -.04em; }
.cartao .rot { max-width: 24ch; color: var(--muted); font-size: .84rem; font-weight: 560; line-height: 1.35; }
#visao-nota { max-width: 70ch; }

.qr { margin-top: 24px; padding: 24px; display: grid; justify-items: center; gap: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--surface-subtle); }
.qr img { width: min(280px, 100%); height: auto; aspect-ratio: 1; padding: 10px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; box-shadow: var(--shadow-sm); image-rendering: crisp-edges; }
.qr .muted { max-width: 56ch; margin: 0; text-align: center; }
.pre { margin-top: 18px; padding: clamp(18px, 3vw, 24px); overflow: auto; white-space: pre-wrap; word-break: break-word; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); font: inherit; line-height: 1.65; box-shadow: var(--shadow-sm); }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.lista li:first-child { padding-top: 0; }
.lista li:last-child { padding-bottom: 0; border-bottom: 0; }
.lista time { color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .grade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cartao, .cartao:nth-child(-n+2) { grid-column: span 1; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; align-content: start; }
  .nav {
    z-index: 10;
    position: sticky;
    align-self: start;
    width: 100%;
    height: auto;
    padding: 12px 14px 10px;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(20, 30, 55, .06);
  }
  .marca { display: none; }
  .nav nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .nav nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 auto; min-height: 40px; padding: 8px 11px; white-space: nowrap; }
  .rodape-nav { display: none; }
  .conteudo { padding: 26px 18px 40px; }
  h2 { margin-bottom: 20px; }
  .lista li { grid-template-columns: 1fr; gap: 3px; }
}

@media (max-width: 520px) {
  .login { padding: 16px; }
  .grade { grid-template-columns: 1fr; }
  .cartao { min-height: 112px; }
  .linha { align-items: flex-start; flex-direction: column; gap: 7px; }
  .botoes { display: grid; grid-template-columns: 1fr; }
  .botoes .btn { width: 100%; }
  .qr { padding: 18px 12px; }
}

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