:root {
  --ink: #101318;
  --muted: #667085;
  --line: #315424;
  --paper: #dbe6f8;
  --green: #2f8d33;
  --green-dark: #25581f;
  --surface: #ffffff;
  --bg: #f4f6f9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid #e2e6ee;
  padding: 14px 28px;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  gap: 12px;
  text-decoration: none;
}

.brand img {
  display: block;
  height: 34px;
  width: auto;
}

.brand-mark {
  color: var(--green);
  font-size: 28px;
  letter-spacing: 0;
}

main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 30px 22px;
}

.panel,
.notes {
  background: var(--surface);
  border: 1px solid #e2e6ee;
  border-radius: 8px;
  padding: 26px;
}

.notes {
  margin-top: 18px;
}

.panel-heading h1,
.notes h2 {
  margin: 0 0 8px;
}

.panel-heading p {
  color: var(--muted);
  margin: 0;
}

.row-between {
  align-items: flex-start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
}

.form-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-weight: 700;
}

.field input {
  border: 1px solid #cfd6e3;
  border-radius: 6px;
  font: inherit;
  padding: 12px;
  width: 100%;
}

.wide {
  grid-column: 1 / -1;
}

button,
.button {
  background: var(--green);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-weight: 800;
  padding: 11px 16px;
  text-decoration: none;
}

.secondary {
  background: #263238;
}

.action-row,
.print-actions {
  display: flex;
  gap: 10px;
}

.print-actions {
  justify-content: flex-end;
  margin: 0 auto 16px;
  max-width: 1100px;
}

.alerts {
  margin-bottom: 16px;
}

.alert {
  background: #fff1f1;
  border: 1px solid #ffd2d2;
  border-radius: 6px;
  color: #9f1d1d;
  padding: 12px;
}

.column-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.column-list span {
  background: #eef5f0;
  border: 1px solid #cfe2d4;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  padding: 7px 10px;
}

.rate-strip {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 24px 0;
}

.rate-strip div {
  background: #f5f8fb;
  border: 1px solid #e0e6ef;
  border-radius: 6px;
  padding: 14px;
}

.rate-strip strong,
.rate-strip span {
  display: block;
}

.rate-strip span {
  font-size: 22px;
  font-weight: 800;
  margin-top: 4px;
}

.pdf-downloads {
  border: 1px solid #e0e6ef;
  border-radius: 6px;
  margin: 0 0 24px;
  padding: 14px;
}

.pdf-downloads strong {
  display: block;
  margin-bottom: 12px;
}

.chunk-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.bill-list {
  border: 1px solid #e0e6ef;
  border-radius: 8px;
  overflow: hidden;
}

.bill-row {
  align-items: center;
  color: var(--ink);
  display: grid;
  gap: 12px;
  grid-template-columns: 1.3fr .5fr 1.4fr .6fr .6fr .6fr;
  padding: 13px 14px;
  text-decoration: none;
}

.bill-row:nth-child(even) {
  background: #f7f9fc;
}

.bill-row:hover {
  background: #edf6ef;
}

.bill-name {
  font-weight: 800;
}

.bill-page {
  background: var(--paper);
  margin: 0 auto 22px;
  max-width: 1100px;
  min-height: 1420px;
  padding: 54px 46px;
  page-break-after: always;
}

.bill-header {
  align-items: flex-start;
  display: grid;
  gap: 24px;
  grid-template-columns: 190px 1fr;
}

.logo-box {
  padding-top: 8px;
}

.logo-box img {
  display: block;
  height: auto;
  max-width: 180px;
  width: 100%;
}

.company-info {
  text-align: center;
}

.company-info h1 {
  font-size: 32px;
  margin: 0 0 50px;
}

.company-info p {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 13px;
}

.company-info .email {
  margin-top: 52px;
  text-align: right;
}

.customer-grid {
  display: grid;
  font-size: 18px;
  gap: 150px;
  grid-template-columns: 1.2fr .8fr;
  margin: 70px 12px 84px;
}

.customer-grid p {
  margin: 0 0 18px;
}

.customer-grid strong {
  display: inline-block;
  min-width: 115px;
}

.customer-grid span {
  font-weight: 700;
}

.bill-table {
  border-collapse: collapse;
  font-size: 15px;
  table-layout: fixed;
  width: 100%;
}

.bill-table th,
.bill-table td {
  border: 1.5px solid var(--line);
  padding: 10px 8px;
  vertical-align: middle;
}

.bill-table th {
  font-size: 16px;
  font-weight: 900;
  text-align: center;
}

.bill-table th:nth-child(1),
.bill-table td:nth-child(1) {
  text-align: center;
  width: 8%;
}

.bill-table th:nth-child(2),
.bill-table td:nth-child(2) {
  width: 27%;
  word-break: break-word;
}

.bill-table th:nth-child(3),
.bill-table td:nth-child(3) {
  width: 34%;
}

.bill-table th:nth-child(4),
.bill-table td:nth-child(4) {
  width: 17%;
}

.bill-table th:nth-child(5),
.bill-table td:nth-child(5) {
  width: 14%;
}

.num {
  text-align: right;
}

.totals {
  display: grid;
  gap: 10px;
  justify-content: end;
  margin-top: 24px;
  width: 100%;
}

.totals div {
  align-items: center;
  display: grid;
  grid-template-columns: 180px 150px;
}

.totals span,
.totals strong {
  border: 1.5px solid var(--line);
  padding: 10px 12px;
}

.totals span {
  background: rgba(255, 255, 255, .35);
  font-weight: 900;
}

.totals strong {
  text-align: right;
}

.bill-footer {
  border-bottom: 1.5px solid var(--line);
  border-top: 1.5px solid var(--line);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.28;
  margin-top: 38px;
  padding: 12px 0 14px;
}

.bill-footer ol {
  margin: 0;
  padding-left: 28px;
}

.bill-footer li {
  margin: 0 0 4px;
}

.bill-footer p {
  color: #d72d36;
  font-size: 16px;
  font-weight: 900;
  margin: 3px 0 0 28px;
}

@media (max-width: 760px) {
  main {
    padding: 18px 12px;
  }

  .form-grid,
  .rate-strip,
  .row-between {
    display: block;
  }

  .field,
  .rate-strip div,
  .action-row {
    margin-top: 14px;
  }

  .bill-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    margin: 9mm;
    size: A4 portrait;
  }

  body {
    background: #fff;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .no-print,
  .topbar {
    display: none !important;
  }

  .bill-page {
    margin: 0;
    max-width: none;
    min-height: auto;
    padding: 38px 32px;
  }

  .bill-table {
    page-break-inside: auto;
  }

  .bill-table tr {
    page-break-inside: avoid;
  }

  .bill-table thead {
    display: table-header-group;
  }
}
