:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #616e7c;
  --line: #d9dee3;
  --accent: #1b6ec2;
  --accent-dark: #155a9e;
  --ok: #1e7f4f;
  --ok-bg: #e6f4ec;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --err: #a12622;
  --err-bg: #fbe9e7;
  --info: #1b4f8a;
  --info-bg: #e7f0fb;
  --highlight: #fff1cc;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

main { max-width: 1100px; margin: 0 auto; padding: 0 20px 40px; }

.page-header {
  max-width: 1100px; margin: 0 auto; padding: 32px 20px 12px;
}
.back-link {
  display: inline-block; color: var(--muted); font-size: 13.5px; text-decoration: none; margin-bottom: 14px;
}
.back-link:hover { color: var(--accent); text-decoration: underline; }
.page-header .logo { display: block; width: 260px; max-width: 100%; height: auto; margin: 0 0 20px; }
.page-header h1 { margin: 0 0 6px; font-size: 32px; }
.page-header p { margin: 8px 0; color: var(--muted);font-size: 18px }
.page-header ol { margin: 8px 0 0 20px; color: var(--muted); font-size: 18px; }

.page-footer {
  max-width: 1100px; margin: 0 auto; padding: 0 20px 40px; color: var(--muted); font-size: 13px; text-align: center;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 24px;
  margin: 16px 0;
}
.card h2 { margin: 0 0 12px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.card h3 { margin: 20px 0 6px; font-size: 15px; }

.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
}

.hint { color: var(--muted); font-size: 13.5px; margin: 6px 0; }

/* Period radios */
.radio-row { display: flex; gap: 12px; flex-wrap: wrap; }
.radio {
  flex: 1 1 200px; display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer;
}
.radio:has(input:checked) { border-color: var(--accent); background: #eef5fc; }
.radio input { margin-top: 3px; }
.radio span { display: flex; flex-direction: column; }
.radio small { color: var(--muted); }

/* File drop zones */
.drop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .drop-grid { grid-template-columns: 1fr; } }

.drop {
  border: 2px dashed var(--line); border-radius: 10px; padding: 18px; cursor: pointer;
  min-height: 130px; transition: border-color .15s, background .15s; outline: none;
}
.drop:hover, .drop:focus-visible { border-color: var(--accent); background: #f7fbff; }
.drop.dragover { border-color: var(--accent); background: #eef5fc; }
.drop.loaded { border-style: solid; border-color: var(--ok); }
.drop.failed { border-style: solid; border-color: var(--err); }
.drop-title { font-weight: 600; font-size: 16px; }
.drop-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.file-info { margin-top: 10px; font-size: 13.5px; }
.file-info .fname { font-weight: 600; word-break: break-all; }
.file-info dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 6px 0 0; }
.file-info dt { color: var(--muted); }
.file-info dd { margin: 0; }
.file-info .err { color: var(--err); }
.file-info .note { color: var(--warn); }

/* Review form */
.form-grid {
  display: grid; grid-template-columns: max-content 1fr; gap: 12px 16px; align-items: center;
}
.form-grid label { font-weight: 600; }
.form-grid input[type=text], .form-grid select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; max-width: 420px; width: 100%;
}
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 400 !important; }
.hint-inline { color: var(--muted); font-size: 13px; }
.check-row { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.check-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.badge {
  display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px;
  background: #e4e7eb; color: var(--muted); margin-left: 2px;
}
.badge.missing { background: var(--warn-bg); color: var(--warn); }

/* Mapping table */
.map-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.map-table th, .map-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.map-table th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.map-table select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; min-width: 220px; }
.map-table tr.needs-attention { background: var(--highlight); }
.map-table tr.needs-attention select { border-color: var(--warn); }
.tag {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 4px;
}
.tag-pl { background: #e7f0fb; color: var(--info); }
.tag-bs { background: #ece7fb; color: #4a3a9a; }

/* Messages */
#messages { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg {
  border-radius: 8px; padding: 10px 14px; font-size: 14px; border: 1px solid transparent;
}
.msg ul { margin: 4px 0 0; padding-left: 20px; }
.msg li { margin: 2px 0; }
.msg-error { background: var(--err-bg); color: var(--err); border-color: #f1c2be; }
.msg-warn { background: var(--warn-bg); color: var(--warn); border-color: #f0d79a; }
.msg-info { background: var(--info-bg); color: var(--info); border-color: #bcd3ef; }
.msg-ok { background: var(--ok-bg); color: var(--ok); border-color: #b9dfc8; }

/* Actions */
.actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.btn-primary {
  font: inherit; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 8px; padding: 10px 18px; cursor: pointer;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-primary:disabled { background: #b5bcc4; cursor: not-allowed; }

/* Preview */
details { margin-top: 18px; }
summary { cursor: pointer; font-weight: 600; }
.preview-scroll { overflow: auto; max-height: 520px; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.preview { border-collapse: collapse; font-size: 13px; min-width: 100%; white-space: nowrap; }
.preview th, .preview td { padding: 4px 10px; border-bottom: 1px solid #eef0f2; }
.preview th { position: sticky; top: 0; background: #e9ecef; text-align: right; }
.preview th:first-child, .preview th:nth-child(2) { text-align: left; }
.preview td.num { text-align: right; font-variant-numeric: tabular-nums; }
.preview td.neg { color: var(--err); }
.preview tr.section td { font-weight: 600; padding-top: 10px; }
.preview tr.section td:first-child { font-weight: 700; }
.preview tr.total td, .preview tr.grand td { font-weight: 600; border-top: 1px solid var(--line); }
.preview tr.blank td { height: 6px; padding: 0; border: 0; }
