:root {
  --bg: #0b1220;
  --card: #111827;
  --card-hover: #1a2332;
  --border: #1f2937;
  --muted: #9ca3af;
  --text: #e5e7eb;
  --accent: #22c55e;
  --accent-dim: rgba(34, 197, 94, 0.15);
  --danger: #ef4444;
  --warn: #f59e0b;
  --info: #3b82f6;
}

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

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

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
}

.back-link:hover { opacity: 0.8; }

.header-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.user-badge {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Main */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
}

/* Filter Panel */
.filter-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

.filter-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
}

.filter-actions {
  flex: 0 0 auto;
  min-width: auto;
}

select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  width: 100%;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.btn-accent {
  background: var(--accent);
  color: #000;
}

.btn-accent:hover:not(:disabled) {
  background: #16a34a;
}

.btn-export {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
}

.btn-export:hover {
  background: var(--card-hover);
  border-color: var(--muted);
}

.btn-pdf:hover { border-color: var(--danger); color: var(--danger); }
.btn-csv:hover { border-color: var(--accent); color: var(--accent); }
.btn-excel:hover { border-color: var(--info); color: var(--info); }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

/* Report Section */
.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.report-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.report-subtitle {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.export-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Data Table */
.table-wrapper {
  padding: 0;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 600px;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
}

.data-table tbody tr:hover {
  background: var(--card-hover);
}

.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:nth-child(even):hover {
  background: var(--card-hover);
}

.data-table tfoot td {
  background: var(--bg);
  font-weight: 700;
  color: var(--accent);
  border-top: 2px solid var(--accent);
  border-bottom: none;
}

/* Chart */
.chart-wrapper {
  position: relative;
}

.chart-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 400px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #fff;
  background: var(--card);
  border: 1px solid var(--border);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}

.toast.success { border-color: var(--accent); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(1rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .main { padding: 1rem; }

  .filter-row {
    flex-direction: column;
  }

  .filter-group {
    min-width: 100%;
  }

  .filter-actions {
    min-width: 100%;
  }

  .filter-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .report-header {
    flex-direction: column;
  }

  .export-actions {
    width: 100%;
  }

  .export-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .chart-container {
    height: 300px;
  }

  .header-title {
    font-size: 1rem;
  }
}
