:root {
  color-scheme: light;
  --ink: #1b2520;
  --muted: #65706b;
  --line: #d9ded9;
  --surface: #f6f7f4;
  --paper: #ffffff;
  --accent: #2f6f4e;
  --accent-dark: #234f3a;
  --warn: #9a4a24;
}

* {
  box-sizing: border-box;
}

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

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(620px, 1fr);
  min-height: 100vh;
}

.editor-panel {
  border-right: 1px solid var(--line);
  background: #eef2ed;
  padding: 24px;
  overflow: auto;
}

.preview-panel {
  padding: 28px;
  overflow: auto;
}

.brand-row,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
}

.section-title {
  margin-top: 28px;
  margin-bottom: 12px;
}

.section-title h2 {
  font-size: 17px;
}

.control-grid,
.totals-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

label,
.notes-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.notes-label {
  margin-top: 14px;
}

.primary-button,
.ghost-button,
.icon-button,
.remove-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button,
.icon-button {
  background: var(--accent);
  color: white;
  padding: 0 14px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--accent-dark);
  padding: 0 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.item-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.25fr) minmax(150px, 1.2fr) minmax(120px, 1fr) minmax(110px, 0.9fr) 72px 78px 92px 40px;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  padding: 10px;
}

.storage-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  padding: 12px;
}

.storage-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.storage-status.ok {
  color: var(--accent-dark);
}

.storage-status.error {
  color: var(--warn);
}

.saved-quotes {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.saved-quote-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
}

.quote-load-button,
.quote-delete-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.quote-load-button {
  overflow: hidden;
  padding: 0 10px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-delete-button {
  color: var(--warn);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.remove-button {
  width: 38px;
  padding: 0;
  border-color: #d8b3a0;
  color: var(--warn);
  background: #fff7f2;
}

.totals-editor {
  margin-top: 16px;
}

.quote-document {
  width: min(100%, 920px);
  min-height: 1180px;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(27, 37, 32, 0.08);
  padding: 42px;
}

.quote-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 22px;
}

.quote-header h2 {
  font-size: 30px;
}

.quote-brand {
  min-width: 0;
}

.quote-logo {
  display: block;
  width: 210px;
  height: auto;
  margin-bottom: 12px;
}

#previewCompanyInfo,
#previewCustomerInfo,
.terms,
.quote-footer {
  color: var(--muted);
  line-height: 1.5;
}

.quote-meta {
  display: grid;
  gap: 6px;
  min-width: 180px;
  text-align: right;
}

.customer-box {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin: 28px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.customer-box span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.customer-box strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.quote-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.quote-table th {
  background: #e7eee8;
  color: var(--accent-dark);
  text-align: left;
}

.quote-table th,
.quote-table td {
  border: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
}

.quote-table th:nth-child(n+4),
.quote-table td:nth-child(n+4) {
  text-align: right;
}

.summary-block {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 28px;
  margin-top: 28px;
}

.terms p {
  margin: 0 0 8px;
}

.totals {
  display: grid;
  gap: 8px;
}

.totals div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: baseline;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.totals span {
  min-width: 0;
  text-align: left;
}

.totals strong {
  min-width: 118px;
  text-align: right;
  white-space: nowrap;
}

.grand-total {
  color: var(--accent-dark);
  font-size: 20px;
}

.quote-footer {
  margin-top: 72px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .editor-panel,
  .preview-panel,
  .quote-document {
    padding: 18px;
  }

  .control-grid,
  .totals-editor,
  .summary-block {
    grid-template-columns: 1fr;
  }

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

  .quote-header,
  .customer-box {
    display: grid;
  }

  .quote-meta {
    text-align: left;
  }

  .quote-table {
    font-size: 12px;
    min-width: 620px;
  }
}

@media print {
  body {
    background: white;
  }

  .editor-panel {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .preview-panel {
    padding: 0;
  }

  .quote-document {
    width: 100%;
    min-height: auto;
    border: 0;
    box-shadow: none;
    padding: 22mm;
  }
}
