:root {
  --primary: #075E54;
  --primary-light: #128C7E;
  --primary-dark: #054D44;
  --secondary: #25D366;
  --accent: #34B7F1;
  --warning: #f39c12;
  --danger: #e74c3c;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
  --transition: all 0.2s ease;
}

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

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

.navbar {
  background: var(--primary);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(7,94,84,0.2);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 60px;
  gap: 8px;
}

.nav-brand {
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 24px;
}

.nav-brand::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 28px;
  background: var(--secondary);
  border-radius: 8px;
}

.nav-links {
  display: flex;
  gap: 2px;
  overflow-x: auto;
}

.nav-link {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

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

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
  cursor: default;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.card-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 12px;
}

.card-info { flex: 1; }
.card-value { font-size: 26px; font-weight: 700; display: block; color: var(--text); }
.card-label { font-size: 12px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }

.panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.panel h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.panel h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  font-size: 14px;
}

.table th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fffe; }
.table .empty { text-align: center; color: var(--text-light); padding: 40px; font-style: italic; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  gap: 4px;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }
.badge-sm { font-size: 11px; padding: 2px 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  line-height: 1.4;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #6b7280; color: #fff; }
.btn-success { background: var(--secondary); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary-light); }

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

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: var(--transition);
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(18,140,126,0.1);
}

.form-group textarea { resize: vertical; min-height: 100px; }
.form-group small { display: block; margin-top: 4px; color: var(--text-light); font-size: 12px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.form-actions { display: flex; gap: 12px; margin-top: 20px; }

.checkbox-group { margin-bottom: 8px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
}

.checkbox-label:hover { background: #f0fdf4; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary-light); }

.contacts-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 28px;
  max-width: 560px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow-lg);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-lg { max-width: 720px; }
.modal-qr { text-align: center; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: var(--transition);
}

.modal-close:hover { color: var(--text); background: var(--bg); }

.qr-image { margin: 20px auto; text-align: center; }
.qr-image img { max-width: 280px; border-radius: 12px; box-shadow: var(--shadow-lg); }
.qr-status { color: var(--text-light); font-style: italic; }

.alert {
  padding: 14px 18px;
  border-radius: 10px;
  margin: 16px 0;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert a { color: inherit; font-weight: 600; }

/* Preview box */
.preview-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-height: 60px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}

.var-highlight {
  background: #d4edda;
  color: #155724;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
}

/* Status display */
.status-bar, .status-display {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 16px 0;
}

.status-item { font-size: 14px; }
.status-actions { display: flex; gap: 8px; margin-top: 16px; }

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.text-muted { color: var(--text-light); font-size: 14px; }
.text-muted strong { color: var(--text); }

/* Quick actions */
.quick-actions { margin-top: 24px; }

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.action-btn .icon { font-size: 32px; }

.vars-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.vars-grid code {
  background: #e8f5e9;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 13px;
  color: #2e7d32;
  font-weight: 600;
}

.msg-preview { max-width: 300px; overflow: hidden; text-overflow: ellipsis; color: var(--text-light); font-size: 13px; }

/* Kolher styles */
.kolher {
  max-width: 100%;
  margin: 0 auto;
}

.kolher-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

.kolher-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kolher-card-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.kolher-card-body { padding: 20px; }

.kolher-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  border-radius: 10px;
  background: #f8fafc;
  margin-bottom: 16px;
}

.kolher-step-number {
  width: 32px;
  height: 32px;
  background: var(--primary-light);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.kolher-step-content { flex: 1; }

.kolher-step-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.kolher-step-content p {
  font-size: 13px;
  color: var(--text-light);
}

/* Paste area */
.paste-area {
  position: relative;
}

.paste-area textarea {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  min-height: 150px;
  padding: 16px;
}

.paste-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-light);
  text-align: center;
  pointer-events: none;
  transition: var(--transition);
}

.paste-hint.hidden { opacity: 0; }

.paste-hint .icon {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

/* Column mapping */
.col-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.col-map-item {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  transition: var(--transition);
}

.col-map-item.matched { border-color: var(--primary-light); background: #f0fdf4; }

.col-map-item .col-name {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

.col-map-item .col-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.col-map-item select { width: 100%; margin-top: 8px; }

/* Preview table */
.preview-table-scroll {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 12px 0;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.preview-table th {
  background: #f8fafc;
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.preview-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}

.preview-table tr:hover td { background: #f8fffe; }

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 0;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
}

.stat-item strong { color: var(--text); }

/* Gender mini badges */
.gender-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.gender-badge-m { background: #cce5ff; color: #004085; }
.gender-badge-f { background: #f8d7da; color: #721c24; }
.gender-badge-gm { background: #fff3cd; color: #856404; }
.gender-badge-gf { background: #d4edda; color: #155724; }

/* Gender legend */
.gender-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.gender-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-light);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn 0.3s ease;
  font-size: 14px;
  line-height: 1.4;
}

.toast-success { border-left: 4px solid var(--secondary); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--accent); }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-icon { font-size: 18px; line-height: 1.4; }
.toast-close {
  cursor: pointer;
  color: var(--text-light);
  font-size: 16px;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1.4;
}

code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.send-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .send-layout { grid-template-columns: 1fr; }
}

hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
