:root {
  --page: #f5f7fb;
  --page-deep: #e2e8f0;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --surface: #fbfdff;
  --surface-alt: #f5f8fc;
  --surface-inverse: #0f172a;
  --surface-inverse-soft: #111827;
  --line: rgba(15, 23, 42, 0.09);
  --line-strong: rgba(15, 23, 42, 0.15);
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --accent: #0f172a;
  --accent-brand: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --radius-shell: 24px;
  --radius-panel: 24px;
  --radius-card: 18px;
  --radius-field: 16px;
  --shadow-shell: 0 24px 60px rgba(15, 23, 42, 0.08);
  --shadow-paper: 0 26px 64px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
  font-family: "Instrument Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.09), transparent 18rem),
    radial-gradient(circle at 85% 10%, rgba(15, 23, 42, 0.08), transparent 20rem),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.ambient {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(32px);
  opacity: 0.5;
}

.ambient-one {
  top: 3rem;
  left: -2rem;
  width: 14rem;
  height: 14rem;
  background: rgba(37, 99, 235, 0.08);
}

.ambient-two {
  right: 8rem;
  bottom: 4rem;
  width: 18rem;
  height: 18rem;
  background: rgba(15, 23, 42, 0.08);
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 1.5rem;
  max-width: 1660px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

.editor-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-shell);
  overflow: hidden;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.82));
  backdrop-filter: blur(18px);
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.1rem;
  color: #f8fafc;
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.18), transparent 15rem),
    linear-gradient(180deg, #131c31 0%, #0a1020 100%);
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 2rem);
}

.preview-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.3), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.editor-panel,
.preview-panel {
  position: relative;
}

.preview-header,
.invoice-paper-wrap {
  position: relative;
  z-index: 1;
}

.brand-row,
.section-head,
.section-head-spread,
.preview-header,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-row h1,
.preview-header h2,
.hero-card h2,
.invoice-company,
.invoice-title {
  margin: 0;
  font-family: "Sora", sans-serif;
}

.brand-row h1 {
  font-size: clamp(2.2rem, 2.4vw, 2.7rem);
  letter-spacing: -0.06em;
}

.brand-copy {
  max-width: 26ch;
  margin: 0.7rem 0 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.6;
}

.eyebrow,
.meta-label,
.table-head,
.item-label {
  font-family: "IBM Plex Mono", monospace;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.status-pill,
.preview-badges span,
.hero-meta span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill {
  padding: 0.8rem 1.05rem;
  color: #ffffff;
  background: linear-gradient(180deg, #0f172a, #111827);
  border: 1px solid rgba(15, 23, 42, 0.16);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.hero-card,
.form-card {
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
}

.hero-card {
  display: grid;
  gap: 1.1rem;
  padding: 1.35rem;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.16), transparent 11rem),
    linear-gradient(135deg, #111827, #0f172a 68%, #18294c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.hero-copy {
  display: grid;
  gap: 0.5rem;
}

.hero-label {
  margin: 0;
  color: rgba(226, 232, 240, 0.8);
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.hero-card h2 {
  max-width: 17ch;
  font-size: clamp(1.32rem, 1.8vw, 1.8rem);
  line-height: 1.16;
  letter-spacing: -0.04em;
  color: #ffffff;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hero-meta span,
.preview-badges span {
  padding: 0.52rem 0.82rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(241, 245, 249, 0.86);
  font-size: 0.8rem;
  font-weight: 600;
}

.editor-form {
  display: grid;
  gap: 1.05rem;
}

.form-card {
  padding: 1.05rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.04);
}

.section-head {
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.section-head span,
.section-head-spread span {
  color: var(--ink-faint);
  font-size: 0.9rem;
}

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

.field {
  display: grid;
  gap: 0.4rem;
}

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

.field span {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
}

.field input,
.field textarea,
.field select,
.item-card input,
.item-card textarea {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: var(--radius-field);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  color: var(--ink);
  font: inherit;
  font-size: 0.98rem;
  padding: 0.94rem 1rem;
  outline: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease,
    background 150ms ease;
}

.field textarea,
.item-card textarea {
  resize: vertical;
  min-height: 5.5rem;
}

.field input::placeholder,
.field textarea::placeholder,
.item-card input::placeholder,
.item-card textarea::placeholder {
  color: #94a3b8;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.item-card input:focus,
.item-card textarea:focus {
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  background: #ffffff;
  transform: translateY(-1px);
}

.items-editor {
  display: grid;
  gap: 0.8rem;
}

.item-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.item-card-head,
.item-card-grid {
  display: grid;
  gap: 0.75rem;
}

.item-card-head {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.item-card-grid {
  grid-template-columns: minmax(0, 1fr) 94px 130px;
}

.item-label {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.danger-button {
  appearance: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.primary-button,
.secondary-button {
  padding: 0.95rem 1.2rem;
}

.primary-button {
  border: 1px solid #0f172a;
  color: #ffffff;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.16);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
}

.danger-button {
  border: 1px solid rgba(239, 68, 68, 0.14);
  color: #b91c1c;
  background: rgba(254, 242, 242, 1);
  padding: 0.68rem 0.95rem;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.primary-button:hover {
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.2);
}

.preview-header {
  padding: 0;
}

.preview-header h2 {
  font-size: 1.65rem;
  letter-spacing: -0.05em;
  color: #ffffff;
}

.preview-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preview-panel .eyebrow,
.preview-panel .preview-badges span {
  color: rgba(241, 245, 249, 0.74);
}

.preview-panel .preview-badges span {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.invoice-paper-wrap {
  position: relative;
  flex: 1;
  overflow: auto;
  padding: 0.1rem;
}

.invoice-paper {
  width: 100%;
  margin: 0 auto;
  padding: 2.1rem;
  border-radius: 22px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.04), transparent 12rem),
    linear-gradient(180deg, #ffffff, #fbfdff);
  box-shadow: var(--shadow-paper);
}

.paper-accent {
  width: 100%;
  height: 0.32rem;
  margin-bottom: 1.8rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f172a, #2563eb, #bfdbfe);
}

.invoice-header,
.invoice-meta-grid,
.meta-card-right,
.table-head,
.table-row,
.total-row,
.footer-grid,
.payment-grid {
  display: grid;
}

.invoice-header {
  grid-template-columns: minmax(0, 1.15fr) 250px;
  gap: 1.75rem;
  align-items: start;
}

.invoice-company {
  font-size: clamp(2rem, 3.1vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.invoice-company.is-placeholder {
  color: #94a3b8 !important;
  font-weight: 600;
}

.invoice-title {
  font-size: clamp(2.1rem, 3vw, 2.9rem);
  letter-spacing: -0.08em;
  text-align: right;
}

.invoice-mark-block {
  display: grid;
  gap: 0.45rem;
  padding: 0.4rem 0 0.4rem 1.5rem;
  border: none;
  border-left: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0;
  background: transparent;
}

.invoice-number,
.invoice-tagline,
.muted-line,
.notes-copy {
  margin: 0.2rem 0 0;
  line-height: 1.6;
}

.invoice-number {
  color: var(--ink-soft);
  font-size: 1rem;
  font-weight: 700;
  text-align: right;
}

.invoice-tagline {
  color: var(--ink-faint);
  font-size: 0.95rem;
  text-align: right;
}

.muted-line,
.notes-copy,
.payment-grid span {
  color: var(--ink-soft);
}

.is-hidden {
  display: none !important;
}

.is-placeholder {
  color: var(--ink-faint) !important;
}

.invoice-meta-grid {
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1rem;
  margin-top: 1.8rem;
}

.meta-card {
  padding: 1rem 1.05rem;
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: 14px;
  background: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.meta-card-right {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.meta-label {
  margin: 0 0 0.32rem;
  color: var(--ink-faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.meta-strong,
.total-row strong,
.payment-grid strong {
  margin: 0;
  color: var(--ink);
}

.meta-strong {
  font-size: 1.08rem;
  font-weight: 700;
}

.table-section {
  margin-top: 1.8rem;
}

.table-head,
.table-row {
  grid-template-columns: minmax(0, 1fr) 80px 120px 140px;
  gap: 0.75rem;
  align-items: start;
}

.table-head {
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.table-body {
  display: grid;
}

.table-row {
  padding: 0.95rem 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.table-row p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.item-description {
  color: var(--ink) !important;
  font-size: 1rem;
  font-weight: 600;
}

.table-empty {
  padding: 1rem 1.05rem;
  color: var(--ink-soft);
  border: 1px dashed rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  background: #f8fafc;
}

.align-right {
  text-align: right;
}

.totals-section {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.totals-stack {
  width: min(100%, 320px);
  display: grid;
  gap: 0.75rem;
  padding: 1rem 1.05rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  background: #fbfdff;
}

.total-row {
  grid-template-columns: 1fr auto;
  gap: 1rem;
  color: var(--ink-soft);
}

.grand-total {
  padding-top: 0.9rem;
  border-top: 1px solid rgba(15, 23, 42, 0.1);
}

.grand-total span,
.grand-total strong {
  color: var(--ink);
}

.grand-total strong {
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.footer-grid {
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 1rem;
  margin-top: 1.8rem;
}

.footer-card {
  padding: 1rem 1.05rem;
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: 14px;
  background: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.payment-grid {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.42rem 1rem;
}

.payment-grid strong {
  word-break: break-word;
}

.notes-copy {
  margin-top: 0.3rem;
  white-space: pre-wrap;
}

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

  .preview-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0.75rem;
    gap: 1rem;
  }

  .editor-panel,
  .preview-panel {
    padding: 1rem;
    border-radius: 18px;
  }

  .field-grid,
  .item-card-grid,
  .invoice-header,
  .invoice-meta-grid,
  .footer-grid,
  .table-head,
  .table-row {
    grid-template-columns: 1fr;
  }

  .meta-card-right {
    grid-template-columns: 1fr;
  }

  .brand-row,
  .preview-header,
  .action-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-card,
  .form-card,
  .item-card {
    padding: 1rem;
  }

  .status-pill {
    padding: 0.72rem 0.94rem;
  }

  .action-row {
    width: 100%;
  }

  .action-row button {
    width: 100%;
  }

  .invoice-mark-block,
  .invoice-title,
  .invoice-number,
  .invoice-tagline,
  .align-right {
    text-align: left;
  }

  .invoice-paper {
    padding: 1.35rem;
    border-radius: 18px;
  }
}

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

  .ambient,
  .editor-panel,
  .preview-header {
    display: none !important;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .preview-panel {
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 0;
  }

  .invoice-paper-wrap {
    padding: 0;
    overflow: visible;
  }

  .invoice-paper {
    width: 100%;
    max-width: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }
}
