:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #dde1e7;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

html, body { height: 100%; }

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

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: #1e2a3a;
  color: #c9d3e0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid #2d3d50;
}

.sidebar-logo h1 { color: #fff; font-size: 15px; font-weight: 700; }
.sidebar-logo small { color: #8a9ab0; font-size: 11px; }

.sidebar nav { flex: 1; padding: 12px 0; }

.nav-section { padding: 8px 16px 4px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; color: #5a7090; font-weight: 600; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: #c9d3e0; text-decoration: none;
  font-size: 13.5px; cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
  transition: background 0.15s;
}
.nav-link:hover { background: #2d3d50; color: #fff; }
.nav-link.active { background: #1d4ed8; color: #fff; }
.nav-link .icon { font-size: 16px; width: 20px; text-align: center; }

.main { margin-left: 220px; flex: 1; padding: 24px; }

.page { display: none; }
.page.active { display: block; }

/* Header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 700; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }

/* Stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 2px; }
.stat-card.danger .value { color: var(--danger); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.success .value { color: var(--success); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; text-decoration: none; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-success { background: var(--success); color: #fff; }

/* Filtros */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-end;
}
.filters select, .filters input {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px;
  background: var(--surface); color: var(--text);
}

/* Tabela */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  padding: 8px 12px; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* Status badges */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-aberto { background: #dbeafe; color: #1d4ed8; }
.badge-em_analise { background: #fef3c7; color: #92400e; }
.badge-acao_corretiva { background: #ede9fe; color: #6d28d9; }
.badge-em_verificacao { background: #ffedd5; color: #c2410c; }
.badge-encerrado { background: #dcfce7; color: #166534; }
.badge-pendente { background: #fee2e2; color: #991b1b; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-alerta { background: #fef3c7; color: #92400e; }

/* NPR colors */
.npr-low { color: var(--success); font-weight: 700; }
.npr-medium { color: var(--warning); font-weight: 700; }
.npr-high { color: var(--danger); font-weight: 700; }

/* Progress bar */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.progress-fill.low { background: var(--danger); }
.progress-fill.medium { background: var(--warning); }
.progress-fill.high { background: var(--success); }

/* Checklist card */
.etapa-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.etapa-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.etapa-header h3 { font-size: 14px; font-weight: 600; }
.etapa-pct { font-size: 22px; font-weight: 700; }
.etapa-itens { padding: 0; }
.item-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-row.pendente { background: #fff8f8; }
.item-check { width: 18px; height: 18px; cursor: pointer; }
.item-desc { flex: 1; font-size: 13px; }
.item-meta { font-size: 11px; color: var(--text-muted); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 10px;
  width: 90%; max-width: 680px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Form */
.form-row { display: grid; gap: 16px; margin-bottom: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px;
  background: var(--surface); color: var(--text);
  font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
}

/* Timeline */
.timeline { border-left: 2px solid var(--border); padding-left: 16px; }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -21px; top: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--surface);
}
.timeline-item .time { font-size: 11px; color: var(--text-muted); }
.timeline-item .msg { font-size: 13px; margin-top: 2px; }

/* Alerta de revisão */
.alerta-row { background: var(--warning-bg) !important; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1e2a3a; color: #fff;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; z-index: 9999;
  transform: translateY(80px); opacity: 0;
  transition: all 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }

/* ══════════════════════════════════════
   LOGIN — PCB Circuit aesthetic
   ══════════════════════════════════════ */
.lg-root {
  position: relative;
  height: 100vh;
  display: flex;
  background: #060c1a;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Animated canvas sits behind everything */
#lg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.9;
}

/* Radial vignette overlay */
.lg-root::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 80% at 40% 50%, transparent 30%, #060c1a 100%);
  pointer-events: none;
  z-index: 1;
}

/* ── Inner centered wrapper ── */
.lg-inner {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
}

/* ── Left panel ── */
.lg-left {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 40px 48px;
}

.lg-brand-wrap {
  position: absolute;
  top: 36px;
  left: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: lg-fade-up 0.7s ease both;
}

.lg-brand-text { display: flex; flex-direction: column; gap: 2px; }
.lg-brand-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #f1f5f9;
}
.lg-brand-sub {
  font-size: 11px;
  color: #475569;
  letter-spacing: 0.06em;
}

.lg-tagline {
  animation: lg-fade-up 0.7s 0.15s ease both;
}
.lg-headline {
  font-size: clamp(36px, 4.5vw, 58px);
  font-weight: 800;
  line-height: 1.05;
  color: #f8fafc;
  letter-spacing: -0.03em;
  text-wrap: balance;
  margin-bottom: 16px;
}
.lg-headline em {
  font-style: normal;
  background: linear-gradient(135deg, #60a5fa 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lg-desc {
  font-size: 14px;
  color: #64748b;
  line-height: 1.6;
  max-width: 360px;
}

.lg-stats {
  position: absolute;
  bottom: 36px;
  left: 48px;
  display: flex;
  align-items: center;
  gap: 20px;
  animation: lg-fade-up 0.7s 0.3s ease both;
}
.lg-stat { display: flex; flex-direction: column; gap: 3px; }
.lg-stat-v {
  font-size: 16px;
  font-weight: 700;
  color: #60a5fa;
  letter-spacing: -0.01em;
}
.lg-stat-l {
  font-size: 10px;
  color: #475569;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.lg-stat-div {
  width: 1px;
  height: 28px;
  background: #1e2d45;
}

/* ── Right panel ── */
.lg-right {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 420px;
  flex-shrink: 0;
  padding: 32px 40px;
}

.lg-card {
  width: 100%;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 32px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow:
    0 0 0 1px rgba(37,99,235,0.08),
    0 24px 56px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.06);
  animation: lg-card-in 0.8s 0.1s cubic-bezier(0.22,1,0.36,1) both;
}

.lg-card-header { margin-bottom: 24px; }
.lg-card-title {
  font-size: 20px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.lg-card-sub {
  font-size: 13px;
  color: #475569;
}

/* Form fields */
.lg-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }

.lg-field { display: flex; flex-direction: column; gap: 6px; }
.lg-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #64748b;
}
.lg-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.lg-input-icon {
  position: absolute;
  left: 14px;
  color: #334155;
  pointer-events: none;
  transition: color 0.2s;
}
.lg-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  font-size: 14px;
  color: #f1f5f9;
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.lg-input::placeholder { color: #334155; }
.lg-input:focus {
  border-color: rgba(37,99,235,0.6);
  background: rgba(37,99,235,0.06);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.lg-input:focus + .lg-input-icon,
.lg-input-wrap:focus-within .lg-input-icon {
  color: #60a5fa;
}

/* Submit button */
.lg-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 60%, #0284c7 100%);
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 24px rgba(37,99,235,0.35);
  margin-top: 4px;
}
.lg-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 32px rgba(37,99,235,0.5);
}
.lg-btn:active { transform: translateY(0); }

.lg-btn-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
  pointer-events: none;
}
.lg-btn-arrow {
  font-size: 16px;
  transition: transform 0.2s;
}
.lg-btn:hover .lg-btn-arrow { transform: translateX(3px); }

/* Shimmer sweep on hover */
.lg-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.5s;
}
.lg-btn:hover::after { left: 150%; }

/* Error */
.lg-erro {
  font-size: 12px;
  color: #f87171;
  min-height: 16px;
  padding: 0 2px;
}

/* Footer link */
.lg-footer {
  text-align: center;
  font-size: 13px;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.lg-link {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}
.lg-link:hover { color: #93c5fd; }

/* Animations */
@keyframes lg-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes lg-card-in {
  from { opacity: 0; transform: translateX(32px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 860px) {
  .lg-inner { flex-direction: column; height: auto; min-height: 100%; }
  .lg-left {
    gap: 20px;
    padding: 80px 24px 24px;
    flex: none;
  }
  .lg-headline { font-size: 32px; }
  .lg-stats { display: none; }
  .lg-brand-wrap { left: 24px; }
  .lg-right {
    width: 100%;
    padding: 0 20px 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lg-brand-wrap, .lg-tagline, .lg-stats, .lg-card { animation: none; }
}

/* Custo total destaque */
.custo-total { font-size: 22px; font-weight: 700; color: var(--danger); }

/* Dashboard */
.chart-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.stat-card .value.success { color: var(--success); }
.kpi-trend { font-size: 11px; margin-top: 4px; }
.kpi-trend.up { color: var(--danger); }
.kpi-trend.down { color: var(--success); }

@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; height: auto; }
  .main { margin-left: 0; padding: 16px; }
  .layout { flex-direction: column; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
}
