:root {
  --navy: #0a2463;
  --navy-2: #1a3a8f;
  --red: #b8960c;
  --ink: #1b2430;
  --muted: #5d6b7c;
  --line: #d9e0e8;
  --bg: #f3f5f8;
  --card: #ffffff;
  --ok: #17794a;
  --ok-bg: #e6f4ec;
  --warn-bg: #fff5e0;
  --err: #a8121f;
  --err-bg: #fdecee;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--navy-2); }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 650; margin-bottom: 16px; }
p { margin: 0; }
[hidden] { display: none !important; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1280px; }

/* Header */
.topbar { background: #fff; color: var(--ink); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-logo { height: 44px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; letter-spacing: 0.02em; }
.brand-text small { font-size: 12px; font-weight: 700; color: var(--navy); letter-spacing: 0.08em; text-transform: uppercase; padding-left: 16px; border-left: 1px solid var(--line); line-height: 2.4; }
.top-link { color: var(--navy); font-size: 14px; font-weight: 600; text-decoration: none; }
.top-link:hover { text-decoration: underline; }
.stripe { height: 3px; background: linear-gradient(90deg, var(--navy) 0 70%, var(--red) 70% 100%); }

/* Intro + steps */
.intro { padding: 32px 0 20px; }
.intro p { margin-top: 8px; color: var(--muted); max-width: 680px; }

.steps { list-style: none; display: flex; gap: 0; padding: 0; margin: 0 0 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.steps li { flex: 1; padding: 12px 16px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; font-size: 14px; border-right: 1px solid var(--line); }
.steps li:last-child { border-right: 0; }
.steps li span { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid currentColor; display: grid; place-items: center; font-size: 12px; flex: none; }
.steps li.is-active { color: var(--navy); box-shadow: inset 0 -3px 0 var(--red); }
.steps li.is-active span { background: var(--navy); border-color: var(--navy); color: #fff; }
.steps li.is-done { color: var(--ok); }
.steps li.is-done span { background: var(--ok); border-color: var(--ok); color: #fff; }

/* Cards + forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
label, .field-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
label em { font-weight: 400; color: var(--muted); font-style: normal; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #b9c3cf; border-radius: 4px; background: #fff;
  font: inherit; color: var(--ink);
}
input:focus, select:focus, textarea:focus, .dropzone:focus, .btn:focus-visible {
  outline: 2px solid var(--navy-2); outline-offset: 1px; border-color: var(--navy-2);
}
textarea { resize: vertical; }
.hint { color: var(--muted); font-size: 13px; margin-top: 8px; }
.field { margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 4px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: #fff; color: var(--navy); border-color: #b9c3cf; }
.btn-ghost:hover { border-color: var(--navy); }
.btn-danger { background: #fff; color: var(--err); border-color: #e3b4b9; }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions.center { justify-content: center; margin-top: 20px; }

.lookup-row { display: flex; gap: 10px; }
.lookup-row input { font-size: 18px; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; max-width: 360px; }

.msg { padding: 10px 14px; border-radius: 4px; margin: 0 0 16px; font-size: 14px; }
.lookup .msg { margin: 14px 0 0; }
.msg-error { background: var(--err-bg); color: var(--err); border: 1px solid #f0c2c7; }
.msg-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe0cd; }

/* Invoice summary */
.invoice-card { border-top: 3px solid var(--navy); }
.invoice-head { display: flex; gap: 40px; align-items: flex-end; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.invoice-head .btn { margin-left: auto; }
.label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.invoice-no { font-size: 22px; font-variant-numeric: tabular-nums; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding-top: 16px; }
.party strong { display: block; font-size: 16px; margin-bottom: 2px; }
.party p { color: #3c4857; }
.party .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Dropzone */
.dropzone {
  border: 2px dashed #9eabba; border-radius: var(--radius); padding: 28px 16px; text-align: center;
  background: #f9fafc; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.dropzone span { color: var(--muted); font-size: 13px; }
.dropzone.is-over { border-color: var(--navy); background: #edf2fa; }
.filelist { list-style: none; padding: 0; margin: 10px 0 0; }
.filelist li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 4px; margin-bottom: 6px; background: #fff; }
.filelist .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.filelist .fsize { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.filelist button { border: 0; background: none; color: var(--err); cursor: pointer; font: inherit; font-size: 13px; padding: 2px 4px; }

.progress { height: 8px; background: #e3e8ee; border-radius: 4px; overflow: hidden; margin: 14px 0; }
.progress div { height: 100%; width: 0; background: var(--navy); transition: width 0.15s linear; }

.done { text-align: center; padding: 40px 24px; }
.done h2 { font-size: 22px; margin-bottom: 8px; }
.done-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; font-size: 28px; margin: 0 auto 14px; }

.footer { color: var(--muted); font-size: 13px; padding: 16px 0 40px; }
.footer p { margin-bottom: 4px; }

/* Admin */
.admin-nav { display: flex; gap: 4px; align-items: center; }
.admin-nav a { color: var(--ink); text-decoration: none; padding: 8px 14px; border-radius: 4px; font-size: 14px; font-weight: 600; }
.admin-nav a:hover { background: var(--bg); }
.admin-nav a.is-current { background: var(--navy); color: #fff; }
.admin-nav form { margin-left: 12px; }
.admin-nav .btn { background: #fff; color: var(--navy); border-color: #b9c3cf; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 0 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.stats { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; min-width: 150px; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type=search] { flex: 1; min-width: 240px; max-width: 440px; }
.filters select { width: auto; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; margin-bottom: 20px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); background: #f8f9fb; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; }
td small { color: var(--muted); display: block; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 700; }
.badge-new { background: var(--warn-bg); color: #8a5a00; }
.badge-reviewed { background: var(--ok-bg); color: var(--ok); }
.badge-off { background: #e9edf2; color: var(--muted); }
.files-cell { min-width: 220px; }
.files-cell a { display: block; overflow-wrap: anywhere; }
.files-cell small { display: inline; }
.note-cell { max-width: 240px; color: #3c4857; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 6px; }
.row-actions .btn { white-space: nowrap; }
.row-actions form { margin: 0; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; margin-bottom: 32px; color: var(--muted); font-size: 14px; }
.login-box { max-width: 380px; margin: 64px auto; }

@media (max-width: 720px) {
  .grid, .grid-2, .parties { grid-template-columns: 1fr; }
  .invoice-head { flex-wrap: wrap; gap: 16px; }
  .invoice-head .btn { margin-left: 0; }
  .steps li { padding: 10px; font-size: 13px; }
  .lookup-row { flex-direction: column; }
  .lookup-row input { max-width: none; }
  h1 { font-size: 22px; }
}
