:root {
  --bg: #f4efe7;
  --panel: rgba(12, 18, 30, 0.82);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #121826;
  --muted: #6f7892;
  --accent: #ec6a3c;
  --accent-soft: #ffd6ba;
  --accent-soft-white-82: #ffddc8;
  --accent-alpha-20: rgba(236, 106, 60, 0.2);
  --accent-alpha-10: rgba(236, 106, 60, 0.1);
  --accent-alpha-06: rgba(236, 106, 60, 0.06);
  --accent-alpha-34: rgba(236, 106, 60, 0.34);
  --accent-soft-alpha-60: rgba(255, 214, 186, 0.6);
  --accent-soft-alpha-72: rgba(255, 214, 186, 0.72);
  --accent-white-08: #ee7650;
  --accent-black-45: #6a301b;
  --accent-black-52: #7b371f;
  --accent-black-68: #a24829;
  --accent-black-86: #cb5b34;
  --accent-soft-white-72: #ffe3d1;
  --surface: #fffdf8;
  --line: rgba(18, 24, 38, 0.08);
  --shadow: 0 24px 60px rgba(12, 18, 30, 0.16);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Instrument Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(236, 106, 60, 0.16), transparent 24%),
    radial-gradient(circle at right 20%, rgba(65, 148, 212, 0.15), transparent 25%),
    linear-gradient(135deg, #fbf5ec 0%, #f1f6fb 45%, #eef0f8 100%);
  color: var(--text);
}

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

button {
  cursor: pointer;
  border: 0;
}

.shell {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  min-height: 100vh;
}

.control-panel {
  padding: 28px;
  background: var(--panel);
  color: #fff;
  border-right: 1px solid var(--panel-border);
  overflow-y: auto;
  backdrop-filter: blur(18px);
}

.hero-card,
.panel-section {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 18px;
}

.eyebrow,
.preview-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.66);
}

.hero-card h1,
.preview-chrome h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.02;
}

.hero-copy {
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.6;
  margin: 14px 0 0;
}

.hero-actions,
.toolbar-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.78rem;
}

.primary-btn,
.ghost-btn,
.secondary-btn,
.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.primary-btn {
  background: linear-gradient(135deg, #fff2eb 0%, #ffd1bc 100%);
  color: #2f1c13;
  font-weight: 700;
}

.ghost-btn,
.secondary-btn,
.file-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.primary-btn:hover,
.ghost-btn:hover,
.secondary-btn:hover,
.file-btn:hover,
.template-card:hover {
  transform: translateY(-1px);
}

.panel-section h2,
.section-head span,
.editor-card strong {
  margin: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 1rem;
}

.section-head span {
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.82rem;
}

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

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

label {
  display: grid;
  gap: 8px;
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.8);
}

label input,
label textarea,
label select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 9, 16, 0.28);
  color: #fff;
  padding: 12px 14px;
  outline: none;
}

input[type="color"] {
  height: 48px;
  padding: 6px;
}

textarea {
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.template-picker,
.stack-list {
  display: grid;
  gap: 12px;
}

.tab-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.tab-btn {
  min-height: 46px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.72);
  font-weight: 600;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(255, 209, 188, 0.24), rgba(255, 255, 255, 0.08));
  color: white;
  border-color: rgba(255, 209, 188, 0.38);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.template-card {
  text-align: left;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.template-card.active {
  background: linear-gradient(135deg, rgba(255, 209, 188, 0.28), rgba(255, 255, 255, 0.08));
  border-color: rgba(255, 209, 188, 0.54);
}

.template-card strong,
.template-card small,
.template-badge {
  display: block;
}

.template-card small {
  color: rgba(255, 255, 255, 0.64);
  margin-top: 8px;
  line-height: 1.45;
}

.template-badge {
  width: 42px;
  height: 8px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.editor-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px;
}

.saved-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 16px;
}

.saved-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.saved-card-head strong,
.saved-card-head small {
  display: block;
}

.saved-card-head strong {
  color: white;
  font-size: 0.96rem;
}

.saved-card-head small,
.saved-summary {
  color: rgba(255, 255, 255, 0.62);
}

.saved-card-head small {
  margin-top: 6px;
  line-height: 1.4;
}

.saved-summary {
  margin: 14px 0 0;
  line-height: 1.55;
}

.saved-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.74rem;
}

.saved-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.danger-soft {
  color: #ffb5b5;
  border-color: rgba(255, 120, 120, 0.24);
}

.empty-archive {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.62);
  line-height: 1.6;
}

.modal-shell[hidden] {
  display: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 18, 0.56);
  backdrop-filter: blur(10px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  max-height: min(88vh, 920px);
  overflow: auto;
  border-radius: 28px;
  padding: 24px;
  background: #fffdf8;
  color: #1a2439;
  box-shadow: 0 30px 80px rgba(7, 12, 24, 0.26);
}

.modal-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: #7b849d;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.modal-head h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.modal-head .ghost-btn {
  background: #f6f8fb;
  border-color: rgba(18, 24, 38, 0.08);
  color: #1f2d47;
  font-weight: 700;
}

.modal-body {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.modal-items {
  display: grid;
  gap: 18px;
}

.modal-items-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  margin-top: 0;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid rgba(18, 24, 38, 0.08);
  box-shadow: 0 10px 24px rgba(18, 24, 38, 0.06);
}

.modal-items-toolbar .secondary-btn {
  gap: 8px;
  background: #f6f8fb;
  color: #1f2d47;
  border: 1px solid rgba(18, 24, 38, 0.08);
  font-weight: 700;
}

.modal-items-toolbar .secondary-btn i {
  font-size: 0.9rem;
}

.modal-items-section {
  display: grid;
  gap: 12px;
}

.modal-items-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-items-heading h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  color: #1a2439;
}

.modal-items-heading span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f6f8fb;
  border: 1px solid rgba(18, 24, 38, 0.08);
  color: #5d6782;
  font-size: 0.78rem;
  font-weight: 600;
}

.modal-body label {
  color: #33415f;
}

.modal-body input,
.modal-body textarea,
.modal-body select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(18, 24, 38, 0.1);
  background: #fff;
  color: #1a2439;
  padding: 12px 14px;
  outline: none;
}

.note-images-editor {
  display: grid;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid rgba(18, 24, 38, 0.08);
}

.note-images-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.note-images-head h3,
.note-images-head p {
  margin: 0;
}

.note-images-head h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
}

.note-images-head p {
  margin-top: 5px;
  color: #6f7892;
  font-size: 0.84rem;
  line-height: 1.45;
}

.note-image-upload,
.note-image-replace {
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  gap: 8px;
  background: #f6f8fb;
  border-color: rgba(18, 24, 38, 0.1);
  color: #1f2d47;
  font-weight: 700;
}

.note-image-upload input,
.note-image-replace input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.note-image-upload.is-disabled,
.note-image-replace.is-disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.note-image-list {
  display: grid;
  gap: 10px;
}

.note-image-card {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(18, 24, 38, 0.08);
  border-radius: 16px;
  background: #fff;
}

.note-image-card > img {
  display: block;
  width: 86px;
  height: 70px;
  border-radius: 10px;
  border: 1px solid rgba(18, 24, 38, 0.08);
  object-fit: cover;
}

.note-image-card-copy {
  min-width: 0;
}

.note-image-card-copy strong,
.note-image-card-copy small {
  display: block;
}

.note-image-card-copy strong {
  overflow: hidden;
  color: #1a2439;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-image-card-copy small {
  margin-top: 5px;
  color: #7b849d;
}

.note-image-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.note-image-actions .secondary-btn,
.note-image-actions .ghost-btn {
  min-height: 38px;
  padding: 0 13px;
}

.note-image-actions .ghost-btn {
  background: #fff4f4;
  border-color: #ffd7d7;
  color: #c43c3c;
}

.note-images-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 96px;
  padding: 18px;
  border: 1px dashed rgba(18, 24, 38, 0.16);
  border-radius: 16px;
  background: #fafbfc;
  color: #6f7892;
  text-align: center;
}

.note-images-empty i {
  font-size: 1.25rem;
}

.note-images-status {
  margin: 0;
  color: #6f7892;
  font-size: 0.84rem;
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

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

.modal-body .editor-card {
  background: #fff;
  border: 1px solid rgba(18, 24, 38, 0.08);
  box-shadow: 0 10px 22px rgba(18, 24, 38, 0.04);
}

.modal-body .editor-card strong {
  color: #14203a;
}

.modal-body .danger-text {
  color: #ff7d7d;
  font-weight: 600;
}

.row-fields {
  display: grid;
  gap: 12px;
}

.danger-text {
  padding: 0;
  background: transparent;
  color: #ff9e9e;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.preview-panel {
  padding: 28px;
}

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

.preview-chrome h2,
.preview-label {
  color: #20304c;
}

.preview-dots {
  display: flex;
  gap: 8px;
}

.preview-dots span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: rgba(32, 48, 76, 0.24);
}

.invoice-canvas {
  min-height: calc(100vh - 118px);
  padding: 24px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.52)),
    linear-gradient(135deg, rgba(236, 106, 60, 0.08), rgba(65, 148, 212, 0.08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.invoice-paper {
  width: min(100%, 794px);
  margin: 0 auto;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 18px 44px rgba(12, 18, 30, 0.12);
  overflow: hidden;
}

.invoice {
  position: relative;
  padding: 28px 28px 24px;
  background: var(--surface);
  color: var(--text);
}

.invoice::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.invoice::after {
  content: "";
  position: absolute;
  top: 0;
  left: 28px;
  right: 28px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft-white-82));
}

.template-a::before {
  background:
    radial-gradient(circle at top right, var(--accent-alpha-20) 0%, transparent 34%),
    linear-gradient(180deg, transparent 0%, transparent 72%, var(--accent-alpha-06) 100%);
}

.template-b::before {
  background:
    linear-gradient(135deg, var(--accent-alpha-10) 0 22%, transparent 22% 100%),
    radial-gradient(circle at bottom left, var(--accent-soft-alpha-60), transparent 38%);
}

.template-c::before {
  background:
    linear-gradient(90deg, var(--accent-white-08) 0 10px, transparent 10px 100%),
    radial-gradient(circle at top left, var(--accent-soft-alpha-72), transparent 26%);
}

.invoice > * {
  position: relative;
  z-index: 1;
}

.edit-anchor {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
}

.edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(18, 24, 38, 0.08);
  color: #1c2943;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 20px rgba(18, 24, 38, 0.08);
}

.edit-btn i {
  font-size: 0.8rem;
  line-height: 1;
}

.invoice-header,
.meta-grid,
.detail-card,
.invoice-table-wrap,
.footer-note,
.summary-card,
.invoice-footer {
  position: relative;
}

.invoice-header {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 18px;
  align-items: start;
}

.brand-lockup {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 64px;
  min-width: 64px;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.12rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-black-45));
  box-shadow: 0 20px 34px var(--accent-alpha-34);
  line-height: 1;
}

.brand-copy h1,
.invoice-stamp h2,
.summary-card strong,
.detail-card h3,
.meta-pill strong {
  font-family: "Space Grotesk", sans-serif;
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2vw + 0.7rem, 2.25rem);
  line-height: 1.1;
  white-space: nowrap;
}

.brand-copy p,
.muted,
.detail-card p,
.meta-list span,
.summary-row small,
.footer-note p {
  color: var(--muted);
}

.brand-copy p {
  margin: 6px 0 0;
  line-height: 1.45;
  font-size: 0.92rem;
}

.invoice-stamp {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.invoice-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft-white-72);
  color: var(--accent-black-68);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.invoice-stamp h2 {
  margin: 0;
  font-size: clamp(2rem, 3.4vw, 2.8rem);
  line-height: 0.95;
}

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

.meta-pill {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 209, 188, 0.16);
  border: 0;
}

.meta-pill span {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.meta-pill strong {
  font-size: 0.92rem;
}

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

.detail-card {
  padding: 14px 0;
  border-radius: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.detail-card h3 {
  margin: 0 0 12px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-card p {
  margin: 0;
  white-space: pre-line;
  line-height: 1.45;
  font-size: 0.93rem;
}

.invoice-table-wrap {
  margin-top: 16px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(18, 24, 38, 0.06);
  box-shadow: none;
}

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

.invoice-table thead th {
  background: rgba(255, 209, 188, 0.16);
  color: #24314f;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.invoice-table tbody tr:last-child td {
  border-bottom: 0;
}

.invoice-table tbody td {
  color: #263249;
  font-size: 0.9rem;
}

.table-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-layout {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(250px, 0.82fr);
  gap: 14px;
  align-items: start;
}

.footer-note,
.summary-card {
  border-radius: 14px;
  padding: 14px;
  box-shadow: none;
}

.footer-note {
  background: rgba(255, 209, 188, 0.1);
  border: 0;
}

.footer-note h3,
.summary-card h3 {
  margin: 0 0 12px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.footer-note p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-line;
  font-size: 0.9rem;
}

.note-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin-top: 12px;
}

.note-figure {
  margin: 0;
  width: 100%;
}

.note-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(18, 24, 38, 0.08);
  object-fit: cover;
}

.summary-card {
  background: #0f1729;
  color: white;
  display: flex;
  flex-direction: column;
}

.summary-rows {
  display: grid;
  gap: 10px;
}

.summary-row,
.summary-total,
.summary-balance {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.summary-row small,
.summary-total small,
.summary-balance small {
  font-size: 0.76rem;
}

.summary-row strong,
.summary-total strong,
.summary-balance strong {
  font-size: 0.92rem;
}

.summary-total {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.summary-total strong {
  font-size: 1.1rem;
}

.summary-balance {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-black-86), var(--accent-black-52));
}

.signature-strip {
  margin-top: 14px;
}

.signature-strip-inline {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.signature-card {
  position: relative;
  overflow: hidden;
  display: block;
  padding: 14px 0 10px;
  border-radius: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.signature-card::after {
  display: none;
}

.signature-copy {
  position: relative;
  z-index: 1;
  margin-left: auto;
  width: min(100%, 210px);
  text-align: right;
}

.signature-copy small {
  display: block;
  color: var(--muted);
}

.signature-copy small {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.signature-copy strong {
  display: block;
  margin-top: 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  color: #1d2940;
}

.summary-card .signature-copy strong,
.summary-card .signature-copy span,
.summary-card .signature-copy small {
  color: rgba(255, 255, 255, 0.92);
}

.summary-card .signature-art svg path {
  stroke: rgba(255, 255, 255, 0.96);
}

.signature-art {
  margin-top: 2px;
  margin-left: auto;
  width: min(100%, 200px);
}

.signature-art svg {
  display: block;
  width: 100%;
  height: auto;
}

.signature-copy span {
  display: block;
  margin-top: 3px;
  font-size: 0.82rem;
  color: var(--muted);
}

.invoice-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.95fr);
  gap: 10px;
  align-items: end;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.bank-list {
  display: grid;
  gap: 4px;
}

.bank-item {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  flex-wrap: wrap;
}

.bank-item strong {
  color: var(--text);
}

.thank-you {
  text-align: right;
  min-width: 0;
}

.thank-you p {
  margin: 0;
  white-space: pre-line;
  line-height: 1.45;
  font-size: 0.88rem;
  text-wrap: pretty;
}

.invoice.export-mode {
  padding: 22px 22px 18px !important;
  min-height: 1123px;
  display: flex;
  flex-direction: column;
}

.invoice.export-mode::after {
  left: 22px;
  right: 22px;
}

.invoice.export-mode .invoice-header {
  gap: 14px;
}

.invoice.export-mode .brand-mark {
  width: 54px;
  min-width: 54px;
  height: 54px;
}

.invoice.export-mode .brand-copy h1 {
  font-size: 1.95rem;
}

.invoice.export-mode .brand-copy p,
.invoice.export-mode .detail-card p,
.invoice.export-mode .footer-note p,
.invoice.export-mode .thank-you p,
.invoice.export-mode .invoice-table tbody td,
.invoice.export-mode .bank-item {
  font-size: 0.84rem;
}

.invoice.export-mode .meta-grid,
.invoice.export-mode .detail-grid,
.invoice.export-mode .summary-layout {
  gap: 10px;
  margin-top: 12px;
}

.invoice.export-mode .meta-pill,
.invoice.export-mode .footer-note,
.invoice.export-mode .summary-card {
  padding: 10px 12px;
}

.invoice.export-mode .invoice-table th,
.invoice.export-mode .invoice-table td {
  padding: 8px 10px;
}

.invoice.export-mode .note-gallery {
  max-width: 260px;
}

.invoice.export-mode .signature-art {
  width: min(100%, 170px);
}

.invoice.export-mode .summary-balance {
  padding: 10px 12px;
}

.invoice.export-mode .invoice-footer {
  margin-top: auto;
  padding-top: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 0.92fr);
}

.template-b .invoice-header,
.template-b .summary-layout {
  grid-template-columns: 1fr;
}

.template-b .invoice-stamp {
  justify-items: start;
}

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

.template-b .detail-grid {
  grid-template-columns: 1.1fr 0.9fr;
}

.template-c .invoice {
  padding-left: 56px;
}

.template-c .invoice-stamp {
  justify-items: start;
}

.template-c .invoice-header {
  grid-template-columns: 1fr;
}

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

.template-c .detail-grid,
.template-c .summary-layout,
.template-c .invoice-footer {
  grid-template-columns: 1fr;
}

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

  .preview-panel {
    padding-top: 0;
  }
}

@media (max-width: 760px) {
  .control-panel,
  .preview-panel,
  .invoice-canvas,
  .invoice {
    padding: 18px;
  }

  .field-grid,
  .compact-grid,
  .tab-switch,
  .meta-grid,
  .detail-grid,
  .summary-layout,
  .invoice-header,
  .invoice-footer {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .brand-lockup {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-copy h1 {
    white-space: normal;
  }

  .invoice-paper {
    border-radius: 24px;
  }

  .invoice-table-wrap {
    overflow-x: auto;
  }

  .invoice-table {
    min-width: 620px;
  }

  .thank-you {
    text-align: left;
  }

  .modal-items-toolbar {
    position: static;
  }

  .modal-items-toolbar .secondary-btn {
    width: 100%;
  }

  .modal-items-heading {
    align-items: start;
    flex-direction: column;
  }

  .note-images-head,
  .note-image-card {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .note-images-head {
    flex-direction: column;
  }

  .note-image-upload {
    width: 100%;
  }

  .note-image-card > img {
    width: 100%;
    height: 160px;
  }

  .note-image-actions {
    justify-content: stretch;
  }

  .note-image-actions .secondary-btn,
  .note-image-actions .ghost-btn {
    flex: 1 1 120px;
  }

  .modal-card {
    padding: 18px;
  }
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  :root {
    color-scheme: light;
  }

  html,
  body {
    background: white;
    margin: 0;
    padding: 0;
  }

  .control-panel,
  .preview-chrome,
  .edit-anchor {
    display: none !important;
  }

  .shell,
  .preview-panel,
  .invoice-canvas {
    display: block;
    padding: 0;
    min-height: auto;
    background: white;
    box-shadow: none;
    border-radius: 0;
  }

  .invoice-paper {
    width: 794px;
    max-width: 794px;
    margin: 0 auto;
    border-radius: 0;
    box-shadow: none;
    background: var(--surface);
    overflow: hidden;
  }

  .invoice {
    padding: 28px 28px 24px;
    break-inside: avoid;
    background: #fffdf8;
    min-height: 1123px;
    display: flex;
    flex-direction: column;
  }

  .invoice .brand-mark {
    width: 54px;
    min-width: 54px;
    height: 54px;
  }

  .invoice .brand-copy h1 {
    font-size: 1.95rem;
  }

  .invoice .brand-copy p,
  .invoice .detail-card p,
  .invoice .footer-note p,
  .invoice .thank-you p,
  .invoice .invoice-table tbody td,
  .invoice .bank-item {
    font-size: 0.84rem;
  }

  .invoice .meta-grid,
  .invoice .detail-grid,
  .invoice .summary-layout {
    gap: 10px;
    margin-top: 12px;
  }

  .invoice .meta-pill,
  .invoice .footer-note,
  .invoice .summary-card {
    padding: 10px 12px;
  }

  .invoice .invoice-table th,
  .invoice .invoice-table td {
    padding: 8px 10px;
  }

  .invoice .note-gallery {
    max-width: 260px;
  }

  .invoice .signature-art {
    width: min(100%, 170px);
  }

  .invoice .summary-balance {
    padding: 10px 12px;
  }

  .invoice .invoice-footer {
    margin-top: auto;
    padding-top: 10px;
    grid-template-columns: minmax(0, 1fr) minmax(200px, 0.92fr);
  }

  .invoice .bank-item,
  .invoice .thank-you p {
    font-size: 0.8rem;
    line-height: 1.35;
  }

  .invoice::after {
    left: 28px;
    right: 28px;
  }

  .template-a::before,
  .template-b::before,
  .template-c::before {
    display: block;
  }
}
