/* =====================================================================
   DIAMOND KYC — design tokens
   Palette: deep charcoal-navy shell, warm paper content area,
   champagne-gold accent (restrained — used only for emphasis/active states)
   Type: Playfair Display (headings, used sparingly) + Inter (everything else,
   this is a data-entry tool so legibility wins over decoration)
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --navy-950: #0e141f;
  --navy-900: #131b29;
  --navy-800: #1b2536;
  --navy-700: #263248;
  --paper: #f7f5f0;
  --paper-card: #ffffff;
  --line: #e5e1d6;
  --ink: #1a1f29;
  --ink-soft: #5b6472;
  --gold: #c9a24b;
  --gold-dark: #a6822f;
  --gold-tint: #f3ead2;
  --success: #2f7a4d;
  --success-tint: #e6f2ea;
  --danger: #c0392b;
  --danger-tint: #fbe9e7;
  --info: #2b6ca3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(14,20,31,0.06), 0 4px 16px rgba(14,20,31,0.06);
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

:focus-visible {
  outline: 2px solid var(--gold-dark);
  outline-offset: 2px;
}

.mark { width: 22px; height: 22px; flex: none; display: inline-block; }

/* ---------------- Login screen ---------------- */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 15% -10%, #1b2536 0%, transparent 60%),
    linear-gradient(160deg, var(--navy-950) 0%, var(--navy-900) 55%, var(--navy-800) 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper-card);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  padding: 40px 36px 32px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-brand .mark path { fill: var(--gold); }
.login-brand span { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: 0.2px; }
.login-sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 28px; }
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold-dark); box-shadow: 0 0 0 3px rgba(201,162,75,0.18); outline: none;
}
.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.field.required label::after { content: ' *'; color: var(--danger); }

/* Contact number fields: country-code dropdown + number, side by side */
.contact-input-row { display: flex; gap: 8px; }
.contact-input-row .contact-code-select {
  flex: 0 0 148px; width: 148px; padding-left: 8px; padding-right: 6px;
  font-variant-numeric: tabular-nums;
}
.contact-input-row .contact-number-input { flex: 1 1 auto; min-width: 0; }
.repeat-row .contact-input-row { margin-top: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 6px; border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: transform .05s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { background: var(--navy-800); }
.btn-gold { background: var(--gold); color: var(--navy-950); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink-soft); }
.btn-danger { background: var(--danger-tint); color: var(--danger); }
.btn-danger:hover { filter: brightness(0.97); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.error-banner {
  background: var(--danger-tint); color: var(--danger); padding: 10px 12px; border-radius: 6px;
  font-size: 13px; margin-bottom: 16px; display: none;
}
.error-banner.show { display: block; }

.toast-stack { position: fixed; top: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy-900); color: #fff; padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow);
  font-size: 13.5px; min-width: 240px; max-width: 360px; border-left: 3px solid var(--gold);
  animation: slideIn .2s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------------- App shell ---------------- */
#appShell { display: none; min-height: 100vh; }
#appShell.active { display: flex; }

.sidebar {
  width: 236px; flex: none;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: #cfd6e2; display: flex; flex-direction: column; padding: 22px 14px;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 18px;
}
.sidebar-brand .mark path { fill: var(--gold); }
.sidebar-brand span { font-family: var(--font-display); font-weight: 700; color: #fff; font-size: 17px; }

.nav-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px; color: #7c879b; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-radius: 6px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; color: #cfd6e2;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(201,162,75,0.15); color: var(--gold); }
.nav-item svg { width: 16px; height: 16px; flex: none; }

.sidebar-footer { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: #8a93a5; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; background: var(--paper-card); border-bottom: 1px solid var(--line);
}
.topbar-title { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.sector-badge { background: var(--gold-tint); color: var(--gold-dark); padding: 5px 12px; border-radius: 100px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--navy-900); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px;
}

.content { flex: 1; overflow-y: auto; padding: 26px; }
.view { display: none; }
.view.active { display: block; }

.card { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { font-family: var(--font-display); font-size: 16px; margin: 0; }
.card-header .step-num {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--navy-900); color: var(--gold); font-size: 11px; font-weight: 700; margin-right: 8px;
}
.card-body { padding: 20px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .num { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--navy-900); }
.stat-card .label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 2px; }
.stat-card .num.gold { color: var(--gold-dark); }

.repeat-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 10px; }
.repeat-row.repeat-row-people { grid-template-columns: 1fr 1fr 1fr auto; }
.repeat-remove { height: 38px; width: 38px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--danger); cursor: pointer; font-size: 16px; }
.add-link { display: inline-flex; align-items: center; gap: 6px; color: var(--gold-dark); font-weight: 600; font-size: 13px; cursor: pointer; margin-top: 4px; }
.add-link:hover { text-decoration: underline; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 100px; font-size: 11.5px; font-weight: 700; }
.pill-Ap { background: #f3ead2; color: #8a6d1c; }
.pill-A { background: #e6f2ea; color: #2f7a4d; }
.pill-B { background: #e6eef7; color: #2b6ca3; }
.pill-C { background: #f4ecf7; color: #7d3c98; }
.pill-D { background: #fbe9e7; color: #c0392b; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; padding: 10px 12px; background: var(--navy-950); color: #cfd6e2;
  font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; position: sticky; top: 0;
}
.data-table th:first-child { border-top-left-radius: 6px; }
.data-table th:last-child { border-top-right-radius: 6px; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: #fbf9f4; }
.table-wrap { overflow-x: auto; border-radius: 6px; border: 1px solid var(--line); }
.row-link { color: var(--navy-900); font-weight: 600; cursor: pointer; }
.row-link:hover { color: var(--gold-dark); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input, .toolbar select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.toolbar .spacer { flex: 1; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 10px; opacity: 0.5; }

.pagination { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--ink-soft); }

/* ---------------- Radio button group (e.g. A / B / Both) ---------------- */
.radio-row { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 4px 0 2px; }
.field label.radio-option {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px;
  font-weight: 500; color: var(--ink); text-transform: none; letter-spacing: normal;
  margin-bottom: 0; cursor: pointer;
}
.radio-option input[type="radio"] { width: auto; accent-color: var(--gold-dark); cursor: pointer; }

/* ---------------- Company combobox (select existing or add new) ---------------- */
.combobox { position: relative; }
.combobox input { padding-right: 34px; }
.combobox-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border: none; background: transparent; cursor: pointer;
  color: var(--ink-soft); font-size: 14px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.combobox-toggle:hover { background: var(--gold-tint); color: var(--ink); }
.combobox-panel {
  display: none;
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 260px; overflow-y: auto;
}
.combobox-panel.show { display: block; }
.combobox-item {
  padding: 10px 12px; cursor: pointer; font-size: 13.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.combobox-item:last-child { border-bottom: none; }
.combobox-item:hover, .combobox-item.active { background: var(--gold-tint); }
.combobox-item .cb-name { font-weight: 500; }
.combobox-item .cb-meta { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.combobox-empty { padding: 12px; font-size: 12.5px; color: var(--ink-soft); text-align: center; }
.combobox-loading { padding: 12px; font-size: 12.5px; color: var(--ink-soft); text-align: center; }
.combobox-new {
  padding: 10px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--gold-dark);
  background: #fbf9f4; display: flex; align-items: center; gap: 6px;
}
.combobox-new:hover { background: var(--gold-tint); }
.company-selected-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px;
  background: var(--success-tint); color: var(--success); padding: 3px 10px; border-radius: 100px; font-weight: 600;
}
.company-new-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px;
  background: var(--gold-tint); color: var(--gold-dark); padding: 3px 10px; border-radius: 100px; font-weight: 600;
}

.dropzone {
  border: 2px dashed var(--line); border-radius: 8px; padding: 26px; text-align: center;
  cursor: pointer; color: var(--ink-soft); transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--gold); background: var(--gold-tint); }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 12.5px; margin: 4px 6px 0 0;
}
.file-chip a { color: var(--info); text-decoration: none; font-weight: 600; }
.file-chip button { border: none; background: none; color: var(--danger); cursor: pointer; font-size: 13px; }

.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(14,20,31,0.55);
  align-items: center; justify-content: center; z-index: 900; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 480px; box-shadow: 0 24px 60px rgba(0,0,0,0.35); max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-family: var(--font-display); font-size: 16px; }
.modal-close { cursor: pointer; color: var(--ink-soft); font-size: 20px; background: none; border: none; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

.badge-role { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 100px; }
.badge-User { background: #e6eef7; color: #2b6ca3; }
.badge-Admin { background: #f3ead2; color: #8a6d1c; }
.badge-SuperAdmin { background: #f4ecf7; color: #7d3c98; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-active { background: var(--success); }
.status-inactive { background: var(--ink-soft); }

.helper-text { font-size: 12px; color: var(--ink-soft); margin-top: -8px; margin-bottom: 14px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d8d3c6; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

.hamburger { display: none; }
@media (max-width: 720px) {
  .hamburger { display: inline-flex; }
  .sidebar { position: fixed; z-index: 800; height: 100vh; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 16px; }
}

/* =====================================================================
   MOBILE-FRIENDLY REFINEMENTS
   Tuned for phones/small tablets on top of the existing 720px sidebar
   breakpoint and the 860px grid-2/grid-3 collapse above.
   ===================================================================== */
@media (max-width: 720px) {
  html { -webkit-text-size-adjust: 100%; }

  /* Prevent iOS Safari's auto-zoom-on-focus by keeping form controls >=16px */
  .field input, .field select, .field textarea,
  .toolbar input, .toolbar select,
  .contact-code-select, .contact-number-input,
  .login-card input {
    font-size: 16px;
  }

  /* Topbar: allow wrapping instead of overflowing off-screen */
  .topbar {
    height: auto; min-height: 58px; padding: 10px 14px; flex-wrap: wrap; gap: 8px 0; row-gap: 8px;
  }
  .topbar-title { font-size: 16px; }
  .topbar-right { gap: 8px; flex-wrap: wrap; }
  .user-chip div { display: none; } /* keep just the avatar circle on small screens; name/role text is available in Manage Users / the login state */
  .sector-badge { font-size: 11px; padding: 4px 9px; }

  .content { padding: 12px; }

  .card-header { padding: 12px 14px; }
  .card-header h2 { font-size: 14.5px; }
  .card-body { padding: 14px; }

  /* Stack repeated rows (Related People / References) and contact code+number */
  .repeat-row, .repeat-row.repeat-row-people { grid-template-columns: 1fr; }
  .repeat-remove { justify-self: end; width: auto; padding: 0 14px; }
  .contact-input-row { flex-wrap: wrap; }
  .contact-input-row .contact-code-select { flex: 1 1 120px; width: auto; }
  .contact-input-row .contact-number-input { flex: 1 1 160px; }

  /* Toolbars (search/filter bars) stack and go full width */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select, .toolbar .btn { width: 100%; }
  .toolbar .spacer { display: none; }

  /* Form action buttons + modal footers stack and go full-width for easy tapping */
  #kycForm > div[style*="flex-end"],
  .modal-footer {
    flex-direction: column-reverse;
  }
  #kycForm > div[style*="flex-end"] .btn,
  .modal-footer .btn {
    width: 100%;
  }

  .modal { max-width: 100%; }
  .modal-body { padding: 16px; }

  .data-table th, .data-table td { padding: 8px 10px; font-size: 12.5px; }

  .stats-row { grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .num { font-size: 22px; }

  .login-card { padding: 30px 22px 24px; }
}

@media (max-width: 480px) {
  .data-table th, .data-table td { padding: 7px 8px; font-size: 12px; }
  .btn { padding: 10px 14px; }
  .pagination { flex-wrap: wrap; justify-content: center; text-align: center; }
}

/* =====================================================================
   PRINTABLE BLANK KYC FORM
   Hidden on screen at all times; only revealed inside @media print,
   at which point everything else in the app is hidden.
   ===================================================================== */
#printBlankContainer { display: none; }

.pb-page { font-family: var(--font-body); color: #111; }
.pb-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 14px; }
.pb-brand { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.pb-sub { font-size: 11px; color: #444; margin-top: 2px; }
.pb-meta { text-align: right; font-size: 11px; color: #444; }
.pb-section { margin-bottom: 14px; page-break-inside: avoid; }
.pb-section-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; background: #eee; padding: 4px 8px; margin-bottom: 8px; border-left: 3px solid #111; }
.pb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.pb-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 24px; }
.pb-field { margin-bottom: 10px; }
.pb-field label { display: block; font-size: 10.5px; font-weight: 600; color: #333; margin-bottom: 2px; }
.pb-line { border: none; border-bottom: 1px solid #111; height: 18px; width: 100%; }
.pb-line-tall { border: none; border-bottom: 1px solid #111; height: 34px; width: 100%; }
.pb-checkbox-row { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.pb-checkbox { display: flex; align-items: center; gap: 5px; font-size: 11.5px; }
.pb-checkbox .pb-box { display: inline-block; width: 11px; height: 11px; border: 1px solid #111; }
.pb-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.pb-table th, .pb-table td { border: 1px solid #111; padding: 6px 6px; text-align: left; }
.pb-table th { background: #eee; font-size: 10.5px; }
.pb-table td { height: 24px; }
.pb-footnote { font-size: 10px; color: #555; margin-top: 4px; }
.pb-signblock { display: flex; justify-content: space-between; margin-top: 26px; page-break-inside: avoid; }
.pb-signbox { width: 45%; }
.pb-signbox .pb-line { margin-top: 26px; }
.pb-signbox label { font-size: 10.5px; font-weight: 600; }

@media print {
  body * { visibility: hidden !important; }
  #printBlankContainer, #printBlankContainer * { visibility: visible !important; }
  #printBlankContainer { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
  @page { margin: 14mm; }
}
