/* ==========================================================
   TMLHUB Remit — staff back-office styles
   ========================================================== */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --ink: #142033;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0b3d6e;
  --brand-dark: #082c50;
  --brand-2: #0e7c66;
  --accent: #f59e0b;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 16px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
code { background: #eef2f7; padding: 1px 6px; border-radius: 5px; font-size: 12px; word-break: break-all; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #c7d4e5; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #10b981, #0e7c66); color: #fff; font-weight: 800; font-size: 15px;
}
.brand small { display: block; font-weight: 500; font-size: 11px; color: #93a9c4; letter-spacing: .04em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: #c7d4e5; font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.nav a .count { margin-left: auto; background: var(--accent); color: #111; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; }
.nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #7f9bbd; margin: 18px 12px 6px; }
.nav .cta { background: var(--brand-2); color: #fff; margin-bottom: 10px; justify-content: center; font-weight: 700; }
.nav .cta:hover { background: #0b6b58; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #dbe7f5; color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.topbar .role { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.topbar form { margin: 0; }
.counter-pick { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.counter-pick select { padding: 5px 8px; border-radius: 7px; border: 1px solid var(--line); font: inherit; }
.content { padding: 22px 24px 40px; width: 100%; max-width: 1320px; }
.footer { margin-top: auto; padding: 14px 24px; color: var(--muted); font-size: 12px; }

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0 0 2px; }
.page-head p { margin: 0; color: var(--muted); }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card > h2, .card-head h2 { font-size: 15px; margin: 0 0 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 16px 18px 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }

/* ---------- Stats ---------- */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat.accent { border-left: 4px solid var(--brand-2); }
.stat.warn { border-left: 4px solid var(--warn); }
.stat.purple { border-left: 4px solid #7c3aed; }
.stat.blue { border-left: 4px solid var(--info); }
a.stat:hover { text-decoration: none; border-color: #cbd5e1; }
a.stat { color: inherit; display: block; }

/* ---------- Bars ---------- */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 170px; padding-top: 10px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar .fill { width: 100%; max-width: 46px; background: linear-gradient(180deg, #34d399, #0e7c66); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.bar .amt { font-size: 11px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.bar .day { font-size: 11px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff;
  text-decoration: none !important; white-space: nowrap; line-height: 1.3;
}
.btn:hover { filter: brightness(1.08); }
.btn-outline { background: #fff; color: var(--ink); border-color: #cbd5e1; }
.btn-outline:hover { background: #f8fafc; filter: none; }
.btn-success { background: var(--ok); }
.btn-danger { background: var(--danger); }
.btn-warn { background: var(--warn); }
.btn-teal { background: var(--brand-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #eef2f7; filter: none; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar form { margin: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #f8fafc; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:hover td { background: #f8fbff; }
.table tr:last-child td { border-bottom: 0; }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--line); }
.table .sub { display: block; font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px !important; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #e2e8f0; color: #334155; white-space: nowrap; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gray { background: #e5e7eb; color: #374151; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--ink-2); }
.field .req { color: var(--danger); }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: 2px solid #bfdbfe; border-color: #3b82f6; }
.input[readonly] { background: #f8fafc; }
.field.has-error .input { border-color: var(--danger); background: #fffafa; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); font-weight: 700; margin: 6px 0 12px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 17px; height: 17px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 140px; }
.filters .grow { flex: 1; min-width: 220px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert strong { display: block; }

/* ---------- Key/value ---------- */
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 7px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.big-amount { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.text-ok { color: var(--ok); } .text-danger { color: var(--danger); } .text-warn { color: var(--warn); }
.divider { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- Stepper ---------- */
.stepper { display: flex; gap: 0; margin: 4px 0 18px; overflow-x: auto; }
.step { flex: 1; min-width: 120px; position: relative; text-align: center; font-size: 12px; color: var(--muted); padding-top: 34px; }
.step::before {
  content: attr(data-n); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: #e2e8f0; color: var(--muted); font-weight: 700; z-index: 1;
}
.step::after { content: ""; position: absolute; top: 13px; left: 50%; width: 100%; height: 3px; background: #e2e8f0; }
.step:last-child::after { display: none; }
.step.done { color: var(--ok); }
.step.done::before { content: "✓"; background: var(--ok); color: #fff; }
.step.done::after { background: var(--ok); }
.step.current { color: var(--brand); font-weight: 700; }
.step.current::before { background: var(--brand); color: #fff; box-shadow: 0 0 0 4px #dbeafe; }
.step.stopped::before { content: "✕"; background: var(--danger); color: #fff; }
.step.stopped { color: var(--danger); font-weight: 700; }

/* ---------- Quote box ---------- */
.quote { background: linear-gradient(135deg, #0b3d6e, #0e7c66); color: #fff; border-radius: 12px; padding: 18px; }
.quote .row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed rgba(255,255,255,.2); }
.quote .row:last-child { border-bottom: 0; }
.quote .lbl { opacity: .8; }
.quote .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.quote .receive { font-size: 24px; font-weight: 800; }
.quote .edd { margin-top: 10px; background: rgba(245, 158, 11, .2); border: 1px solid rgba(245, 158, 11, .6); border-radius: 8px; padding: 8px 10px; font-size: 13px; }

/* ---------- Beneficiary picker ---------- */
.pick-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.pick { border: 2px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; display: block; background: #fff; position: relative; }
.pick:hover { border-color: #93c5fd; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick.checked, .pick:has(input:checked) { border-color: var(--brand-2); background: #f0fdf9; box-shadow: 0 0 0 3px #ccfbf1; }
.pick .name { font-weight: 700; }
.pick .meta { font-size: 12px; color: var(--muted); }

/* ---------- Signature / display panel ---------- */
.signature-box { border: 1px dashed #cbd5e1; border-radius: 10px; padding: 10px; background: #fff; text-align: center; }
.signature-box img { max-width: 100%; max-height: 120px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--warn); }
.live::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(217,119,6,.6); } 100% { box-shadow: 0 0 0 10px rgba(217,119,6,0); } }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .t { font-size: 12px; color: var(--muted); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(140deg, #0b3d6e 0%, #0e7c66 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { font-size: 34px; margin: 0 0 12px; }
.auth-hero p { opacity: .85; max-width: 440px; }
.auth-hero ul { padding-left: 18px; opacity: .9; line-height: 1.9; }
.auth-panel { display: grid; place-items: center; padding: 32px; background: #fff; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 22px; margin: 0 0 6px; }
.demo-box { margin-top: 18px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 13px; }
.demo-box table { width: 100%; border-collapse: collapse; }
.demo-box td { padding: 3px 0; }
.demo-fill { cursor: pointer; color: var(--info); font-weight: 600; }

/* ---------- Modal (native dialog) ---------- */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(480px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .dlg-body { padding: 20px; }
dialog h3 { margin: 0 0 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid-2, .grid-3, .grid-4, .form-grid, .form-grid.cols-2, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .content { padding: 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}
