:root {
  --color-primary: #6D4AFF;
  --color-primary-dark: #6B46C1;
  --color-lavender: #F3F0FF;
  --color-success: #34D399;
  --color-warning: #FEF3C7;
  --color-text: #1F2937;
  --color-muted: #6B7280;
  --radius-card: 20px;
  --shadow-card: 0 4px 24px rgba(107, 70, 193, 0.08);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--color-text);
  margin: 0;
  background: #FAFAFF;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s ease;
}

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

.btn-secondary {
  background: var(--color-lavender);
  color: var(--color-primary-dark);
}
.btn-secondary:hover { background: #E8E0FF; }

.btn-outline {
  background: white;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.card {
  background: white;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.input-group label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text);
}

.input-field {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 2.75rem;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  font-size: 1rem;
  background: white;
  transition: border-color 0.15s;
}
.input-field:focus {
  outline: none;
  border-color: var(--color-primary);
}

.input-wrapper {
  position: relative;
}
.input-wrapper .input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-pro { background: var(--color-lavender); color: var(--color-primary-dark); }

.region-card {
  border: 2px solid #E5E7EB;
  border-radius: 16px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
}
.region-card:hover { border-color: #C4B5FD; }
.region-card.selected {
  border-color: var(--color-primary);
  background: var(--color-lavender);
}
.region-card--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.region-card--disabled:hover {
  border-color: #E5E7EB;
}

.stat-card {
  background: white;
  border-radius: var(--radius-card);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary-dark);
}
.stat-card .stat-label {
  color: var(--color-muted);
  font-size: 0.875rem;
}
.stat-card .stat-change {
  font-size: 0.75rem;
  color: var(--color-success);
}

.sidebar {
  width: 260px;
  min-height: 100vh;
  background: white;
  border-right: 1px solid #F0F0F5;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.75rem 1.5rem;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-primary-dark);
  text-decoration: none;
}
.sidebar-nav { flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  color: var(--color-muted);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--color-lavender);
  color: var(--color-primary);
}

.tip-box {
  background: var(--color-warning);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.proxy-chrome {
  background: var(--color-primary);
  color: white;
  padding: 0.75rem 1rem;
}
.proxy-status {
  background: var(--color-lavender);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--color-primary-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.proxy-footer {
  background: var(--color-primary);
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  text-align: center;
}

.alert-error {
  background: #FEE2E2;
  color: #991B1B;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 24rem;
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  font-size: 0.875rem;
}
.toast--success { background: #D1FAE5; color: #065F46; }
.toast--error { background: #FEE2E2; color: #991B1B; }
.toast--warning { background: #FEF3C7; color: #92400E; }
.toast--info { background: #DBEAFE; color: #1E40AF; }

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

.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

.dashboard-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dashboard-main {
  flex: 1;
  padding: 2rem;
  overflow-x: auto;
}

.mobile-header {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-close {
  display: none;
}

.sidebar-header .sidebar-logo {
  padding-bottom: 0;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.list-row__meta {
  flex-shrink: 0;
  text-align: right;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
}

.btn-group .btn {
  flex: 1;
}

.copy-field {
  display: flex;
  gap: 0.5rem;
}

.copy-field .input-field {
  flex: 1;
  min-width: 0;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .grid-2, .grid-4 { grid-template-columns: 1fr; }

  .dashboard-layout {
    flex-direction: column;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid #F0F0F5;
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .mobile-header__logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--color-primary-dark);
    text-decoration: none;
  }

  .mobile-header__toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
  }

  .mobile-header__toggle:hover {
    background: var(--color-lavender);
  }

  .mobile-header__toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-primary-dark);
    border-radius: 1px;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 30;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: 280px;
    max-width: 85vw;
    min-height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    border-right: 1px solid #F0F0F5;
    overflow-y: auto;
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--color-muted);
    cursor: pointer;
    border-radius: 8px;
  }

  .sidebar-close:hover {
    background: var(--color-lavender);
    color: var(--color-primary);
  }

  .sidebar-header .sidebar-logo {
    padding: 0 0.75rem;
  }

  .dashboard-main {
    padding: 1rem;
  }

  .card {
    padding: 1rem;
  }

  .chart-container {
    padding: 1rem;
  }

  .list-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .list-row__meta {
    align-self: flex-start;
    text-align: left;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
  }

  .copy-field {
    flex-direction: column;
  }

  .copy-field .btn {
    width: 100%;
  }

  .tip-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .tab {
    flex-shrink: 0;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  .page-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }
}

@media (min-width: 769px) {
  .sidebar {
    position: sticky;
    top: 0;
    flex-shrink: 0;
  }

  .sidebar-header .sidebar-logo {
    padding-bottom: 1.5rem;
  }
}

[x-cloak] { display: none !important; }

.tab {
  padding: 0.5rem 1.25rem;
  border-radius: 999px;
  border: none;
  background: #F3F4F6;
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  color: var(--color-muted);
}
.tab.active { background: var(--color-primary); color: white; }

.progress-bar {
  height: 8px;
  background: #F3F4F6;
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
}

.chart-container {
  background: white;
  border-radius: var(--radius-card);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}
