:root {
  --bg: #eef3f6;
  --ink: #172126;
  --muted: #64737d;
  --line: #d8e1e6;
  --panel: #ffffff;
  --accent: #0b7285;
  --accent-2: #1f9d8a;
  --danger: #b42318;
  --nav: #111b20;
  --nav-2: #1d2a30;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  background: #095d6c;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #40515a;
  font-size: 12px;
  text-transform: uppercase;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(115deg, rgba(7, 36, 43, 0.86), rgba(14, 93, 106, 0.72)),
    url("./assets/airflows-instagram-logo.jpg") center / 260px no-repeat,
    #102027;
}

.login-panel {
  width: min(380px, calc(100vw - 36px));
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

.login-logo {
  display: block;
  width: 118px;
  height: 118px;
  object-fit: contain;
  margin: 0 auto 22px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.form-error {
  color: var(--danger);
  margin: 0;
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #e9f2f4;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  min-height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #aebcc3;
  font-size: 12px;
}

.nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-item {
  background: transparent;
  color: #d9e5e8;
  text-align: left;
  border: 1px solid transparent;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  color: #b8c6cc;
  font-size: 13px;
}

#logout-button {
  background: rgba(255, 255, 255, 0.12);
}

.workspace {
  padding: 24px 28px 92px;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -24px -28px 20px;
  padding: 18px 28px 14px;
  background: rgba(238, 243, 246, 0.96);
  border-bottom: 1px solid rgba(216, 225, 230, 0.95);
  box-shadow: 0 10px 24px rgba(17, 27, 32, 0.08);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.top-actions,
.line-actions,
.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.save-status {
  color: var(--accent);
  font-size: 13px;
  min-height: 18px;
}

.markdown-view {
  display: grid;
  gap: 8px;
  color: var(--ink);
  line-height: 1.5;
}

.markdown-view h2,
.markdown-view h3,
.markdown-view h4,
.markdown-view p {
  margin: 0;
}

.markdown-view h2 {
  font-size: 22px;
}

.markdown-view h3 {
  margin-top: 10px;
  font-size: 17px;
}

.markdown-view h4 {
  margin-top: 6px;
  font-size: 14px;
}

.markdown-bullet::before {
  content: "- ";
  color: var(--accent);
  font-weight: 700;
}

.markdown-gap {
  height: 4px;
}

.compact-search {
  width: min(260px, 42vw);
  min-height: 32px;
  font-size: 13px;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.icon-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  line-height: 1;
}

.icon-button.secondary {
  background: #edf2f4;
  color: #17323a;
}

.icon-button.danger {
  background: #f7e8e6;
  color: var(--danger);
}

.view {
  display: none;
}

.active-view {
  display: grid;
  gap: 18px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.span-2 {
  grid-column: span 2;
}

.table-wrap {
  overflow-x: auto;
}

.line-table input,
.line-table textarea,
.line-table select {
  min-width: 0;
}

.line-name {
  min-width: 360px;
  min-height: 52px;
  padding-right: 34px;
}

.designation-cell {
  position: relative;
}

.line-info-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 50%;
  background: #edf2f4;
  color: #17323a;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
  z-index: 2;
}

.line-info-button:hover {
  background: #dbe7eb;
}

.line-table {
  table-layout: fixed;
}

.line-table .col-designation {
  width: 34%;
}

.line-table .col-qty {
  width: 64px;
}

.line-table .col-price {
  width: 96px;
}

.line-table .col-vat {
  width: 62px;
}

.line-table .col-total {
  width: 92px;
}

.line-table .col-actions {
  width: 150px;
}

.line-table td:nth-child(2) input,
.line-table td:nth-child(5) input {
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
}

.quote-line-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.remove-line {
  background: #edf2f4;
  color: var(--danger);
  min-width: 34px;
  padding: 0 10px;
}

.totals-panel {
  background: #f9fbfc;
}

.internal-panel {
  background: #fffaf0;
  border-color: #ead7a7;
}

.internal-panel h2 {
  color: #5d430b;
}

.totals-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.totals-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.totals-list dt {
  color: var(--muted);
}

.totals-list dd {
  margin: 0;
  font-weight: 700;
}

.catalog-list {
  display: grid;
  gap: 12px;
}

.partner-checks {
  display: grid;
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check-row input {
  width: auto;
  min-height: auto;
}

.partner-list,
.client-list {
  display: grid;
  gap: 12px;
}

.partner-item,
.client-item {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr 1fr 0.5fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.catalog-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.catalog-summary {
  min-height: 44px;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  border: 0;
  text-align: left;
  display: grid;
  gap: 2px;
}

.catalog-summary:hover {
  background: #eef6f7;
}

.catalog-summary strong {
  font-size: 15px;
}

.catalog-summary span {
  color: var(--muted);
  font-size: 12px;
}

.catalog-name-label {
  color: var(--ink);
  font-weight: 800;
}

.catalog-name-input {
  font-weight: 800;
  color: #0d252c;
  border-color: #9eb6c0;
  background: #f4fafb;
}

.catalog-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.catalog-details {
  grid-column: 1 / -1;
  grid-template-columns: 1.25fr 0.75fr repeat(4, minmax(90px, 0.5fr));
  gap: 10px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.catalog-details:not([hidden]) {
  display: grid;
}

.catalog-item .wide {
  grid-column: span 2;
}

.company-doc-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) auto;
  gap: 12px;
  align-items: end;
}

.company-doc-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.company-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.company-doc-item strong,
.company-doc-item span {
  display: block;
}

.company-doc-item span {
  color: var(--muted);
  font-size: 12px;
}

.company-doc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.company-doc-actions a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.danger-button {
  background: var(--danger);
}

.powered {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  justify-items: center;
  gap: 2px;
  pointer-events: none;
  color: #7b8b92;
  font-size: 10px;
  opacity: 0.76;
  background: rgba(238, 243, 246, 0.94);
  border-top: 1px solid rgba(216, 225, 230, 0.85);
  padding: 5px 0 7px;
  z-index: 30;
}

.powered img {
  max-width: 54px;
  max-height: 20px;
  object-fit: contain;
}

#print-area {
  display: none;
}

.print-doc {
  font-family: Arial, Helvetica, sans-serif;
  font-variant-ligatures: normal;
  text-rendering: optimizeLegibility;
  color: #111;
  padding: 18mm;
}

.print-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid #111;
  padding-bottom: 12px;
  margin-bottom: 18px;
  break-inside: avoid;
}

.print-head img {
  width: 90px;
  height: 90px;
  object-fit: contain;
}

.print-doc h1 {
  margin: 0;
  font-size: 28px;
}

.print-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 16px 0;
}

.print-small {
  font-size: 12px;
  color: #333;
}

.print-totals {
  width: 320px;
  margin-left: auto;
}

.print-lines {
  break-inside: auto;
  page-break-inside: auto;
  width: 100%;
  margin-top: 6px;
}

.print-lines thead {
  display: table-header-group;
}

.print-block,
.print-signature {
  break-inside: avoid;
  page-break-inside: avoid;
}

.print-lines tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

.print-lines-page {
  break-inside: auto;
  page-break-inside: auto;
}

.print-page-break {
  break-before: page;
  page-break-before: always;
  padding-top: 4mm;
}

.print-report {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #cfd8de;
  background: #f6f8f9;
  padding: 7px 10px;
  margin-bottom: 8px;
  font-size: 13px;
}

.print-report span {
  color: #40515a;
}

.print-delivery,
.print-payment {
  margin-top: 16px;
  border-left: 4px solid var(--accent);
  background: #f6fafb;
  padding: 10px 12px;
}

.print-delivery strong,
.print-payment strong {
  display: inline-block;
  margin-bottom: 5px;
  font-size: 14px;
  text-decoration: underline;
}

.print-delivery p,
.print-payment p {
  margin: 0;
  line-height: 1.35;
}

.print-page-counter {
  display: none;
}

.print-signature {
  margin-top: 34px;
  border: 1px solid #bbb;
  padding: 12px;
  min-height: 116px;
}

.print-comment {
  white-space: pre-line;
}

.print-powered {
  margin-top: 28px;
  text-align: center;
  font-size: 9px;
  color: #777;
}

.print-powered img {
  display: block;
  margin: 4px auto 0;
  width: 48px;
}

.print-partners {
  display: grid;
  gap: 8px;
  margin-top: 7px;
}

.print-partner {
  display: flex;
  align-items: center;
  gap: 10px;
  break-inside: avoid;
}

.print-partner img {
  width: 56px;
  max-height: 28px;
  object-fit: contain;
}

.print-bank {
  margin: 12px 0;
  border: 1px solid #d6dde2;
  padding: 10px 12px;
}

.print-bank p {
  margin: 6px 0 0;
}

#detail-text {
  min-height: 150px;
}

.print-terms {
  margin-top: 16px;
  font-size: 10.5px;
  color: #222;
}

.print-terms h2 {
  margin: 0 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid #cfd8de;
  font-size: 15px;
}

.print-terms h3 {
  margin: 9px 0 2px;
  font-size: 11px;
  font-weight: 800;
}

.print-terms p {
  margin: 0 0 5px;
  line-height: 1.32;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(17, 27, 32, 0.48);
  padding: 18px;
}

.modal {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.26);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.modal h2 {
  margin: 0;
  font-size: 18px;
}

.modal p {
  margin: 0;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#cancel-link {
  background: #edf2f4;
  color: var(--ink);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .workspace {
    padding: 18px 16px 84px;
  }

  .topbar {
    margin: -18px -16px 18px;
    padding: 14px 16px 12px;
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-grid,
  .form-grid,
  .company-doc-form {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media print {
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    background: #fff !important;
  }

  body > :not(#print-area) {
    display: none !important;
  }

  #print-area {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  @page {
    margin: 12mm 10mm 16mm;
    @bottom-center {
      content: "Page " counter(page) "/" counter(pages);
      font-size: 10px;
      color: #56646b;
    }
  }

  .print-doc {
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-head {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  .print-lines {
    margin-top: 6px;
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  .print-lines th {
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .print-lines td {
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .print-small {
    font-size: 11px;
    line-height: 1.28;
  }

  .print-lines tbody,
  .print-lines tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-lines-page {
    break-inside: auto;
    page-break-inside: auto;
  }

  .print-page-break {
    break-before: page;
    page-break-before: always;
  }

  .print-page-counter {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 4mm;
    text-align: center;
    font-size: 10px;
    color: #56646b;
    z-index: 1000;
  }

  .print-page-counter::after {
    content: "Page " counter(page) "/" counter(pages);
  }
}

.client-quote-actions,
.logo-line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-line {
  align-self: end;
  min-height: 38px;
}
.logo-line .muted {
  flex: 1;
}
