:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green-bg: #dcfce7;
  --green-fg: #166534;
  --yellow-bg: #fef9c3;
  --yellow-fg: #854d0e;
  --red-bg: #fee2e2;
  --red-fg: #991b1b;
  --gray-bg: #f1f5f9;
  --gray-fg: #475569;
  --blue-bg: #dbeafe;
  --blue-fg: #1e40af;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--muted); }

.tabs { display: flex; gap: 6px; background: var(--gray-bg); padding: 4px; border-radius: 8px; }
.tab-btn {
  border: none; background: transparent; padding: 7px 14px; border-radius: 6px;
  cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px;
}
.tab-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

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

.container { padding: 16px 20px; max-width: 100%; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 12px; background: var(--surface); padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--border);
}

.input, .select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: #fff; color: var(--text);
}
.input { min-width: 240px; }
.count-pill { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 12px; }

.btn {
  border: none; border-radius: 6px; padding: 7px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--gray-bg); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: #16a34a; color: #fff; }
.btn-warning { background: #d97706; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-xs { padding: 4px 8px; font-size: 11px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th {
  background: #f8fafc; padding: 10px 12px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tr:hover td { background: #f8fafc; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green-fg); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow-fg); }
.badge-red { background: var(--red-bg); color: var(--red-fg); }
.badge-gray { background: var(--gray-bg); color: var(--gray-fg); }
.badge-blue { background: var(--blue-bg); color: var(--blue-fg); }

.sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.strong { font-weight: 600; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; }

/* Modals */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--surface); border-radius: 12px; width: 100%; max-width: 520px;
  max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1060px; }
.modal-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.card-box {
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  background: #f8fafc; margin-bottom: 12px;
}
.card-box h4 { margin: 0 0 8px 0; font-size: 13px; }

.passport-photos { display: flex; flex-direction: column; gap: 8px; }
.passport-photos img { max-width: 100%; border-radius: 6px; border: 1px solid var(--border); }
.low-conf { border-color: #f59e0b !important; background: #fffbeb !important; }

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 100;
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast.hidden { display: none; }
