/* Telegram Web App Theme */
:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #222);
  --hint: var(--tg-theme-hint-color, #999);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #fff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --section-bg: var(--tg-theme-section-bg-color, #fff);
  --section-separator: var(--tg-theme-section-separator-color, #e0e0e0);
  --accent: var(--tg-theme-accent-text-color, #2481cc);
  --destructive: #e53935;
  --success: #43a047;
  --radius: 12px;
}

* { 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;
  padding: 0 0 24px 0;
}

#app { max-width: 500px; margin: 0 auto; padding: 0 16px; }

header {
  text-align: center;
  padding: 24px 0 16px;
}

header h1 { font-size: 28px; font-weight: 700; }
.subtitle { color: var(--hint); font-size: 14px; margin-top: 4px; }

/* Уведомления */
#notification {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

#notification.success { background: #e8f5e9; color: #2e7d32; }
#notification.error { background: #ffebee; color: #c62828; }
#notification.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Табы */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--secondary-bg);
  color: var(--hint);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: var(--button);
  color: var(--button-text);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Форма */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.field .required { color: var(--destructive); }

.field input, .field textarea, .field select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--section-separator);
  border-radius: var(--radius);
  background: var(--section-bg);
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.2s;
  outline: none;
  font-family: inherit;
}

.field input:focus, .field textarea:focus {
  border-color: var(--button);
}

.field textarea { resize: vertical; min-height: 50px; }

.field input::placeholder, .field textarea::placeholder {
  color: var(--hint);
  font-size: 14px;
}

/* Кнопки */
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--button);
  color: var(--button-text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 4px;
}

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

.btn-primary:not(:disabled):hover {
  opacity: 0.9;
}

.btn-small {
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

/* Список контактов */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: var(--hint);
  font-size: 14px;
  font-weight: 500;
}

.contact-card {
  background: var(--section-bg);
  border: 1px solid var(--section-separator);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.contact-info { flex: 1; }

.contact-name {
  font-size: 16px;
  font-weight: 600;
}

.contact-details {
  font-size: 13px;
  color: var(--hint);
  margin-top: 3px;
}

.contact-details span {
  margin-right: 8px;
}

.contact-style {
  font-size: 12px;
  color: var(--hint);
  margin-top: 6px;
  font-style: italic;
  line-height: 1.4;
}

.contact-actions {
  display: flex;
  gap: 6px;
}

.btn-delete {
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: #ffebee;
  color: var(--destructive);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.loading, .empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--hint);
  font-size: 14px;
}

.empty-state { font-size: 16px; }

/* Модалка */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 24px;
  width: 300px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.modal-content p {
  font-size: 16px;
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
}

.btn-danger, .btn-secondary {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger { background: var(--destructive); color: #fff; }
.btn-secondary { background: var(--secondary-bg); color: var(--text); }
