:root {
  color-scheme: light;
  --ink: #222222;
  --muted: #5f6368;
  --line: #222222;
  --paper: #ffffff;
  --panel: rgba(255, 255, 255, 0.94);
  --soft: #f5f7fb;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --gold: #b7791f;
  --paid: #15803d;
  --unpaid: #b45309;
  --shadow: 0 18px 55px rgba(23, 32, 51, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.12), rgba(183, 121, 31, 0.1)),
    #f3f6fb;
  color: var(--ink);
}

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

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(400px, 560px) minmax(460px, 1fr);
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(215, 222, 234, 0.95);
  box-shadow: var(--shadow);
}

.editor {
  border-radius: 8px;
  padding: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.12;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid #b7d7d5;
  color: var(--accent-dark);
  background: #eef9f7;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 800;
}

.section-title {
  border-top: 1px solid var(--line);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  margin: 22px 0 14px;
  padding-top: 18px;
  text-transform: uppercase;
}

.section-title:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: #425066;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input[type="file"] {
  padding: 9px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.paid-toggle {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
}

.customer-tools {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 14px;
}

.paid-toggle input {
  accent-color: var(--accent);
  height: 18px;
  width: 18px;
}

.items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 12px;
}

.soft-button,
.primary,
.secondary,
.remove-item,
.text-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 42px;
  font-weight: 800;
}

.soft-button {
  background: #e7f3f2;
  color: var(--accent-dark);
  padding: 0 13px;
}

.items {
  display: grid;
  gap: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 68px 92px 92px 42px;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.item-row textarea {
  min-height: 82px;
}

.remove-item {
  display: grid;
  place-items: center;
  border: 1px solid #f1c8c3;
  color: #9f2f24;
  background: #fff1ef;
  font-size: 20px;
}

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

.summary-inputs label:last-child {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.primary {
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary {
  background: #eef2f6;
  color: #2e3a4c;
  padding: 0 16px;
}

.record-box {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 18px;
}

.record-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.text-button {
  background: transparent;
  color: var(--muted);
  min-height: auto;
  padding: 4px 0;
}

.record-list {
  display: grid;
  gap: 8px;
}

.record-columns {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.record-columns h3 {
  color: var(--accent-dark);
  font-size: 13px;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.record-row {
  align-items: start;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  padding: 10px 12px;
}

.record-row strong,
.record-row span {
  display: block;
}

.record-row span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.status-paid,
.status-unpaid {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
}

.status-paid {
  background: #dcfce7;
  color: var(--paid);
}

.status-unpaid {
  background: #fef3c7;
  color: var(--unpaid);
}

.empty-record {
  color: var(--muted);
  margin: 0;
}

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

.record-actions button {
  border: 1px solid #d7deea;
  border-radius: 5px;
  background: #ffffff;
  color: #2e3a4c;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  min-height: 30px;
  padding: 0 9px;
}

.record-actions button[data-action="delete"] {
  border-color: #f1c8c3;
  color: #9f2f24;
}

.monthly-report {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}

.monthly-report input {
  max-width: 170px;
}

.report-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-grid div {
  background: #fbfcfe;
  border: 1px solid #d7deea;
  border-radius: 8px;
  padding: 11px;
}

.report-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
}

.report-grid strong {
  display: block;
  font-size: 16px;
}

.preview-panel {
  border-radius: 8px;
  padding: 20px;
  position: sticky;
  top: 24px;
}

.invoice-preview {
  background: var(--paper);
  border: 1px solid #d7deea;
  color: var(--ink);
  min-height: 842px;
  overflow: hidden;
  position: relative;
  width: min(100%, 760px);
  margin: 0 auto;
}

.invoice-top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 44px 40px 20px;
}

.brand-block {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  max-width: 58%;
}

.logo-frame {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 2px;
  color: #222222;
  display: flex;
  flex: 0 0 auto;
  font-size: 18px;
  font-weight: 900;
  height: 58px;
  justify-content: center;
  overflow: hidden;
  width: 58px;
}

.logo-frame img {
  display: none;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.logo-frame.has-logo img {
  display: block;
}

.logo-frame.has-logo span {
  display: none;
}

.ssm-line {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin: 0 0 5px;
  text-transform: uppercase;
}

.invoice-top h2 {
  font-size: 15px;
  line-height: 1.2;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.invoice-top p {
  font-size: 11px;
  line-height: 1.35;
  margin: 0 0 2px;
  color: var(--muted);
}

.invoice-title {
  text-align: right;
  display: grid;
  gap: 7px;
  align-content: start;
}

.invoice-title span {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0;
}

.invoice-number-line {
  font-size: 18px;
  font-weight: 400;
  white-space: nowrap;
}

.invoice-number-line strong {
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  padding: 0;
}

.invoice-number-line b {
  font-size: 18px;
}

.invoice-title > strong {
  border-radius: 999px;
  font-size: 11px;
  justify-self: end;
  padding: 5px 10px;
}

.invoice-title > strong.paid {
  background: #dcfce7;
  color: var(--paid);
}

.invoice-title > strong.unpaid {
  background: #fef3c7;
  color: var(--unpaid);
}

.invoice-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 20px;
  padding: 2px 40px 24px;
}

.bill-to,
.invoice-meta div,
.payment-record {
  border: 0;
  border-radius: 0;
  padding: 0;
}

.bill-to {
  background: transparent;
}

.invoice-meta {
  display: grid;
  gap: 8px;
  justify-items: end;
  text-align: right;
}

.bill-to span,
.invoice-meta span,
.payment-record span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.bill-to strong,
.invoice-meta strong,
.payment-record strong {
  overflow-wrap: anywhere;
}

.bill-to strong {
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.bill-to p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin: 0 0 3px;
}

.invoice-table {
  border-collapse: collapse;
  margin: 0 40px;
  width: calc(100% - 80px);
}

.invoice-table th,
.invoice-table td {
  border-bottom: 1px solid #d6d6d6;
  padding: 14px 8px;
  text-align: right;
  vertical-align: top;
  font-size: 12px;
}

.invoice-table tbody td {
  min-height: 54px;
}

.invoice-table tbody tr {
  height: 74px;
}

.invoice-table th:nth-child(2),
.invoice-table td:nth-child(2) {
  padding-left: 20px;
  text-align: left;
}

.invoice-table th:nth-child(2),
.invoice-table td:nth-child(2) {
  width: 46%;
}

.description-cell {
  line-height: 1.55;
  white-space: normal;
}

.invoice-table th {
  background: transparent;
  border-bottom: 1.6px solid #222222;
  border-top: 1.6px solid #222222;
  color: #222222;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 24px;
  padding: 18px 40px 0;
}

#previewNotes {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 12px;
}

.thank-you {
  font-size: 23px;
  font-weight: 700;
  margin-bottom: 18px;
}

.payment-record {
  margin-bottom: 16px;
}

.notice-box {
  color: #222222;
  font-size: 12px;
  line-height: 1.35;
}

.notice-box strong {
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
}

.notice-box p {
  margin: 0 0 5px;
}

.totals {
  display: grid;
  align-content: start;
  gap: 7px;
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.totals .grand {
  border-top: 1.6px solid var(--ink);
  font-size: 14px;
  margin-top: 4px;
  padding-top: 8px;
}

.computer-note {
  border-top: 0;
  color: var(--muted);
  font-size: 12px;
  margin: 96px 40px 0;
  padding: 0 0 28px;
  text-align: center;
}

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

  .preview-panel {
    position: static;
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 12px;
  }

  .editor,
  .preview-panel {
    padding: 16px;
  }

  .grid.two,
  .customer-tools,
  .summary-inputs,
  .invoice-info,
  .invoice-meta,
  .invoice-bottom {
    grid-template-columns: 1fr;
  }

  .item-row {
    grid-template-columns: 1fr 74px 1fr 1fr 42px;
  }

  .record-columns,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .invoice-top {
    display: grid;
    padding: 24px 18px;
  }

  .invoice-title {
    text-align: left;
  }

  .invoice-title strong {
    justify-self: start;
  }

  .invoice-info,
  .invoice-bottom {
    padding-left: 18px;
    padding-right: 18px;
  }

  .invoice-table {
    margin: 0 18px;
    width: calc(100% - 36px);
  }

  .computer-note {
    margin-left: 18px;
    margin-right: 18px;
  }

  .actions {
    display: grid;
  }
}

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

  .editor {
    display: none;
  }

  .app-shell,
  .preview-panel,
  .invoice-preview {
    border: 0;
    box-shadow: none;
    margin: 0;
    padding: 0;
    width: 100%;
  }

  .workspace {
    display: block;
  }

  .invoice-preview {
    min-height: auto;
  }
}

.record-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.restore-button {
  color: var(--muted);
  cursor: pointer;
  display: inline-block;
  font-size: 13px;
  font-weight: 800;
}

.restore-button input {
  display: none;
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(215, 222, 234, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 420px;
  padding: 28px;
  width: min(100%, 420px);
}

.login-card h1 {
  margin-bottom: 4px;
}

.login-error {
  background: #fff1ef;
  border: 1px solid #f1c8c3;
  border-radius: 6px;
  color: #9f2f24;
  margin: 0;
  padding: 10px 12px;
}

.logout-link {
  background: #ffffff;
  border: 1px solid #d7deea;
  border-radius: 999px;
  color: #2e3a4c;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 13px;
  position: fixed;
  right: 18px;
  text-decoration: none;
  top: 18px;
  z-index: 10;
}
