/* Visa Tracker Portal — Binary Consultants */
:root {
  --navy: #12305a;
  --navy-2: #1c4480;
  --ink: #1d2433;
  --muted: #5b6475;
  --line: #e2e6ee;
  --bg: #f4f6fa;
  --card: #ffffff;
  --focus: #2f6fdb;

  --red: #c62828;    --red-bg: #fdecea;    --red-line: #f4c2bd;
  --orange: #c25400; --orange-bg: #fff1e3; --orange-line: #fbcf9f;
  --yellow: #8a6400; --yellow-bg: #fff8dc; --yellow-line: #f2dc8a;
  --green: #1b7a3a;  --green-bg: #e8f5ec;  --green-line: #bfe3ca;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20;
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; height: 56px; }
.brand { color: #fff; font-weight: 700; letter-spacing: .01em; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.brand small { font-weight: 500; opacity: .75; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: rgba(255,255,255,.82); padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-size: .92rem; }
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.nav .pill { background: var(--red); color: #fff; border-radius: 99px; padding: 1px 7px; font-size: .75rem; margin-left: 4px; }
.userbox { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: .88rem; }
.userbox .role { background: rgba(255,255,255,.14); padding: 2px 8px; border-radius: 99px; font-size: .75rem; }
.userbox form { margin: 0; }
.linkbtn { background: none; border: 0; color: rgba(255,255,255,.85); cursor: pointer; font: inherit; padding: 6px 4px; }
.linkbtn:hover { color: #fff; text-decoration: underline; }

.page { max-width: 1400px; margin: 0 auto; padding: 22px 16px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* ---------- Cards & counters ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.two-col > .card + .card, .two-col > * + .card { margin-top: 0; }
.counters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.counter { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: inherit; display: block; border-top: 3px solid var(--navy-2); }
.counter:hover { text-decoration: none; border-color: #c9d2e3; }
.counter .n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counter .l { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.counter.red { border-top-color: var(--red); } .counter.red .n { color: var(--red); }
.counter.orange { border-top-color: var(--orange); } .counter.orange .n { color: var(--orange); }
.counter.green { border-top-color: var(--green); }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-size: .92rem; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: #f7f8fb; text-decoration: none; }
.btn-primary { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.btn-primary:hover { background: var(--navy); }
.btn-danger { color: var(--red); border-color: var(--red-line); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 5px 10px; font-size: .84rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd6e2; border-radius: 8px; font: inherit; font-size: .93rem; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.field { margin-bottom: 14px; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.field .err { font-size: .8rem; color: var(--red); margin-top: 3px; }
.field.has-err input, .field.has-err select { border-color: var(--red); background: #fffafa; }
.field .src { font-size: .72rem; color: #7a8497; float: right; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.form-section { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 6px; }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section h2 { font-size: 1rem; color: var(--navy); }
.form-actions { position: sticky; bottom: 0; background: rgba(244,246,250,.95); padding: 12px 0; margin-top: 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: .9rem; }
.check input { width: 16px; height: 16px; }

/* ---------- Filters ---------- */
.filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(0, 1fr)) auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 99px; color: var(--muted); font-size: .88rem; border: 1px solid transparent; }
.tabs a.active { background: #fff; border-color: var(--line); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---------- Table ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th { text-align: left; font-weight: 600; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: #f9fbff; }
table.grid tr.lvl-red td:first-child { box-shadow: inset 4px 0 0 var(--red); }
table.grid tr.lvl-orange td:first-child { box-shadow: inset 4px 0 0 var(--orange); }
table.grid tr.lvl-yellow td:first-child { box-shadow: inset 4px 0 0 #e0b000; }
table.grid tr.lvl-green td:first-child { box-shadow: inset 4px 0 0 #8fd0a5; }
.name-cell a { font-weight: 600; color: var(--ink); }
.sub { color: var(--muted); font-size: .8rem; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 2px 9px; font-size: .78rem; font-weight: 600; border: 1px solid; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.red { color: var(--red); background: var(--red-bg); border-color: var(--red-line); }
.badge.orange { color: var(--orange); background: var(--orange-bg); border-color: var(--orange-line); }
.badge.yellow { color: var(--yellow); background: var(--yellow-bg); border-color: var(--yellow-line); }
.badge.green { color: var(--green); background: var(--green-bg); border-color: var(--green-line); }
.stage { display: inline-block; font-size: .8rem; padding: 2px 8px; border-radius: 6px; background: #eef2f8; color: #33415c; white-space: nowrap; }
.stage.s-Completed { background: var(--green-bg); color: var(--green); }
.stage.s-Cancelled { background: #f1f1f1; color: #777; text-decoration: line-through; }
.stage.s-Application-To-Be-Submitted { background: #fff4e0; color: #8a5a00; }
.app-pending { color: #8a5a00; font-weight: 600; }
.app-submit { display: block !important; }
.app-submit .field { margin-bottom: 8px; }
.app-submit .btn { width: 100%; justify-content: center; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 64px; width: 100%; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--blue, #2457c5); font-size: .8rem; cursor: pointer; padding: 4px 6px; }
.export-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.export-groups fieldset { border: 1px solid #e3e8f0; border-radius: 8px; padding: 10px 12px; margin: 0; }
.export-groups legend { font-weight: 600; font-size: .85rem; padding: 0 4px; }
.export-groups label { display: flex; gap: 6px; align-items: center; font-size: .88rem; padding: 2px 0; }
.stage.s-On-Hold { background: #f3eefc; color: #5b3b9a; }
.alert-line { display: flex; gap: 8px; align-items: baseline; margin: 2px 0; }
.alert-line .txt { font-size: .84rem; }
.more { font-size: .78rem; color: var(--muted); }

/* ---------- Flash ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-size: .92rem; }
.flash.success { background: var(--green-bg); border-color: var(--green-line); color: #14532d; }
.flash.error { background: var(--red-bg); border-color: var(--red-line); color: #7f1d1d; }
.flash.info { background: #eaf1fd; border-color: #c6d8f7; color: #1e3a6e; }
.warnbox { background: var(--yellow-bg); border: 1px solid var(--yellow-line); color: #5f4600; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .9rem; }
.warnbox ul { margin: 4px 0 0 18px; padding: 0; }

/* ---------- Applicant page ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
dl.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; margin: 0; }
dl.kv div { min-width: 0; }
dl.kv dt { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
dl.kv dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
dl.kv dd.empty-v { color: #a3abb9; font-weight: 400; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-title h2 { margin: 0; color: var(--navy); font-size: 1rem; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: -6px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--green-line); }
.timeline li.deadline::after { background: #fff; box-shadow: 0 0 0 2px var(--navy-2); }
.timeline li.future { color: var(--muted); }
.timeline li.today-marker::after { background: var(--navy-2); }
.timeline .d { font-size: .8rem; color: var(--muted); }
.secret { display: flex; gap: 8px; align-items: center; }
.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li { padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; border: 1px solid; font-size: .9rem; }
.alert-list li.red { background: var(--red-bg); border-color: var(--red-line); }
.alert-list li.orange { background: var(--orange-bg); border-color: var(--orange-line); }
.alert-list li.yellow { background: var(--yellow-bg); border-color: var(--yellow-line); }
.alert-list b { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.quick form { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.quick input { max-width: 140px; }
.quick .app-submit input { max-width: none; width: 100%; }
details.danger { margin-top: 10px; }
details.danger summary { cursor: pointer; color: var(--red); font-size: .88rem; }

/* ---------- Modal (login alerts) ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12,20,36,.55); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(920px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0 0 4px; font-size: 1.2rem; }
.modal-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.modal-body { overflow-y: auto; padding: 8px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.popup-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid #eef1f6; }
.popup-row:last-child { border-bottom: 0; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--navy) 0%, #0b1f3d 100%); }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card .brand-mark { background: var(--navy); color: #fff; width: 40px; height: 40px; font-size: 16px; border-radius: 10px; margin-bottom: 14px; }

/* ---------- Settings ---------- */
table.rules { width: 100%; border-collapse: collapse; }
table.rules td, table.rules th { padding: 8px; border-bottom: 1px solid #eef1f6; text-align: left; vertical-align: middle; }
table.rules th { font-size: .78rem; color: var(--muted); text-transform: uppercase; }
table.rules input[type=number] { width: 90px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }

/* ---------- Documents ---------- */
.review-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.review-grid .card + .card { margin-top: 16px; }
.preview { padding: 0; overflow: hidden; position: sticky; top: 72px; height: calc(100vh - 96px); min-height: 420px; }
.preview iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-open { display: none; }
.preview img { width: 100%; height: 100%; object-fit: contain; background: #f2f4f8; display: block; }
.review-table td { vertical-align: top; }
.review-table input[type=text], .review-table select { min-width: 150px; }
.review-table tr.conf-low td { background: var(--red-bg); }
.review-table tr.conf-medium td { background: #fffdf3; }
.review-table tr.conf-missing td { color: var(--muted); }
.review-table tr.is-same td { opacity: .7; }
.doc-line { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid #eef1f6; font-size: .9rem; }
.doc-upload { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.doc-upload input[type=file] { font-size: .85rem; max-width: 100%; }

.app-head { display: flex; gap: 14px; align-items: center; }
.avatar { width: 64px; height: 80px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .review-grid { grid-template-columns: 1fr; }
  .preview { position: static; height: 70vh; }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters .field:first-child { grid-column: 1 / -1; }
  .counters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { font-size: 14.5px; }
  .topbar-inner { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .nav { order: 3; width: 100%; flex: none; }
  .userbox { margin-left: auto; }
  .userbox .uname { display: none; }
  .counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .form-grid, dl.kv, .two-col { grid-template-columns: 1fr 1fr; }
  .popup-row { grid-template-columns: 1fr; gap: 4px; }
  /* PDFs rarely display inside a page on phones — offer a button instead */
  .preview:has(iframe) { height: auto; min-height: 0; padding: 14px; }
  .preview iframe { display: none; }
  .preview-open { display: flex; justify-content: center; white-space: normal; text-align: center; }
  /* Review table → stacked */
  .review-table thead { display: none; }
  .review-table tr { display: grid; grid-template-columns: 30px minmax(0, 1fr); border-bottom: 1px solid #eef1f6; }
  .review-table td { display: block; border: 0; padding: 4px 6px; }
  .review-table td:nth-child(1) { grid-row: span 3; padding-top: 8px; }
  .review-table td:nth-child(3), .review-table td:nth-child(4) { grid-column: 2; }
  .review-table td:nth-child(4)::before { content: "Now in portal: "; color: var(--muted); }
  .review-table input[type=text], .review-table select { min-width: 0; width: 100%; }
  /* Table → cards */
  table.grid.responsive thead { display: none; }
  table.grid.responsive, table.grid.responsive tbody, table.grid.responsive tr, table.grid.responsive td { display: block; width: 100%; }
  table.grid.responsive tr { border-bottom: 1px solid var(--line); padding: 8px 4px; }
  table.grid.responsive td { border: 0; padding: 4px 12px; }
  table.grid.responsive td[data-l]::before { content: attr(data-l); display: block; font-size: .7rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
  table.grid.responsive tr.lvl-red { box-shadow: inset 4px 0 0 var(--red); }
  table.grid.responsive tr.lvl-orange { box-shadow: inset 4px 0 0 var(--orange); }
  table.grid.responsive tr.lvl-yellow { box-shadow: inset 4px 0 0 #e0b000; }
  table.grid.responsive tr td:first-child { box-shadow: none !important; }
}
@media (max-width: 480px) {
  .form-grid, dl.kv, .two-col { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; gap: 8px; }
}
@media print {
  .topbar, .btn, .filters, .tabs, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .table-wrap { box-shadow: none; }
}

.access-form .check { display: flex; gap: 6px; align-items: center; font-size: .88rem; margin: 3px 0; }
.access-list { margin: 4px 0 8px 22px; padding-left: 8px; border-left: 2px solid #e3e8f0; }
.users-table details[open] { min-width: 300px; }
.users-table td[data-l="Companies"] { max-width: 260px; }
.app-foot { text-align: center; color: #8a94a6; font-size: .75rem; padding: 18px 16px 26px; }
