@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ================================
   RESET & BASE
================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #21262d;
  --bg-card-hover: #2d333b;
  --border: #30363d;
  --border-active: #484f58;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-subtle: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --info: #58a6ff;
  --purple: #bc8cff;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: all 0.15s;
  margin: 1px 8px;
  border-radius: var(--radius);
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text);
}

.nav-item.active {
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-bottom {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
  text-align: center;
}

/* Main content */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ================================
   COMPONENTS
================================ */

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.15s;
}

.card:hover {
  border-color: var(--border-active);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.stat-card:hover {
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-color, var(--accent));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-bg, rgba(88, 166, 255, .12));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-subtle);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card-hover);
  color: var(--text);
  border-color: var(--border-active);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-danger {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 81, 73, 0.25);
}

.btn-success {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
  border-color: rgba(63, 185, 80, 0.3);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

.btn-icon {
  padding: 7px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-pending {
  background: rgba(210, 153, 34, .15);
  color: var(--warning);
}

.badge-processed {
  background: rgba(63, 185, 80, .15);
  color: var(--success);
}

.badge-filtered {
  background: rgba(188, 140, 255, .15);
  color: var(--purple);
}

.badge-error {
  background: rgba(248, 81, 73, .15);
  color: var(--danger);
}

.badge-completed {
  background: rgba(63, 185, 80, .15);
  color: var(--success);
}

.badge-processing {
  background: rgba(88, 166, 255, .15);
  color: var(--accent);
}

.badge-inss_processado {
  background: rgba(0, 200, 150, .15);
  color: #00c896;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .1s;
}

.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.detail-value {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.detail-full {
  grid-column: 1 / -1;
}

.modal-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-secondary);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

tbody td {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
}

.td-muted {
  color: var(--text-muted);
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, .15);
}

.form-control::placeholder {
  color: var(--text-subtle);
}

select.form-control {
  cursor: pointer;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-active);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-secondary);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(88, 166, 255, .05);
}

.upload-zone .upload-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.upload-zone .upload-text {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.upload-zone .upload-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Progress bar */
.progress {
  height: 6px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 99px;
  transition: width 0.3s;
}

/* Filter sidebar layout */
.two-col {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

.filter-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: sticky;
  top: calc(var(--header-h) + 16px);
}

.filter-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  justify-content: center;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.page-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-success {
  background: rgba(63, 185, 80, .12);
  border: 1px solid rgba(63, 185, 80, .3);
  color: var(--success);
}

.alert-danger {
  background: rgba(248, 81, 73, .12);
  border: 1px solid rgba(248, 81, 73, .3);
  color: var(--danger);
}

.alert-info {
  background: rgba(88, 166, 255, .12);
  border: 1px solid rgba(88, 166, 255, .3);
  color: var(--accent);
}

.alert-warning {
  background: rgba(210, 153, 34, .12);
  border: 1px solid rgba(210, 153, 34, .3);
  color: var(--warning);
}

/* Checkbox */
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

input[type="radio"] {
  accent-color: var(--accent);
}

/* Misc */
.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.mt-16 {
  margin-top: 16px;
}

.text-muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

.text-sm {
  font-size: 12px;
}

.font-medium {
  font-weight: 500;
}

.font-bold {
  font-weight: 700;
}

.w-full {
  width: 100%;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state .empty-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.empty-state .empty-sub {
  font-size: 13px;
  color: var(--text-subtle);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  min-width: 260px;
  max-width: 380px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success {
  border-color: rgba(63, 185, 80, .4);
}

.toast-error {
  border-color: rgba(248, 81, 73, .4);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
}

/* Column select grid */
.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: background 0.1s;
}

.field-check:hover {
  background: var(--bg-card-hover);
}

.field-check label {
  cursor: pointer;
  font-size: 13px;
}

/* Upload list */
.upload-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-item .file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
}

.upload-item .file-size {
  font-size: 12px;
  color: var(--text-muted);
}

/* Recent activity */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  transition: background 0.1s;
}

.activity-item:hover {
  background: var(--bg-card-hover);
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: none;
  }

  .main {
    margin-left: 0;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hamburger {
    display: flex !important;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  background: transparent;
  border: none;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.2s;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}