:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #272b2d;
  background: #f2f3f5;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
header {
  background: #25292b;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px max(24px, calc((100vw - 1100px) / 2));
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
}
.brand strong {
  letter-spacing: 3px;
  font-size: 20px;
}
.brand span {
  display: block;
  font-size: 14px;
  color: #c8cbce;
  margin-top: 3px;
}
button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid #d8dce0;
  border-radius: 8px;
  background: white;
  color: #303438;
  padding: 11px 17px;
  cursor: pointer;
  min-height: 44px;
}
button:hover {
  border-color: #ff6128;
}
header button {
  background: transparent;
  color: white;
  border-color: #626568;
}
.primary {
  background: #ff6128;
  color: white;
  border-color: #ff6128;
}
main {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 24px 50px;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.eyebrow {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1.5px;
  color: #686f74;
}
h1 {
  font-size: 32px;
  margin: 8px 0 24px;
  letter-spacing: -1px;
}
nav {
  display: flex;
  border-bottom: 1px solid #d5d8dc;
  gap: 10px;
  margin-bottom: 24px;
}
nav button {
  border: none;
  background: none;
  border-radius: 0;
  padding: 14px 25px;
  color: #73787d;
}
nav .active {
  border-bottom: 3px solid #ff6128;
  color: #24292d;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
.card {
  background: white;
  border: 1px solid #e0e3e6;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 3px 12px #20252b04;
}
h2 {
  font-size: 18px;
  margin: 0 0 22px;
}
label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}
label span {
  display: block;
  margin-bottom: 8px;
}
input,
textarea,
select {
  width: 100%;
  font: inherit;
  font-weight: 400;
  font-size: 16px;
  border: 1px solid #d5d9dd;
  border-radius: 7px;
  padding: 11px 12px;
  background: #fff;
  color: #272b2d;
  min-height: 44px;
}
textarea {
  resize: vertical;
  line-height: 1.5;
}
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid #ff612866;
  border-color: #ff6128;
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.cardTitle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.cardTitle h2 {
  margin: 0;
}
.item {
  display: grid;
  grid-template-columns: 1fr 100px 140px 115px 44px;
  gap: 12px;
  border-top: 1px solid #eceff1;
  padding-top: 18px;
  margin-top: 18px;
  align-items: start;
}
.item .description {
  grid-column: 1;
}
.item textarea {
  margin-top: 8px;
  font-size: 14px;
}
.item label {
  margin: 0;
}
.item .amount {
  padding-top: 36px;
  font-size: 16px;
  font-weight: 600;
  text-align: right;
}
.remove {
  margin-top: 25px;
  padding: 10px;
  color: #a04432;
}
.hint {
  font-size: 14px;
  color: #687078;
  line-height: 1.5;
}
.bottom {
  grid-template-columns: 1.4fr 1fr;
}
.summary div {
  display: flex;
  justify-content: space-between;
  margin: 16px 0;
  gap: 15px;
}
.summary strong {
  font-size: 23px;
}
.summary .balance {
  border-top: 1px solid #e1e3e6;
  padding-top: 20px;
  margin-top: 22px;
}
.paper {
  background: white;
  max-width: 816px;
  min-height: 980px;
  margin: auto;
  padding: 56px;
  box-shadow: 0 4px 25px #20252b12;
  line-height: 1.5;
}
.invoice-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 3px solid #ff6128;
  padding-bottom: 28px;
}
.invoice-head img {
  width: 125px;
  height: 125px;
  object-fit: contain;
}
.invoice-head .business {
  text-align: right;
  font-size: 14px;
}
.invoice-head h2 {
  font-size: 28px;
  margin: 0 0 10px;
}
.invoice-meta {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 30px 0;
  font-size: 14px;
}
.invoice-meta strong {
  display: block;
}
.paper table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
.paper th {
  background: #272b2d;
  color: white;
  text-align: left;
  padding: 12px;
}
.paper td {
  vertical-align: top;
  padding: 18px 10px;
  border-bottom: 1px solid #e4e6e8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.paper td:first-child {
  width: 55%;
}
.paper td:not(:first-child),
.paper th:not(:first-child) {
  text-align: right;
}
.paper td strong {
  display: block;
  margin-bottom: 5px;
}
.invoice-totals {
  margin: 25px 0 35px auto;
  max-width: 280px;
}
.invoice-totals div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0;
}
.invoice-totals .final {
  border-top: 2px solid #ff6128;
  font-weight: bold;
  font-size: 18px;
}
.invoice-notes {
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.paper footer {
  font-size: 12px;
  color: #686f74;
  border-top: 1px solid #ddd;
  margin-top: 55px;
  padding-top: 12px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 700px) {
  main {
    padding: 0 14px;
    margin: 23px auto;
  }
  .grid,
  .bottom {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .card {
    padding: 18px;
  }
  .item {
    grid-template-columns: 1fr 1fr 44px;
  }
  .item .description {
    grid-column: 1/4;
  }
  .item .amount {
    grid-column: 1/3;
    grid-row: 3;
    padding: 0;
    text-align: left;
  }
  .remove {
    grid-column: 3;
    grid-row: 2;
    margin-top: 24px;
  }
  .top h1 {
    font-size: 26px;
  }
  .paper {
    padding: 22px;
    min-height: 800px;
  }
  .invoice-head img {
    width: 85px;
    height: 85px;
  }
  .invoice-head .business {
    font-size: 12px;
  }
  .invoice-head h2 {
    font-size: 22px;
  }
  .paper table {
    font-size: 12px;
  }
  .paper th,
  .paper td {
    padding: 10px 5px;
  }
  .invoice-meta {
    font-size: 12px;
  }
  .pair {
    gap: 10px;
  }
}
@media print {
  @page {
    size: A4;
    margin: 14mm;
  }
  body {
    background: white;
  }
  header,
  .top,
  nav,
  #editor,
  .hint {
    display: none !important;
  }
  main {
    max-width: none;
    margin: 0;
    padding: 0;
  }
  #preview {
    display: block !important;
  }
  .paper {
    padding: 0;
    box-shadow: none;
    min-height: 0;
    max-width: none;
  }
  .paper th {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .paper tr {
    break-inside: avoid;
  }
  .invoice-head img {
    width: 105px;
    height: 105px;
  }
  .invoice-notes {
    break-inside: avoid;
  }
}

.item {
  grid-template-columns: minmax(180px, 1fr) 130px 90px 145px 100px 44px;
}
.item label > span {
  margin-bottom: 0;
}
.discount-applied {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.rate-unit {
  font-size: 12px;
  color: #687078;
}
@media (max-width: 950px) {
  .item {
    grid-template-columns: 1fr 1fr 1fr 44px;
  }
  .item .description {
    grid-column: 1/5;
  }
  .item .unit {
    grid-column: 1;
  }
  .item .amount {
    grid-column: 1/4;
    grid-row: 3;
    padding: 0;
    text-align: left;
  }
  .remove {
    grid-column: 4;
    grid-row: 2;
    margin-top: 24px;
  }
}
@media (max-width: 500px) {
  .item {
    grid-template-columns: 1fr 1fr 44px;
  }
  .item .description {
    grid-column: 1/4;
  }
  .item .unit {
    grid-column: 1/3;
  }
  .item .amount {
    grid-column: 1/3;
    grid-row: 4;
  }
  .remove {
    grid-column: 3;
    grid-row: 3;
  }
  .item input,
  .item select {
    margin-top: 6px;
  }
  .pair {
    grid-template-columns: 1fr;
  }
  .paper td:first-child {
    width: 44%;
  }
}

:root {
  --accent: #ff6128;
}
button:hover {
  border-color: var(--accent);
}
.primary {
  background: var(--accent);
  border-color: var(--accent);
}
nav .active,
.invoice-head,
.invoice-totals .final {
  border-color: var(--accent);
}
input:focus,
textarea:focus,
select:focus {
  outline-color: var(--accent);
  border-color: var(--accent);
}
.company-card label {
  max-width: 480px;
  margin-bottom: 0;
}
.profile-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.logo-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 100px;
  margin-bottom: 16px;
}
.logo-preview img {
  width: 90px;
  height: 90px;
  object-fit: contain;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
}
.check input {
  width: 20px;
  min-height: 20px;
}
.check span {
  margin: 0;
}
input[type="color"] {
  height: 48px;
  padding: 5px;
  width: 100px;
}
.error {
  color: #a52b22 !important;
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
#companyManager .grid {
  gap: 24px;
}
.invoice-head {
  min-height: 150px;
}

.saved-company {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid #e0e3e6;
  flex-wrap: wrap;
}
.saved-company img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.saved-company div {
  flex: 1;
  min-width: 160px;
}
.saved-company span {
  display: block;
  font-size: 14px;
  color: #687078;
  margin-top: 6px;
}
.saved-companies {
  margin-bottom: 20px;
}
input[readonly] {
  background: #f2f3f5;
}

#accountEmail {
  font-size: 14px;
}
#signOut {
  color: white;
  font-size: 14px;
}
#invoiceList button {
  margin: 4px;
}
header {
  flex-wrap: wrap;
}
@media print {
  main > .card {
    display: none;
  }
}
.login-main {
  max-width: 540px;
}
.login-main h1 {
  font-size: 26px;
}
.login-main hr {
  border: 0;
  border-top: 1px solid #e0e3e6;
  margin: 24px 0;
}
.login-main a {
  color: #b83b10;
}
#linkCompany {
  margin-bottom: 16px;
}
#linkStatus input {
  margin: 12px 0;
}
#accountEmail {
  overflow-wrap: anywhere;
}
#passwordManager {
  max-width: 540px;
}

.main-nav {
  flex-wrap: wrap;
}
.home-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  background: white;
  border: 1px solid #e0e3e6;
  padding: 24px;
  border-radius: 12px;
}
#savedPage h1 {
  font-size: 26px;
  margin: 0;
}
#invoiceList {
  display: grid;
  gap: 8px;
}
#invoiceList button {
  text-align: left;
  margin: 0;
}
#invoiceSaveStatus:empty {
  display: none;
}
@media print {
  #homePage,
  #savedPage,
  #invoiceSaveStatus {
    display: none !important;
  }
}

#homePage #companyManager {
  margin-top: 24px;
}
.company-link-tools {
  border-top: 1px solid #e0e3e6;
  padding-top: 20px;
  margin-bottom: 20px;
}
.company-link-tools label {
  max-width: 480px;
}
.company-card > label {
  margin-bottom: 0;
}
.send-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 11px 17px;
  border: 1px solid #d8dce0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: #303438;
  background: white;
}
.send-link:hover {
  border-color: var(--accent);
}
.viewer-actions {
  justify-content: flex-end;
  margin-bottom: 20px;
}
@media print {
  #sendPanel,
  .viewer-actions,
  #viewerStatus {
    display: none !important;
  }
}

.translation-notice {
  max-width: 1100px;
  margin: auto;
  padding: 0 20px;
}
.translation-notice p:empty {
  display: none;
}
.translation-notice p {
  margin: 12px 0;
  color: var(--ink, #222);
}

.voice-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 6px;
}
.voice-field input,
.voice-field textarea {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
.voice-button {
  min-height: 44px;
  flex-shrink: 0;
  padding: 10px;
  font-size: 14px;
}
.voice-button[aria-pressed="true"] {
  background: #b42318;
  color: white;
}
.voice-status {
  margin: 8px 0 14px;
}

.ai-draft {
  background: #fff8f3;
  border: 1px solid #f2d9c5;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}
.ai-draft h3 {
  margin-top: 0;
}
.ai-suggestion {
  border-top: 1px solid #ecd8c8;
  padding: 16px 0;
}
.ai-draft textarea {
  width: 100%;
  resize: vertical;
}
.ai-draft .profile-actions {
  margin-top: 12px;
}
.ai-draft ul {
  padding-left: 22px;
}
.ai-draft li {
  margin: 8px 0;
}
@media print {
  .ai-draft {
    display: none;
  }
}
