@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap");

:root {
  --bg0: #070b17;
  --bg1: #0b1226;
  --panel: rgba(10, 16, 35, 0.62);
  --panel2: rgba(9, 14, 30, 0.72);
  --stroke: rgba(255, 255, 255, 0.10);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.65);
  --accent: #6d5efc;
  --accent2: #2f86ff;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

body.page-app {
  margin: 0;
  min-height: 100vh;
  padding: 26px;
  color: var(--text);
  font-family: "Poppins", Arial, sans-serif;
  visibility: hidden;
  background:
    radial-gradient(1200px 700px at 20% 10%, rgba(109, 94, 252, 0.22), transparent 55%),
    radial-gradient(900px 600px at 85% 15%, rgba(47, 134, 255, 0.14), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

#loader {
  max-width: 1240px;
  margin: 0 auto 14px;
  padding: 14px 16px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  color: var(--muted);
  font-weight: 600;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  box-shadow: var(--shadow);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 999;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(6, 10, 24, 0.55);
  backdrop-filter: blur(10px);
}

.app-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-link,
.nav-link:visited {
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 500;
  text-decoration: none;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-active {
  color: #fff;
  background: rgba(120, 110, 255, 0.18);
  border-color: rgba(120, 110, 255, 0.35);
}

.nav-logout,
.primary-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, #6f7bff, #2f86ff);
  box-shadow: 0 10px 22px rgba(88, 101, 242, 0.35);
}

.toolbar {
  width: min(1240px, 100%);
  margin: 0 auto 16px;
  padding: 16px;
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  box-shadow: var(--shadow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

select,
input,
textarea {
  font-family: inherit;
}

select {
  min-width: 280px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: var(--text);
  outline: none;
  background: rgba(255, 255, 255, 0.08);
}

.invoice-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  overflow: auto;
}

.invoice-paper {
  width: 310mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 8mm;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10px;
  line-height: 1.18;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.invoice-paper input,
.invoice-paper textarea {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #000;
  padding: 0 2px;
  width: 100%;
  min-width: 0;
  resize: none;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10px;
  line-height: 1;
  height: 12px;
  min-height: 0;
  display: block;
}

.company-address {
  height: 14px !important;
  min-height: 0 !important;
}

.company-name {
  height: 18px !important;
  margin-bottom: 2px !important;
  line-height: 18px !important;
}

.company-text {
  padding: 3px 8px !important;
  text-align: center !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
}

.invoice-paper textarea {
  overflow: hidden;
  min-height: 26px;
}

.invoice-paper input:focus,
.invoice-paper textarea:focus {
  outline: 1px dashed #999;
}

.invoice-topline {
  display: grid !important;
  grid-template-columns: 92px 1fr 110px !important;
  align-items: center !important;
  border: 1px solid #000 !important;
  border-bottom: 0 !important;
}

.invoice-title {
  grid-column: 2 !important;
  text-align: center !important;
  width: 100% !important;
  padding: 4px 0 !important;
  font-size: 17px !important;
  font-weight: 700 !important;
}

.invoice-title {
  transform: translateX(48px) !important;
}

.copy-type {
  grid-column: 3 !important;
  position: static !important;
  width: 110px !important;
  height: 100% !important;
  border-left: 1px solid #000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  padding-left: 12px !important;
}

.company-head {
  display: grid !important;
  grid-template-columns: 92px 1fr !important;
  border: 1px solid #000 !important;
  border-bottom: 0 !important;
  min-height: 76px !important;
  height: auto !important;
}

.logo-box {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 4px !important;
}

.logo-box img {
  max-width: 88px !important;
  max-height: 58px !important;
  object-fit: contain !important;
}

.company-name {
  text-align: center;
  text-transform: uppercase;
  font-size: 15px !important;
  font-weight: 700;
}

.company-address,
#isoLine,
#contactLine,
#sellerGstin {
  text-align: center;
}

#contactLine {
  margin-bottom: 4px !important;
  display: block !important;
}

#isoLine {
  margin-bottom: 4px !important;
}

.company-address {
  min-height: 24px;
}

#sellerGstin {
  font-weight: 700;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid #000;
  border-left: 1px solid #000;
}

.meta-cell {
  min-height: 22px;
  padding: 3px 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
}

.meta-cell b {
  white-space: nowrap;
}

.meta-cell.wide {
  grid-column: span 2;
}

.party-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-left: 1px solid #000;
}

.party-box {
  min-height: 116px;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
}

.party-box:nth-child(2) .box-title {
  border-top: 1px solid #000 !important;
}

.box-title {
  padding: 4px;
  border-bottom: 1px solid #000;
  text-align: center;
  font-weight: 700;
}

.line-field {
  display: grid;
  grid-template-columns: 55px 1fr;
  gap: 4px;
  padding: 3px 5px;
}

.line-field textarea {
  min-height: 30px;
}

.state-row {
  display: grid;
  grid-template-columns: 48px 1fr 38px 42px;
  align-items: center;
  gap: 4px;
  padding: 3px 5px;
}

.items-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.items-table th,
.items-table td {
  border: 1px solid #000;
  padding: 3px;
  text-align: center;
  vertical-align: middle;
}

.items-table th {
  background: #f4f4f4;
  font-weight: 700;
}

.items-table th:nth-child(1) {
  width: 24px;
}

.items-table th:nth-child(2) {
  width: 185px;
}

.items-table th:nth-child(3) {
  width: 54px;
}

.items-table th:nth-child(4) {
  width: 64px;
}

.items-table th:nth-child(5) {
  width: 68px;
}

.items-table th:nth-child(6) {
  width: 62px;
}

.items-table th:nth-child(7) {
  width: 64px;
}

.items-table th:nth-child(8) {
  width: 78px;
}

.items-table th:nth-child(9),
.items-table th:nth-child(10),
.items-table th:nth-child(11) {
  width: 55px;
}

.items-table th:nth-child(12) {
  width: 70px;
}

.items-table th:nth-child(13),
.items-table td:nth-child(13) {
  width: 70px;
}

.items-table input,
.items-table textarea {
  text-align: center;
}

.items-table textarea.desc {
  min-height: 34px;
  text-align: left;
}

.tax-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.tax-cell input {
  height: 22px !important;
  min-height: 22px !important;
  padding: 0 !important;
  text-align: center !important;
  font-weight: 700;
  line-height: 22px !important;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.remove-row {
  padding: 5px 8px;
  border: 0;
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  background: #382e2e;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 260px;
  align-items: stretch;
  border-right: 1px solid #000;
  border-bottom: 0;
  border-left: 1px solid #000;
}

.terms-box {
  min-height: 132px;
  padding: 6px;
  border-right: 1px solid #000;
}

.payment-row {
  display: grid;
  grid-template-columns: 95px 1fr;
  align-items: center;
  gap: 4px;
}

.terms-title {
  margin-top: 8px;
  font-weight: 700;
}

#termsText {
  min-height: 46px;
  margin-top: 3px;
}

.bank-block {
  display: grid;
  grid-template-columns: 82px 160px 72px 1fr;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}

.service-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  margin-top: 7px;
}

.totals-box {
  align-self: stretch;
}

.total-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  min-height: 22px;
  align-items: center;
  overflow: hidden;
  border-bottom: 1px solid #000;
}

.total-row span {
  min-width: 0;
  padding: 4px 6px;
  overflow: hidden;
  border-right: 1px solid #000;
  font-weight: 700;
  white-space: nowrap;
}

.total-row strong,
.total-row input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 4px 6px !important;
  box-sizing: border-box;
  text-align: right !important;
  font-weight: 700;
}

.grand {
  font-size: 12px;
}

.words-sign-row {
  display: grid;
  grid-template-columns: 1fr 260px;
  min-height: 45px;
  margin-top: 0;
  border: 1px solid #000;
}

.amount-words {
  padding: 6px;
}

.amount-words span {
  display: block;
  margin-top: 5px;
  font-weight: 700;
}

.sign-box {
  padding: 6px;
  border-left: 1px solid #000;
  text-align: center;
}

.sign-space {
  height: 56px;
}

.c {
  text-align: center;
}

.r {
  text-align: right;
}

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

@media print {
  body.page-app {
    padding: 0 !important;
    visibility: visible !important;
    background: #fff !important;
  }

  .no-print,
  .app-header,
  #loader {
    display: none !important;
  }

  #mainContent {
    display: block !important;
  }

  .invoice-shell {
    width: 100%;
    margin: 0;
    overflow: visible;
  }

  .invoice-paper {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    padding: 8mm;
    box-shadow: none;
  }

  .invoice-paper input,
  .invoice-paper textarea {
    outline: none !important;
  }
}

#companySelect option {
  color: #000;
}

.invoice-paper {
  width: 310mm;
  min-height: auto !important;
  height: auto !important;
}

@media print {
  .invoice-paper {
    min-height: 297mm !important;
  }
}