:root {
  --bg:        #0f1117;
  --bg2:       #1a1d27;
  --bg3:       #23273a;
  --border:    #2e3348;
  --text:      #e2e4ef;
  --text-muted:#7b82a0;
  --primary:   #5c6ef8;
  --primary-h: #4455e8;
  --success:   #22c55e;
  --warn:      #f59e0b;
  --danger:    #ef4444;
  --radius:    8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Container ── */
.container { max-width: 900px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

/* ── Navbar ── */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.5rem;
  position: sticky; top: 0; z-index: 50;
}
.navbar .brand { font-size: 1.25rem; font-weight: 700; color: var(--primary); letter-spacing: 2px; }
.nav-links { display: flex; align-items: center; gap: 1.25rem; }
.nav-links a { color: var(--text-muted); font-size: .9rem; transition: color .15s; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.btn-logout { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: .3rem .9rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.25rem; border-radius: var(--radius);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  border: none; transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-full { width: 100%; justify-content: center; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: .85rem; padding: 0; }
.btn-link:hover { text-decoration: underline; }

/* ── Auth pages ── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 2.5rem 2rem; width: 100%; max-width: 380px;
}
.auth-logo { text-align: center; font-size: 2rem; color: var(--primary); letter-spacing: 4px; margin-bottom: .25rem; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: .85rem; margin-bottom: 1.75rem; }
.auth-card label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: .3rem; margin-top: 1rem; }
.auth-card input { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .85rem; color: var(--text); font-size: .95rem; }
.auth-card input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.auth-card .btn { margin-top: 1.5rem; }

/* ── Alerts ── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #3b1111; border: 1px solid var(--danger); color: #fca5a5; }
.alert-ok    { background: #0f2e1a; border: 1px solid var(--success); color: #86efac; }
.alert-warn  { background: #2d2000; border: 1px solid var(--warn); color: #fcd34d; }

/* ── Dashboard ── */
.dashboard-hero { margin-bottom: 2rem; }
.dashboard-hero h1 { font-size: 1.75rem; }
.dashboard-hero p  { color: var(--text-muted); }
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.dash-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.5rem; display: flex; flex-direction: column; gap: .5rem;
  color: var(--text); transition: border-color .15s, transform .1s;
}
.dash-card:hover { border-color: var(--primary); transform: translateY(-2px); text-decoration: none; }
.dash-icon { font-size: 1.75rem; }
.dash-card strong { font-size: 1.05rem; }
.dash-card span { font-size: .82rem; color: var(--text-muted); }

/* ── Dropzone ── */
.page-sub { color: var(--text-muted); margin-bottom: 1.5rem; }
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px;
  background: var(--bg2); padding: 3rem 2rem; text-align: center;
  cursor: pointer; transition: border-color .2s, background .2s;
}
.dropzone.drag-over { border-color: var(--primary); background: #1a1f3a; }
.dz-icon { font-size: 2.5rem; }
.dropzone p { color: var(--text-muted); margin-top: .75rem; }

.file-list { list-style: none; margin: 1rem 0; display: flex; flex-direction: column; gap: .4rem; }
.file-list li {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .5rem .85rem; display: flex; justify-content: space-between; align-items: center;
  font-size: .88rem;
}
.file-list .file-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; }

.upload-actions { display: flex; gap: .75rem; margin-top: 1.25rem; }

/* ── Spinner ── */
.spinner-overlay {
  position: fixed; inset: 0; background: rgba(15,17,23,.85);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
.spinner-box { text-align: center; }
.spinner {
  width: 48px; height: 48px; border: 4px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Resultado ── */
.result-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.result-header h2 { font-size: 1.5rem; }

.badge { font-size: .75rem; font-weight: 700; padding: .25rem .65rem; border-radius: 20px; text-transform: uppercase; }
.badge-concluida { background: #0f2e1a; color: var(--success); border: 1px solid var(--success); }
.badge-processando { background: #2d2000; color: var(--warn); border: 1px solid var(--warn); }
.badge-erro { background: #3b1111; color: var(--danger); border: 1px solid var(--danger); }

.meta-boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.meta-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem 1rem;
}
.meta-label { display: block; font-size: .75rem; color: var(--text-muted); margin-bottom: .2rem; }
.meta-value { font-size: .95rem; font-weight: 600; }

.verdict-card {
  background: linear-gradient(135deg, #1a1f3a, #1e233b);
  border: 1px solid var(--primary); border-radius: 10px;
  padding: 1.25rem 1.5rem; margin-bottom: 1.25rem;
}
.verdict-decisao { font-size: 1.15rem; font-weight: 800; color: var(--primary); margin-bottom: .5rem; }
.verdict-text { color: var(--text-muted); font-size: .93rem; }

.viab-badge {
  display: inline-block; padding: .4rem 1rem; border-radius: 20px;
  font-size: .85rem; margin-bottom: 1.5rem; font-weight: 600;
}
.viab-badge.viab-ALTA, .viab-inline.viab-ALTA { background: #0f2e1a; color: var(--success); border: 1px solid var(--success); }
.viab-badge.viab-MÉDIA, .viab-inline.viab-MÉDIA { background: #2d2000; color: var(--warn); border: 1px solid var(--warn); }
.viab-badge.viab-BAIXA, .viab-inline.viab-BAIXA { background: #2e1a00; color: #fb923c; border: 1px solid #fb923c; }
.viab-badge.viab-INVIÁVEL, .viab-inline.viab-INVIÁVEL { background: #3b1111; color: var(--danger); border: 1px solid var(--danger); }
.viab-inline { font-size: .78rem; padding: .2rem .6rem; border-radius: 12px; font-weight: 600; }

.secoes-title { margin-bottom: .75rem; color: var(--text-muted); font-size: 1rem; font-weight: 600; }
.secoes { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.secao-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.secao-box summary {
  padding: .75rem 1rem; cursor: pointer; font-weight: 600; font-size: .9rem;
  list-style: none; user-select: none; transition: background .15s;
}
.secao-box summary:hover { background: var(--bg3); }
.secao-box[open] summary { border-bottom: 1px solid var(--border); }
.secao-content { padding: 1rem; }
.secao-content pre { white-space: pre-wrap; font-family: inherit; font-size: .88rem; color: var(--text-muted); }
.full-text { margin-top: .5rem; }

.arquivos-list { margin: 1.5rem 0; font-size: .85rem; color: var(--text-muted); }
.arquivos-list ul { margin-top: .4rem; padding-left: 1.2rem; }
.arquivos-list li { margin-bottom: .2rem; }

.result-actions { display: flex; gap: .75rem; margin-top: 2rem; }

/* ── Histórico ── */
h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.search-form { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 200px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .55rem .85rem; color: var(--text);
}
.search-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th {
  text-align: left; padding: .6rem 1rem; background: var(--bg2);
  border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 600;
}
.data-table td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg2); }
.row-status-erro td:first-child { border-left: 3px solid var(--danger); }
.row-status-processando td:first-child { border-left: 3px solid var(--warn); }

.empty-state { text-align: center; color: var(--text-muted); padding: 3rem 0; }

/* ── Usuários ── */
.section-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; }
.section-card h3 { margin-bottom: 1rem; font-size: 1rem; color: var(--text-muted); }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .5rem .75rem; color: var(--text); font-size: .88rem;
}
.inline-form select { background: var(--bg3); }

/* ── Error page ── */
.error-page { text-align: center; padding: 5rem 0; }
.error-page h1 { font-size: 2rem; margin-bottom: 1rem; }
.error-page p { color: var(--text-muted); margin-bottom: 2rem; }
