:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #dde1e6;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ok-bg: #f0fdf4;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --brand-navy: #0f2d5c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --card: #1c2028;
    --border: #2c313b;
    --text: #e6e8eb;
    --muted: #9aa1ac;
    --accent: #3b82f6;
    --accent-dark: #60a5fa;
    --danger: #f87171;
    --danger-bg: #3a1f1f;
    --ok-bg: #16261c;
    --warn: #fbbf24;
    --warn-bg: #3a2f14;
    --brand-navy: #6ea0f5;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, "Segoe UI", sans-serif;
  background: #e9f2fb;
  background-image: radial-gradient(1100px 560px at 50% 0, #ffffff 0%, #e9f2fb 55%, #d9e9f6 100%);
  background-attachment: fixed;
  color: var(--text);
}

.app-header {
  padding: 24px 32px 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.header-left h1 { margin: 0; font-size: 22px; color: var(--brand-navy); font-weight: 800; }
.subtitle { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.revision { color: var(--muted); margin: 6px 0 0; font-size: 12px; }
.revision #revision-value { font-weight: 600; color: var(--text); }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.header-right img#logo-img { height: 58px; width: auto; display: block; }
.header-left { display: flex; align-items: center; gap: 14px; }
#brand-1fmv { height: 120px; width: auto; display: block; flex-shrink: 0; }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.card h2 { margin-top: 0; font-size: 16px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 220px; }
.field label { font-size: 12px; color: var(--muted); }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

#paste-panel {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
#paste-panel summary { cursor: pointer; font-size: 13px; color: var(--muted); }
#paste-text { width: 100%; margin: 10px 0; box-sizing: border-box; resize: vertical; }

button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
button:hover { border-color: var(--accent); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.hint { font-size: 12px; color: var(--muted); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 20px;
  margin: 10px 0;
  font-size: 14px;
}
.info-grid .label { display: block; font-size: 11px; color: var(--muted); }

.hidden { display: none !important; }

#group-options { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.group-option {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}
.group-option.selected { border-color: var(--accent); background: rgba(37,99,235,0.08); }
.group-option .variant { color: var(--muted); font-size: 11px; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 13px;
}
#results-table { table-layout: fixed; }
th, td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  overflow-wrap: break-word;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td input { width: 100%; padding: 4px 6px; font-size: 13px; }
tr.not-found { background: var(--danger-bg); }
tr.found { background: var(--ok-bg); }
.suggestions { font-size: 12px; color: var(--muted); margin-top: 4px; }
.suggestions button { padding: 2px 6px; font-size: 11px; margin-right: 4px; margin-bottom: 4px; }
.nf-row { display: flex; gap: 6px; }
.nf-row .nf-desc { flex: 1; }
.nf-row .nf-qty { width: 70px; flex: none; }
.btn-relookup, .btn-relookup-manual { white-space: nowrap; }

tr.needs-confirm { background: var(--warn-bg); }
.remark-text { font-weight: 600; color: var(--warn); display: block; }
.machine-text { color: var(--muted); font-size: 12px; display: block; margin-bottom: 2px; }
.hint.warn { color: var(--warn); font-weight: 600; }
.remove-btn { color: var(--danger); border: none; background: none; cursor: pointer; }

.remove-cell { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn-insert-after {
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 1;
  font-weight: 700;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-remove-row {
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 1;
  font-weight: 700;
  font-size: 18px;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-remove-row:hover { background: var(--danger-bg); border-color: var(--danger); }
.manual-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 4px;
  margin-bottom: 2px;
}
.btn-accept-manual { margin-left: 4px; }

.total-row { justify-content: flex-end; }
.total-label { font-weight: 600; }

.status { text-align: center; color: var(--muted); font-size: 13px; min-height: 20px; }
.status.error { color: var(--danger); }

.finalize-row { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 14px; }
.btn-pending { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); font-weight: 600; }
.btn-pending:hover { border-color: var(--warn); }
.btn-issued { background: var(--ok-bg); border-color: #16a34a; color: #16a34a; font-weight: 600; }
.btn-issued:hover { border-color: #16a34a; }

#pending-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  flex-wrap: wrap;
}
.pending-item .pending-meta { font-size: 13px; }
.pending-item .pending-meta small { color: var(--muted); }
.pending-item .pending-actions { display: flex; gap: 6px; }
.pending-item .btn-resume { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* R202607-02 additions */
.subpanel { margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; }
.subpanel > label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.radio.block { display: flex; padding: 5px 0; }
.pill { display: inline-block; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-size: 12px; color: var(--muted); }
#c-currency.pill { font-weight: 700; color: var(--text); }
.badge { display: inline-block; font-size: 10px; font-weight: 700; border-radius: 4px; padding: 1px 5px; margin-left: 4px; }
.badge.lt { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.badge.pcn { background: #fef2f2; color: var(--danger); border: 1px solid var(--danger); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.status-cell { white-space: nowrap; }
.status-cell .warn { color: var(--warn); font-weight: 600; }

/* R202607-02: results Action column — 3 fixed slots (checkbox / + / −) that
   line up vertically; the checkbox slot stays reserved (empty) when a row
   doesn't need confirmation. */
.action-cell { display: grid; grid-template-columns: 20px 24px 24px; gap: 4px; align-items: center; justify-content: start; }
.act-slot { display: inline-flex; align-items: center; justify-content: center; }
span.act-slot { width: 20px; height: 20px; }
.action-cell .r-confirm { width: 16px; height: 16px; margin: 0; }
.action-cell .btn-insert-after, .action-cell .btn-remove-row { width: 22px; height: 22px; }

/* R202607-02: coordinator welcome banner + withholding-tax badge */
.header-center { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 200px; }
#welcome-msg { font-size: 24pt; line-height: 1.2; text-align: center; }
.badge.wht { background: #eef2ff; color: #4338ca; border: 1px solid #4338ca; }
@media (prefers-color-scheme: dark) { .badge.wht { background: #1e1b4b; color: #a5b4fc; border-color: #a5b4fc; } }
