:root {
  --primary: #008751; /* Tanzania Flag Green */
  --primary-hover: #006b40;
  --secondary: #00a3e0; /* Tanzania Flag Blue */
  --accent: #fcd116; /* Tanzania Flag Yellow */
  --dark: #0f172a;
  --light-bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text-muted: #64748b;
  --error: #ef4444;
  --success: #10b981;
  --radius: 12px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--light-bg);
  color: var(--dark);
  line-height: 1.5;
}

/* Header */
.header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-weight: 800;
  font-size: 1.25rem;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-area h1 {
  font-size: 1.15rem;
  font-weight: 700;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nav-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
  flex-wrap: wrap;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Main */
.main-content {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.tab-content {
  display: none;
}

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

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  margin-bottom: 1.5rem;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.card h2 {
  font-size: 1.25rem;
  color: #0f172a;
}

.description {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #334155;
}

.input-wrapper {
  display: flex;
  gap: 0.75rem;
}

input[type="text"], select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  background: #ffffff;
  transition: border-color 0.2s;
}

input[type="text"]:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 135, 81, 0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

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

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.checkbox-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.btn {
  padding: 0.7rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* Loading & Alerts */
.loading-state {
  text-align: center;
  padding: 2.5rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 135, 81, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 0.75rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.alert {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.hidden {
  display: none !important;
}

/* Results */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.badge {
  background: #e0f2fe;
  color: #0369a1;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.meta-info {
  display: flex;
  gap: 2rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

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

.ward-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.ward-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.85rem;
}

.ward-card h5 {
  font-size: 1rem;
  color: #0f172a;
}

.ward-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Unmask banner */
.unmask-banner {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
  padding: 0.85rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* NIDA ID CARD STYLING */
.nida-card-wrapper {
  margin-top: 1.5rem;
}

.nida-id-card {
  background: linear-gradient(145deg, #ffffff, #f0fdf4);
  border: 2px solid #cbd5e1;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.nida-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #008751;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.gov-crest {
  font-weight: 900;
  font-size: 0.9rem;
  color: var(--primary);
  letter-spacing: 1px;
}

.gov-title {
  text-align: center;
}

.gov-title h3 {
  font-size: 0.95rem;
  color: #0f172a;
}

.gov-title p {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
}

.source-tag {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 6px;
}

.nida-card-body {
  display: flex;
  gap: 1.5rem;
}

@media (max-width: 650px) {
  .nida-card-body {
    flex-direction: column;
  }
}

.id-photo-box {
  width: 140px;
  height: 175px;
  background: #e2e8f0;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.id-photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder {
  font-size: 0.7rem;
  color: #64748b;
  text-align: center;
  padding: 4px;
}

.code-badge {
  position: absolute;
  bottom: 4px;
  font-size: 0.65rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
}

.id-details {
  flex-grow: 1;
}

.id-nin-row {
  margin-bottom: 0.75rem;
}

.nin-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.nin-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 1px;
  margin-left: 0.5rem;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem 1rem;
}

.span-2 {
  grid-column: span 2;
}

.highlight-box {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}

.unmasked-name {
  font-size: 1.1rem !important;
  font-weight: 800 !important;
  color: #065f46;
}

.details-grid label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.details-grid p {
  font-size: 0.85rem;
  font-weight: 600;
}

.nida-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.75rem;
  margin-top: 1rem;
}

.signature-box {
  height: 45px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.sig-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.masked-note {
  font-size: 0.75rem;
  color: #94a3b8;
  font-style: italic;
}

/* Standalone Resolver Grid */
.code-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.code-detail-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 8px;
}

.code-detail-item label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.code-detail-item h4 {
  font-size: 1.05rem;
  color: var(--primary);
  font-weight: 700;
}

.json-card pre {
  background: #0f172a;
  color: #f8fafc;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  max-height: 250px;
  overflow-y: auto;
}
