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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0F172A;
  color: #F8FAFC;
  min-height: 100vh;
}

a { color: inherit; }

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: #111827;
  border: 1px solid #1E293B;
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-card h1 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.login-card p.subtitle {
  color: #94A3B8;
  font-size: 0.85rem;
  margin-bottom: 24px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 0.75rem;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  background: #0F172A;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  color: #F8FAFC;
  font-size: 0.95rem;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: #2563EB;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary { background: #2563EB; color: white; width: 100%; }
.btn-primary:hover { background: #1D4ED8; }
.btn-secondary { background: #1E293B; color: #F8FAFC; border: 1px solid #334155; }
.btn-secondary:hover { background: #334155; }

.error-msg {
  background: #7F1D1D;
  color: #FECACA;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  margin-bottom: 16px;
}

/* ===== APP ===== */
.app-container {
  display: flex;
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #111827;
  border: 1px solid #1E293B;
  border-radius: 16px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar h2 {
  font-size: 0.75rem;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #1E293B;
  padding-bottom: 10px;
}

.empresa-info div { font-size: 0.85rem; margin-bottom: 4px; color: #CBD5E1; }
.empresa-info strong { color: #F8FAFC; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: #111827;
  border: 1px solid #1E293B;
  border-radius: 16px;
  padding: 20px;
}

.card h2 { font-size: 1rem; margin-bottom: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.table-container { overflow-x: auto; border-radius: 12px; border: 1px solid #1E293B; }

table { width: 100%; border-collapse: collapse; background: #0F172A; font-size: 12px; min-width: 900px; }

th {
  background: #0F172A;
  color: #94A3B8;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  border-bottom: 2px solid #1E293B;
  white-space: nowrap;
}

td { padding: 8px 12px; border-bottom: 1px solid #1E293B; color: #E2E8F0; white-space: nowrap; }

tbody tr:nth-child(even) { background: #0F172A; }
tbody tr:nth-child(odd) { background: #111827; }

.valor-destaque { font-weight: 700; color: #10B981; }

.button-row { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

.top-bar { display: flex; justify-content: space-between; align-items: center; }

.hidden { display: none !important; }

/* ===== SHELL MASTER (Empresas / Usuarios) ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.rail {
  width: 96px;
  flex-shrink: 0;
  background: #111827;
  border-right: 1px solid #1E293B;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px;
  gap: 24px;
}

.rail-top { display: flex; justify-content: center; }

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #2563EB;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
}

.rail-nav { display: flex; flex-direction: column; gap: 8px; width: 100%; }

.rail-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 6px;
  color: #94A3B8;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.rail-btn:hover { background: #1E293B; color: #F8FAFC; }
.rail-btn[aria-current="page"] { background: rgba(37, 99, 235, 0.16); color: #60A5FA; }

.content { flex: 1; min-width: 0; padding: 24px 32px; display: flex; flex-direction: column; gap: 20px; }

.top-row { display: flex; align-items: center; justify-content: space-between; }
.top-row h2 { font-size: 1.2rem; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}
.status-pill.on { background: rgba(16, 185, 129, 0.14); color: #10B981; }
.status-pill.off { background: rgba(239, 68, 68, 0.14); color: #F87171; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 380px;
  background: #111827;
  border: 1px solid #1E293B;
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.modal h3 { margin-bottom: 18px; }
.modal.modal-wide { max-width: 560px; max-height: 88vh; overflow-y: auto; }

/* ===== MOTOR (accordion + upload cards) ===== */
.motor-shell { min-height: 100vh; display: flex; flex-direction: column; }

.motor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #1E293B;
}
.motor-topbar h1 { font-size: 1.05rem; font-weight: 600; }

.motor-body { flex: 1; display: flex; gap: 16px; padding: 16px; align-items: flex-start; }

.config-col {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.config-heading {
  font-size: 0.75rem;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 10px;
  border-bottom: 1px solid #1E293B;
}

.config-subheading {
  font-size: 0.75rem;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 18px 0 10px;
}

.accordion-item {
  background: #111827;
  border: 1px solid #1E293B;
  border-radius: 12px;
  overflow: hidden;
}

.accordion-header {
  width: 100%;
  background: none;
  border: none;
  color: #F8FAFC;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.accordion-header:hover { background: #1E293B; }
.accordion-header .chevron { color: #94A3B8; transition: transform 0.15s ease; }

.accordion-body {
  padding: 0 16px 16px;
  display: none;
}
.accordion-item.open .accordion-body { display: block; }
.accordion-item.open .chevron { transform: rotate(180deg); }

.empresa-readonly {
  background: #0F172A;
  border: 1px solid #1E293B;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}
.empresa-readonly div { color: #CBD5E1; }
.empresa-readonly strong { color: #F8FAFC; }

.field-hint { display: block; font-size: 0.72rem; color: #64748B; margin-top: -4px; margin-bottom: 6px; }

.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: #E2E8F0;
  cursor: pointer;
}
.radio-group input[type="radio"] { accent-color: #2563EB; width: 16px; height: 16px; }

.work-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.upload-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .upload-row { grid-template-columns: 1fr; } }

.upload-card {
  position: relative;
  background: #111827;
  border: 1px solid #1E293B;
  border-radius: 14px;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
}
.upload-card .upload-icon { font-size: 1.8rem; }
.upload-card strong { font-size: 0.95rem; }
.upload-card .upload-sub { font-size: 0.78rem; color: #94A3B8; margin-bottom: 10px; }
.upload-card .upload-drop {
  border: 1.5px dashed #334155;
  border-radius: 10px;
  padding: 14px;
  font-size: 0.8rem;
  color: #94A3B8;
  width: 100%;
}
.upload-card:hover .upload-drop { border-color: #2563EB; color: #F8FAFC; }
.upload-card input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.status-text { color: #94A3B8; font-size: 0.85rem; }

.mono { font-family: 'SFMono-Regular', Consolas, monospace; }

.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat-tile {
  background: #0F172A;
  border: 1px solid #1E293B;
  border-radius: 12px;
  padding: 16px 8px;
  text-align: center;
}
.stat-num { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.68rem; color: #94A3B8; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }

.preview-search-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.preview-search-row input {
  flex: 1;
  background: #0F172A;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 9px 12px;
  color: #F8FAFC;
  font-size: 0.9rem;
}
.preview-search-row input:focus { outline: none; border-color: #2563EB; }

.preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }

.btn-expandir {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1E293B;
  color: #94A3B8;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.btn-expandir:hover { background: #334155; color: #F8FAFC; }
.btn-expandir.aberto { background: #2563EB; color: white; border-color: #2563EB; }

.linha-detalhe td { background: #0B1220; padding: 16px 20px; }
.detalhe-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.detalhe-grupo h4 {
  font-size: 0.7rem;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  border-bottom: 1px solid #1E293B;
  padding-bottom: 6px;
}
.detalhe-item { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 3px 0; }
.detalhe-item span:first-child { color: #94A3B8; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #1E293B;
  border-top-color: #2563EB;
  border-radius: 50%;
  margin: 0 auto;
  animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

.barra-progresso {
  width: 100%;
  height: 10px;
  background: #1E293B;
  border-radius: 999px;
  overflow: hidden;
}
.barra-progresso-preenchida {
  height: 100%;
  width: 0%;
  background: #2563EB;
  border-radius: 999px;
  transition: width 0.3s ease;
}
