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

:root {
  --green: #1B5E20;
  --green-dark: #0d3b10;
  --green-light: #E8F5E9;
  --green-hover: #2E7D32;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-500: #999;
  --gray-600: #666;
  --gray-900: #222;
  --red: #c62828;
  --blue: #1976D2;
  --orange: #F57C00;
}

body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
}

.logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  color: white;
}
.logo span { color: #A5D6A7; }

/* ===== LOGIN ===== */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  background: white;
  padding: 40px 32px;
  border-radius: 20px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-box .logo { color: var(--green); text-align: center; margin-bottom: 20px; }
.login-box .logo span { color: var(--gray-900); }

.login-box h1 {
  font-size: 22px;
  text-align: center;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.login-sub {
  text-align: center;
  color: var(--gray-600);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-box label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 14px 0 6px;
  color: var(--gray-900);
}

.login-box input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  border: 2px solid var(--gray-300);
  border-radius: 10px;
  transition: border-color 0.2s;
}

.login-box input:focus {
  outline: none;
  border-color: var(--green);
}

.error-msg {
  background: #ffebee;
  color: var(--red);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 14px;
}

.btn-primary {
  background: var(--green);
  color: white;
  border: none;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-top: 20px;
}

.btn-primary:hover { background: var(--green-hover); }

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--green);
  color: white;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar .logo { padding: 0 24px 28px; }

.sidebar nav { flex: 1; }

.nav-link {
  display: block;
  padding: 14px 24px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  border-left: 4px solid transparent;
  transition: all 0.2s;
}

.nav-link:hover { background: rgba(255,255,255,0.08); color: white; }

.nav-link.active {
  background: var(--green-dark);
  color: white;
  border-left-color: #A5D6A7;
}

.btn-logout {
  margin: 20px 24px 0;
  background: transparent;
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 10px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover { background: rgba(255,255,255,0.1); }

.main {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
}

.view { display: none; }
.view.active { display: block; }

.view h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 24px;
}

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

.view-header h1 { margin: 0; }

.view-header .btn-primary { width: auto; margin: 0; }

.filter-select {
  padding: 10px 14px;
  border: 2px solid var(--gray-300);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: white;
  cursor: pointer;
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-card {
  background: white;
  padding: 24px;
  border-radius: 14px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--green);
}

/* ===== TABLES ===== */
.table-wrap {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--gray-200);
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: var(--green-light);
}

th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 800;
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-900);
}

tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--gray-100); }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-new { background: #FFF3E0; color: var(--orange); }
.badge-contacted { background: #E3F2FD; color: var(--blue); }
.badge-converted { background: var(--green-light); color: var(--green); }
.badge-lost { background: #FFEBEE; color: var(--red); }
.badge-active { background: var(--green-light); color: var(--green); }
.badge-inactive { background: #FFEBEE; color: var(--red); }

.service-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  color: white;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  margin-right: 6px;
  transition: all 0.15s;
}

.btn-sm:last-child { margin-right: 0; }

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

.btn-outline {
  background: white;
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover { border-color: var(--green); color: var(--green); }

.btn-red { background: #FFEBEE; color: var(--red); }
.btn-red:hover { background: #FFCDD2; }

.qr-thumb {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 20px;
  color: var(--green);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--gray-500);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-body { padding: 24px; }

.modal-body label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 14px 0 6px;
}

.modal-body label:first-child { margin-top: 0; }

.modal-body input,
.modal-body select {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 2px solid var(--gray-300);
  border-radius: 8px;
  background: white;
}

.modal-body input:focus,
.modal-body select:focus {
  outline: none;
  border-color: var(--green);
}

.modal-body .btn-primary { margin-top: 20px; }

.qr-preview {
  text-align: center;
  padding: 16px;
  background: var(--gray-50);
  border-radius: 10px;
  margin-top: 16px;
}

.qr-preview img { max-width: 240px; border-radius: 8px; }
.qr-preview p { margin-top: 10px; font-size: 13px; color: var(--gray-600); font-family: monospace; }

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--gray-500);
  font-size: 15px;
}

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

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.detail-card {
  background: white;
  padding: 24px;
  border-radius: 14px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.detail-card h3 {
  color: var(--green);
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--green-light);
}

.detail-card p {
  font-size: 14px;
  line-height: 1.8;
  color: var(--gray-900);
}

.detail-card p strong { color: var(--gray-600); font-weight: 700; }

.code-highlight {
  display: inline-block;
  background: var(--green-light);
  color: var(--green);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 15px;
  margin-right: 6px;
}
