* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f8fafc;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.45;
}

header {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo-wrap { display: flex; align-items: center; }
.logo-img { height: 44px; width: auto; display: block; }
.logo-fallback { font-weight: 600; font-size: 16px; }
.logo-fallback span { color: #2563eb; }

nav { display: flex; gap: 4px; }
nav button {
  background: none; border: none;
  padding: 6px 12px; border-radius: 6px;
  color: #475569; cursor: pointer;
  font-size: 13px;
}
nav button:hover { background: #f1f5f9; }
nav button.active { background: #2563eb; color: white; }

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

h1 { font-size: 22px; margin: 0 0 4px; }
.subtitle { color: #64748b; font-size: 13px; margin: 0 0 20px; }

.card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .grid-3 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 0 0 auto; }

label { display: block; font-size: 12px; color: #64748b; margin-bottom: 3px; }
input, select, textarea, button {
  font-family: inherit; font-size: 13px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1; border-radius: 6px;
  background: white; color: #0f172a;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #2563eb; outline-offset: -1px;
  border-color: transparent;
}
button {
  cursor: pointer; background: #f1f5f9; border-color: #cbd5e1;
}
button:hover { background: #e2e8f0; }
button.primary { background: #2563eb; color: white; border-color: #2563eb; }
button.primary:hover { background: #1d4ed8; }
button.dark { background: #0f172a; color: white; border-color: #0f172a; }
button.danger { color: #dc2626; background: white; border-color: #fecaca; }
button.link {
  background: none; border: none; color: #2563eb; padding: 0; font-size: 13px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: #64748b; padding: 8px; border-bottom: 1px solid #e2e8f0; }
td { padding: 8px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: ui-monospace, monospace; }

.pill {
  display: inline-block;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; color: white;
}
.tag {
  display: inline-block;
  background: #f1f5f9; color: #475569;
  padding: 2px 6px; border-radius: 4px;
  font-size: 11px; margin: 2px;
  font-family: ui-monospace, monospace;
}

.summary-big { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; font-family: ui-monospace, monospace; }

.muted { color: #64748b; }
.sm { font-size: 12px; }

.error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 8px; border-radius: 6px; font-size: 13px; }
.warn  { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 8px; border-radius: 6px; font-size: 13px; }
.ok    { color: #059669; }

.split-row { display: grid; grid-template-columns: 140px 1fr 40px; gap: 8px; align-items: center; margin-bottom: 6px; }
.split-row .name { font-weight: 500; font-size: 13px; }
.split-row .code { font-size: 11px; color: #64748b; }

.view { display: none; }
.view.active { display: block; }

/* statement print layout */
.statement {
  page-break-after: always;
  margin-bottom: 24px;
}
.statement header {
  background: none; border: none; padding: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 1px solid #e2e8f0; padding-bottom: 12px; margin-bottom: 12px;
}
.statement .co-name { font-size: 22px; font-weight: 700; margin: 4px 0; }
.statement .issued-label { font-size: 11px; color: #64748b; }

@media print {
  body { background: white; }
  body > header, nav, .no-print { display: none !important; }
  main { padding: 0; max-width: 100%; }
  .card { box-shadow: none; border: none; padding: 0; margin-bottom: 24px; }
  /* when body has print-one-<id>, hide all statements except that one */
  body[class*="print-one-"] .statement { display: none !important; }
  body.print-one-all .statement { display: block !important; }
}
/* helper class to mark the currently-printing statement visible */
body[class*="print-one-"] .statement.print-target { display: block !important; }
