:root {
  --navy: #1f3a4f;
  --navy-dark: #162b3b;
  --bg: #f3f5f7;
  --card: #ffffff;
  --line: #d9e0e5;
  --text: #1b2329;
  --muted: #647480;
  --danger: #b3261e;
  --ok: #1e6b3a;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 14px; color: var(--navy); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

header.top {
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
header.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
header.top nav button {
  background: transparent;
  color: #cfdbe3;
  border: 0;
  padding: 8px 14px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
header.top nav button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
header.top nav button.active { background: #fff; color: var(--navy); font-weight: 600; }

main { max-width: 1040px; margin: 24px auto; padding: 0 16px 60px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
}
.narrow { max-width: 440px; margin: 8vh auto; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
textarea { resize: vertical; min-height: 38px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid #5b8fb3; outline-offset: 1px; }
.field { margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

button.btn {
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  cursor: pointer;
}
button.btn:hover { background: var(--navy-dark); }
button.btn:disabled { opacity: .55; cursor: default; }
button.btn.ghost { background: #fff; color: var(--navy); border-color: var(--line); }
button.btn.ghost:hover { background: var(--bg); }
button.btn.danger { background: #fff; color: var(--danger); border-color: #e6c3c0; }
button.btn.danger:hover { background: #fdf1f0; }
button.btn.sm { padding: 5px 10px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 2px solid var(--line);
}
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; }
table.items td { padding: 5px 4px; border-bottom: 0; }
table.items th { padding: 6px 4px; }
.w-pos { width: 150px; }
.w-qty { width: 80px; }
.w-price { width: 130px; }
.w-total { width: 120px; }
.w-x { width: 40px; }
.line-total { padding-top: 13px !important; white-space: nowrap; }

.totals { margin-top: 14px; display: flex; justify-content: flex-end; }
.totals table { width: auto; }
.totals td { border: 0; padding: 3px 0 3px 28px; }
.totals tr.grand td { font-weight: 700; font-size: 17px; color: var(--navy); border-top: 2px solid var(--navy); padding-top: 8px; }

.badge {
  display: inline-block;
  background: #e8eef3;
  color: var(--navy);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.msg { padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; }
.msg.err { background: #fdf1f0; color: var(--danger); border: 1px solid #e6c3c0; }
.msg.ok { background: #edf7f0; color: var(--ok); border: 1px solid #bcdcc7; }
.qr { display: block; margin: 8px auto 12px; image-rendering: pixelated; width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Menlo, monospace; letter-spacing: .08em; word-break: break-all; text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
