:root {
  --bg-body: #09090b;
  --bg-card: #18181b;
  --bg-card-hover: #27272a;
  --bg-input: #27272a;

  --border-color: #27272a;
  --border-hover: #3f3f46;

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-text: #ffffff;

  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

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

.sidebar {
  width: 260px;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background-color: var(--bg-input);
  color: var(--text-primary);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.user-profile {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
}

.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  height: 100vh;
}

/* Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-title h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.025em;
}

.page-title p {
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}

.actions {
  display: flex;
  gap: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: var(--accent-text);
}

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

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-ghost:hover {
  background-color: var(--bg-input);
  color: var(--text-primary);
}

.btn-danger {
  background-color: transparent;
  color: var(--danger);
  border-color: var(--border-color);
}

.btn-danger:hover {
  border-color: var(--danger);
  background-color: rgba(239, 68, 68, 0.1);
}

/* Cards & KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

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

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
}

.kpi-card .label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.kpi-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.kpi-card .trend {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.trend.up {
  color: var(--success);
}

.trend.down {
  color: var(--danger);
}

/* Tables */
.table-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-title h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.table-controls {
  display: flex;
  gap: 1rem;
}

.search-input {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  width: 240px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

select {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 2rem 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23a1a1aa' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
}

.table-responsive {
  overflow-x: auto;
}

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

th {
  text-align: left;
  padding: 0.75rem 1.5rem;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  background-color: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 1rem 1.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-color);
}

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

tbody tr {
  transition: background-color 0.1s;
  cursor: pointer;
}

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

/* Auth */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-body);
}

.auth-box {
  background-color: var(--bg-card);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}

.auth-header p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.875rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.btn-full {
  width: 100%;
  margin-top: 1rem;
}

.error-message,
.success-message {
  padding: 0.75rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
  text-align: center;
  font-size: 0.875rem;
}

.error-message {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.success-message {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

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

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

.kpi-card,
.chart-grid .card,
.table-container {
  animation: fadeIn 0.4s ease-out forwards;
}

.kpi-card:nth-child(1) {
  animation-delay: 0.1s;
}

.kpi-card:nth-child(2) {
  animation-delay: 0.2s;
}

.kpi-card:nth-child(3) {
  animation-delay: 0.3s;
}

.kpi-card:nth-child(4) {
  animation-delay: 0.4s;
}

.chart-grid .card:nth-child(1) {
  animation-delay: 0.5s;
}

.chart-grid .card:nth-child(2) {
  animation-delay: 0.6s;
}

.chart-grid .card:nth-child(3) {
  animation-delay: 0.7s;
}

.table-section {
  animation-delay: 0.8s;
  opacity: 0;
  animation: fadeIn 0.4s ease-out 0.8s forwards;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Responsive */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar-header {
    margin-bottom: 1rem;
  }

  .nav-links {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }

  .main-content {
    padding: 1rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .table-controls {
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }
}

/* View Switching */
.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}