:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #252525;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --danger: #ef4444;
  --border: #333;
  --radius: 12px;
}

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

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

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.auth-status {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.auth-status.active {
  color: var(--success);
}

/* Navigation */
.nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.nav-btn {
  padding: 0.75rem 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

.nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Content */
.content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--border);
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.tab h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.tab h3 {
  font-size: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.hint {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.manager-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.manager-stat {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid var(--border);
}

.manager-stat .name {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.manager-stat .amount {
  color: var(--success);
  font-weight: 600;
}

.manager-stat .count {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Forms */
.add-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.add-form input {
  flex: 1;
  min-width: 150px;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
}

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

.add-form button,
button[type="submit"] {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.add-form button:hover,
button[type="submit"]:hover {
  background: var(--accent-hover);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

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

.data-table th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  font-size: 0.875rem;
}

.data-table tr:hover {
  background: var(--bg-tertiary);
}

.data-table .delete-btn {
  padding: 0.375rem 0.75rem;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: 6px;
  color: var(--danger);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.data-table .delete-btn:hover {
  background: var(--danger);
  color: white;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge.active {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.badge.inactive {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.badge.osnova {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
}

.badge.obshaya {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
}

.modal-content h2 {
  margin-bottom: 1.5rem;
  text-align: center;
}

.modal-content form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-content input {
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
}

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

/* Responsive */
@media (max-width: 640px) {
  .app {
    padding: 1rem;
  }
  
  .header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .content {
    padding: 1rem;
  }
  
  .data-table {
    font-size: 0.75rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.5rem;
  }
}

/* Check link with preview */
.check-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 6px;
  transition: all 0.2s;
}

.check-link:hover {
  background: rgba(99, 102, 241, 0.2);
}

.check-link::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) scale(0);
  width: 500px;
  height: 400px;
  background-image: var(--preview-url);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 100;
  margin-bottom: 8px;
}

.check-link:hover::after {
  transform: translateX(-50%) scale(1);
  opacity: 1;
}

/* Image Modal */
.image-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; z-index: 9999; cursor: zoom-out; opacity: 0; visibility: hidden; transition: all 0.3s ease; }
.image-modal.active { opacity: 1; visibility: visible; }
.image-modal img { max-width: 90vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 10px 50px rgba(0,0,0,0.5); object-fit: contain; }
.image-modal .close-btn { position: absolute; top: 20px; right: 30px; font-size: 2rem; color: white; cursor: pointer; opacity: 0.7; transition: opacity 0.2s; }
.image-modal .close-btn:hover { opacity: 1; }
