* {
  box-sizing: border-box;
}

:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #d6dce5;
  --brand: #143f6b;
  --brand-2: #4d92cf;
  --accent: #e8f1fb;
  --warn: #fb923c;
  --good: #dbe8d1;
  --yellow: #fff0c7;
}

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

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

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 28px 28px 18px;
  background: linear-gradient(135deg, #173f69, #5c9bd1);
  color: white;
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.app-header p {
  margin: 0;
  max-width: 780px;
  color: rgba(255,255,255,.88);
}

.header-actions, .inline-actions, .panel-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.header-actions button, .inline-actions button, .panel-title-row button, .danger, #printBtn {
  border: 0;
  background: #16395b;
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.panel-title-row button, #printBtn {
  background: #225b92;
}

.danger {
  background: #b23838;
  padding: 8px 10px;
}

.layout {
  padding: 24px;
  display: grid;
  gap: 18px;
}

.panel, .bill-sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 28px rgba(20, 63, 107, 0.08);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 22px;
}

.grid {
  display: grid;
  gap: 14px;
}
.two-col {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
}

textarea {
  resize: vertical;
}

.mt-12 {
  margin-top: 12px;
}

.help {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  border-collapse: collapse;
  width: 100%;
}

#readingsTable th {
  background: #ebf2fa;
  color: #183a60;
  font-size: 13px;
  position: sticky;
  top: 0;
}

#readingsTable th, #readingsTable td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  white-space: nowrap;
}

#readingsTable td input {
  min-width: 110px;
}

#readingsTable .calc {
  text-align: right;
  background: #fafbfc;
  font-weight: bold;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fafcff;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.summary-card strong {
  font-size: 24px;
}

.bill-sheet {
  background: #fff;
  max-width: 1080px;
}

.bill-top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0 20px;
  border-bottom: 2px solid #dfe6ef;
}

.eyebrow {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--brand);
  font-weight: bold;
  margin-bottom: 12px;
}

.bill-top h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.bill-top p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.issue-box {
  min-width: 250px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}

.issue-box div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.issue-box div + div {
  border-top: none;
}

.issue-box span {
  color: var(--muted);
}

.issue-box::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 50%;
  height: 1px;
  background: var(--line);
  transform: translateY(-50%);
}

.issue-box div:first-child {
  margin-top: 2px;
}

.issue-box div:last-child {
  margin-top: 10px;   /* adjust this value */
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fbfdff;
}

.mini-card span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.mini-card strong {
  font-size: 20px;
}

.charge-banner {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.chip {
  border: 2px solid #b33737;
  border-radius: 18px;
  padding: 14px;
  text-align: center;
  background: #fff;
}

.chip span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.chip strong {
  font-size: 26px;
}

.chip.emphasis {
  background: #fff8ef;
}

.operator {
  font-size: 32px;
  color: #8b1e1e;
  font-weight: bold;
  text-align: center;
}

.bill-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

.bill-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.bill-panel h3, .notes-box h4 {
  margin: 0 0 12px;
}

.charge-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
}

.charge-table td:last-child {
  text-align: right;
  font-weight: bold;
}

.total-row td {
  font-size: 22px;
  border-bottom: 0;
  background: var(--good);
}

.formula-box {
  padding: 14px;
  border-radius: 12px;
  background: #f8fbff;
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.formula-box p {
  margin: 0 0 10px;
  line-height: 1.5;
}
.formula-box p:last-child {
  margin-bottom: 0;
}

.notes-box {
  padding: 14px;
  border-radius: 12px;
  background: var(--yellow);
  border: 1px solid #f0d58c;
}



@media print {
  @page {
    size: A3 portrait;
    margin: 8mm;
  }

  body {
    background: white;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

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

  .layout {
    padding: 0;
    display: block;
  }

  .bill-sheet {
    width: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    box-shadow: none;
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
