:root {
  --blue: #075dff;
  --blue-deep: #0047d8;
  --black: #060708;
  --ink: #111318;
  --muted: #6b7280;
  --line: #e6eaf0;
  --soft: #f5f7fb;
  --white: #ffffff;
  --shadow: 0 24px 70px rgba(17, 24, 39, 0.12);
  --radius: 8px;
  --font: "Manrope", "Inter", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(7, 93, 255, 0.16), transparent 28rem),
    linear-gradient(135deg, #ffffff 0%, #f7f9fd 48%, #eef3fb 100%);
  color: var(--ink);
  font-family: var(--font);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: url("assets/bannDA.png") top right / min(760px, 80vw) auto no-repeat;
  opacity: 0.035;
  z-index: 0;
}

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

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

button {
  cursor: pointer;
}

.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
  padding: 22px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid rgba(17, 19, 24, 0.08);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-lockup {
  width: 138px;
  height: 54px;
  display: grid;
  place-items: center;
}

.brand-logo {
  max-width: 138px;
  max-height: 54px;
  object-fit: contain;
}

.brand-fallback,
.invoice-brand-fallback {
  display: none;
  font-weight: 800;
  color: var(--blue);
}

.missing-asset + .brand-fallback,
.missing-asset + .invoice-brand-fallback {
  display: block;
}

.missing-asset {
  display: none !important;
}

.header-copy p,
.preview-toolbar p,
.invoice-title-block p {
  margin: 0;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.header-copy h1 {
  margin: 3px 0 0;
  font-size: clamp(1.3rem, 2.4vw, 2.3rem);
  line-height: 1.05;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.button {
  border: 0;
  min-height: 42px;
  border-radius: var(--radius);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  box-shadow: 0 12px 26px rgba(7, 93, 255, 0.28);
}

.button.secondary,
.button.compact {
  color: var(--ink);
  background: #eef2f7;
}

.button.compact {
  min-height: 36px;
  padding: 0 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(520px, 1.05fr);
  gap: clamp(18px, 3vw, 34px);
  align-items: start;
  padding: clamp(18px, 3vw, 42px);
}

.editor-panel,
.preview-panel {
  min-width: 0;
}

.editor-panel {
  display: grid;
  gap: 18px;
}

#invoiceForm {
  display: grid;
  gap: 18px;
}

.panel-section {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(17, 19, 24, 0.08);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 12px 34px rgba(17, 24, 39, 0.06);
}

.section-heading {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.section-heading.with-action {
  justify-content: space-between;
}

.section-heading.with-action > div {
  display: flex;
  gap: 10px;
  align-items: center;
}

.section-index {
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
}

.section-heading h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
}

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

label {
  display: grid;
  gap: 7px;
}

label span {
  color: #3f4652;
  font-size: 0.78rem;
  font-weight: 800;
}

.discount-control {
  display: grid;
  gap: 8px;
}

.discount-control-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.discount-control-top > span {
  color: #3f4652;
  font-size: 0.78rem;
  font-weight: 800;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-width: 138px;
  padding: 3px;
  border: 1px solid #dce3ed;
  border-radius: var(--radius);
  background: #eef2f7;
}

.segmented-control label {
  display: block;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  min-height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #596273;
  font-size: 0.72rem;
  font-weight: 900;
}

.segmented-control input:checked + span {
  color: white;
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(7, 93, 255, 0.22);
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(7, 93, 255, 0.62);
  box-shadow: 0 0 0 4px rgba(7, 93, 255, 0.12);
}

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

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

.line-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 82px 110px 94px 36px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.line-editor output {
  min-height: 42px;
  display: grid;
  place-items: center end;
  color: var(--ink);
  font-weight: 900;
  white-space: nowrap;
}

.icon-button {
  width: 36px;
  height: 42px;
  border: 0;
  border-radius: var(--radius);
  color: #dc2626;
  background: #fff1f1;
  font-size: 1.4rem;
  line-height: 1;
}

.preview-panel {
  position: sticky;
  top: 118px;
}

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

.preview-toolbar strong {
  display: block;
  font-size: 1.6rem;
  line-height: 1.1;
}

.status-pill,
.invoice-title-block span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  color: white;
  background: var(--black);
  font-size: 0.78rem;
  font-weight: 900;
}

.invoice-page {
  width: min(100%, 794px);
  min-height: 1123px;
  margin: 0 auto;
  background: #ffffff url("assets/backgroundpdf.png") center / cover no-repeat;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  padding: 74px 58px 54px;
}

.document-top-accent {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: block;
  width: 104px;
  height: 112px;
  background: linear-gradient(145deg, #075dff 0%, #004cff 58%, #006dff 100%);
  border-radius: 0 0 64px 0;
  box-shadow: 20px 26px 42px rgba(7, 93, 255, 0.18);
}

.invoice-page::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  display: block;
  width: 184px;
  height: 184px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 0 0 86px 0;
  box-shadow: 22px 24px 44px rgba(17, 24, 39, 0.08);
}

.invoice-page::after {
  display: none;
}

.invoice-document-header,
.invoice-meta-grid,
.invoice-lines,
.invoice-summary-section,
.invoice-footer {
  position: relative;
  z-index: 2;
}

.invoice-document-header {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: flex-start;
  margin-bottom: 42px;
}

.invoice-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
  object-position: center;
  padding: 9px;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 34px rgba(17, 24, 39, 0.08);
}

.invoice-title-block {
  text-align: right;
}

.invoice-title-block h2 {
  margin: 6px 0 10px;
  font-size: 2.15rem;
  line-height: 1;
}

.invoice-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 170px;
  gap: 24px;
  padding: 22px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 18px 40px rgba(17, 24, 39, 0.06);
  backdrop-filter: blur(3px);
}

.invoice-meta-grid span,
.invoice-notes h3 {
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.invoice-meta-grid h3 {
  margin: 8px 0;
  font-size: 1rem;
}

.invoice-meta-grid p {
  margin: 4px 0;
  color: #505762;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-line;
}

.date-card {
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--black), #121723);
  color: white;
  box-shadow: 0 16px 34px rgba(7, 9, 12, 0.18);
}

.date-card dl,
.date-card dd {
  margin: 0;
}

.date-card div + div {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.date-card dt {
  color: #9dbdff;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.date-card dd {
  margin-top: 4px;
  font-size: 0.88rem;
  font-weight: 800;
}

.invoice-lines {
  margin-top: 26px;
  padding: 14px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 16px 36px rgba(17, 24, 39, 0.05);
  backdrop-filter: blur(3px);
}

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

th {
  color: white;
  background: var(--black);
  padding: 13px 12px;
  font-size: 0.72rem;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

th:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

th:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

td {
  padding: 15px 12px;
  border-bottom: 1px solid var(--line);
  color: #333944;
  font-size: 0.86rem;
  vertical-align: top;
}

td:nth-child(2),
td:nth-child(3),
td:nth-child(4),
th:nth-child(2),
th:nth-child(3),
th:nth-child(4) {
  text-align: right;
  white-space: nowrap;
}

.invoice-summary-section {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 34px;
  margin-top: 26px;
}

.brand-signature {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-start;
  margin: 28px 0 0 auto;
  padding-left: 0;
}

.brand-signature span {
  width: 420px;
  color: #556070;
  font-size: 0.68rem;
  font-weight: 900;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  line-height: 1.55;
}

.invoice-notes {
  padding: 18px;
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.invoice-notes h3 {
  margin: 0 0 8px;
}

.invoice-notes h3:not(:first-child) {
  margin-top: 22px;
}

.invoice-notes p {
  margin: 0;
  color: #505762;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-line;
}

.totals-box {
  display: grid;
  gap: 2px;
  align-self: start;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(246, 248, 252, 0.9);
  box-shadow: 0 16px 34px rgba(17, 24, 39, 0.07);
}

.totals-box div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 0;
  color: #515967;
  font-size: 0.86rem;
}

.totals-box strong {
  color: var(--ink);
  white-space: nowrap;
}

.totals-box .grand-total {
  align-items: center;
  margin-top: 8px;
  padding: 16px 0 2px;
  border-top: 1px solid #d8dee8;
  color: var(--black);
  font-weight: 900;
}

.grand-total strong {
  color: var(--blue);
  font-size: 1.45rem;
}

.invoice-footer {
  display: block;
  margin-top: 16px;
  padding: 22px 0 0;
  border-top: 1px solid rgba(226, 232, 240, 0.86);
}

.invoice-footer p {
  max-width: 420px;
  margin: 0;
  color: #363d48;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: pre-line;
}

.is-invalid {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1) !important;
}

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

  .preview-panel {
    position: static;
  }
}

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

  .brand-lockup {
    justify-content: start;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .field-grid,
  .invoice-summary-section,
  .invoice-meta-grid {
    grid-template-columns: 1fr;
  }

  .line-editor {
    grid-template-columns: 1fr 1fr;
  }

  .line-editor .description-field {
    grid-column: 1 / -1;
  }

  .line-editor output {
    place-items: center start;
  }

  .invoice-page {
    padding: 44px 20px 34px;
    min-height: auto;
  }

  .invoice-document-header,
  .invoice-footer {
    flex-direction: column;
    align-items: stretch;
  }

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

  .invoice-logo {
    width: 220px;
  }

  th,
  td {
    padding-inline: 8px;
    font-size: 0.76rem;
  }
}

@media print {
  body {
    background: white;
  }

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

  .workspace {
    display: block;
    padding: 0;
  }

  .invoice-page {
    width: 210mm;
    min-height: 297mm;
    box-shadow: none;
    border-radius: 0;
  }
}
