/* Light dashboard theme: soft grey ground, white rounded cards, near-black ink, lime green as the one accent. */
:root {
  --bg: #f1f2ef;
  --card: #ffffff;
  --ink: #15171a;
  --muted: #71767c;
  --line: #e9eae6;
  --dark: #16181b;            /* primary buttons, step markers, code blocks */
  --green: #a4d65e;           /* fills: the highlighted tile, selected choices, progress */
  --brand: #3f7a14;           /* green for text and links (readable on white) */
  --brand-soft: #eaf5da;
  --brand-ink: #ffffff;
  --amber: #ffb057;
  --amber-soft: #fff1de;
  --amber-ink: #8f5200;
  --danger: #c4372d;
  --danger-soft: #fde9e7;
  --side: #16181b;            /* kept for anything that still asks for the old dark surface */
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.03);
  --display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--body);
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.08rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--brand); }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); font-weight: 600; }
.ok { color: var(--brand); font-weight: 600; }
.mono { font-family: var(--mono); font-size: 0.9em; }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

label { display: block; font-weight: 600; font-size: 0.85rem; margin: 14px 0 5px; }
input, select, textarea, button { font: inherit; }
input[type="text"], input[type="tel"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #a3a7ab; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

button, .btn {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--dark);
  border-radius: var(--radius-sm);
  background: var(--dark);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.35;
}
button:hover, .btn:hover { background: #2a2d31; }
button.secondary, .btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
button.secondary:hover, .btn.secondary:hover { background: #f6f7f4; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #a92d24; }
button.link { background: none; border: none; color: var(--brand); padding: 4px 6px; font-weight: 600; }
button.link:hover { background: none; text-decoration: underline; }
button.link.danger { color: var(--danger); }
button:disabled { opacity: 0.5; cursor: default; }
button.block { display: block; width: 100%; }
/* The one action that sends an agent to Safari is the only green button. */
#approve-btn { background: var(--green); border-color: var(--green); color: var(--ink); }
#approve-btn:hover { background: #97cb4f; }
label.btn { margin: 0; font-size: inherit; }
label.btn:has(+ input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Field form (opened from WhatsApp) ---------- */
.form-page { max-width: 520px; margin: 0 auto; padding: 16px; font-size: 16px; }
.form-page header { margin-bottom: 16px; }
.form-page h1 { font-size: 1.35rem; }
.form-page input, .form-page button { padding-top: 12px; padding-bottom: 12px; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices label {
  flex: 1 1 0;
  margin: 0;
  text-align: center;
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}
.choices input { position: absolute; opacity: 0; }
.choices label:has(input:checked) { background: var(--green); border-color: var(--green); color: var(--ink); }
.choices label:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 1px; }

.combo { position: relative; }
.combo-list {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: 100%;
  max-height: 240px;
  overflow-y: auto;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14);
}
.combo-list li { padding: 10px 12px; cursor: pointer; border-radius: 8px; }
.combo-list li:hover, .combo-list li.active { background: var(--brand-soft); }
.combo-list li.empty { color: var(--muted); cursor: default; }

.photo-field { margin-top: 14px; }
.group-title { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; }
.photo-pick { display: flex; gap: 8px; }
.photo-pick label.btn { flex: 1 1 0; text-align: center; padding: 12px 8px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.photo-preview { display: block; max-width: 100%; max-height: 220px; margin-top: 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.big-ref { font-family: var(--mono); font-size: 1.6rem; font-weight: 600; letter-spacing: 1px; }

.banner { background: var(--amber-soft); color: var(--amber-ink); border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 600; }
.outbox-list { list-style: none; margin: 0 0 8px; padding: 0; }
.outbox-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.outbox-list li:last-child { border-bottom: none; }
.outbox-list strong, .outbox-list span { display: block; }
.outbox-actions { flex: none; }
.form-note { margin-top: 10px; }

/* ---------- Sign in ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login { width: min(390px, 100%); margin: 0; padding: 32px; box-shadow: 0 12px 40px rgba(16, 24, 40, 0.08); }
.login h1 { margin-bottom: 4px; }

/* ---------- Dashboard shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  padding: 22px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { padding: 2px 12px 6px; }
.logo { display: block; height: auto; }
.brand .logo { width: 104px; margin-bottom: 10px; }
.login-logo { width: 150px; margin: 0 0 18px; }
.form-logo { width: 120px; margin: 0 0 12px; }
.dialog-head h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.small-btn { padding: 6px 12px; font-size: 0.85rem; font-family: var(--body); font-weight: 600; }
.brand strong { display: block; font-family: var(--display); font-size: 1.22rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.brand span { font-size: 0.78rem; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: rgba(22, 24, 27, 0.05); }
.nav a.active { background: #e4e6e1; font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--ink); }
.nav .count { margin-left: auto; min-width: 22px; text-align: center; background: var(--ink); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 0.74rem; font-weight: 700; }
.nav-label { font-size: 0.72rem; color: var(--muted); padding: 16px 12px 4px; }
.side-foot { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; font-size: 0.85rem; }
.side-foot strong { display: block; font-family: var(--display); font-size: 0.98rem; }
.side-foot span { color: var(--muted); }

.main { padding: 16px 24px 48px 8px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.topbar .search { position: relative; flex: 0 1 340px; }
.topbar .search svg { position: absolute; left: 14px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.topbar .search input { padding-left: 40px; border-color: transparent; box-shadow: var(--shadow); border-radius: 14px; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 6px 14px 6px 6px; }
.user-chip .avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--green); font-family: var(--display); font-weight: 700; }
.user-chip strong { display: block; font-size: 0.88rem; line-height: 1.2; }
.user-chip span { display: block; font-size: 0.74rem; color: var(--muted); line-height: 1.2; }
.topbar #logout { border-radius: 14px; box-shadow: var(--shadow); border-color: transparent; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.tile .label { font-size: 0.82rem; color: var(--muted); }
.tile .value { font-family: var(--display); font-size: 2.3rem; font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; }
.tile .hint { font-size: 0.8rem; color: var(--muted); }
/* The tile that needs a decision: lime with a fine diagonal hatch, like the card in the reference design. */
.tile.attention { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0 2px, transparent 2px 9px), var(--green); }
.tile.attention .label, .tile.attention .hint { color: #2c3d12; }
.tile.alert { background: var(--danger-soft); }
.tile.alert .label, .tile.alert .hint, .tile.alert .value { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.grid-2 > * { min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 18px 20px 4px; }
.card.flush .table-wrap { box-shadow: none; border-radius: 0; }

.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.status-list li:last-child { border-bottom: none; padding-bottom: 0; }
#sc-connector .status-list { margin-bottom: 12px; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 4px 4px; }
.pager:empty { display: none; }
.pager-buttons { display: flex; align-items: center; gap: 10px; }
.pager-buttons button { padding: 7px 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; flex: 0 1 220px; }
.filters .spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; font-size: 0.9rem; white-space: nowrap; }
.filters .check input { flex: none; width: auto; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form > div { flex: 1 1 170px; }
.inline-form label { margin-top: 0; }

.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 0.78rem; color: var(--muted); font-weight: 500; padding-top: 14px; padding-bottom: 10px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #fafbf8; }
tr:last-child td { border-bottom: none; }
td.empty { text-align: center; color: var(--muted); padding: 36px; white-space: normal; }
td.actions-cell { text-align: right; }
td .sub { display: block; font-size: 0.8rem; color: var(--muted); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; }
.badge.pending, .badge.sending { background: var(--amber-soft); color: var(--amber-ink); }
.badge.approved, .badge.on { background: var(--brand-soft); color: var(--brand); }
.badge.rejected, .badge.send_failed, .badge.locked { background: var(--danger-soft); color: var(--danger); }
.badge.off { background: #ecedea; color: var(--muted); }

/* Network tags: one colour per operator, always next to the operator's name. */
.net { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.net::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--muted); }
.net.paxtel::before { background: #2f6fde; }
.net.salamtel::before { background: #c2410c; }
.net.agrotel::before { background: #4d8b1f; }

.kind { display: inline-block; font-size: 0.74rem; font-weight: 700; padding: 3px 9px; border-radius: 8px; background: #ecedea; color: var(--muted); }
.kind.safari { background: #e3ecfb; color: #1f4fa8; }
.kind.whatsapp { background: var(--brand-soft); color: var(--brand); }
.kind.admin { background: #efe6f7; color: #6b3a99; }
.kind.kyc { background: #fdf0d8; color: #8a5a00; }
.net.union::before { background: #1e9bd7; }

/* Review dialog: KYC check and the documents a network requires */
.kyc-box, .archive-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; }
.kyc-box h3, .archive-box h3, .documents h3 { margin: 0 0 6px; font-size: 0.95rem; }
.kyc-box p, .archive-box p { margin: 0 0 8px; }
.meter-row + .meter-row { margin-top: 14px; }
.meter-row p { margin: 6px 0 0; }
.meter-label { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; margin-bottom: 6px; }
.meter { height: 8px; border-radius: 4px; background: #ecedea; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.meter.high span { background: var(--amber); }
.meter.full span { background: var(--danger); }
.warn { color: var(--amber-ink); }
.kyc-names span { display: inline-block; min-width: 8.5em; color: var(--muted); }
.documents { margin-bottom: 18px; }
.doc { margin-top: 12px; }
.doc-head { margin-bottom: 6px; }
.doc-pages { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-page { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 112px; text-decoration: none; color: var(--ink); }
.doc-page img { width: 112px; height: 140px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #f3f4f1; }
.doc-page.pdf span { display: grid; place-items: center; width: 112px; height: 140px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fbeaea; color: #a3261c; font-weight: 700; }
.doc-page small { font-size: 0.75rem; color: var(--muted); text-align: center; }

/* Field form: extra documents for networks that require them */
.doc-slot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.doc-slot:first-of-type { border-top: none; margin-top: 4px; }
.doc-slot .group-title { display: block; font-weight: 600; }
.doc-slot .photo-pick { margin-top: 8px; }
.doc-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.doc-thumb { position: relative; width: 76px; }
.doc-thumb img, .doc-thumb .pdf { width: 76px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); display: grid; place-items: center; background: #fbeaea; color: #a3261c; font-weight: 700; font-size: 0.8rem; }
.doc-thumb button { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; padding: 0; border-radius: 50%; line-height: 1; }
.doc-thumb small { display: block; text-align: center; font-size: 0.72rem; color: var(--muted); }

/* Authentication procedure */
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 18px 46px; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--dark);
  color: #fff;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.88rem;
}
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 14px; top: 36px; bottom: 6px; width: 2px; background: var(--line); }
.steps li:last-child { padding-bottom: 0; }
.steps strong { display: block; }
.steps span { color: var(--muted); }
.rule { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rule label { margin: 0; font-size: 0.95rem; }
.rule small { display: block; font-weight: 400; color: var(--muted); }
.rule .field { display: flex; align-items: center; gap: 8px; flex: none; }
.rule input { width: 84px; text-align: right; }
.form-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; }
.qr { display: block; margin: 0 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
pre.command { margin: 0 0 12px; padding: 12px 14px; background: var(--dark); color: #e9ede6; border-radius: var(--radius-sm); font: 0.82rem/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }

.notice { padding: 11px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); margin-bottom: 16px; overflow-wrap: anywhere; }
.result-ok { padding: 11px 14px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand); font-weight: 600; margin-top: 12px; }
.result-ok.waiting { background: var(--amber-soft); color: var(--amber-ink); margin: 0 0 16px; }
#bulk-result .notice { margin: 12px 0 0; }
#bulk-result ul { margin: 6px 0 0; padding-left: 20px; }

/* Logs */
.log-table td.wrap { white-space: normal; min-width: 260px; max-width: 520px; overflow-wrap: anywhere; }
.log-table tr.failed > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.log-table tr.detail-row:hover { background: none; }
.log-table tr.detail-row > td { white-space: normal; background: #f7f8f5; padding: 16px 18px; }
.log-detail h3 { font-size: 0.78rem; color: var(--muted); margin: 0 0 5px; font-family: var(--body); font-weight: 500; }
.log-detail pre { margin: 0 0 12px; padding: 11px 13px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); font: 0.82rem/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; }
.log-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 14px; }

/* Review dialog */
dialog { width: min(920px, 94vw); max-height: 92vh; border: none; border-radius: 22px; padding: 0; color: var(--ink); box-shadow: 0 24px 70px rgba(16, 24, 40, 0.25); }
dialog::backdrop { background: rgba(22, 24, 27, 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 22px; }
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 20px; margin: 0 0 18px; }
.details dt { font-size: 0.78rem; color: var(--muted); }
.details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 18px; }
.photos figure { margin: 0; }
.photos img { width: 100%; max-height: 360px; object-fit: contain; background: #111; border-radius: var(--radius-sm); display: block; }
.photos figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.outgoing { background: var(--bg); border-radius: var(--radius-sm); padding: 16px 18px 6px; margin-bottom: 18px; }
.outgoing h3 { font-size: 0.98rem; margin: 0 0 10px; }
.outgoing .details { margin-bottom: 10px; }
.outgoing .details dt { font-family: var(--mono); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 16px; }
.actions textarea { flex: 1 1 260px; min-height: 44px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { min-width: 0; position: static; height: auto; overflow: visible; gap: 8px; padding: 14px 16px 4px; }
  .nav { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .nav a { white-space: nowrap; }
  .nav a.active::before { display: none; }
  .nav-label, .side-foot { display: none; }
  .main { padding: 12px 16px 40px; }
  .topbar { flex-wrap: wrap; }
  .topbar .search { flex: 1 1 100%; order: 3; }
  .user-chip span { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}
