:root {
  --bg: #0c0e13;
  --bg-soft: #12151c;
  --card: #161a23;
  --card-2: #1c212c;
  --line: #272d39;
  --line-soft: #20252f;
  --text: #eef1f6;
  --muted: #919aab;
  --accent: #5b8cff;
  --accent-dark: #3f6fe0;
  --accent-soft: #1e2942;
  --accent-text: #aec6ff;
  --error: #ff7676;
  --green: #51d08a;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 700px at 50% -10%, #161b27 0%, var(--bg) 60%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

h1 { font-size: 1.15rem; margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--error); font-size: 0.88rem; margin: 0; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.4rem; }
.brand.sm h1 { font-size: 1.1rem; }
.brand p { margin: 2px 0 0; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #7a5bff 100%);
  color: #fff; font-weight: 800; font-size: 1.05rem;
  box-shadow: 0 6px 20px -6px rgba(91,140,255,0.6);
}
.brand.sm .brand-mark { width: 34px; height: 34px; font-size: 0.9rem; border-radius: 10px; }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px -24px rgba(0,0,0,0.7);
}
.login-card .brand { margin-bottom: 26px; }

form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 0.8rem; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }

input, select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  color: var(--text);
  font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #5c6577; }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,140,255,0.18);
}

/* Chevron próprio (remove a seta nativa, que varia entre navegadores e cola no texto) */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23919aab' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  text-overflow: ellipsis;
}
select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%235b8cff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; cursor: pointer;
  font-size: 1rem; padding: 6px 8px; opacity: 0.7;
}
.pw-toggle:hover { opacity: 1; background: transparent; }

button {
  font-family: inherit;
  background: var(--accent);
  color: #fff; border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.98rem; font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
button:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary.block { width: 100%; padding: 13px; margin-top: 2px; }
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
button.ghost:hover { background: var(--card-2); color: var(--text); }
.hint { text-align: center; margin: 4px 0 0; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(12,14,19,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
#listView { max-width: 820px; margin-inline: auto; padding-bottom: 40px; }

/* ---------- Toolbar / filtros ---------- */
.toolbar { padding: 18px 20px 6px; }
.filters {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.select { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 110px; }
.select > span { font-size: 0.72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.select select { padding: 9px 32px 9px 11px; font-size: 0.92rem; cursor: pointer; }
.status { padding: 14px 20px 4px; margin: 0; }

/* ---------- Lista de documentos ---------- */
.doc-list { display: flex; flex-direction: column; gap: 10px; padding: 6px 20px 0; }
.doc {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color .15s, transform .08s;
}
.doc:hover { border-color: #344056; }
.doc:active { transform: scale(0.997); }

.doc-icon {
  width: 42px; height: 42px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  font-size: 1.2rem;
}
.doc-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.doc-title { display: flex; align-items: center; gap: 8px; }
.doc-title strong { font-size: 0.98rem; font-weight: 600; }
.doc-sub { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.7rem; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  white-space: nowrap;
}
.dot-new {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(81,208,138,0.18);
}
.doc-actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn-sm {
  background: var(--accent); color: #fff;
  text-decoration: none; border: 0;
  border-radius: 9px; padding: 8px 12px;
  font-size: 0.84rem; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background .15s;
}
.btn-sm:hover { background: var(--accent-dark); }
.btn-sm.ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn-sm.ghost:hover { background: #232a37; }

/* ---------- Estado vazio ---------- */
.empty {
  text-align: center; color: var(--muted);
  padding: 48px 20px; font-size: 0.92rem;
}
.empty .big { font-size: 2.2rem; display: block; margin-bottom: 10px; opacity: 0.7; }

/* ---------- Skeleton ---------- */
.skeleton {
  height: 74px; border-radius: var(--radius);
  background: linear-gradient(100deg, var(--card) 30%, var(--card-2) 50%, var(--card) 70%);
  background-size: 200% 100%;
  animation: sk 1.2s infinite;
}
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Modal PDF ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.9);
  display: flex; flex-direction: column;
}
.modal-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 11px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.modal-title { font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-actions { display: flex; gap: 8px; flex-shrink: 0; }
.modal-actions a { text-decoration: none; }
.modal-loading {
  position: absolute; inset: 52px 0 0; display: grid; place-items: center;
  color: var(--muted); font-size: 0.9rem; pointer-events: none;
}
#pdfFrame { flex: 1; border: 0; width: 100%; background: #525659; }

/* ---------- Nota "Reporte bugs" ---------- */
.bug-note {
  position: fixed;
  right: 14px; bottom: 12px;
  z-index: 4;
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(18,21,28,0.7);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 6px 12px;
}
.bug-note a {
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 600;
}
.bug-note a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .doc-actions .label { display: none; }
  .filters .select { min-width: 90px; }
}
