:root {
  --ink: #050B18;         /* DataCell deep navy */
  --cyan: #0891B2;        /* DataCell cyan (dark variant for light bg) */
  --cyan-bright: #22D3EE;
  --muted: #6B7280;
  --rule: #E5E7EB;
  --rule-strong: #D1D5DB;
  --card: #FFFFFF;
  --bg: #F5F6F8;
  --shade: #F3F4F6;
  --danger: #B91C1C;
  --success: #047857;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }

.shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 24px 96px;
}

/* ---------- masthead ---------- */
.masthead {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}
.masthead-logo { height: 44px; width: auto; display: block; }
.masthead-copy h1 {
  margin: 0 0 2px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.masthead-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 24px 28px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(5, 11, 24, 0.04);
}
.card h2 {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.card-summary {
  padding: 18px 24px;
}

/* ---------- invoice number display (read-only) ---------- */
.invoice-number-display {
  display: inline-block;
  padding: 10px 14px;
  background: var(--shade);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.5px;
  width: fit-content;
  user-select: all;
}
.summary-line {
  margin: 2px 0;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.6;
}
.summary-key { color: var(--muted); margin-right: 4px; }
.summary-sep { color: var(--rule-strong); margin: 0 6px; }
.summary-muted { color: var(--muted); }

/* ---------- grid + fields ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; }
.field-wide { grid-column: 1 / -1; }

.field label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field small {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.field code {
  background: var(--shade);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

input, textarea, select {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  transition: border-color 120ms, box-shadow 120ms;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(5, 11, 24, 0.08);
}
textarea { resize: vertical; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---------- line items ---------- */
.line-items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.line-item {
  display: grid;
  grid-template-columns: 1fr 90px 140px auto;
  gap: 12px;
  align-items: end;
}
.line-item .field label { font-size: 11px; }
.add-item {
  padding: 9px 16px;
}

/* ---------- meta card (invoice # + totals) ---------- */
.card-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
}
.totals-strip {
  display: flex;
  gap: 24px;
  align-items: center;
}
.totals-strip > div {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.totals-strip span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.totals-strip output {
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.totals-strip output.total-pop {
  font-size: 22px;
  color: var(--cyan);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 100ms, background 120ms, color 120ms, border-color 120ms;
  background: var(--card);
}
.btn-primary {
  background: var(--ink);
  color: white;
  padding: 12px 22px;
  font-size: 15px;
  border-radius: 12px;
}
.btn-primary:hover { background: #0b1a30; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: 0.6; cursor: progress; }
.btn-outline {
  background: var(--card);
  color: var(--ink);
  border-color: var(--ink);
}
.btn-outline:hover { background: var(--ink); color: white; }
.btn-ghost {
  background: var(--card);
  color: var(--muted);
  border-color: var(--rule);
  padding: 8px 14px;
  font-size: 13px;
}
.btn-ghost:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- actions bar ---------- */
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}
.status { font-size: 13px; color: var(--muted); flex: 1; }
.status.success { color: var(--success); }
.status.error { color: var(--danger); }

/* ---------- spinner ---------- */
.btn-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  display: none;
}
.btn.loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .card-meta { grid-template-columns: 1fr; }
  .totals-strip { justify-content: flex-start; }
  .line-item { grid-template-columns: 1fr 1fr; }
  .line-item .field-desc { grid-column: 1 / -1; }
  .line-item .remove-line { grid-column: 2; justify-self: end; }
}
