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

:root {
  --tg-theme-bg-color: #ffffff;
  --tg-theme-text-color: #000000;
  --tg-theme-hint-color: #999999;
  --tg-theme-link-color: #2481cc;
  --tg-theme-button-color: #2481cc;
  --tg-theme-button-text-color: #ffffff;
  --primary-color: #2481cc;
  --success-color: #4caf50;
  --danger-color: #f44336;
  --warning-color: #ff9800;
  --border-color: #e0e0e0;
  --bg-light: #f5f5f5;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  line-height: 1.6;
  padding: 0;
  margin: 0;
}

.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.header {
  background: var(--primary-color);
  color: white;
  padding: 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header {
  position: relative;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.back-button {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background-color 0.2s;
  z-index: 101;
}

.back-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.back-button:active {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Navigation */
.nav {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 56px;
  z-index: 99;
}

.nav-item {
  flex: 1;
  padding: 12px;
  text-align: center;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--tg-theme-text-color);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-item.active {
  border-bottom-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: 600;
}

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

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

.card-subtitle {
  font-size: 12px;
  color: var(--tg-theme-hint-color);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
  text-align: center;
  text-decoration: none;
}

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

.btn-success {
  background: var(--success-color);
  color: white;
}

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

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

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

.btn-block {
  width: 100%;
  display: block;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 12px;
}

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

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--tg-theme-hint-color);
}

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

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--tg-theme-hint-color);
}

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

/* Badge */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success {
  background: #e8f5e9;
  color: var(--success-color);
}

.badge-warning {
  background: #fff3e0;
  color: var(--warning-color);
}

.badge-danger {
  background: #ffebee;
  color: var(--danger-color);
}

.badge-info {
  background: #e3f2fd;
  color: var(--primary-color);
}

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

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--tg-theme-hint-color);
}

/* Chat */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.message {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.message.own {
  align-items: flex-end;
}

.message-content {
  max-width: 70%;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-light);
}

.message.own .message-content {
  background: var(--primary-color);
  color: white;
}

.message-author {
  font-size: 12px;
  color: var(--tg-theme-hint-color);
  margin-bottom: 4px;
}

.message.own .message-author {
  text-align: right;
}

.message-time {
  font-size: 11px;
  color: var(--tg-theme-hint-color);
  margin-top: 4px;
}

.chat-input-container {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: white;
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  font-size: 14px;
}

.chat-send-btn {
  padding: 12px 24px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 24px;
  cursor: pointer;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  padding: 16px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--primary-color);
}

.stat-label {
  font-size: 12px;
  color: var(--tg-theme-hint-color);
  margin-top: 4px;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 12px;
  }
  
  .card {
    padding: 12px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Utilities */
.text-center {
  text-align: center;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hidden {
  display: none;
}


