:root {
  --primary: #25d366;
  --primary-dark: #128c7e;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #111b21;
  --text-muted: #667781;
  --border: #e9edef;
  --danger: #ea4335;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 10px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  padding: 20px 12px;
}

/* Login View */
.login-wrapper {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  padding: 28px 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-icon {
  width: 52px;
  height: 52px;
  background: #25d366;
  color: white;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.login-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

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

.login-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.login-form input, .input-inline input, .search-field {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  transition: border-color 0.2s;
}

.login-form input:focus, .input-inline input:focus, .search-field:focus {
  outline: none;
  border-color: var(--primary-dark);
}

.login-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 14px;
}

.error-msg {
  color: var(--danger);
  font-size: 0.8rem;
  margin-bottom: 12px;
  text-align: center;
}

/* Dashboard Container */
.container {
  max-width: 900px;
  margin: 0 auto;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-icon-small {
  width: 34px;
  height: 34px;
  background: #25d366;
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logged-user {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Badges */
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-gray { background: #e2e8f0; color: #475569; }
.badge-yellow { background: #fef08a; color: #854d0e; }
.badge-green { background: #bbf7d0; color: #166534; }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Connected Banner */
.connected-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: 8px;
  padding: 12px 16px;
}

.connected-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-online-dot {
  width: 10px;
  height: 10px;
  background: #2e7d32;
  border-radius: 50%;
}

.connected-info strong {
  font-size: 0.9rem;
  color: #1b5e20;
}

.connected-info p {
  font-size: 0.8rem;
  color: #388e3c;
}

/* Connection Modes */
.mode-switch {
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.mode-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}

.mode-opt input:checked + span {
  color: var(--primary-dark);
}

.mode-content {
  padding-top: 6px;
}

/* QR Code */
.qr-wrapper {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.qr-box {
  width: 180px;
  height: 180px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  overflow: hidden;
}

.qr-placeholder {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 10px;
}

.qr-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-action {
  flex: 1;
  min-width: 220px;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Pairing Code */
.pairing-simple {
  max-width: 480px;
}

.input-inline {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.input-inline input {
  font-family: var(--font-mono);
}

.code-result {
  margin-top: 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.code-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.code-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.code-big {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #0f172a;
}

/* Contacts Header & Counter Chips */
.contacts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.contacts-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.counter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.chip:hover {
  background: #e2e8f0;
}

.chip-active {
  background: #dcfce7 !important;
  color: #166534 !important;
  border-color: #86efac !important;
}

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

/* Filters */
.filters-row {
  margin-bottom: 12px;
}

.search-field {
  width: 100%;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

th {
  background: #f8fafc;
  padding: 9px 12px;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

.empty-state {
  text-align: center;
  padding: 30px !important;
  color: var(--text-muted);
}

.pill-saved {
  font-size: 0.72rem;
  background: #dcfce7;
  color: #15803d;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.pill-lead {
  font-size: 0.72rem;
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.btn-chat {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
}
.btn-chat:hover {
  text-decoration: underline;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: #25d366;
  color: white;
}
.btn-primary:hover {
  background: #1ebc59;
}

.btn-outline {
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover {
  background: #f8fafc;
}

.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

/* User Management Section */
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-title-row h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.user-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  background: #f8fafc;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

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

.alert-box {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.alert-success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.alert-danger {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.badge-you {
  font-size: 0.7rem;
  background: #e0f2fe;
  color: #0369a1;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
}

.actions-cell {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.hidden {
  display: none !important;
}
