/* Design language adopted from the TCG HRIS sign-in mockup:
   soft grey-blue page (#f2f4f8), white cards with 14–16px radii and gentle
   shadows, dark-indigo brand (#2b2666), indigo actions (#5a52dd),
   rounded inputs, pill badges. Libre Franklin throughout. */
* { box-sizing: border-box; }
:root {
  --page: #f2f4f8;
  --card: #ffffff;
  --ink: #17203d;
  --body-ink: #3a4664;
  --muted: #5a6b8c;
  --line: #e9edf3;
  --input-line: #dfe4ec;
  --tile: #2b2666;
  --accent: #5a52dd;
  --accent-dark: #4a43c4;
  --focus: #8f8af0;
  --danger: #ad4d52;
  --ok: #2e7d4f;
  --warn: #bd8d35;
}
body {
  margin: 0;
  font-family: "Libre Franklin", "Segoe UI", system-ui, sans-serif;
  background: var(--page);
  color: var(--body-ink);
  font-size: 14px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--tile);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.14);
}
.topbar-inner {
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  min-height: 54px;
  gap: 16px;
}
.brand-mark {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  text-decoration: none;
}
.brand-mark img { display: block; border-radius: 9px; }
.brand-mark span { font-weight: 400; opacity: 0.75; }
.primary-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 0;
}
.primary-nav::-webkit-scrollbar { display: none; }
.nav-item {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  color: #d9ddf4;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease;
}
.nav-item:hover, .nav-item:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  outline: none;
}
.nav-item.active {
  background: var(--accent);
  color: #fff;
}
.nav-item.nav-new { color: #b3b0f5; font-weight: 600; }
.account-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 13px;
  white-space: nowrap;
  color: #b7bcec;
}
.account-area .who { font-size: 12px; }
.account-area a { color: #d9ddf4; font-size: 12px; text-decoration: none; }
.account-area a:hover, .account-area a:focus-visible { text-decoration: underline; outline: none; }
.linklike {
  background: none; border: none; color: #d9ddf4; cursor: pointer;
  font: inherit; font-size: 12px; padding: 0;
}
.linklike:hover { text-decoration: underline; }
@media (max-width: 760px) {
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .account-area .who { display: none; }
}

/* ---------- Layout ---------- */
.container { width: 100%; margin: 22px auto; padding: 0 24px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(23, 32, 61, 0.05);
}
.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.narrow-lg { max-width: 760px; margin-left: auto; margin-right: auto; }
.narrow-xl { max-width: 1100px; margin-left: auto; margin-right: auto; }

/* Scrollable OPE picker on the New DV form: sticky header, bounded height */
.ope-picker {
  max-height: 420px; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px;
}
.ope-picker table { border-collapse: separate; border-spacing: 0; }
.ope-picker thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.ope-picker td.ellipsis { max-width: clamp(180px, 18vw, 380px); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 21px; margin: 4px 0 14px; letter-spacing: -0.02em; color: var(--ink); }
h2 {
  font-size: 11.5px; margin: 2px 0 10px; color: var(--muted);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
code { background: #eceef8; padding: 1px 5px; border-radius: 5px; font-size: 12.5px; color: var(--ink); }

/* ---------- Grids & stat cards ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.align-top { align-items: start; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { min-height: 96px; padding: 15px 17px; }
.stat .stat-label {
  color: var(--muted); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px;
}
.stat .stat-value {
  font-size: 27px; font-weight: 700; line-height: 1; letter-spacing: -0.03em;
  margin: 0 0 4px; color: var(--ink); font-variant-numeric: tabular-nums;
}
.stat .stat-sub { color: var(--muted); font-size: 11.5px; }
@media (max-width: 820px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; margin: 10px 0; font-weight: 600; font-size: 13px; color: var(--body-ink); }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; font-weight: 500; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=month], select, textarea {
  width: 100%; padding: 9px 12px; margin-top: 5px;
  border: 1px solid var(--input-line); border-radius: 10px;
  font: inherit; font-size: 13.5px; background: #fff; color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #9aa7bd; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--accent);
}
label.inline input { width: auto; margin: 0; }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; padding: 10px 14px 14px; }
legend { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0 6px; }
.filter-bar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; min-width: 140px; }
.filter-bar label { margin: 0; }
.actions { display: flex; gap: 10px; margin-top: 14px; align-items: center; }
.inline-form { display: inline; }
.stack > * + * { margin-top: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--input-line); background: #fff; color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background 140ms ease;
}
.btn:hover { background: #f0f2fa; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #93393e; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 11px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
a { color: var(--accent-dark); }
a:focus-visible, .btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  padding: 8px 10px 6px; color: #7c89a3; font-size: 10px; font-weight: 700;
  line-height: 1.1; text-align: left; text-transform: uppercase; letter-spacing: 0.05em;
}
td {
  padding: 7px 10px; border-top: 1px solid #eef1f7;
  color: var(--body-ink); font-size: 12.5px; line-height: 1.3; vertical-align: middle;
}
td a { color: var(--accent-dark); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
td a:hover { color: var(--tile); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.ellipsis {
  max-width: clamp(220px, 26vw, 620px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
tr:hover td { background: #f6f8fc; }
.total-row td { border-top: 2px solid var(--ink); color: var(--ink); }
table input, table select { margin-top: 0; }
.table-scroll { overflow-x: auto; }

/* ---------- Panel headings (with warning dot) ---------- */
.panel-heading { display: flex; align-items: center; min-height: 20px; margin-bottom: 8px; }
.warning-dot {
  display: inline-block; width: 8px; height: 8px; margin-right: 8px;
  border-radius: 50%; background: var(--warn);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-pending, .badge-eng_verified, .badge-checked, .badge-proc_verified { background: #f8efd9; color: #8a6720; }
.badge-approved { background: #e4e2fb; color: var(--accent-dark); }
.badge-paid, .badge-disbursed { background: #ddefe4; color: var(--ok); }
.badge-rejected { background: #f6e2e3; color: var(--danger); }
.badge-cancelled { background: #eaedf3; color: var(--muted); }
.badge-unbilled { background: #f8efd9; color: #8a6720; }
.badge-billed { background: #e4e2fb; color: var(--accent-dark); }
.badge-reimbursed { background: #ddefe4; color: var(--ok); }

/* ---------- Flash ---------- */
.flash { padding: 10px 15px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; font-size: 13px; }
.flash-success { background: #ddefe4; color: var(--ok); }
.flash-error { background: #f6e2e3; color: var(--danger); }

/* ---------- Detail list ---------- */
dl.detail { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 0 0 16px; }
dl.detail dt {
  color: #7c89a3; font-weight: 700; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.05em; padding-top: 2px;
}
dl.detail dd { margin: 0; font-size: 13px; color: var(--body-ink); }

/* ---------- Sign-off chain ---------- */
ol.chain { list-style: none; padding: 0; margin: 0 0 12px; }
ol.chain li { padding: 6px 0 6px 24px; position: relative; border-left: 2px solid var(--line); margin-left: 8px; font-size: 13px; }
ol.chain li::before {
  content: ''; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px;
  border-radius: 50%; background: #eaedf3; border: 2px solid var(--input-line);
}
ol.chain li.done::before { background: var(--ok); border-color: var(--ok); }
ol.chain li.current::before { background: #fff; border-color: var(--accent); }
ol.chain li.current { font-weight: 600; color: var(--ink); }

/* ---------- Dashboard queues ---------- */
.queue-list { list-style: none; padding: 0; margin: 0; }
.queue-list li { padding: 7px 0; border-bottom: 1px solid #eef1f7; font-size: 13px; }
.queue-list li:last-child { border-bottom: none; }
.queue-list a { text-decoration: none; color: var(--accent-dark); font-weight: 600; }
.queue-list a:hover { text-decoration: underline; color: var(--tile); }
.caps-cell label.inline { margin-right: 8px; font-size: 11.5px; white-space: nowrap; }

/* ---------- Budget bars ---------- */
.bar { background: #eaedf3; border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 999px; }
.bar-fill.over { background: var(--danger); }

/* ---------- Document checks ---------- */
.doc-checklist { list-style: none; padding: 0; margin: 0 0 12px; }
.doc-checklist li { padding: 4px 0; font-size: 13px; }
.doc-checklist li.ok { color: var(--ok); }
.doc-checklist li.missing { color: var(--danger); font-weight: 600; }
.doc-files li { display: block; border-bottom: 1px solid #eef1f7; padding: 8px 0; }
.doc-files li:last-child { border-bottom: none; }
.doc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* Document preview modal (Xero-style overlay) */
.doc-modal { position: fixed; inset: 0; z-index: 200; }
.doc-modal-backdrop { position: absolute; inset: 0; background: rgba(23, 21, 50, 0.55); }
.doc-modal-panel {
  position: relative; margin: 4vh auto; width: min(940px, 94vw); height: 92vh;
  background: #fff; border-radius: 14px; box-shadow: 0 18px 60px rgba(23, 21, 50, 0.35);
  display: flex; flex-direction: column; overflow: hidden;
}
.doc-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid #e2e6f0;
}
.doc-modal-head h3 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-modal-close {
  border: none; background: none; font-size: 16px; color: var(--muted); cursor: pointer;
  padding: 4px 8px; border-radius: 8px;
}
.doc-modal-close:hover { background: #eceef8; color: var(--ink); }
.doc-modal-body { flex: 1; background: #3c3f4a; display: flex; align-items: center; justify-content: center; overflow: auto; }
.doc-modal-body iframe { width: 100%; height: 100%; border: none; }
.doc-modal-body img { max-width: 96%; max-height: 96%; background: #fff; border-radius: 4px; }
.doc-modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-top: 1px solid #e2e6f0;
}
.doc-modal-nav { display: flex; align-items: center; gap: 8px; }
.doc-modal-nav .btn[disabled] { opacity: 0.45; cursor: default; }
.doc-type-tag {
  font-size: 10.5px; font-weight: 600; color: var(--muted); background: #eceef8;
  padding: 2px 9px; border-radius: 6px; white-space: nowrap;
}
.ai-chip {
  font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.ai-pending { background: #f8efd9; color: #8a6720; }
.ai-pass { background: #ddefe4; color: var(--ok); }
.ai-flagged { background: #f6e2e3; color: var(--danger); }
.ai-flagged.overridden { background: #eaedf3; color: var(--muted); text-decoration: line-through; }
.ai-error { background: #f6e2e3; color: var(--danger); opacity: 0.7; }
.ai-skipped { background: #eaedf3; color: var(--muted); }
.ai-note { font-size: 12px; margin: 4px 0 0 2px; }
.doc-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.attach-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.attach-row select { width: auto; min-width: 190px; margin-top: 0; }
.attach-row input[type=file] { margin-top: 0; flex: 1; min-width: 220px; }
.attach-actions { display: flex; gap: 8px; align-items: center; }
#attach-rows .attach-row + .attach-row { margin-top: 8px; }

/* ---------- Series registry ---------- */
.registry-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.reg-tab {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--input-line);
  color: var(--body-ink); font-size: 13px; font-weight: 600; text-decoration: none;
}
.reg-tab:hover { background: #f0f2fa; }
.reg-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
tr.gap-row td {
  background: #f6e2e3;
  color: var(--danger); font-weight: 700;
}
tr.gap-row:hover td { background: #f2d6d8; }
tr.cancelled-row td { color: #9aa4b8; }
tr.cancelled-row td a { color: #9aa4b8; }
tr.voided-row td { background: #f0f2f7; color: #7c89a3; font-style: italic; }
tr.voided-row:hover td { background: #eaedf4; }
tr.gap-row .inline-form input[type=text] { margin-top: 0; padding: 4px 8px; font-size: 12px; }

/* ---------- Bank processing ---------- */
.bank-row-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bank-row-form select, .bank-row-form input { margin-top: 0; padding: 5px 8px; font-size: 12.5px; width: auto; }

/* ---------- Files ---------- */
.file-list { list-style: none; padding: 0; margin: 0 0 12px; }
.file-list li { padding: 5px 0; display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }

.footer { text-align: center; color: var(--muted); padding: 18px; font-size: 11.5px; }
