:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #64748b;
  --line: #dbe2ea;
  --soft: #f8fafc;
  --gold: #ffde15;
  --gold-dark: #b7791f;
  --green: #047857;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.toolbar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.toolbar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 38px;
  padding: 0 13px;
  font-weight: 700;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.secondary-button,
.icon-button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.icon-button {
  width: 38px;
  padding: 0;
}

.material-symbols-outlined {
  font-size: 19px;
  line-height: 1;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(620px, 1fr);
  gap: 18px;
  align-items: start;
}

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

fieldset {
  border: 0;
  padding: 0;
  margin: 18px 0 0;
}

fieldset:first-of-type {
  margin-top: 16px;
}

legend {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

label {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
}

.toggle-row input {
  width: 16px;
  min-height: 16px;
}

.toggle-row span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

label span,
.file-label span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

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

textarea {
  resize: vertical;
  min-height: 72px;
}

.wide-field textarea {
  min-height: 54px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 3px rgba(255, 222, 21, 0.22);
}

.hidden {
  display: none !important;
}

.section-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.item-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--soft);
}

.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.item-head strong {
  font-size: 12px;
}

.remove-item {
  min-width: 30px;
  min-height: 30px;
  border: 1px solid #fecaca;
  color: var(--danger);
  background: #fff;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-label {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.bank-summary {
  display: grid;
  gap: 4px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.file-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-control input {
  padding-top: 7px;
  font-size: 12px;
}

.preview-stage {
  overflow: auto;
  padding: 0 0 18px;
}

.invoice-sheet {
  position: relative;
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: #fff;
  padding: 42px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.watermark {
  position: absolute;
  top: 54%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  color: rgba(15, 23, 42, 0.035);
  font-size: 126px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
}

.invoice-header,
.document-strip,
.details-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.invoice-header {
  align-items: start;
}

.invoice-header h2 {
  margin: 0 0 7px;
  font-size: 18px;
}

.invoice-header p,
.document-strip p,
.message p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.brand-mark {
  justify-self: end;
  width: 82px;
  height: 82px;
}

.brand-mark svg,
.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-mark img {
  object-fit: contain;
}

.rule {
  position: relative;
  height: 1px;
  background: var(--gold);
  margin: 26px 0 18px;
}

.document-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 14px;
  border-radius: 16px;
  background: #eef2f6;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

.status-box {
  justify-self: stretch;
  align-self: start;
  border-left: 4px solid var(--gold-dark);
  background: #fffbeb;
  border-radius: 7px;
  padding: 14px 16px;
}

.status-box strong {
  display: block;
  color: #92400e;
  font-size: 14px;
  margin-bottom: 4px;
}

.status-box span {
  color: #92400e;
  font-size: 10px;
}

.details-grid {
  margin: 30px 0 22px;
}

h3 {
  position: relative;
  margin: 0 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--gold);
  font-size: 12px;
}

.right {
  text-align: right;
}

.info-block {
  min-height: 86px;
  background: #f8fafc;
  border-radius: 7px;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}

.info-block strong {
  color: var(--ink);
  font-size: 12px;
}

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

th {
  background: #e5e7eb;
  color: #374151;
  font-size: 10px;
  padding: 8px;
  text-align: left;
}

td {
  border-bottom: 1px solid #f1f5f9;
  padding: 10px 8px;
  color: var(--ink);
  font-size: 11px;
  vertical-align: middle;
}

.center {
  text-align: center;
}

.right {
  text-align: right;
}

.product-preview {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  align-items: center;
}

.product-preview img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 3px;
}

.product-placeholder {
  width: 48px;
  height: 48px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #fff;
}

.product-preview strong {
  font-size: 11px;
}

.total-row {
  display: flex;
  justify-content: flex-end;
  margin: 20px 0 28px;
}

.total-row div {
  width: 240px;
  min-height: 44px;
  border-radius: 7px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.total-row span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.total-row strong {
  font-size: 15px;
}

.message {
  position: relative;
}

.message p {
  color: var(--ink);
}

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

  .panel {
    max-width: 760px;
  }
}

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

  .toolbar {
    align-items: flex-start;
  }

  .section-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .invoice-sheet {
    transform-origin: top left;
    transform: scale(0.62);
    margin-right: -302px;
    margin-bottom: -427px;
  }
}

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

  .toolbar,
  .panel {
    display: none;
  }

  .workspace,
  .preview-stage {
    padding: 0;
  }

  .editor-grid {
    display: block;
  }

  .invoice-sheet {
    width: 210mm;
    min-height: 297mm;
    box-shadow: none;
    margin: 0;
    transform: none;
  }
}
