:root {
  --bg-1: #f6fbff;
  --bg-2: #e7f1ff;
  --card: #ffffff;
  --text: #0f2a44;
  --muted: #4f6882;
  --line: #d2e2f3;
  --primary: #1f66d1;
  --primary-strong: #154d9f;
  --accent: #5a9cff;
  --accent-soft: #edf4ff;
  --danger: #bc3f3f;
  --danger-soft: #ffe6e6;
  --success-soft: #e8f8ef;
  --success-text: #1e7440;
  --error-soft: #ffeded;
  --error-text: #8a2f2f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, #f0f8ff 0%, transparent 35%),
    radial-gradient(circle at 100% 10%, #ddebff 0%, transparent 40%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

.wrap {
  width: min(1180px, 94vw);
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
  background: rgba(248, 252, 255, 0.9);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.8rem 0;
}

.brand {
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: 0.95rem;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  background: #f2f7ff;
  border: 1px solid #d6e4f5;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
}

.nav-group {
  position: relative;
}

.nav-group summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  background: #f2f7ff;
  border: 1px solid #d6e4f5;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group[open] summary {
  color: var(--primary-strong);
  border-color: #9ec1f0;
}

.nav-group-items {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 10;
  display: grid;
  gap: 0.35rem;
  min-width: 180px;
  padding: 0.45rem;
  border: 1px solid #d3e2f3;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(25, 60, 80, 0.13);
}

.nav-group-items-right {
  left: auto;
  right: 0;
}

.nav-group-items a {
  background: #f6faff;
  border-radius: 8px;
  border: 1px solid #dbe8f6;
}

.nav a:hover {
  color: var(--primary-strong);
  border-color: #9ec1f0;
}

.main {
  padding: 1.35rem 0 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 24px rgba(18, 70, 90, 0.05);
}

.stat-card h2 {
  margin: 0;
  color: var(--primary-strong);
}

.stat-card p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.two-panels {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stack {
  display: grid;
  gap: 0.8rem;
}

label {
  display: grid;
  gap: 0.3rem;
  font-weight: 600;
  color: #27485b;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.checkbox-inline input[type="checkbox"] {
  width: auto;
  margin: 0;
}

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

input,
select,
textarea {
  width: 100%;
  padding: 0.56rem 0.65rem;
  border-radius: 10px;
  border: 1px solid #cddde7;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #86aee7;
  outline: 2px solid #dce9fb;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.56rem 0.92rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn-primary {
  background: linear-gradient(180deg, #2a75e4, #1f60c6);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #2267ce, #164fa6);
}

.btn-light {
  background: var(--accent-soft);
  color: #1f4f8f;
  border: 1px solid #c9dcf7;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f5b9b9;
}

.btn-success {
  background: linear-gradient(180deg, #2aa65d, #1f854a);
  color: #fff;
}

.btn-success:hover {
  background: linear-gradient(180deg, #249455, #1a7441);
}

.btn-danger-solid {
  background: linear-gradient(180deg, #d84d4d, #b93636);
  color: #fff;
}

.btn-danger-solid:hover {
  background: linear-gradient(180deg, #c94343, #a83030);
}

.decision-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #d9e5f2;
}

.decision-form.is-hidden {
  display: none;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.actions-stack {
  display: grid;
  gap: 0.5rem;
}

.action-menu {
  position: relative;
}

.action-menu summary {
  list-style: none;
}

.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu[open] summary {
  border-color: #9ec1f0;
}

.action-menu-items {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 0.35rem;
  min-width: 230px;
  padding: 0.45rem;
  border: 1px solid #d3e2f3;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(25, 60, 80, 0.13);
}

.action-menu-item {
  display: block;
  width: 100%;
  text-decoration: none;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #dbe8f6;
  background: #f6faff;
  color: #1f4f8f;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.action-menu-items form {
  display: block;
  margin: 0;
}

.inline-form {
  display: inline;
}

.contact-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.plan-item-editor {
  border: 1px dashed #bfd8e6;
  border-radius: 12px;
  padding: 0.75rem;
  background: #fbfeff;
  cursor: grab;
}

.plan-item-editor.dragging {
  opacity: 0.65;
  border-color: #88addb;
  background: #f1f7ff;
}

.plan-item-grid {
  grid-template-columns: 1.2fr 1.8fr auto;
  align-items: start;
}

.textarea-lg {
  min-height: 120px;
  resize: vertical;
}

.plan-item-controls {
  display: grid;
  gap: 0.6rem;
  align-content: start;
  justify-items: start;
  min-width: 170px;
}

.plan-item-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.plan-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.plan-list-item {
  border: 1px solid #d7e6f2;
  border-radius: 12px;
  padding: 0.85rem;
  background: linear-gradient(180deg, #ffffff, #f8fcff);
}

.plan-list-item h3 {
  margin: 0 0 0.35rem;
  color: #11497e;
}

.plan-list-item p {
  margin: 0;
  color: #355b7a;
  white-space: pre-wrap;
}

.item-grid {
  grid-template-columns: 2.3fr 1fr 1fr auto;
  align-items: start;
}

.item-grid-invoice {
  grid-template-columns: 2.1fr 1fr 0.9fr 1fr auto;
}

.line-item-input {
  min-height: 2.2rem;
  resize: vertical;
}

.line-item-description {
  white-space: pre-wrap;
}

.item-row {
  border: 1px dashed #bfd8e6;
  border-radius: 10px;
  padding: 0.65rem;
  background: #fbfeff;
}

.contact-block {
  border: 1px dashed #bfd8e6;
  border-radius: 10px;
  padding: 0.7rem;
  background: #fbfeff;
}

.contact-multi-wrap {
  border: 1px dashed #bfd6f4;
  border-radius: 10px;
  padding: 0.65rem;
  background: #f8fbff;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  padding: 0.58rem;
}

th {
  color: var(--muted);
  font-size: 0.88rem;
}

.table-sort-link {
  color: inherit;
  text-decoration: none;
}

.pill {
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  text-transform: capitalize;
  border: 1px solid;
}

.pill.draft {
  background: #edf5ff;
  color: #2f65a0;
  border-color: #b9d5ff;
}

.pill.sent {
  background: #fff4e2;
  color: #8b5d13;
  border-color: #f6d19a;
}

.pill.paid,
.pill.converted,
.pill.accepted,
.pill.income {
  background: #e8f8ef;
  color: #1d7b43;
  border-color: #bdeacb;
}

.pill.overdue,
.pill.rejected,
.pill.expense,
.pill.cancelled {
  background: #ffecee;
  color: #9b2d35;
  border-color: #f3c0c7;
}

.pill.open,
.pill.low {
  background: #eef6ff;
  color: #2f5f95;
  border-color: #bed6f4;
}

.pill.in_progress,
.pill.medium,
.pill.waiting_customer,
.pill.high {
  background: #fff2df;
  color: #8b5c15;
  border-color: #f4d19d;
}

.pill.closed,
.pill.critical,
.pill.blocked {
  background: #ffecee;
  color: #9b2d35;
  border-color: #f3c0c7;
}

.alert {
  border-radius: 11px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 1rem;
}

.alert-success {
  background: var(--success-soft);
  color: var(--success-text);
  border: 1px solid #bceac9;
}

.alert-error {
  background: var(--error-soft);
  color: var(--error-text);
  border: 1px solid #f1bec0;
}

.muted {
  color: var(--muted);
}

.doc-head {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.doc-party-right {
  text-align: right;
  justify-self: end;
}

.totals {
  margin-left: 0;
  width: 100%;
  margin-top: 1rem;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

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

.totals-table th,
.totals-table td {
  border-bottom: 1px solid #dce9f2;
  padding: 0.45rem 0.25rem;
  white-space: nowrap;
  word-break: normal;
}

.totals-table th {
  text-align: right;
  color: #2a4f63;
  font-weight: 700;
  width: 80%;
}

.totals-table td {
  text-align: right;
  font-weight: 700;
  color: #123f66;
  width: 20%;
}

.totals-table .totals-grand-row th,
.totals-table .totals-grand-row td {
  border-top: 2px solid #bfd4e8;
  border-bottom: 0;
  font-size: 1.02rem;
  color: #0f4a88;
}

.big-total {
  font-size: 1.1rem;
  color: #124f72;
}

.notes {
  margin-top: 1rem;
  border-top: 1px dashed #c6d9e5;
  padding-top: 0.7rem;
}

.notes p {
  white-space: pre-line;
}

.report-filter .end-align {
  align-self: end;
}

.top-spacer {
  margin-top: 0.65rem;
}

.status-inline-form {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.status-inline-form select {
  min-width: 125px;
}

.ticket-problem {
  border-top: 1px dashed #c9dae7;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
}

.ticket-thread {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.6rem;
}

.ticket-comment {
  border: 1px solid #d9e7f1;
  background: #f9fdff;
  border-radius: 10px;
  padding: 0.65rem;
}

.public-card {
  max-width: 760px;
  margin: 0 auto 1rem;
}

.hidden-block {
  display: none;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
}

.checkbox-line input[type='checkbox'] {
  width: auto;
}

.card-soft {
  background: #fcfeff;
  border-color: #d7e7f2;
}

.portal-permissions {
  margin-top: 0.45rem;
  padding: 0.5rem;
  border: 1px dashed #c6d8e7;
  border-radius: 10px;
  background: #f7fcff;
}

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

.operations-group-card h3 {
  margin: 0;
  color: #164a7d;
}

.operations-group-card .stack {
  margin-top: 0.65rem;
}

.operations-task-item {
  border: 1px dashed #c8dced;
  border-radius: 10px;
  padding: 0.7rem;
  background: #fbfdff;
}

.operations-task-item .muted {
  margin: 0.35rem 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(22, 49, 66, 0.38);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(760px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #d8e4ee;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 22px 44px rgba(16, 55, 78, 0.2);
}

.modal-lg {
  width: min(980px, 96vw);
}

.metric-bars {
  display: grid;
  gap: 0.7rem;
}

.metric-row {
  display: grid;
  gap: 0.35rem;
}

.metric-label {
  font-weight: 600;
  color: #2a4f63;
}

.metric-track {
  height: 12px;
  border-radius: 999px;
  background: #e8f2f9;
  overflow: hidden;
  border: 1px solid #d4e4ef;
}

.metric-fill {
  height: 100%;
  background: linear-gradient(90deg, #2a75e4, #6ea2f6);
}

.chart-card {
  min-height: 280px;
  border: 1px solid #dce8f2;
  border-radius: 12px;
  padding: 0.6rem;
  background: #fbfeff;
}

.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background:
    radial-gradient(circle at 0% 0%, rgba(73, 131, 212, 0.16) 0%, transparent 45%),
    radial-gradient(circle at 100% 100%, rgba(42, 157, 143, 0.15) 0%, transparent 40%),
    #f9fcff;
}

.dashboard-hero h1 {
  margin: 0;
  font-size: 1.42rem;
}

.dashboard-hero p {
  margin: 0.4rem 0 0;
}

.dashboard-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.dashboard-kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-kpi {
  border-color: #cfe1ef;
  background: linear-gradient(180deg, #ffffff, #f8fcff);
}

.dashboard-kpi-label {
  margin: 0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #3f678a;
}

.dashboard-kpi h2 {
  margin: 0.45rem 0 0.3rem;
  color: #11497e;
}

.dashboard-kpi .muted {
  margin: 0;
}

.dashboard-chart {
  min-height: 290px;
}

.dashboard-chart-sm {
  min-height: 250px;
}

.dashboard-bank-grid {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.8rem;
}

.dashboard-bank-card {
  margin: 0;
  padding: 0.75rem;
}

.dashboard-bank-card h4 {
  margin: 0 0 0.55rem;
  color: #1a4f84;
}

.chart-fallback {
  display: grid;
  gap: 0.45rem;
  padding: 0.25rem;
}

.chart-fallback-row {
  display: grid;
  gap: 0.25rem;
}

.chart-fallback-row strong {
  font-size: 0.82rem;
  color: #355b7a;
}

.chart-fallback-row span {
  color: #355b7a;
  font-size: 0.86rem;
}

.chart-fallback-bar {
  position: relative;
  border: 1px solid #d5e4f1;
  border-radius: 999px;
  height: 18px;
  overflow: hidden;
  background: #f3f8fd;
}

.chart-fallback-fill {
  display: block;
  height: 100%;
}

.chart-fallback-bar em {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  font-style: normal;
  font-size: 0.75rem;
  color: #173e60;
  font-weight: 700;
}

.doc-brand {
  border: 1px solid #c8daef;
  border-radius: 14px;
  padding: 0.95rem 1.1rem;
  margin-bottom: 1rem;
  background:
    linear-gradient(135deg, rgba(16, 56, 99, 0.96), rgba(34, 97, 170, 0.96)),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.16), transparent 38%);
  color: #eff6ff;
  box-shadow: 0 8px 18px rgba(17, 66, 120, 0.16);
}

.doc-brand h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
}

.doc-brand p {
  margin: 0.25rem 0 0;
  color: #dbeafe;
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

.pdf-doc {
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
}

.doc-head h2,
.doc-head h3 {
  margin: 0 0 0.4rem;
}

.doc-head p {
  margin: 0.16rem 0;
  color: #2e4d68;
}

.pdf-doc h1 {
  margin: 0.15rem 0 0.75rem;
  color: #123f73;
  letter-spacing: 0.01em;
}

.pdf-doc h2 {
  margin: 0.25rem 0 0.55rem;
  color: #174b84;
}

.pdf-doc h3 {
  margin: 0.2rem 0 0.35rem;
  color: #1b3f67;
}

.pdf-doc .doc-brand h2 {
  color: #ffffff;
}

.pdf-doc .doc-brand p {
  color: #dbeafe;
}

.print-area table {
  width: 100%;
  border-collapse: collapse;
}

.doc-items-table {
  width: 100%;
  min-width: 100%;
  table-layout: fixed;
  display: table;
  border: 1px solid #d1deee;
  border-radius: 12px;
  overflow: hidden;
  margin: 0;
}

.doc-items-table thead,
.doc-items-table tbody,
.doc-items-table tfoot {
  display: table-row-group;
}

.doc-items-table tr {
  display: table-row;
}

.doc-items-table th,
.doc-items-table td {
  display: table-cell;
}

.doc-items-table th:nth-child(1),
.doc-items-table td:nth-child(1) {
  width: 56%;
}

.doc-items-table th:nth-child(2),
.doc-items-table td:nth-child(2),
.doc-items-table th:nth-child(3),
.doc-items-table td:nth-child(3) {
  width: 13%;
  text-align: right;
  white-space: nowrap;
}

.doc-items-table th:nth-child(4),
.doc-items-table td:nth-child(4) {
  width: 18%;
  text-align: right;
  white-space: nowrap;
}


.doc-items-table tfoot .doc-totals-label {
  text-align: right;
  font-weight: 700;
  color: #24435f;
}

.doc-items-table tfoot .doc-totals-value {
  text-align: right;
  font-weight: 700;
  color: #123f66;
  white-space: nowrap;
}

.doc-items-table tfoot th,
.doc-items-table tfoot td {
  text-align: right;
}

.doc-items-table tfoot .doc-grand-total .doc-totals-label,
.doc-items-table tfoot .doc-grand-total .doc-totals-value {
  border-top: 2px solid #bfd4e8;
  border-bottom: 0;
  font-size: 1.05rem;
  color: #0f4a88;
}

.print-area thead th {
  background: #edf4fc;
  color: #24486e;
  font-weight: 700;
}

.print-area tbody tr:nth-child(even) td {
  background: #f8fbff;
}

.print-area tbody tr:hover td {
  background: #eef5ff;
}

.notes {
  margin-top: 0.95rem;
  border: 1px solid #d4e2f1;
  background: #f8fbff;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
}

.notes h3 {
  margin-top: 0;
}

.full-width-table {
  width: 100% !important;
  table-layout: auto;
}

.tax-expense-table th:nth-child(1),
.tax-expense-table td:nth-child(1) {
  white-space: nowrap;
  width: 120px;
}

.tax-expense-table th:nth-child(6),
.tax-expense-table td:nth-child(6) {
  white-space: nowrap;
  width: 140px;
  min-width: 140px;
  text-align: right;
}

.receipt-table {
  width: 100% !important;
  min-width: 100% !important;
  table-layout: fixed;
  margin: 0;
}

.receipt-table th:nth-child(1),
.receipt-table td:nth-child(1) {
  width: 85%;
}

.receipt-table th:nth-child(2),
.receipt-table td:nth-child(2) {
  width: 15%;
  text-align: right;
  white-space: nowrap;
}

.master-section {
  width: 100%;
}

.page-break-before {
  page-break-before: always;
  break-before: page;
}

.site-footer {
  padding: 0 0 1rem;
  color: #486483;
  font-size: 0.88rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.pagination {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.pagination-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.pagination-page-pill {
  pointer-events: none;
}

.inline-table-pagination {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.btn.disabled,
.btn[aria-disabled='true'] {
  pointer-events: none;
  opacity: 0.55;
}

@media (max-width: 960px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
  }

  .nav-group {
    width: 100%;
  }

  .nav-group summary,
  .nav > a {
    width: 100%;
  }

  .nav-group-items {
    position: static;
    margin-top: 0.35rem;
    box-shadow: none;
  }

  .action-menu-items {
    position: static;
    margin-top: 0.35rem;
    box-shadow: none;
  }

  .grid.stats,
  .grid.two-panels,
  .grid.two,
  .grid.three,
  .dashboard-kpi-grid,
  .filter-grid-4,
  .operations-group-grid,
  .item-grid,
  .plan-item-grid,
  .doc-head {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .doc-party-right {
    text-align: left;
    justify-self: stretch;
  }

  .totals {
    width: 100%;
    margin-left: 0;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media print {
  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  @page {
    size: auto;
    margin: 1in;
  }

  .topbar,
  .no-print,
  .alert,
  .nav {
    display: none !important;
  }

  html,
  body {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white;
    font-size: 12px;
  }

  .main {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .wrap {
    width: 100%;
    max-width: 100%;
    margin: 0 !important;
    padding: 0 !important;
  }

  .card {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .pdf-doc {
    max-width: none !important;
    margin: 0 !important;
  }

  .print-area {
    border: 0 !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: white !important;
  }

  .doc-brand {
    margin-bottom: 0.6rem;
    break-inside: avoid-page;
    page-break-inside: avoid;
    background:
      linear-gradient(135deg, rgba(16, 56, 99, 0.96), rgba(34, 97, 170, 0.96)) !important;
    border-color: #1f4f83 !important;
    color: #ffffff !important;
  }

  .doc-brand h2 {
    color: #ffffff !important;
  }

  .doc-brand p {
    color: #dbeafe !important;
  }

  .doc-head {
    grid-template-columns: 1fr 1fr !important;
    align-items: start;
    gap: 0.65rem !important;
    margin-bottom: 0.65rem !important;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .doc-party-right {
    text-align: right !important;
    justify-self: end !important;
  }

  .totals {
    width: 100% !important;
    margin-left: 0 !important;
    border: 0 !important;
    background: transparent !important;
    padding: 0 !important;
  }

  .print-area table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: fixed !important;
  }

  .doc-items-table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: fixed !important;
  }

  .doc-items-table thead {
    display: table-header-group;
  }

  .doc-items-table tfoot {
    display: table-footer-group;
  }

  .doc-items-table tr {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .doc-items-table th:nth-child(1),
  .doc-items-table td:nth-child(1) {
    width: 56% !important;
    text-align: left !important;
    white-space: normal !important;
  }

  .doc-items-table th:nth-child(2),
  .doc-items-table td:nth-child(2),
  .doc-items-table th:nth-child(3),
  .doc-items-table td:nth-child(3) {
    width: 13% !important;
    text-align: right !important;
    white-space: nowrap !important;
  }

  .doc-items-table th:nth-child(4),
  .doc-items-table td:nth-child(4) {
    width: 18% !important;
    text-align: right !important;
    white-space: nowrap !important;
  }


  .doc-items-table tfoot th,
  .doc-items-table tfoot td,
  .doc-items-table tfoot .doc-totals-label,
  .doc-items-table tfoot .doc-totals-value {
    text-align: right !important;
  }

  .full-width-table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: fixed !important;
  }

  .receipt-table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: fixed !important;
  }

  .totals-table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: fixed !important;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .totals-table th,
  .totals-table td {
    text-align: right !important;
    white-space: nowrap !important;
    word-break: normal !important;
  }

  .receipt-table thead {
    display: table-header-group;
  }

  .print-area th,
  .print-area td {
    white-space: normal;
    word-break: break-word;
    border-color: #d2deec !important;
  }

  .tax-expense-table th:nth-child(1),
  .tax-expense-table td:nth-child(1) {
    white-space: nowrap !important;
    word-break: normal !important;
    width: 120px !important;
  }

  .tax-expense-table th:nth-child(6),
  .tax-expense-table td:nth-child(6) {
    white-space: nowrap !important;
    word-break: normal !important;
    width: 140px !important;
    min-width: 140px !important;
    text-align: right !important;
  }

  .receipt-table th:nth-child(2),
  .receipt-table td:nth-child(2) {
    width: 20% !important;
    text-align: right !important;
    white-space: nowrap !important;
  }

  .totals-table th {
    text-align: left !important;
  }

  .page-break-before {
    page-break-before: always !important;
    break-before: page !important;
  }

  .notes {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }
}
