:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #697586;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --soft: #edf7f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions button:nth-child(2),
.actions button:nth-child(3) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(420px, 1fr);
  gap: 18px;
  padding: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
  text-transform: none;
}

textarea {
  resize: vertical;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.btn-icon {
  min-height: 24px;
  min-width: 24px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
  flex-shrink: 0;
}

.add-customer-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.add-customer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#newCustomerStatus {
  font-size: 12px;
  color: var(--muted);
}

.customer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  min-height: 72px;
  color: var(--muted);
}

.customer-card strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.line-head,
.line-item {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 72px 92px 72px 36px;
  gap: 8px;
  align-items: center;
}

.line-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

#lineItems {
  display: grid;
  gap: 8px;
}

.remove-line {
  padding: 0;
  min-width: 36px;
}

.preview-wrap {
  padding: 22px;
  overflow: auto;
}

.invoice {
  max-width: 860px;
  min-height: 980px;
  margin: 0 auto;
  background: #fff;
  color: #111827;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 44px;
}

.invoice-header,
.invoice-meta,
.invoice-total-row,
.invoice-party-grid {
  display: flex;
  justify-content: space-between;
  gap: 28px;
}

.invoice-title {
  font-size: 34px;
  font-weight: 800;
}

.invoice-subtitle,
.invoice-muted {
  color: #667085;
}

.invoice-box {
  margin-top: 28px;
}

.invoice-party-grid > div {
  flex: 1;
}

.invoice table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 28px;
}

.invoice th,
.invoice td {
  border-bottom: 1px solid #e5e7eb;
  padding: 11px 0;
  text-align: left;
  vertical-align: top;
}

.invoice th:not(:first-child),
.invoice td:not(:first-child) {
  text-align: right;
}

.totals {
  margin: 24px 0 0 auto;
  width: min(340px, 100%);
}

.invoice-total-row {
  padding: 7px 0;
  border-bottom: 1px solid #e5e7eb;
}

.invoice-total-row.grand {
  font-size: 20px;
  font-weight: 800;
  border-bottom: 0;
}

.notes {
  margin-top: 34px;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .grid.two,
  .line-head,
  .line-item {
    grid-template-columns: 1fr;
  }

  .line-head {
    display: none;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .controls {
    display: none;
  }

  .workspace,
  .preview-wrap {
    display: block;
    padding: 0;
  }

  .panel,
  .invoice {
    border: 0;
    border-radius: 0;
  }

  .invoice {
    max-width: none;
    min-height: auto;
    padding: 24px;
  }
}
