:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #696963;
  --border: #d9d9d3;
  --border-strong: #b8b8af;
  --accent: #253d1e;
  --accent-dark: #1a2c15;
  --soft-blue: #eef4ea;
  --panel: #f6f1fa;
  --danger: #9b2f2f;
  --paid: #276749;
  --partial: #8a5a00;
  --cancelled: #77716b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
}

button:hover {
  border-color: var(--border-strong);
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.primary:hover {
  background: var(--accent-dark);
}

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

.link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}

#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 210px 1fr;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 0 10px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 76px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  margin: 0 -10px 10px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-weight: 700;
}

.brand strong,
.brand span {
  display: block;
  color: var(--text);
}

.brand div span {
  color: var(--muted);
  font-size: 12px;
}

.mobile-menu-toggle {
  display: none;
}

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

nav button {
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: #53637c;
  display: block;
  align-items: center;
  min-height: 42px;
  font-weight: 500;
}

nav button.active {
  background: #e8f0e4;
  border-color: #e8f0e4;
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset -3px 0 0 var(--accent);
}

.user-strip {
  margin: auto -10px 0;
  border-top: 1px solid var(--border);
  padding: 12px 14px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-strip > span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e6f0e1;
  color: var(--accent);
  font-weight: 700;
}

.user-strip strong,
.user-strip small {
  display: block;
}

.main {
  min-width: 0;
  padding: 0;
}

.topbar {
  height: 56px;
  overflow: visible;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 4;
}

.topbar h1 {
  font-size: 22px;
  margin: 0;
}

.content {
  padding: 28px 32px 72px;
  overflow-x: auto;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  margin-bottom: 5px;
  font-weight: 650;
}

h2 {
  font-size: 17px;
  margin-bottom: 0;
}

h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  margin-bottom: 8px;
}

.page-head p,
.empty,
small {
  color: var(--muted);
}

.head-actions,
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.metrics,
.detail-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 24px;
}

.detail-hero h1 {
  font-size: 34px;
  margin: 0 0 6px;
}

.detail-hero p {
  color: var(--muted);
  margin: 0;
  font-size: 16px;
}

.detail-hero .status {
  font-size: 15px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
}

.detail-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.detail-cards div {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 10px 28px rgba(25, 35, 50, 0.08);
}

.detail-cards span,
.detail-cards small {
  display: block;
  color: var(--muted);
}

.detail-cards strong {
  display: block;
  font-size: 25px;
  margin: 12px 0 8px;
}

.detail-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 20px;
  align-items: start;
}

.detail-workspace.single-workspace {
  grid-template-columns: minmax(0, 1fr);
}

.detail-line-items,
.payment-overview,
.payment-history-section {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
}

.detail-line-items,
.payment-overview {
  margin-top: 0;
}

.detail-line-items .section-title,
.payment-overview .section-title,
.payment-history-section .section-title {
  min-height: 72px;
  margin: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.detail-line-items .section-title h2,
.payment-overview .section-title h2,
.payment-history-section .section-title h2 {
  margin: 0;
  font-size: 18px;
}

.detail-line-items .section-title p,
.payment-overview .section-title p,
.payment-history-section .section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-line-items .section-title > span,
.payment-history-section .section-title > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.detail-line-list {
  width: 100%;
}

.detail-line-head,
.detail-line-row {
  display: grid;
  align-items: center;
}

.detail-invoice-grid {
  grid-template-columns: 46px minmax(220px, 1fr) 92px 94px 140px 150px;
}

.detail-goods-grid {
  grid-template-columns: 46px minmax(260px, 1fr) 120px 140px;
}

.detail-line-head {
  min-height: 38px;
  padding: 0 18px;
  background: #f7f9fc;
  color: #667085;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-line-head span:not(:nth-child(2)) {
  text-align: right;
}

.detail-line-head span:first-child {
  text-align: left;
}

.detail-line-row {
  min-height: 76px;
  padding: 12px 18px;
  border-top: 1px solid #e7ebf0;
}

.detail-line-head + .detail-line-row {
  border-top: 0;
}

.detail-line-row:hover {
  background: #f9fbf7;
}

.line-number {
  color: #98a2b3;
  font-size: 12px;
  font-weight: 700;
}

.line-description,
.line-value {
  min-width: 0;
}

.line-description strong,
.line-description small,
.line-value strong,
.line-value small {
  display: block;
}

.line-description strong,
.line-description small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-description strong {
  color: #101828;
  font-size: 14px;
}

.line-description small,
.line-value small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.line-value {
  text-align: right;
}

.line-value small {
  display: none;
}

.line-value strong {
  color: #344054;
  font-size: 13px;
}

.line-value.total strong {
  color: #101828;
  font-weight: 750;
}

.payment-chart-wrap {
  display: grid;
  justify-items: center;
  gap: 24px;
  padding: 26px 22px 24px;
}

.payment-donut {
  position: relative;
  display: grid;
  width: 176px;
  height: 176px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#16845b 0 var(--paid-angle), #e46868 var(--paid-angle) 360deg);
}

.payment-donut::after {
  content: "";
  position: absolute;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px #edf0f4;
}

.payment-donut > div {
  position: relative;
  z-index: 1;
  text-align: center;
}

.payment-donut strong,
.payment-donut span {
  display: block;
}

.payment-donut strong {
  color: #101828;
  font-size: 28px;
  line-height: 1;
}

.payment-donut span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.payment-legend {
  display: grid;
  width: 100%;
  gap: 10px;
}

.payment-legend > div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  padding: 10px 12px;
  border: 1px solid #e7ebf0;
  border-radius: 8px;
}

.payment-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.paid-dot {
  background: #16845b;
}

.unpaid-dot {
  background: #e46868;
}

.payment-legend span,
.payment-legend span small {
  color: #475467;
}

.payment-legend span small {
  margin-left: 4px;
}

.payment-legend strong {
  color: #101828;
  font-size: 12px;
}

.payment-history-section {
  margin-top: 20px;
}

.payment-history-list {
  display: grid;
}

.payment-history-row {
  display: grid;
  grid-template-columns: 42px 125px 150px minmax(130px, 0.8fr) minmax(180px, 1fr) 160px;
  gap: 16px;
  align-items: center;
  min-height: 74px;
  padding: 12px 20px;
  border-top: 1px solid #e7ebf0;
}

.payment-history-row:first-child {
  border-top: 0;
}

.payment-history-row > div {
  min-width: 0;
}

.payment-history-row small,
.payment-history-row strong {
  display: block;
}

.payment-history-row small {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.payment-history-row strong {
  overflow: hidden;
  color: #344054;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payment-sequence {
  color: #98a2b3;
  font-size: 12px;
  font-weight: 700;
}

.payment-amount {
  text-align: right;
}

.payment-amount strong {
  color: #101828;
  font-size: 14px;
  font-weight: 750;
}

.payment-empty {
  min-height: 120px;
  padding: 42px 20px;
  text-align: center;
}

.hero-strip {
  background: #233146;
  color: #fff;
  border-radius: 14px;
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 16px 32px rgba(25, 35, 50, 0.18);
  margin-bottom: 28px;
}

.hero-strip h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.hero-strip p {
  color: #d4d9e3;
  margin: 0;
}

.invoiso-metrics {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 16px;
  border: 0;
}

.invoiso-metrics div,
.list-stats div {
  background: #fff;
  border: 0;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 10px 28px rgba(25, 35, 50, 0.08);
}

.invoiso-metrics span {
  font-weight: 650;
  color: #5b5b5b;
}

.list-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.list-stats span {
  color: var(--muted);
  font-size: 12px;
}

.list-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.alert-list {
  margin: 24px 0;
}

.danger-line {
  border-left: 4px solid #ee3232;
  padding-left: 12px;
}

.danger-line h2 small,
.count {
  border: 1px solid #ff9c9c;
  background: #fff2f2;
  color: #ee3232;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  margin-left: 8px;
}

.alert-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 16px;
  align-items: center;
  background: #fff7ff;
  border: 1px solid #ffb4b4;
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 10px;
  box-shadow: 0 2px 5px rgba(120, 50, 50, 0.15);
}

.metrics div,
.detail-strip div {
  padding: 12px 16px;
  border-right: 1px solid var(--border);
}

.metrics div:last-child,
.detail-strip div:last-child {
  border-right: 0;
}

.metrics span,
.detail-strip span,
.totals span,
.print-totals span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metrics strong,
.detail-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  font-weight: 650;
}

.section {
  margin-top: 24px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dashboard-documents .section-title {
  margin-bottom: 14px;
}

.dashboard-documents .section-title h2 {
  margin: 0;
}

.dashboard-documents .section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-documents .section-title > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.document-filter-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(190px, 220px) minmax(190px, 220px);
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(16, 24, 40, 0.04);
}

.document-filter-bar label {
  gap: 5px;
}

.document-filter-bar label > span {
  color: #667085;
  font-size: 11px;
  font-weight: 700;
}

.document-filter-bar input,
.document-filter-bar select {
  min-height: 42px;
}

.dashboard-documents-table[hidden],
.dashboard-documents-table tr[hidden],
#dashboardDocumentEmpty[hidden] {
  display: none;
}

.document-filter-empty {
  min-height: 150px;
  padding: 58px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.empty.compact {
  min-height: 58px;
  padding: 18px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 9px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: #3b3b37;
  font-size: 13px;
  font-weight: 500;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  background: #fff;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(25, 35, 50, 0.04);
}

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

th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
  background: #f8f9fc;
}

.invoice-bar {
  background: var(--accent);
  color: #fff;
  margin: -28px -32px 12px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
}

.invoice-bar h1 {
  margin: 0;
  font-size: 23px;
}

.builder-grid {
  display: grid;
  grid-template-columns: 320px minmax(760px, 1fr);
  gap: 18px;
  align-items: start;
}

.picker-column {
  display: grid;
  gap: 22px;
  align-content: start;
}

.panel {
  background: var(--panel);
  border: 1px solid #e3deeb;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 3px 7px rgba(30, 20, 50, 0.16);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-title h2,
.panel h2 {
  font-size: 17px;
  margin: 0 0 10px;
}

.panel-title h2 {
  margin: 0;
}

.pick-list {
  display: grid;
  gap: 8px;
  height: 270px;
  overflow-y: auto;
  margin-top: 12px;
  padding-right: 6px;
  scrollbar-color: #b6b1c7 #f2edf8;
  scrollbar-width: thin;
}

.pick-list button {
  display: block;
  text-align: left;
  border: 1px solid #e7e2ef;
  background: #fff;
  padding: 12px;
  border-radius: 10px;
}

.pick-list button.selected,
.pick-list button:hover {
  background: #e4e3f1;
  border-color: #c8c2d8;
}

.pick-list strong,
.pick-list small {
  display: block;
}

.builder-main {
  display: grid;
  gap: 14px;
}

.builder-top-panels {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 14px;
  align-items: stretch;
}

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

.customer-snapshot {
  min-height: 114px;
  display: grid;
  gap: 4px;
  color: #4b4b55;
}

.saved,
.count {
  background: #fff;
  border: 1px solid #dfdbe8;
  color: #7a7384;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.invoice-items-panel {
  min-height: 300px;
}

.invoice-item-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 6px;
}

.invoice-item-card {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 36px minmax(420px, 1fr) 150px 80px;
  gap: 12px;
  align-items: center;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.invoice-item-card.active,
.invoice-item-card:focus-within {
  background: #f8fbff;
  border-color: #9cc584;
  border-left-color: #2f5a24;
  box-shadow: 0 0 0 3px rgba(47, 90, 36, 0.12), 0 6px 18px rgba(16, 24, 40, 0.08);
}

.invoice-item-card.active .line-no,
.invoice-item-card:focus-within .line-no {
  background: #2f5a24;
  color: #fff;
}

.line-no {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #e5f4ff;
  color: #3d6b2f;
  font-weight: 800;
}

.line-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.line-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.bottom-composer {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 220px 220px;
  gap: 12px;
  align-items: start;
}

.additional-toggle {
  grid-column: 1 / -1;
  background: #f1fbfb;
  border-color: #b8e4e4;
  color: #007070;
  text-align: left;
}

.bottom-composer .wide {
  grid-column: 1 / 2;
}

.bottom-composer .totals {
  grid-column: 1 / -1;
}

.bottom-composer .additional-toggle {
  grid-column: 1 / -1;
}

.payment-selects,
.tax-box {
  display: grid;
  gap: 8px;
}

.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.switch-row input {
  width: auto;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--panel);
  border: 1px solid #ded8e9;
  border-radius: 12px;
  padding: 12px;
  margin: 18px 0 0 338px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  box-shadow: 0 -2px 8px rgba(35, 30, 45, 0.14);
}

.sticky-actions .primary {
  min-width: 260px;
}

.wide-modal {
  width: min(1000px, 96vw);
}

td small {
  display: block;
  margin-top: 3px;
}

.num {
  text-align: right;
  white-space: nowrap;
}

td:first-child,
td:nth-child(3) {
  white-space: nowrap;
}

td.actions,
.actions {
  min-width: 340px;
  flex-wrap: nowrap;
}

.empty {
  padding: 18px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.status {
  font-weight: 600;
  white-space: nowrap;
}

.status.paid {
  color: var(--paid);
}

.status.partially-paid {
  color: var(--partial);
}

.status.cancelled {
  color: var(--cancelled);
}

.status.unpaid {
  color: var(--danger);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 16px;
  align-items: start;
}

.wide {
  grid-column: span 2;
}

.line-table td:first-child {
  width: 34px;
}

.line-table select {
  margin-bottom: 6px;
}

.invoice-options {
  display: grid;
  grid-template-columns: 160px 140px 1fr 260px;
  gap: 16px;
  align-items: start;
  margin-top: 18px;
}

.totals,
.print-totals {
  border-top: 1px solid var(--border);
}

.totals div,
.print-totals div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.totals strong,
.print-totals strong {
  font-weight: 650;
  text-align: right;
}

.totals .grand,
.print-totals div:last-child {
  font-size: 16px;
}

.errors {
  border-left: 3px solid var(--danger);
  padding: 10px 12px;
  background: #fff5f5;
  color: var(--danger);
  margin-bottom: 16px;
}

.field-error {
  margin-top: -4px;
  padding: 9px 11px;
  border-left: 3px solid var(--danger);
  border-radius: 4px;
  background: #fff4f2;
  color: var(--danger);
  font-size: 12px;
  font-weight: 650;
}

.field-error[hidden] {
  display: none;
}

.error-modal {
  border-top: 4px solid var(--danger);
}

.error-modal ul {
  margin: 0;
  padding-left: 20px;
  color: var(--danger);
}

fieldset {
  border: 0;
  border-top: 1px solid var(--border);
  padding: 16px 0 22px;
  margin: 0;
}

legend {
  font-size: 16px;
  font-weight: 650;
  padding-right: 12px;
}

.invoice-preview {
  background: #fff;
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 26px rgba(25, 35, 50, 0.08);
}

.invoice-top {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(420px, 1.4fr);
  gap: 28px;
  align-items: start;
  border-bottom: 1px solid #8c8c8c;
  padding-bottom: 14px;
}

.invoice-logo {
  font-size: 20px;
  color: #111;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.invoice-brandline {
  align-items: flex-start;
}

.invoice-logo-img,
.invoice-logo-fallback {
  width: 128px;
  height: 96px;
  border: 0;
  border-radius: 0;
  padding: 0;
  object-fit: contain;
}

.invoice-logo-fallback {
  display: grid;
  place-items: center;
  background: #3d6b2f;
  color: #fff;
  font-size: 60px;
  font-weight: 800;
}

.invoice-company p,
.invoice-contact-strip span,
.invoice-contact-strip small {
  color: #111;
  font-size: 10px;
  line-height: 1.18;
}

.invoice-contact-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.invoice-contact-strip > div {
  min-height: 76px;
  border-left: 1px solid #8c8c8c;
  padding-left: 22px;
}

.invoice-contact-strip b {
  display: block;
  color: #f58220;
  font-size: 11px;
  margin-bottom: 12px;
}

.invoice-contact-strip a {
  color: #2f5a24;
  font-size: 14px;
  font-weight: 600;
}

.invoice-middle {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 42px;
  align-items: start;
  padding: 18px 0 18px;
}

.invoice-summary-zone h2 {
  text-align: center;
  font-size: 36px;
  color: #000;
  margin: 0 0 28px;
  font-weight: 800;
}

.summary-band {
  background: #f58220;
  color: #000;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 24px 18px 18px;
}

.summary-band span,
.summary-band strong {
  display: block;
  color: #000;
}

.summary-band span {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 10px;
}

.bill-to {
  padding: 0;
}

.bill-to h3 {
  color: #f58220;
  margin-bottom: 12px;
}

.bill-to p {
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 18px;
}

.print-table {
  margin-top: 0;
  min-width: 0;
  box-shadow: none;
  table-layout: fixed;
  border: 0;
  border-radius: 0;
}

.print-table thead th {
  background: #fff;
  color: #000;
  font-size: 16px;
  text-transform: none;
  border-bottom: 0;
}

.print-table tbody {
  background: #d9d9d9;
}

.print-table tbody td {
  background: #d9d9d9;
  color: #000;
  padding: 3px 10px;
  font-size: 12px;
  border-bottom: 0;
  line-height: 1.2;
}

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

.print-table tbody::after {
  content: "";
  display: table-row;
  height: 170px;
  background: #d9d9d9;
}

.invoice-preview table {
  min-width: 0;
}

.invoice-bottom {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 380px;
  gap: 28px 48px;
  margin-top: 26px;
  align-items: start;
}

.payment-method {
  width: 420px;
  max-width: 100%;
  background: #9f9f9f;
  color: #000;
  padding: 10px 18px;
}

.bank-details {
  grid-column: 1;
  margin-top: 80px;
  font-size: 10px;
}

.bank-details h3 {
  color: #000;
  text-transform: none;
}

.bank-details p {
  color: #000;
}

.print-totals {
  grid-column: 2;
  grid-row: 1 / span 2;
  border-top: 0;
}

.print-totals div {
  border-bottom: 0;
  padding: 8px 0;
  color: #000;
}

.print-totals .total-due {
  background: #f58220;
  padding: 14px 18px;
  margin-top: 8px;
  font-size: 17px;
  align-items: center;
}

.print-totals .total-due span {
  color: #000;
  font-size: 17px;
  font-weight: 800;
}

.signature {
  grid-column: 2;
  display: grid;
  gap: 34px;
  justify-items: center;
  color: #000;
  padding-top: 60px;
}

.signature strong {
  font-size: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 18, 0.32);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: grid;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.16);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
}

.template-option {
  display: grid;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.template-option.selected,
.template-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 61, 30, 0.12);
}

.template-option input {
  width: auto;
}

.template-card {
  height: 150px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcff;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.template-card em {
  justify-self: end;
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
}

.template-card i {
  display: block;
  height: 10px;
  background: #e7ecf6;
  border-radius: 4px;
}

.template-card strong {
  justify-self: end;
}

.template-card.classic {
  border-top: 6px solid var(--accent);
}

.template-card.minimal {
  border-color: transparent;
  background: #fff;
}

/* Final layout polish for a cleaner SaaS default */
.topbar {
  display: none;
}

.content {
  overflow-x: hidden;
}

.page-head {
  margin-bottom: 16px;
}

.brand-mark.logo-image,
.invoice-logo-img {
  object-fit: contain;
  background: #fff;
}

.brand-mark.logo-image {
  padding: 3px;
}

.invoice-brandline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.invoice-logo-img {
  width: 58px;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
  flex: 0 0 auto;
}

.logo-uploader {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px);
  gap: 14px;
  align-items: end;
}

.logo-preview {
  min-height: 82px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.logo-preview img,
.logo-preview > span {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: contain;
  display: grid;
  place-items: center;
  background: var(--soft-blue);
  color: var(--accent);
  font-weight: 800;
}

.sync-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.sync-panel p {
  margin: 0;
  color: var(--muted);
}

.slim {
  padding: 7px 12px;
  min-width: 72px;
}

/* Clean SaaS visual pass */
:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --text: #101828;
  --muted: #667085;
  --border: #e4e7ec;
  --border-strong: #cbd5e1;
  --accent: #2f5a24;
  --accent-dark: #2f5a24;
  --soft-blue: #eff4ff;
  --panel: #ffffff;
  --danger: #b42318;
  --paid: #027a48;
  --partial: #b54708;
  --cancelled: #667085;
}

body {
  background:
    radial-gradient(circle at top right, rgba(47, 90, 36, 0.08), transparent 32rem),
    var(--bg);
  color: var(--text);
}

#app {
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 28px rgba(16, 24, 40, 0.04);
}

@media (min-width: 861px) {
  #app {
    display: block;
    padding-left: 232px;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: 232px;
    height: 100vh;
    overflow-y: auto;
  }

  .main {
    width: 100%;
    min-height: 100vh;
  }
}

.brand {
  height: 72px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: 0 10px 20px rgba(47, 90, 36, 0.22);
}

.brand strong {
  font-size: 15px;
}

nav {
  gap: 5px;
  padding-top: 8px;
}

nav button {
  min-height: 40px;
  border-radius: 10px;
  padding: 10px 12px;
  color: #475467;
}

nav button:hover {
  background: #f2f4f7;
  border-color: transparent;
}

nav button.active {
  background: var(--soft-blue);
  border-color: #d6e7cc;
  box-shadow: inset 3px 0 0 var(--accent);
}

.user-strip {
  border-top: 1px solid var(--border);
}

.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  font-size: 20px;
  font-weight: 700;
}

.content {
  padding: 28px 36px 76px;
}

button {
  border-radius: 10px;
  padding: 9px 13px;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover {
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.primary {
  box-shadow: 0 8px 18px rgba(47, 90, 36, 0.2);
}

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

input,
select,
textarea {
  border-color: #d0d5dd;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 42px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  resize: none;
  overflow: hidden;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 90, 36, 0.12);
}

.hero-strip {
  background: linear-gradient(135deg, #101828, #1d2939);
  border-radius: 20px;
  box-shadow: 0 18px 36px rgba(16, 24, 40, 0.18);
}

.invoiso-metrics {
  gap: 18px;
}

.invoiso-metrics div,
.list-stats div,
.detail-cards div,
.panel,
.invoice-preview,
.modal,
table {
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.07);
}

.invoiso-metrics div,
.list-stats div {
  padding: 20px 22px;
}

.invoiso-metrics strong,
.detail-cards strong {
  color: #101828;
}

.page-head h1,
.invoice-bar h1,
.detail-hero h1 {
  letter-spacing: 0;
}

.toolbar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.05);
}

table {
  min-width: 0;
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  background: #f9fafb;
  color: #475467;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  background: #fff;
}

tbody tr:hover td {
  background: #f9fbff;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: #f2f4f7;
  font-size: 12px;
}

.status.unpaid {
  background: #fef3f2;
}

.status.partially-paid {
  background: #fffaeb;
}

.status.paid {
  background: #ecfdf3;
}

.status.proforma {
  background: #eef4ea;
  color: #253d1e;
}

.invoice-bar {
  margin: 0 0 18px;
  padding: 18px 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, #2f5a24, #253d1e);
  box-shadow: 0 16px 34px rgba(47, 90, 36, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.invoice-bar strong {
  white-space: normal;
}

.builder-grid {
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  gap: 20px;
}

.builder-top-panels {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.two {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.panel {
  padding: 16px;
}

.panel-title h2,
.panel h2 {
  color: #101828;
}

.pick-list button,
.invoice-item-card {
  border-color: var(--border);
  border-radius: 12px;
}

.pick-list {
  height: 220px;
  gap: 7px;
  align-content: start;
  grid-auto-rows: max-content;
}

.pick-list button {
  padding: 9px 10px;
  min-height: 54px;
}

.pick-list strong {
  font-size: 14px;
  line-height: 1.25;
}

.pick-list small {
  font-size: 12px;
}

.pick-list button:hover,
.pick-list button.selected {
  background: var(--soft-blue);
  border-color: #c3dbb5;
}

.invoice-item-card {
  grid-template-columns: 38px minmax(0, 1fr) minmax(120px, auto) auto;
  border-left: 4px solid #c3dbb5;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.05);
}

.invoice-item-card + .invoice-item-card {
  margin-top: 4px;
}

.invoice-item-card > strong {
  white-space: nowrap;
}

.line-meta {
  grid-template-columns: repeat(3, minmax(110px, 1fr));
}

.bottom-composer {
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 220px) minmax(180px, 220px);
}

.line-no {
  border-radius: 12px;
  background: var(--soft-blue);
  color: var(--accent);
}

.additional-toggle {
  background: #f8fbff;
  border-color: #c3dbb5;
  color: var(--accent);
}

.sticky-actions {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  box-shadow: 0 -10px 30px rgba(16, 24, 40, 0.1);
}

.detail-hero {
  grid-template-columns: minmax(260px, 1fr) auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.07);
}

.detail-hero .status {
  justify-self: start;
}

.detail-hero .head-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.detail-hero h1 {
  font-size: 30px;
}

.detail-cards {
  gap: 18px;
}

.invoice-preview {
  border-radius: 18px;
  width: min(920px, 100%);
}

.wide-modal {
  width: min(1120px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  padding: 18px;
}

.wide-modal .invoice-preview {
  max-width: 100%;
  margin: 0;
  padding: 30px;
  overflow: hidden;
}

td.actions,
.actions {
  min-width: 0;
  flex-wrap: wrap;
}

.template-option {
  border-radius: 16px;
}

.template-card {
  border-radius: 14px;
}

.gleva-template {
  max-width: 1040px;
  width: min(1040px, 100%);
  border-radius: 0;
  color: #000;
}

.gleva-template .invoice-top {
  grid-template-columns: minmax(310px, 0.9fr) minmax(430px, 1.2fr);
}

.gleva-template .invoice-brandline {
  align-items: flex-start;
}

.gleva-template .invoice-logo-img,
.gleva-template .invoice-logo-fallback {
  width: 132px;
  height: 98px;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.gleva-template .invoice-middle {
  grid-template-columns: 330px minmax(420px, 1fr);
}

.gleva-template .print-table th:nth-child(1) {
  width: 32px;
}

.gleva-template .print-table th:nth-child(2) {
  width: 48%;
}

.gleva-template .print-table th:nth-child(3) {
  width: 10%;
}

.gleva-template .print-table th:nth-child(4) {
  width: 12%;
}

.gleva-template .print-table th:nth-child(5),
.gleva-template .print-table th:nth-child(6) {
  width: 15%;
}

.gleva-template .invoice-bottom {
  grid-template-columns: minmax(320px, 1fr) 380px;
}

/* Pixel-style invoice sheet matching the provided Proforma reference */
.invoice-preview.gleva-template {
  position: relative;
  width: 1120px;
  max-width: 1120px;
  min-height: 1500px;
  padding: 0;
  background: #fff;
  border: 1px solid #bfbfbf;
  border-radius: 0;
  box-shadow: 0 14px 36px rgba(16, 24, 40, 0.08);
  font-family: Arial, Helvetica, sans-serif;
  transform-origin: top left;
}

.gleva-template .invoice-top,
.gleva-template .invoice-middle,
.gleva-template .invoice-bottom {
  display: block;
}

.gleva-template .invoice-top {
  position: absolute;
  inset: 0 auto auto 0;
  width: 1120px;
  height: 176px;
  border: 0;
  padding: 0;
}

.gleva-template .invoice-company {
  position: absolute;
  left: 0;
  top: 0;
  width: 445px;
  height: 170px;
}

.gleva-template .invoice-brandline {
  display: flex;
  gap: 18px;
  margin: 0;
}

.gleva-template .invoice-logo-img,
.gleva-template .invoice-logo-fallback {
  width: 152px;
  height: 118px;
  margin: 0 0 0 0;
}

.gleva-template .invoice-logo-fallback {
  border: 6px solid #3d6b2f;
  border-radius: 50%;
  background: #fff;
  color: #3d6b2f;
  font-size: 82px;
  line-height: 1;
}

.gleva-template .invoice-logo {
  margin-top: 34px;
  margin-bottom: 6px;
  color: #000;
  font-size: 20px;
  line-height: 1;
  font-weight: 400;
}

.gleva-template .invoice-company p {
  margin: 0;
  color: #000;
  font-size: 10.5px;
  line-height: 1.15;
}

.gleva-template .invoice-contact-strip {
  position: absolute;
  left: 448px;
  top: 62px;
  width: 536px;
  height: 90px;
  display: grid;
  grid-template-columns: 150px 165px 190px;
  gap: 0;
  border-bottom: 1px solid #808080;
}

.gleva-template .invoice-contact-strip > div {
  min-height: 72px;
  border-left: 1px solid #8b8b8b;
  padding-left: 26px;
}

.gleva-template .invoice-contact-strip b {
  color: #f58220;
  font-size: 12px;
  margin-bottom: 14px;
}

.gleva-template .invoice-contact-strip span,
.gleva-template .invoice-contact-strip small {
  display: block;
  color: #000;
  font-size: 9px;
  line-height: 1.15;
}

.gleva-template .invoice-contact-strip a {
  display: block;
  margin-top: 14px;
  color: #2f5a24;
  font-size: 15px;
  font-weight: 400;
}

.gleva-template .invoice-middle {
  position: absolute;
  left: 0;
  top: 178px;
  width: 1120px;
  height: 292px;
  padding: 0;
}

.gleva-template .bill-to {
  position: absolute;
  left: 70px;
  top: 0;
  width: 370px;
  color: #000;
}

.gleva-template .bill-to h3 {
  color: #f58220;
  font-size: 14px;
  margin: 0 0 16px;
  font-weight: 700;
}

.gleva-template .bill-to p {
  color: #000;
  font-size: 13px;
  line-height: 1.2;
  margin: 0 0 26px;
}

.gleva-template .bill-to strong {
  color: #000;
  font-size: 13px;
}

.gleva-template .invoice-summary-zone {
  position: absolute;
  left: 448px;
  top: 0;
  width: 544px;
}

.gleva-template .invoice-summary-zone h2 {
  margin: 0 0 56px;
  text-align: center;
  color: #000;
  font-size: 42px;
  line-height: 1;
  font-weight: 800;
}

.gleva-template .summary-band {
  height: 82px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 28px 16px 12px;
  gap: 0;
  background: #f58220;
  color: #000;
}

.gleva-template .summary-band span {
  margin: 0 0 10px;
  color: #000;
  font-size: 15px;
  line-height: 1;
  font-weight: 800;
}

.gleva-template .summary-band strong {
  color: #000;
  font-size: 13px;
  line-height: 1;
  font-weight: 400;
  text-align: center;
}

.gleva-template .print-table {
  position: absolute;
  left: 0;
  top: 478px;
  width: 992px;
  border: 0;
  border-radius: 0;
  border-collapse: collapse;
  box-shadow: none;
  table-layout: fixed;
}

.gleva-template .print-table thead th {
  height: 26px;
  padding: 0 12px 4px;
  color: #000;
  background: #fff;
  border: 0;
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  text-transform: none;
  vertical-align: bottom;
}

.gleva-template .print-table thead th:nth-child(1) {
  width: 36px;
  text-align: left;
  padding-left: 12px;
}

.gleva-template .print-table thead th:nth-child(2) {
  width: 468px;
  text-align: left;
}

.gleva-template .print-table thead th:nth-child(3) {
  width: 170px;
}

.gleva-template .print-table thead th:nth-child(4) {
  width: 150px;
}

.gleva-template .print-table thead th:nth-child(5) {
  width: 168px;
}

.gleva-template .print-table tbody {
  display: block;
  min-height: 336px;
  background: #d9d9d9;
}

.gleva-template .print-table thead,
.gleva-template .print-table tbody tr {
  display: table;
  width: 992px;
  table-layout: fixed;
}

.gleva-template .print-table tbody td {
  padding: 3px 12px 1px;
  color: #000;
  background: #d9d9d9;
  border: 0;
  font-size: 13px;
  line-height: 1.05;
  vertical-align: top;
}

.gleva-template .print-table tbody tr:nth-child(even) td {
  background: #d9d9d9;
}

.gleva-template .print-table tbody::after {
  display: none;
}

.gleva-template .invoice-bottom {
  position: absolute;
  left: 0;
  top: 814px;
  width: 1120px;
  height: 600px;
  margin: 0;
}

.gleva-template .payment-method {
  position: absolute;
  left: 31px;
  top: 0;
  width: 438px;
  height: 29px;
  padding: 8px 62px;
  background: #9b9b9b;
  color: #000;
  font-size: 12px;
  line-height: 1;
}

.gleva-template .payment-method strong {
  font-weight: 800;
}

.gleva-template .bank-details {
  position: absolute;
  left: 36px;
  top: 168px;
  width: 330px;
  margin: 0;
  color: #000;
  font-size: 10px;
  line-height: 1.1;
}

.gleva-template .bank-details h3 {
  color: #000;
  font-size: 11px;
  margin-bottom: 22px;
  font-weight: 800;
  text-transform: none;
}

.gleva-template .bank-details p {
  color: #000;
  font-size: 10px;
  line-height: 1.12;
}

.gleva-template .print-totals {
  position: absolute;
  left: 620px;
  top: 38px;
  width: 370px;
  color: #000;
}

.gleva-template .print-totals div {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 16px;
  padding: 8px 0;
  color: #000;
  border: 0;
}

.gleva-template .print-totals span {
  color: #000;
  font-size: 14px;
  text-align: left;
}

.gleva-template .print-totals strong {
  color: #000;
  font-size: 13px;
  text-align: right;
  font-weight: 400;
}

.gleva-template .print-totals .total-due {
  display: grid;
  grid-template-columns: 1fr 150px;
  align-items: center;
  width: 370px;
  height: 41px;
  margin-top: 8px;
  padding: 0 48px 0 82px;
  background: #f58220;
}

.gleva-template .print-totals .total-due span {
  color: #000;
  font-size: 19px;
  font-weight: 800;
  white-space: nowrap;
}

.gleva-template .print-totals .total-due strong {
  color: #000;
  font-size: 13px;
  font-weight: 800;
}

.gleva-template .signature {
  position: absolute;
  left: 730px;
  top: 356px;
  display: grid;
  gap: 42px;
  justify-items: center;
  color: #000;
  padding: 0;
  font-size: 12px;
}

.gleva-template .signature strong {
  color: #000;
  font-size: 14px;
  font-weight: 800;
}

@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: block;
    padding: 0;
    background: rgba(255, 255, 255, 0.98);
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
    overflow: visible;
  }

  .brand {
    height: 58px;
    margin: 0;
    padding: 8px 14px;
    justify-content: flex-start;
  }

  .mobile-menu-toggle {
    display: grid;
    width: 42px;
    height: 42px;
    min-height: 42px;
    margin-left: auto;
    padding: 10px;
    place-content: center;
    gap: 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
  }

  .mobile-menu-toggle:hover,
  .mobile-menu-toggle:focus-visible {
    background: #f2f4f7;
  }

  .mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: #344054;
    transition: transform 160ms ease, opacity 160ms ease;
  }

  .mobile-menu-toggle.open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .mobile-menu-toggle.open span:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-toggle.open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .sidebar nav {
    position: absolute;
    top: 58px;
    left: 0;
    right: 0;
    z-index: 21;
    display: none;
    max-height: calc(100vh - 58px);
    overflow-y: auto;
    padding: 10px 12px 14px;
    background: #fff;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 18px 32px rgba(16, 24, 40, 0.14);
  }

  .sidebar nav.open {
    display: grid;
    gap: 4px;
  }

  .sidebar nav button {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    text-align: left;
    white-space: normal;
  }

  .user-strip {
    display: none;
  }

  .content {
    padding: 20px 16px 36px;
    overflow-x: hidden;
  }

  .page-head,
  .invoice-top,
  .invoice-bottom,
  .invoice-options,
  .builder-grid,
  .builder-top-panels,
  .bottom-composer,
  .detail-hero,
  .detail-cards {
    grid-template-columns: 1fr;
  }

  .page-head {
    display: grid;
  }

  .invoice-bar {
    grid-template-columns: 1fr;
    gap: 5px;
    margin: 0 0 14px;
    padding: 14px 16px;
    border-radius: 14px;
  }

  .invoice-bar strong {
    justify-self: start;
    font-size: 12px;
  }

  .builder-grid {
    gap: 14px;
    min-width: 0;
  }

  .builder-grid > .picker-column,
  .builder-grid > .builder-main,
  .builder-main > .builder-top-panels {
    display: contents;
  }

  .document-details-panel {
    order: 1;
  }

  .customer-picker-panel {
    order: 2;
  }

  .customer-details-panel {
    order: 3;
  }

  .item-picker-panel {
    order: 4;
  }

  .invoice-items-panel {
    order: 5;
  }

  .bottom-composer {
    order: 6;
  }

  .builder-grid .panel {
    width: 100%;
    min-width: 0;
  }

  .metrics,
  .detail-strip,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: span 1;
  }

  .invoice-preview {
    padding: 22px;
  }

  .gleva-template .invoice-top,
  .gleva-template .invoice-middle,
  .gleva-template .invoice-bottom {
    grid-template-columns: 1fr;
  }

  .gleva-template .invoice-contact-strip,
  .gleva-template .summary-band {
    grid-template-columns: 1fr;
  }

  .gleva-template .bank-details,
  .gleva-template .print-totals,
  .gleva-template .signature {
    grid-column: auto;
    grid-row: auto;
    margin-top: 0;
  }

  .sticky-actions {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .invoice-item-card {
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: start;
  }

  .invoice-item-card > strong,
  .invoice-item-card > button {
    grid-column: 2;
    justify-self: start;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}

@media print {
  body {
    background: #fff;
  }

  #app {
    display: block;
  }

  .sidebar,
  .no-print,
  .topbar,
  .sticky-actions,
  .modal-backdrop {
    display: none !important;
  }

  .main {
    padding: 0;
  }

  .content {
    padding: 0;
    overflow: visible;
  }

  .invoice-preview {
    display: block !important;
    max-width: none;
    border: 0;
    box-shadow: none;
    padding: 14mm;
  }

  button {
    display: none;
  }

  table {
    break-inside: auto;
  }

  tr {
    break-inside: avoid;
  }
}

@media screen {
  .invoice-preview.gleva-template {
    zoom: 0.88;
  }

  .wide-modal .invoice-preview.gleva-template {
    zoom: 0.86;
  }
}

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

  .invoice-preview.gleva-template {
    width: 1120px;
    min-height: 1500px;
    padding: 0;
    border: 0;
    zoom: 0.75;
  }
}

.invoice-preview:not(.gleva-template) {
  max-width: 920px;
  width: min(920px, 100%);
  min-height: auto;
  padding: 42px;
  border-radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.invoice-preview:not(.gleva-template) .invoice-top {
  display: grid;
  position: static;
  width: auto;
  height: auto;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  border-bottom: 2px solid #20201e;
  padding-bottom: 22px;
}

.invoice-preview:not(.gleva-template) .invoice-brandline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.invoice-preview:not(.gleva-template) .invoice-logo-img {
  width: 58px;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
}

.invoice-preview:not(.gleva-template) .invoice-logo {
  color: var(--accent);
  font-size: 24px;
  font-weight: 700;
  text-transform: none;
  margin: 0;
}

.invoice-preview:not(.gleva-template) .invoice-title {
  text-align: right;
}

.invoice-preview:not(.gleva-template) .invoice-title h2 {
  font-size: 28px;
  margin-bottom: 18px;
}

.invoice-preview:not(.gleva-template) .bill-to {
  position: static;
  width: auto;
  padding: 22px 0 12px;
}

.invoice-preview:not(.gleva-template) .bill-to h3 {
  color: var(--muted);
}

.invoice-preview:not(.gleva-template) .print-table {
  position: static;
  width: 100%;
  margin-top: 8px;
}

.invoice-preview:not(.gleva-template) .print-table thead,
.invoice-preview:not(.gleva-template) .print-table tbody,
.invoice-preview:not(.gleva-template) .print-table tbody tr {
  display: revert;
  width: auto;
}

.invoice-preview:not(.gleva-template) .print-table th {
  background: #f9fafb;
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.invoice-preview:not(.gleva-template) .print-table td {
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  font-size: 14px;
  line-height: 1.35;
  border-bottom: 1px solid var(--border);
}

.invoice-preview:not(.gleva-template) .invoice-bottom {
  display: grid;
  position: static;
  width: auto;
  height: auto;
  grid-template-columns: 1fr 300px;
  gap: 40px;
  margin-top: 24px;
}

/* Modern single invoice style */
.invoice-preview:not(.gleva-template) {
  --invoice-accent: #253d1e;
  --invoice-soft: #eef4ea;
  --invoice-border: #cfe0c3;
  --invoice-ink: #111827;
  width: min(980px, 100%);
  max-width: 980px;
  padding: 44px;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.11);
  color: var(--invoice-ink);
}

.invoice-preview:not(.gleva-template)::before {
  content: "";
  display: block;
  height: 10px;
  margin: -44px -44px 34px;
  background: var(--invoice-accent);
}

.invoice-preview:not(.gleva-template) .invoice-top {
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 40px;
  align-items: start;
  border-bottom: 2px solid var(--invoice-ink);
  padding-bottom: 22px;
}

.invoice-preview:not(.gleva-template) .invoice-logo {
  color: var(--invoice-ink);
  font-size: 28px;
  line-height: 1.05;
  font-weight: 800;
}

.invoice-preview:not(.gleva-template) .invoice-logo-img {
  width: 70px;
  height: 70px;
  border-color: var(--invoice-border);
  background: var(--invoice-soft);
}

.invoice-preview:not(.gleva-template) .invoice-title {
  background: var(--invoice-soft);
  border: 1px solid var(--invoice-border);
  border-radius: 8px;
  padding: 20px;
}

.invoice-preview:not(.gleva-template) .invoice-title h2 {
  color: var(--invoice-accent);
  font-size: 34px;
  margin-bottom: 20px;
  letter-spacing: 0;
}

.invoice-preview:not(.gleva-template) dl {
  gap: 9px 16px;
}

.invoice-preview:not(.gleva-template) dt {
  color: #64748b;
}

.invoice-preview:not(.gleva-template) dd {
  color: var(--invoice-ink);
}

.invoice-preview:not(.gleva-template) .bill-to {
  width: min(430px, 100%);
  margin: 28px 0 30px;
  padding: 22px 24px;
  background: var(--invoice-soft);
  border: 1px solid var(--invoice-border);
  border-radius: 8px;
}

.invoice-preview:not(.gleva-template) .bill-to h3 {
  margin-bottom: 12px;
  color: var(--invoice-accent);
}

.invoice-preview:not(.gleva-template) .print-table {
  border: 1px solid var(--invoice-border);
  border-radius: 8px;
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
}

.invoice-preview:not(.gleva-template) .print-table th {
  background: var(--invoice-accent);
  color: #fff;
  border-bottom: 0;
  padding: 12px 14px;
}

.invoice-preview:not(.gleva-template) .print-table td {
  padding: 14px;
  border-color: #dbe4f0;
}

.invoice-preview:not(.gleva-template) .print-table tbody tr:nth-child(even) td {
  background: #f8fbff;
}

.invoice-preview:not(.gleva-template) .invoice-bottom {
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 44px;
  margin-top: 34px;
  border-top: 2px solid var(--invoice-ink);
  padding-top: 24px;
}

.invoice-preview:not(.gleva-template) .print-totals {
  border: 1px solid var(--invoice-border);
  border-radius: 8px;
  overflow: hidden;
}

.invoice-preview:not(.gleva-template) .print-totals div {
  padding: 12px 16px;
  border-bottom: 1px solid #dbe4f0;
}

.invoice-preview:not(.gleva-template) .print-totals div:last-child {
  background: var(--invoice-soft);
  border-bottom: 0;
  color: var(--invoice-accent);
}

@media (max-width: 1500px) {
  .detail-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .payment-chart-wrap {
    grid-template-columns: auto minmax(280px, 460px);
    justify-content: center;
    align-items: center;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 14px;
    background: #f6f8fc;
  }

  #app {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: block;
    padding: 0;
    background: rgba(255, 255, 255, 0.96);
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
  }

  .brand {
    height: 58px;
    margin: 0;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    justify-content: flex-start;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex: 0 0 auto;
  }

  .brand strong {
    font-size: 15px;
    line-height: 1.1;
  }

  .brand div span {
    font-size: 12px;
  }

  .sidebar nav {
    display: none;
    gap: 4px;
    overflow-y: auto;
    padding: 10px 12px 14px;
  }

  .sidebar nav.open {
    display: grid;
  }

  .sidebar nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar nav button {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    white-space: normal;
    font-size: 14px;
  }

  .sidebar nav button.active {
    box-shadow: inset 3px 0 0 var(--accent);
    border-color: #c3dbb5;
    background: #eff4ff;
  }

  .user-strip {
    display: none;
  }

  .main,
  .content {
    width: 100%;
    min-width: 0;
  }

  .content {
    padding: 16px 14px 96px;
    overflow-x: hidden;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  textarea {
    line-height: 1.4;
  }

  .builder-grid button,
  .modal button {
    min-height: 42px;
  }

  .hero-strip {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0 0 16px;
    padding: 18px;
    border-radius: 16px;
  }

  .hero-strip h2 {
    font-size: 24px;
    line-height: 1.08;
  }

  .hero-strip p,
  .hero-strip strong {
    font-size: 13px;
    line-height: 1.35;
  }

  .metrics,
  .invoiso-metrics,
  .detail-cards,
  .list-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    border: 0;
    margin-bottom: 18px;
  }

  .invoiso-metrics div,
  .list-stats div,
  .detail-cards div {
    min-height: 92px;
    padding: 16px;
    border-radius: 14px;
  }

  .invoiso-metrics strong,
  .detail-cards strong {
    font-size: 20px;
    overflow-wrap: anywhere;
  }

  .page-head {
    display: grid;
    gap: 12px;
  }

  .head-actions,
  .actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

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

  table {
    display: block;
    min-width: 0;
    width: 100%;
    overflow-x: auto;
    border-radius: 14px;
  }

  th,
  td {
    padding: 10px 12px;
    font-size: 13px;
  }

  .section-title h2 {
    font-size: 18px;
  }

  .detail-workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .detail-line-items,
  .payment-overview,
  .payment-history-section {
    border-radius: 12px;
  }

  .detail-line-items .section-title,
  .payment-overview .section-title,
  .payment-history-section .section-title {
    min-height: 64px;
    padding: 14px;
  }

  .detail-line-items .section-title > span,
  .payment-history-section .section-title > span {
    text-align: right;
  }

  .detail-line-head {
    display: none;
  }

  .detail-line-row.detail-invoice-grid,
  .detail-line-row.detail-goods-grid {
    grid-template-columns: 28px repeat(2, minmax(0, 1fr));
    gap: 12px;
    min-height: 0;
    padding: 16px 14px;
  }

  .detail-line-row + .detail-line-row {
    border-top: 1px solid #dfe4ea;
  }

  .detail-line-row .line-number {
    grid-column: 1;
    grid-row: 1 / span 3;
    padding-top: 2px;
  }

  .detail-line-row .line-description {
    grid-column: 2 / -1;
  }

  .line-description strong,
  .line-description small {
    white-space: normal;
  }

  .detail-line-row .line-value {
    min-width: 0;
    padding-top: 9px;
    border-top: 1px solid #edf0f4;
    text-align: left;
  }

  .detail-line-row .line-value small {
    display: block;
  }

  .detail-line-row .line-value strong {
    overflow-wrap: anywhere;
  }

  .payment-chart-wrap {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 22px 16px;
  }

  .payment-donut {
    width: 156px;
    height: 156px;
  }

  .payment-donut::after {
    width: 112px;
    height: 112px;
  }

  .payment-history-row {
    grid-template-columns: 28px repeat(2, minmax(0, 1fr));
    gap: 14px 12px;
    min-height: 0;
    padding: 16px 14px;
  }

  .payment-history-row .payment-sequence {
    grid-column: 1;
    grid-row: 1 / span 3;
  }

  .payment-history-row > div:nth-child(2),
  .payment-history-row > div:nth-child(4) {
    grid-column: 2;
  }

  .payment-history-row > div:nth-child(3),
  .payment-history-row > div:nth-child(5) {
    grid-column: 3;
  }

  .payment-history-row .payment-amount {
    grid-column: 2 / -1;
    padding-top: 10px;
    border-top: 1px solid #edf0f4;
    text-align: left;
  }

  .document-filter-bar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .dashboard-documents .section-title {
    align-items: flex-end;
    gap: 12px;
  }

  .dashboard-documents .section-title > span {
    flex: 0 0 auto;
  }

  .builder-grid,
  .builder-top-panels,
  .bottom-composer,
  .line-meta,
  .form-grid,
  .detail-hero,
  .invoice-preview:not(.gleva-template) .invoice-top,
  .invoice-preview:not(.gleva-template) .invoice-bottom {
    grid-template-columns: 1fr;
  }

  .picker-column {
    gap: 14px;
  }

  .panel {
    border-radius: 14px;
    padding: 14px;
  }

  .pick-list {
    height: min(210px, 30vh);
  }

  .invoice-bar {
    padding: 16px;
    border-radius: 16px;
  }

  .invoice-bar h1 {
    font-size: 22px;
  }

  .invoice-item-list {
    max-height: none;
  }

  .invoice-item-card {
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: start;
  }

  .invoice-item-card > strong,
  .invoice-item-card > button {
    grid-column: 2;
    justify-self: start;
  }

  .sticky-actions {
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    border-radius: 16px 16px 0 0;
    padding: 10px;
    justify-content: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sticky-actions button,
  .sticky-actions .primary {
    width: 100%;
    min-width: 0;
  }

  .detail-hero {
    padding: 16px;
    border-radius: 16px;
  }

  .detail-hero h1 {
    font-size: 24px;
    overflow-wrap: anywhere;
  }

  .wide-modal {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    padding: 12px;
    border-radius: 16px;
  }

  .wide-modal .invoice-preview,
  .invoice-preview:not(.gleva-template) {
    width: 100%;
    max-width: 100%;
    padding: 22px;
    border-radius: 14px;
    overflow-x: auto;
  }

  .invoice-preview:not(.gleva-template)::before {
    margin: -22px -22px 22px;
  }

  .invoice-preview:not(.gleva-template) .invoice-title {
    text-align: left;
  }

  .invoice-preview:not(.gleva-template) .invoice-title h2 {
    font-size: 28px;
  }

  .invoice-preview:not(.gleva-template) .bill-to {
    width: 100%;
    padding: 16px;
  }

  .invoice-preview:not(.gleva-template) .print-table {
    display: table;
    table-layout: auto;
    width: max-content;
    min-width: 680px;
  }

  .invoice-preview:not(.gleva-template) .print-table th,
  .invoice-preview:not(.gleva-template) .print-table td {
    min-width: 96px;
  }

  .invoice-preview:not(.gleva-template) .print-table th:nth-child(2),
  .invoice-preview:not(.gleva-template) .print-table td:nth-child(2) {
    min-width: 220px;
  }

  .sync-panel,
  .logo-uploader {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .content {
    padding-inline: 10px;
  }

  .metrics,
  .invoiso-metrics,
  .detail-cards,
  .list-stats {
    grid-template-columns: 1fr;
  }

  .hero-strip h2 {
    font-size: 22px;
  }

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

/* Exact Gleva document sheet */
.invoice-preview.gleva-template {
  position: relative;
  width: 1120px;
  max-width: none;
  min-height: 1584px;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #b7b7b7;
  border-radius: 0;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  transform-origin: top left;
  zoom: 0.72;
}

.gleva-template .invoice-top {
  position: absolute;
  inset: 0;
  display: block;
  width: 1120px;
  height: 174px;
  padding: 0;
  border: 0;
}

.gleva-template .invoice-company {
  position: absolute;
  top: 28px;
  left: 48px;
  width: 392px;
  height: 145px;
}

.gleva-template .invoice-brandline {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin: 0;
}

.gleva-template .invoice-logo-img {
  flex: 0 0 auto;
  width: 160px;
  height: 132px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  object-fit: contain;
}

.gleva-template .invoice-brandline > div {
  margin: 34px 0 0 -17px;
}

.gleva-template .invoice-logo {
  margin: 0 0 7px;
  color: #000;
  font-size: 19px;
  line-height: 1;
  font-weight: 400;
  text-transform: uppercase;
  white-space: nowrap;
}

.gleva-template .invoice-company p {
  margin: 0;
  color: #000;
  font-size: 10.5px;
  line-height: 1.55;
}

.gleva-template .invoice-contact-strip {
  position: absolute;
  top: 82px;
  left: 490px;
  display: grid;
  width: 580px;
  height: 86px;
  grid-template-columns: 188px 166px 226px;
  border-bottom: 1px solid #8b8b8b;
}

.gleva-template .invoice-contact-strip > div {
  position: relative;
  min-height: 82px;
  padding: 0 18px;
  border-left: 1px solid #8b8b8b;
}

.gleva-template .invoice-contact-strip > div:first-child {
  border-left: 0;
  padding-left: 0;
}

.gleva-template .invoice-contact-strip b {
  display: block;
  height: 28px;
  margin: 0;
  color: #f58220;
  font-size: 22px;
  line-height: 1;
}

.gleva-template .invoice-contact-strip span,
.gleva-template .invoice-contact-strip small {
  display: block;
  color: #000;
  font-size: 9px;
  line-height: 1.35;
}

.gleva-template .invoice-contact-strip a {
  display: block;
  margin-top: 9px;
  color: #2f5a24;
  font-size: 15px;
  line-height: 1;
  font-weight: 600;
  text-decoration: underline;
}

.gleva-template .invoice-middle {
  position: absolute;
  inset: 0;
  display: block;
  width: 1120px;
  height: 430px;
  padding: 0;
}

.gleva-template .bill-to {
  position: absolute;
  top: 180px;
  left: 97px;
  width: 350px;
  padding: 0;
  color: #000;
}

.gleva-template .customer-doc-icon {
  position: relative;
  width: 18px;
  height: 24px;
  margin: 0 0 12px;
  border: 2px solid #f58220;
  border-radius: 1px;
  color: #f58220;
}

.gleva-template .customer-doc-icon::before,
.gleva-template .customer-doc-icon::after {
  content: "";
  position: absolute;
  left: 3px;
  width: 9px;
  height: 2px;
  background: #f58220;
  box-shadow: 0 5px 0 #f58220;
}

.gleva-template .customer-doc-icon::before {
  top: 5px;
}

.gleva-template .customer-doc-icon::after {
  right: -5px;
  bottom: -5px;
  left: auto;
  width: 9px;
  height: 9px;
  border: 2px solid #f58220;
  border-radius: 50%;
  background: #fff;
  box-shadow: none;
}

.gleva-template .bill-to p {
  margin: 0 0 14px;
  color: #000;
  font-size: 13px;
  line-height: 1.35;
}

.gleva-template .bill-to strong {
  color: #000;
  font-size: 13px;
  font-weight: 700;
}

.gleva-template .bill-to .customer-email {
  color: #2f5a24;
  font-size: 15px;
  text-decoration: underline;
}

.gleva-template .company-tin {
  position: absolute;
  top: 398px;
  left: 170px;
  color: #000;
  font-size: 15px;
  line-height: 1;
  font-weight: 700;
}

.gleva-template .invoice-summary-zone {
  position: absolute;
  top: 190px;
  left: 488px;
  width: 582px;
}

.gleva-template .invoice-summary-zone h2 {
  margin: 0;
  color: #000;
  font-size: 43px;
  line-height: 1;
  font-weight: 800;
  text-align: left;
}

.gleva-template.delivery-template .invoice-summary-zone h2 {
  font-size: 38px;
}

.gleva-template .summary-icons {
  position: absolute;
  top: 82px;
  left: 0;
  display: grid;
  width: 430px;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
}

.gleva-template .summary-icons span {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid #8c8c8c;
  border-radius: 50%;
  background: #fff;
  color: #f58220;
  font-size: 19px;
  font-weight: 700;
}

.gleva-template .summary-band {
  position: absolute;
  top: 136px;
  left: 0;
  display: grid;
  width: 582px;
  height: 90px;
  grid-template-columns: repeat(3, 1fr);
  padding: 29px 18px 12px;
  background: #f58220;
  color: #000;
}

.gleva-template .summary-band > div {
  display: grid;
  grid-template-rows: auto auto;
  gap: 10px;
}

.gleva-template .summary-band span {
  color: #000;
  font-size: 15px;
  line-height: 1;
  font-weight: 800;
}

.gleva-template .summary-band strong {
  color: #000;
  font-size: 13px;
  line-height: 1;
  font-weight: 400;
  text-align: center;
}

.gleva-template .print-table {
  position: absolute;
  top: 439px;
  left: 52px;
  display: table;
  width: 1018px;
  margin: 0;
  border: 0;
  border-collapse: collapse;
  border-radius: 0;
  box-shadow: none;
  table-layout: fixed;
}

.gleva-template .print-table thead,
.gleva-template .print-table tbody tr {
  display: table;
  width: 1018px;
  table-layout: fixed;
}

.gleva-template .print-table thead th {
  height: 26px;
  padding: 0 10px 5px;
  border: 0;
  background: #fff;
  color: #000;
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  text-align: left;
  text-transform: none;
  vertical-align: bottom;
}

.gleva-template .print-table th:nth-child(1),
.gleva-template .print-table td:nth-child(1) {
  width: 36px;
}

.gleva-template .print-table th:nth-child(2),
.gleva-template .print-table td:nth-child(2) {
  width: 453px;
}

.gleva-template .print-table th:nth-child(3),
.gleva-template .print-table td:nth-child(3) {
  width: 78px;
}

.gleva-template .print-table th:nth-child(4),
.gleva-template .print-table td:nth-child(4) {
  width: 160px;
}

.gleva-template .print-table th:nth-child(5),
.gleva-template .print-table td:nth-child(5) {
  width: 130px;
}

.gleva-template .print-table th:nth-child(6),
.gleva-template .print-table td:nth-child(6) {
  width: 161px;
}

.gleva-template .print-table th.num,
.gleva-template .print-table td.num {
  text-align: right;
}

.gleva-template .print-table tbody {
  display: block;
  width: 1018px;
  min-height: 424px;
  background: #d6d6d6;
}

.gleva-template .print-table tbody td,
.gleva-template .print-table tbody tr:nth-child(even) td {
  padding: 3px 10px 1px;
  border: 0;
  background: #d6d6d6;
  color: #000;
  font-size: 13px;
  line-height: 1.05;
  font-weight: 400;
  vertical-align: top;
}

.gleva-template .document-reference {
  position: absolute;
  top: 635px;
  left: 168px;
  color: #000;
  font-size: 12px;
  font-weight: 700;
}

.gleva-template .invoice-bottom {
  position: absolute;
  top: 887px;
  left: 0;
  display: block;
  width: 1120px;
  height: 500px;
  margin: 0;
}

.gleva-template .payment-method {
  position: absolute;
  top: 0;
  left: 83px;
  width: 470px;
  height: 31px;
  padding: 8px 47px;
  background: #9b9b9b;
  color: #000;
  font-size: 12px;
  line-height: 1;
}

.gleva-template .bank-details {
  position: absolute;
  top: 150px;
  left: 85px;
  width: 330px;
  margin: 0;
  color: #000;
}

.gleva-template .bank-details h3 {
  margin: 0 0 21px;
  color: #000;
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
}

.gleva-template .bank-details p {
  margin: 0;
  color: #000;
  font-size: 10px;
  line-height: 1.2;
}

.gleva-template .print-totals {
  position: absolute;
  top: 39px;
  left: 694px;
  width: 376px;
  color: #000;
}

.gleva-template .print-totals > div {
  display: grid;
  width: 376px;
  grid-template-columns: 1fr 170px;
  gap: 18px;
  padding: 7px 0;
  border: 0;
}

.gleva-template .print-totals span {
  color: #000;
  font-size: 14px;
  text-align: left;
}

.gleva-template .print-totals strong {
  color: #000;
  font-size: 13px;
  font-weight: 400;
  text-align: right;
}

.gleva-template .print-totals .total-due {
  width: 376px;
  height: 45px;
  margin-top: 4px;
  padding: 11px 46px;
  background: #f58220;
}

.gleva-template .print-totals .total-due span {
  font-size: 20px;
  line-height: 1;
  font-weight: 800;
}

.gleva-template .print-totals .total-due strong {
  font-weight: 800;
}

.gleva-template .signature {
  position: absolute;
  top: 316px;
  left: 801px;
  display: grid;
  gap: 43px;
  justify-items: center;
  color: #000;
  font-size: 12px;
}

.gleva-template .signature strong {
  color: #000;
  font-size: 14px;
  font-weight: 800;
}

.gleva-template .invoice-footer {
  position: absolute;
  top: 1388px;
  left: 0;
  width: 1120px;
  height: 170px;
  color: #000;
}

.gleva-template .thanks {
  font-size: 16px;
  text-align: center;
}

.gleva-template .footer-rule {
  position: absolute;
  top: 22px;
  left: 50px;
  width: 910px;
  height: 4px;
  background: #c75f13;
}

.gleva-template .footer-terms,
.gleva-template .footer-contact {
  position: absolute;
  top: 38px;
  color: #000;
  font-size: 9px;
}

.gleva-template .footer-terms {
  left: 53px;
  width: 520px;
}

.gleva-template .footer-contact {
  left: 698px;
  width: 250px;
}

.gleva-template .footer-terms strong,
.gleva-template .footer-contact strong {
  color: #000;
  font-size: 9px;
}

.gleva-template .footer-terms p,
.gleva-template .footer-contact p {
  margin: 40px 0 0;
  color: #000;
  font-size: 9px;
  line-height: 1.45;
}

@media (max-width: 860px) {
  .invoice-preview.gleva-template,
  .wide-modal .invoice-preview.gleva-template {
    width: 1120px;
    max-width: none;
    min-height: 1584px;
    padding: 0;
    overflow: hidden;
    zoom: 0.62;
  }

  .gleva-template .invoice-contact-strip,
  .gleva-template .summary-band,
  .gleva-template .summary-icons {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .invoice-preview.gleva-template,
  .wide-modal .invoice-preview.gleva-template {
    zoom: 0.31;
  }
}

@media (max-width: 420px) {
  .invoice-preview.gleva-template,
  .wide-modal .invoice-preview.gleva-template {
    zoom: 0.285;
  }
}

@media print {
  .invoice-preview.gleva-template {
    width: 1120px;
    min-height: 1584px;
    padding: 0;
    border: 0;
    box-shadow: none;
    zoom: 0.707;
  }
}

/* Online saving: login screen, save status, log out */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg);
}

.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-card label {
  display: grid;
  gap: 6px;
  text-align: left;
  font-weight: 600;
}

.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

.login-card .errors {
  margin: 0;
  text-align: left;
}

.login-card button[type="submit"] {
  padding: 10px 12px;
}

.login-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin: 0 auto;
}

.user-strip {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.user-id {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-id > span {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef4ea;
  color: #2f5a24;
  font-weight: 700;
}

.user-id strong,
.user-id small {
  display: block;
}

.user-id small {
  color: var(--muted);
}

.logout-button,
.nav-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  border: 1px solid #fecdca;
  border-radius: 10px;
  background: #fef3f2;
  color: #b42318;
  font-weight: 600;
}

.logout-button:hover,
.nav-logout:hover {
  background: #fee4e2;
  border-color: #fda29b;
  color: #912018;
}

.sidebar nav .nav-logout {
  display: none;
}

@media (max-width: 860px) {
  .sidebar nav .nav-logout {
    display: flex;
    justify-content: flex-start;
    margin-top: 8px;
    border-color: #fecdca;
    background: #fef3f2;
    color: #b42318;
  }
}

/* Login and loading screens take the whole page (no sidebar space) */
#app.auth-screen {
  display: block;
  padding-left: 0;
}

/* Show/hide password button inside the password box */
.password-field {
  position: relative;
  display: block;
}

.login-card .password-field input {
  width: 100%;
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--accent);
  background: var(--soft-blue);
}

.password-field input::-ms-reveal,
.password-field input::-ms-clear {
  display: none;
}

/* Split-screen login (brand panel + form) */
.auth-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  background: #fff;
}

.auth-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  padding: 56px 64px 44px;
  color: #fff;
  background:
    radial-gradient(60rem 40rem at 110% 115%, rgba(47, 90, 36, 0.32), transparent 60%),
    radial-gradient(40rem 30rem at -20% -10%, rgba(120, 165, 90, 0.22), transparent 60%),
    linear-gradient(160deg, #0d160a 0%, #17260f 55%, #253d1e 100%);
}

.auth-brand > * {
  position: relative;
  z-index: 1;
}

.auth-brand-top,
.auth-mobile-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-logo {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.auth-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.auth-wordmark strong {
  display: block;
  font-size: 22px;
  letter-spacing: 0.01em;
}

.auth-wordmark span {
  display: block;
  font-size: 13px;
  opacity: 0.72;
}

.auth-brand-body {
  max-width: 520px;
}

.auth-brand h2 {
  margin: 0 0 32px;
  font-size: clamp(30px, 3.2vw, 42px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.auth-brand h2 em {
  font-style: normal;
  color: #a7d18f;
}

.auth-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 22px;
}

.auth-features li {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.auth-feature-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #a7d18f;
}

.auth-features strong {
  display: block;
  font-size: 16px;
  margin: 2px 0 4px;
}

.auth-features p {
  margin: 0;
  color: rgba(255, 255, 255, 0.66);
  line-height: 1.5;
}

.auth-brand-foot {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

.auth-watermark {
  position: absolute;
  right: -90px;
  bottom: -70px;
  width: 440px;
  opacity: 0.07;
  z-index: 0 !important;
  filter: brightness(0) invert(1);
  pointer-events: none;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 48px 24px;
}

.auth-form {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
}

.auth-mobile-brand {
  display: none;
}

.auth-form h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.02em;
}

.auth-lead {
  margin: -6px 0 6px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.auth-form label {
  display: grid;
  gap: 8px;
  font-weight: 500;
  color: #344054;
}

.auth-form input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  background: #f5f9f2;
  font-size: 15px;
}

.auth-form input:focus {
  outline: none;
  border-color: #2f5a24;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(47, 90, 36, 0.14);
}

.password-field input {
  width: 100%;
  padding-right: 48px;
}

.auth-form .errors {
  margin: 0;
}

.auth-submit {
  min-height: 50px;
  margin-top: 4px;
  font-size: 15px;
}

.auth-note {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 960px) {
  .auth-split {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    display: none;
  }

  .auth-panel {
    align-items: start;
    padding: 40px 16px;
    background:
      radial-gradient(30rem 20rem at 100% 0%, rgba(47, 90, 36, 0.08), transparent 70%),
      #fff;
  }

  .auth-mobile-brand {
    display: flex;
    margin-bottom: 18px;
    color: var(--text);
  }

  .auth-mobile-brand .auth-logo {
    box-shadow: 0 4px 14px rgba(16, 24, 40, 0.12);
  }

  .auth-form h1 {
    font-size: 30px;
  }
}

/* ---------------------------------------------------------------
   New Document page
---------------------------------------------------------------- */
.nd-page {
  max-width: 1320px;
  margin: 0 auto;
  padding-bottom: 96px;
}

.nd-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.nd-head h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.nd-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.nd-head p strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.nd-page > .errors {
  margin-bottom: 16px;
}

.nd-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.nd-main {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.nd-side {
  position: sticky;
  top: 20px;
}

.nd-card {
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}

.nd-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.nd-card-head h2,
.nd-summary h2 {
  margin: 0;
  font-size: 18px;
}

.nd-card-action {
  margin-left: auto;
}

.nd-card-action button,
.nd-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.nd-link {
  border: 0;
  background: transparent;
  color: #2f5a24;
  padding: 6px 4px;
  box-shadow: none;
}

.nd-link:hover {
  color: #253d1e;
  text-decoration: underline;
  box-shadow: none;
}

.nd-step {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef4ea;
  color: #2f5a24;
  font-weight: 700;
  font-size: 14px;
}

.nd-search {
  position: relative;
  margin-bottom: 12px;
}

.nd-search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #98a2b3;
  pointer-events: none;
}

.nd-search input {
  width: 100%;
  padding-left: 40px;
}

.nd-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 228px;
  overflow-y: auto;
  padding: 2px;
}

.nd-option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #e4e7ec;
  border-radius: 12px;
  background: #fff;
}

.nd-option:hover {
  border-color: #2f5a24;
  background: #f5f9f2;
}

.nd-option strong,
.nd-option small {
  display: block;
}

.nd-option small {
  color: var(--muted);
  margin-top: 2px;
}

.nd-avatar {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef4ea;
  color: #2f5a24;
  font-weight: 700;
}

.nd-avatar.small {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.nd-customer {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 12px;
  background: #f7faf5;
  border: 1px solid #dcead3;
}

.nd-customer strong {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
}

.nd-customer span:not(.nd-avatar) {
  display: block;
  color: #475467;
  line-height: 1.5;
}

.nd-none {
  grid-column: 1 / -1;
  margin: 4px 0;
  color: var(--muted);
}

.nd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 120px;
  overflow-y: auto;
  padding: 2px;
  margin-bottom: 16px;
}

.nd-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  background: #fff;
}

.nd-chip small {
  color: var(--muted);
}

.nd-chip:hover,
.nd-chip.selected {
  border-color: #2f5a24;
  background: #eef4ea;
  color: #253d1e;
}

.nd-chip[hidden],
.nd-option[hidden] {
  display: none;
}

.nd-lines {
  container-type: inline-size;
  border-top: 1px solid #eaecf0;
}

.nd-lines-head,
.nd-line {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 80px 76px 112px 120px 36px;
  gap: 10px;
  align-items: center;
}

.nd-lines.delivery .nd-lines-head,
.nd-lines.delivery .nd-line {
  grid-template-columns: 24px minmax(0, 1fr) 80px 100px 80px 36px;
}

.nd-lines-head {
  padding: 10px 4px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nd-lines-head .num,
.nd-line-amount {
  text-align: right;
}

.nd-line {
  padding: 10px 4px;
  border-bottom: 1px solid #f2f4f7;
  border-radius: 10px;
}

.nd-line.active {
  background: #f7faf5;
}

.nd-line.just-added {
  animation: nd-flash 1.2s ease;
}

@keyframes nd-flash {
  from { background: #dcead3; }
  to { background: transparent; }
}

.nd-line-no {
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.nd-line-item {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.nd-line input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
}

.nd-line-name {
  font-weight: 600;
}

.nd-line-desc {
  font-size: 13px;
  color: #475467;
}

.nd-field span {
  display: none;
}

.nd-line-amount {
  font-variant-numeric: tabular-nums;
}

.nd-remove {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #98a2b3;
  box-shadow: none;
}

.nd-remove:hover {
  color: var(--danger);
  background: #fff1f0;
  box-shadow: none;
}

.nd-empty {
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
  padding: 32px 16px;
  margin-top: 12px;
  border: 1.5px dashed #d0d5dd;
  border-radius: 12px;
  color: var(--muted);
}

.nd-empty strong {
  color: var(--text);
  font-size: 15px;
}

.nd-costs {
  margin-top: 14px;
}

.nd-costs h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nd-cost {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 36px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.nd-cost input {
  width: 100%;
  min-height: 38px;
}

.nd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 16px;
}

.nd-grid label,
.nd-terms {
  display: grid;
  gap: 6px;
  font-weight: 500;
  color: #344054;
}

.nd-grid small {
  font-weight: 400;
  color: #98a2b3;
}

.nd-grid input {
  width: 100%;
}

.nd-terms span {
  font-weight: 400;
  color: var(--muted);
}

.nd-terms textarea {
  width: 100%;
  min-height: 72px;
}

.nd-summary {
  display: grid;
  gap: 14px;
}

.nd-summary-who {
  padding: 12px;
  border-radius: 10px;
  background: #f9fafb;
}

.nd-summary-who span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.nd-rows {
  display: grid;
  gap: 10px;
}

.nd-rows > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
}

.nd-rows > div[hidden] {
  display: none;
}

.nd-rows span,
.nd-adjust label {
  color: #475467;
}

.nd-rows strong {
  font-variant-numeric: tabular-nums;
}

.nd-adjust label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nd-percent {
  position: relative;
  display: inline-block;
  width: 84px;
}

.nd-percent input {
  width: 100%;
  min-height: 34px;
  padding: 6px 24px 6px 10px;
}

.nd-percent i {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-style: normal;
  color: var(--muted);
}

.nd-adjust .nd-percent {
  margin-right: auto;
}

.nd-check input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: #2f5a24;
}

.nd-grand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 14px;
  border-top: 1px solid #eaecf0;
}

.nd-grand span {
  font-weight: 600;
}

.nd-grand strong {
  font-size: 24px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.nd-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.nd-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 32px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid #e4e7ec;
  box-shadow: 0 -8px 24px rgba(16, 24, 40, 0.06);
}

.nd-footer-total span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.nd-footer-total strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

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

.nd-footer-actions .primary {
  min-width: 220px;
  min-height: 46px;
}

@media (min-width: 861px) {
  .nd-footer {
    left: 232px;
  }
}

@container (max-width: 640px) {
  .nd-lines-head {
    display: none;
  }

  .nd-line,
  .nd-lines.delivery .nd-line {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    position: relative;
    padding: 14px 4px;
  }

  .nd-line-no {
    position: absolute;
    top: 14px;
    left: 4px;
  }

  .nd-line-item {
    grid-column: 1 / -1;
    padding: 0 40px 0 28px;
  }

  .nd-line .nd-remove {
    position: absolute;
    top: 12px;
    right: 0;
  }

  .nd-field span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
  }

  .nd-line-amount {
    grid-column: 1 / -1;
    text-align: right;
  }
}

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

  .nd-side {
    position: static;
  }
}

@media (max-width: 860px) {
  .nd-head h1 {
    font-size: 24px;
  }

  .nd-card {
    padding: 16px;
    border-radius: 14px;
  }

  .nd-footer {
    padding: 10px 16px;
  }

  .nd-footer-actions .primary {
    min-width: 0;
    padding: 10px 22px;
  }

  .nd-footer-total strong {
    font-size: 18px;
    white-space: nowrap;
  }

  .nd-hide-sm {
    display: none;
  }

  .nd-cost {
    grid-template-columns: minmax(0, 1fr) 120px 36px;
  }
}

/* Problem-only save notice (offline / couldn't save) */
.sync-notice {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 14px 12px 16px;
  border-radius: 12px;
  background: #1d2939;
  color: #fff;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.25);
  font-size: 14px;
  line-height: 1.4;
}

.sync-notice[hidden] {
  display: none;
}

.sync-notice button {
  flex: none;
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 600;
}

.sync-notice button:hover {
  background: rgba(255, 255, 255, 0.24);
}

@media (min-width: 861px) {
  .sync-notice {
    left: calc(50% + 116px);
  }
}

/* ---------------------------------------------------------------
   Settings page
---------------------------------------------------------------- */
.st-page {
  max-width: 1100px;
  margin: 0 auto;
  padding-bottom: 48px;
}

.st-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.st-head h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.st-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.st-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid #e4e7ec;
  border-radius: 12px;
  background: #fff;
  overflow-x: auto;
}

.st-tabs a {
  padding: 8px 14px;
  border-radius: 9px;
  color: #475467;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.st-tabs a:hover {
  background: #f2f4f7;
  color: var(--text);
}

.st-section {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
  padding: 24px;
  margin-bottom: 20px;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
  scroll-margin-top: 20px;
}

.st-intro h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.st-intro p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.st-body {
  display: grid;
  gap: 20px;
  min-width: 0;
}

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

.st-field {
  display: grid;
  gap: 6px;
  align-content: start;
}

.st-field.wide {
  grid-column: 1 / -1;
}

.st-field > span {
  font-weight: 500;
  color: #344054;
}

.st-field input,
.st-field textarea {
  width: 100%;
}

.st-field textarea {
  min-height: 76px;
}

.st-field small,
.st-note {
  color: #98a2b3;
  font-size: 13px;
}

.st-note {
  margin: 4px 0 0;
}

.st-logo {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px dashed #d0d5dd;
  border-radius: 14px;
  background: #fcfcfd;
}

.st-logo img {
  width: 72px;
  height: 72px;
  flex: none;
  object-fit: contain;
  padding: 8px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #eaecf0;
}

.st-logo strong,
.st-logo span {
  display: block;
}

.st-logo span {
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.5;
}

.st-logo-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.st-button {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
}

.st-button:hover {
  border-color: #2f5a24;
  color: #2f5a24;
}

.st-sequences {
  display: grid;
  gap: 8px;
}

.st-seq-head,
.st-seq-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.2fr) 100px 130px minmax(100px, 1fr);
  gap: 12px;
  align-items: center;
}

.st-seq-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.st-seq-row {
  padding: 10px 12px;
  border: 1px solid #eaecf0;
  border-radius: 12px;
  background: #fcfcfd;
}

.st-seq-row input {
  width: 100%;
}

.st-preview {
  justify-self: start;
  padding: 5px 10px;
  border-radius: 8px;
  background: #eef4ea;
  color: #2f5a24;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.st-mobile-label {
  display: none;
}

.st-toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid #eaecf0;
  border-radius: 12px;
  cursor: pointer;
}

.st-toggle.wide {
  grid-column: 1 / -1;
}

.st-toggle input {
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 2px 0 0;
  accent-color: #2f5a24;
}

.st-toggle strong,
.st-toggle small {
  display: block;
}

.st-toggle small {
  color: var(--muted);
  margin-top: 2px;
}

.st-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid #eaecf0;
  border-radius: 12px;
}

.st-actions strong,
.st-actions span {
  display: block;
}

.st-actions span {
  color: var(--muted);
  margin-top: 2px;
}

.st-actions button {
  flex: none;
}

@media (max-width: 1080px) {
  .st-section {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 640px) {
  .st-head h1 {
    font-size: 24px;
  }

  .st-tabs {
    width: 100%;
  }

  .st-section {
    padding: 16px;
    scroll-margin-top: 76px;
  }

  .st-grid {
    grid-template-columns: 1fr;
  }

  .st-seq-head {
    display: none;
  }

  .st-seq-row {
    grid-template-columns: 1fr 1fr;
  }

  .st-seq-row strong {
    grid-column: 1 / -1;
  }

  .st-mobile-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
  }

  .st-preview {
    grid-column: 1 / -1;
  }

  .st-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .st-logo {
    align-items: flex-start;
  }
}

/* New Document: type cards, payment methods */
.nd-types {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.nd-type-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  text-align: left;
  border: 1.5px solid #e4e7ec;
  border-radius: 14px;
  background: #fff;
  box-shadow: none;
}

.nd-type-card:hover {
  border-color: #c3dbb5;
  background: #f9fbf7;
  box-shadow: none;
}

.nd-type-card.active {
  border-color: #2f5a24;
  background: #f5f9f2;
  box-shadow: 0 0 0 3px rgba(47, 90, 36, 0.12);
}

.nd-type-card strong,
.nd-type-card small {
  display: block;
}

.nd-type-card strong {
  font-size: 15px;
}

.nd-type-card small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.4;
}

.nd-type-icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #f2f4f7;
  color: #475467;
}

.nd-type-card.active .nd-type-icon {
  background: #2f5a24;
  color: #fff;
}

.nd-sub {
  margin: -6px 0 12px;
  color: var(--muted);
}

.nd-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nd-method {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px solid #d0d5dd;
  border-radius: 999px;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.nd-method input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  accent-color: #2f5a24;
}

.nd-method.active {
  border-color: #2f5a24;
  background: #eef4ea;
  color: #253d1e;
}

.nd-pay-preview {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.nd-pay-preview div {
  padding: 12px 14px;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px solid #eaecf0;
}

.nd-pay-preview span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.nd-pay-preview strong {
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-line;
}

@media (max-width: 760px) {
  .nd-types {
    grid-template-columns: 1fr;
  }

  .nd-type-card {
    padding: 12px;
  }
}

/* ---------------------------------------------------------------
   Dashboard
---------------------------------------------------------------- */
.db-page {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.db-head {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 28px 30px;
  border-radius: 20px;
  color: #fff;
  background:
    radial-gradient(28rem 16rem at 100% 0%, rgba(255, 255, 255, 0.18), transparent 60%),
    radial-gradient(22rem 14rem at 0% 120%, rgba(120, 165, 90, 0.35), transparent 60%),
    linear-gradient(120deg, #2f5a24 0%, #253d1e 55%, #1a2c15 100%);
  box-shadow: 0 14px 34px rgba(47, 90, 36, 0.25);
}

.db-head::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -60px;
  width: 220px;
  height: 220px;
  background: url("./assets/gleva-logo.png") center / contain no-repeat;
  filter: brightness(0) invert(1);
  opacity: 0.08;
  pointer-events: none;
}

.db-head > * {
  position: relative;
  z-index: 1;
}

.db-head h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.db-head p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.82);
}

.db-new {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border: 0;
  background: #fff;
  color: #253d1e;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(15, 28, 10, 0.25);
}

.db-new:hover {
  background: #eef4ea;
  color: #1a2c15;
}

.db-draft {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid #c3dbb5;
  border-radius: 16px;
  background: #f5f9f2;
}

.db-draft > div {
  flex: 1;
  min-width: 0;
}

.db-draft strong,
.db-draft span:not(.db-stat-icon) {
  display: block;
}

.db-draft div span {
  color: var(--muted);
  margin-top: 2px;
}

.db-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.db-stat {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
  min-width: 0;
}

.db-stat > div {
  min-width: 0;
}

.db-stat span:not(.db-stat-icon),
.db-stat small {
  display: block;
  color: var(--muted);
}

.db-stat strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 22px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-stat-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #eef4ea;
  color: #2f5a24;
}

.db-stat.green .db-stat-icon { background: #ecfdf3; color: #067647; }
.db-stat.red .db-stat-icon { background: #fef3f2; color: #b42318; }
.db-stat.purple .db-stat-icon { background: #f4f3ff; color: #5925dc; }
.db-stat.red strong { color: #b42318; }

.db-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.db-card {
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
  min-width: 0;
}

.db-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.db-card-head h2 {
  margin: 0;
  font-size: 18px;
}

.db-card-head > span {
  color: var(--muted);
  font-size: 13px;
}

.db-attn-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 12px 12px 14px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid #eaecf0;
  border-left: 4px solid #f79009;
  background: #fffcf5;
}

.db-attn-row.late {
  border-left-color: #d92d20;
  background: #fffbfa;
}

.db-attn-main {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  box-shadow: none;
}

.db-attn-main:hover {
  box-shadow: none;
}

.db-attn-main strong,
.db-attn-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-attn-main span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.db-attn-row.late .db-attn-main b {
  color: #b42318;
}

.db-attn-row.soon .db-attn-main b {
  color: #b54708;
}

.db-attn-amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.db-small {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.db-more {
  margin-top: 4px;
}

.db-owe-row {
  padding: 10px 0;
  border-bottom: 1px solid #f2f4f7;
}

.db-owe-row:last-child {
  border-bottom: 0;
}

.db-owe-row div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.db-owe-row strong {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-owe-row span {
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.db-owe-row i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2f5a24, #8fbf6e);
}

.db-clear {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
}

.db-clear svg {
  color: #12b76a;
  margin-bottom: 4px;
}

.db-clear strong {
  color: var(--text);
}

.db-clear .primary {
  margin-top: 10px;
}

.db-clear[hidden] {
  display: none;
}

.db-head-actions {
  display: flex;
  gap: 8px;
}

.db-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.db-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: #f2f4f7;
  overflow-x: auto;
  max-width: 100%;
}

.db-tabs button {
  border: 0;
  border-radius: 9px;
  padding: 8px 12px;
  background: transparent;
  color: #475467;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: none;
}

.db-tabs button span {
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #e4e7ec;
  font-size: 12px;
}

.db-tabs button.active {
  background: #fff;
  color: #2f5a24;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

.db-tabs button.active span {
  background: #eef4ea;
}

.db-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.db-filters select {
  width: 170px;
  min-height: 42px;
}

.db-search {
  position: relative;
  display: block;
}

.db-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #98a2b3;
  pointer-events: none;
}

.db-search input {
  width: 300px;
  max-width: 100%;
  padding-left: 38px;
}

.db-list {
  border-top: 1px solid #eaecf0;
}

.db-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.1fr) minmax(160px, 1.6fr) 110px 110px 140px 140px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px 10px;
  border-bottom: 1px solid #f2f4f7;
  cursor: pointer;
}

.db-row:not(.db-row-head):hover {
  background: #f7faf5;
}

.db-row[hidden] {
  display: none;
}

.db-row-head {
  cursor: default;
  padding-top: 10px;
  padding-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.db-row .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.db-row small {
  display: none;
}

.db-doc strong,
.db-doc small {
  display: block;
}

.db-doc strong {
  color: #2f5a24;
}

.db-doc small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.db-cust {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-date,
.db-due {
  color: #475467;
}

.db-due.late {
  color: #b42318;
  font-weight: 600;
}

.db-balance.owed {
  font-weight: 700;
}

.db-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f2f4f7;
  color: #344054;
  white-space: nowrap;
}

.db-pill.paid { background: #ecfdf3; color: #067647; }
.db-pill.partially-paid { background: #fffaeb; color: #b54708; }
.db-pill.unpaid { background: #eef4ea; color: #253d1e; }
.db-pill.overdue { background: #fef3f2; color: #b42318; }
.db-pill.proforma { background: #f4f3ff; color: #5925dc; }
.db-pill.open,
.db-pill.delivered { background: #f0fdf9; color: #107569; }
.db-pill.cancelled { background: #f2f4f7; color: #667085; }

.db-count {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .db-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .db-grid {
    grid-template-columns: 1fr;
  }

  .db-row {
    grid-template-columns: minmax(110px, 1fr) minmax(140px, 1.4fr) 100px 100px 120px 120px 110px;
  }
}

@media (max-width: 980px) {
  .db-row-head {
    display: none;
  }

  .db-row {
    grid-template-columns: 1fr auto;
    gap: 6px 12px;
    padding: 14px 6px;
  }

  .db-doc { grid-column: 1; grid-row: 1; }
  .db-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .db-cust { grid-column: 1 / -1; grid-row: 2; }
  .db-date { grid-column: 1; grid-row: 3; }
  .db-due { grid-column: 2; grid-row: 3; text-align: right; }
  .db-amount { grid-column: 1; grid-row: 4; text-align: left !important; }
  .db-balance { grid-column: 2; grid-row: 4; }

  .db-row small {
    display: inline;
    margin-right: 6px;
    color: var(--muted);
    font-weight: 400;
  }

  .db-doc small {
    display: block;
    margin: 0;
  }

  .db-search input {
    width: 100%;
  }

  .db-filters,
  .db-search {
    width: 100%;
  }

  .db-filters select {
    flex: 1;
    width: auto;
  }
}

@media (max-width: 640px) {
  .db-head {
    padding: 22px 18px;
  }

  .db-head h1 {
    font-size: 23px;
  }

  .db-new {
    width: 100%;
    justify-content: center;
  }

  .db-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .db-stat {
    flex-direction: column;
    gap: 8px;
    padding: 14px;
  }

  .db-stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .db-stat strong {
    font-size: 17px;
  }

  .db-stat span:not(.db-stat-icon),
  .db-stat small {
    font-size: 12px;
  }

  .db-card {
    padding: 16px;
  }

  .db-attn-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .db-attn-row .db-small {
    grid-column: 1 / -1;
  }

  .db-draft {
    flex-wrap: wrap;
  }

  .db-draft > div {
    flex: 1 1 calc(100% - 60px);
  }

  .db-draft .primary {
    flex: 1;
    margin-left: 56px;
  }

  .db-card-head {
    flex-wrap: wrap;
  }
}

/* ---------------------------------------------------------------
   Items, Customers, Reports
---------------------------------------------------------------- */
.pg-page {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.pg-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.pg-head h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.pg-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.pg-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.db-new-solid {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
}

.lib-list {
  border-top: 1px solid #eaecf0;
}

.lib-row {
  display: grid;
  gap: 14px;
  align-items: center;
  padding: 14px 10px;
  border-bottom: 1px solid #f2f4f7;
}

.lib-row:last-child {
  border-bottom: 0;
}

.lib-row[hidden] {
  display: none;
}

.lib-list.items .lib-row {
  grid-template-columns: minmax(220px, 2.4fr) 90px 130px 130px 100px 70px;
}

.lib-list.customers .lib-row {
  grid-template-columns: minmax(220px, 2fr) minmax(120px, 1fr) minmax(160px, 1.3fr) 120px 150px 70px;
}

.lib-list.statement .lib-row {
  grid-template-columns: minmax(160px, 1.6fr) 80px repeat(3, minmax(110px, 1fr));
}

.lib-row:not(.lib-head):hover {
  background: #f7faf5;
}

.lib-head {
  padding-top: 10px;
  padding-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lib-head:hover {
  background: transparent;
}

.lib-row .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.lib-main {
  min-width: 0;
}

.lib-main strong,
.lib-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-main strong {
  font-weight: 600;
}

.lib-main > span,
.lib-main div span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  white-space: nowrap;
}

.lib-main em {
  font-style: normal;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #f2f4f7;
  color: #475467;
  font-size: 11px;
}

.lib-main.with-avatar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lib-main.with-avatar > div {
  min-width: 0;
}

.lib-cell {
  color: #475467;
  min-width: 0;
  overflow-wrap: anywhere;
}

.lib-cell small {
  display: none;
}

.lib-cell em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.lib-cell b {
  color: var(--text);
}

.lib-cell b.late {
  color: #b42318;
}

.lib-price {
  color: var(--text);
  font-weight: 600;
}

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

/* Reports chart */
.rp-legend {
  display: flex;
  gap: 16px;
  margin: -4px 0 12px;
  color: #475467;
  font-size: 13px;
}

.rp-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rp-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.rp-legend .s1,
.rp-bar.s1 { background: #4a7d36; }
.rp-legend .s2,
.rp-bar.s2 { background: #eda100; }

.rp-chart {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  height: 240px;
  padding-bottom: 24px;
}

.rp-axis {
  position: relative;
}

.rp-axis span {
  position: absolute;
  right: 8px;
  transform: translateY(50%);
  font-size: 11px;
  color: #98a2b3;
  font-variant-numeric: tabular-nums;
}

.rp-plot {
  position: relative;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid #d0d5dd;
}

.rp-grid {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed #eaecf0;
}

.rp-month {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
}

.rp-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
}

.rp-bar {
  width: clamp(10px, 2.2vw, 22px);
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  position: relative;
}

.rp-bar::before {
  content: "";
  position: absolute;
  inset: -6px -3px 0;
}

.rp-bar:hover {
  filter: brightness(1.1);
}

.rp-month small {
  position: absolute;
  bottom: -22px;
  font-size: 12px;
  color: #475467;
}

.rp-tip {
  position: absolute;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 8px;
  background: #1d2939;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.2);
}

.rp-table {
  margin-top: 6px;
}

.rp-table summary {
  cursor: pointer;
  color: #2f5a24;
  font-weight: 600;
  font-size: 13px;
}

.rp-table table {
  margin-top: 8px;
  width: 100%;
}

.rp-stack {
  display: flex;
  gap: 2px;
  height: 14px;
  margin: 4px 0 16px;
}

.rp-stack i {
  border-radius: 4px;
  min-width: 4px;
}

.rp-status-list {
  display: grid;
  gap: 4px;
}

.rp-status-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f2f4f7;
}

.rp-status-row:last-child {
  border-bottom: 0;
}

.rp-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.rp-status-row em {
  font-style: normal;
  color: var(--muted);
  font-size: 13px;
}

.rp-status-row strong {
  font-variant-numeric: tabular-nums;
  min-width: 120px;
  text-align: right;
}

.rp-qty {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .lib-list.items .lib-row,
  .lib-list.customers .lib-row,
  .lib-list.statement .lib-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
  }

  .lib-head {
    display: none !important;
  }

  .lib-main {
    grid-column: 1 / -1;
  }

  .lib-row > .db-small {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .lib-cell small {
    display: block;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .lib-row .num {
    text-align: left;
  }
}

@media (max-width: 640px) {
  .pg-head h1 {
    font-size: 24px;
  }

  .pg-head > .primary,
  .pg-actions {
    width: 100%;
  }

  .pg-head > .primary {
    justify-content: center;
  }

  .pg-actions .db-tabs {
    width: 100%;
  }

  .pg-actions .db-tabs button {
    flex: 1;
    padding: 8px 4px;
    font-size: 13px;
  }

  .rp-chart {
    height: 200px;
  }

  .rp-status-row strong {
    min-width: 0;
  }
}

.lib-main .nd-avatar {
  display: grid;
  overflow: visible;
  white-space: nowrap;
  margin: 0;
  color: #2f5a24;
  font-size: 13px;
}

/* Keep page columns within the screen; wide rows (tabs, charts) scroll inside instead */
.pg-page,
.db-page {
  grid-template-columns: minmax(0, 1fr);
}

.pg-page > *,
.db-page > *,
.pg-head > *,
.pg-actions > * {
  min-width: 0;
}

.rp-table {
  overflow-x: auto;
}

.rp-table table {
  min-width: 0;
  width: 100%;
}

/* Nange: unpaid is neutral so it never reads as paid (green) */
.db-pill.unpaid { background: #eef2f6; color: #364152; }

/* Nange login lockup: logo mark + wordmark from the brand files, no tile */
.auth-lockup {
  display: flex;
  align-items: center;
  gap: 20px;
}

.lockup-mark {
  height: 76px;
  width: auto;
}

.lockup-word {
  height: 46px;
  width: auto;
}

@media (max-width: 960px) {
  .auth-mobile-brand.auth-lockup {
    gap: 14px;
  }

  .auth-mobile-brand .lockup-mark {
    height: 56px;
  }

  .auth-mobile-brand .lockup-word {
    height: 34px;
  }
}

/* Nange sidebar: brand mark + wordmark from the logo files, no tile */
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-lockup .lockup-mark {
  height: 44px;
  width: auto;
}

.brand-lockup .lockup-word {
  height: 27px;
  width: auto;
}

/* Selected menu item: plain green, no edge line or outline */
nav button.active,
.sidebar nav button.active {
  background: #2f5a24;
  color: #fff;
  border-color: transparent;
  box-shadow: none;
  font-weight: 600;
}

nav button.active:hover,
.sidebar nav button.active:hover {
  background: #253d1e;
  color: #fff;
}

@media (max-width: 860px) {
  .brand-lockup .lockup-mark {
    height: 36px;
  }

  .brand-lockup .lockup-word {
    height: 22px;
  }
}

/* Settings: change password */
.st-password { display: grid; gap: 16px; }
.st-password .st-field > .password-field { font-weight: 400; color: inherit; }
.st-password .password-field input { width: 100%; padding-right: 48px; }
.st-pw-msg { margin: 0; min-height: 0; font-size: 14px; font-weight: 500; color: #b42318; }
.st-pw-msg:empty { display: none; }
.st-pw-msg.ok { color: #2f5a24; }
.st-pw-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.st-pw-actions small { color: #98a2b3; font-size: 13px; }

/* Mobile login: branded green header like desktop, form on a white sheet */
@media (max-width: 960px) {
  .auth-split {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #17260f;
  }

  .auth-brand {
    display: flex;
    flex: none;
    gap: 30px;
    justify-content: flex-start;
    padding: calc(44px + env(safe-area-inset-top)) 24px 76px;
  }

  .auth-brand .auth-lockup { gap: 14px; }
  .auth-brand .lockup-mark { height: 62px; }
  .auth-brand .lockup-word { height: 38px; }

  .auth-brand h2 {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
    max-width: 16ch;
  }

  .auth-features,
  .auth-brand-foot { display: none; }

  .auth-watermark {
    width: 260px;
    right: -60px;
    bottom: -20px;
    opacity: 0.08;
  }

  .auth-panel {
    flex: 1;
    position: relative;
    z-index: 2;
    margin-top: -28px;
    align-items: start;
    padding: 32px 20px calc(28px + env(safe-area-inset-bottom));
    background: #fff;
    border-radius: 26px 26px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.18);
  }

  .auth-mobile-brand,
  .auth-mobile-brand.auth-lockup { display: none; }

  .auth-form { gap: 16px; }
  .auth-form h1 { font-size: 26px; }
  .auth-lead { margin-top: -6px; }
  .auth-form input { min-height: 52px; font-size: 16px; }
  .auth-submit { min-height: 54px; font-size: 16px; border-radius: 14px; }
}

@media (max-width: 380px) {
  .auth-brand h2 { font-size: 24px; }
}

/* ---------------------------------------------------------------
   Phone navigation: bottom tab bar + Settings gear in the header
---------------------------------------------------------------- */
.tabbar,
.mobile-settings { display: none; }

@media (max-width: 860px) {
  .mobile-menu-toggle,
  .sidebar nav,
  .sidebar nav.open { display: none !important; }

  .sidebar { box-shadow: none; background: rgba(255, 255, 255, 0.94); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
  .brand { height: 60px; padding: 8px 12px 8px 16px; border-bottom: 0; padding-top: calc(8px + env(safe-area-inset-top)); height: calc(60px + env(safe-area-inset-top)); }

  .mobile-settings {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #475467;
  }
  .mobile-settings.active { background: #eef4ea; color: #253d1e; }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid #e4e7ec;
  }
  .tabbar.is-hidden { display: none; }

  .tabbar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-height: 52px;
    padding: 6px 2px 4px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #667085;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: none;
  }
  .tabbar button:hover { background: transparent; }
  .tabbar button.active, .tabbar button.active:hover { color: #253d1e; background: transparent; box-shadow: none; }
  .tabbar button.active svg { stroke-width: 2.3; }

  .tabbar .tab-new { color: #253d1e; }
  .tab-new-circle {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    margin-top: -22px;
    border-radius: 50%;
    background: #2f5a24;
    color: #fff;
    box-shadow: 0 6px 16px rgba(37, 61, 30, 0.35);
    border: 4px solid #fff;
    box-sizing: content-box;
  }

  .content { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
  .sync-notice { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* Phone: tab labels line up; customer cards are compact and readable */
@media (max-width: 860px) {
  .tabbar { align-items: stretch; }
  .tabbar button { justify-content: flex-end; }
}

.lib-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 640px) {
  .lib-list.customers .lib-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 16px 14px;
  }
  .lib-list.customers .lib-main { grid-column: 1; grid-row: 1; }
  .lib-list.customers .lib-owes { grid-column: 2; grid-row: 1; text-align: right; align-self: center; }
  .lib-list.customers .lib-owes small { display: none; }
  .lib-list.customers .lib-owes b { font-size: 15px; }
  .lib-list.customers .lib-cell:not(.lib-owes) { grid-column: 1 / -1; }
  .lib-list.customers .lib-cell.is-empty,
  .lib-list.customers .lib-location,
  .lib-list.customers .lib-contact small { display: none; }
  .lib-list.customers .lib-contact { color: #475467; font-size: 14px; padding-left: 50px; }
  .lib-list.customers .lib-tin { padding-left: 50px; font-size: 13px; color: #667085; }
  .lib-list.customers .lib-tin small { display: inline; margin-right: 6px; }
  .lib-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lib-list.customers .lib-row > .db-small { grid-column: 1 / -1; margin-left: 50px; }
}

/* Phone: document view */
@media (max-width: 640px) {
  .detail-hero { padding: 18px 16px; gap: 12px; }
  .detail-hero h1 { font-size: 24px; }
  .detail-hero .head-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .detail-hero .head-actions button { width: 100%; min-height: 46px; justify-content: center; padding: 10px 8px; white-space: normal; line-height: 1.2; }
  .detail-hero .head-actions .primary { grid-column: 1 / -1; order: -1; min-height: 50px; }
  .detail-hero .head-actions .detail-back { display: none; }
  .detail-cards { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .detail-cards > div { padding: 14px; min-width: 0; }
  .detail-cards strong { font-size: 17px; overflow-wrap: anywhere; }
}

/* Loading screen: brand gradient, logo and a thin progress bar */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  color: #fff;
  background: radial-gradient(60rem 40rem at 110% 115%, rgba(47, 90, 36, 0.32), transparent 60%), radial-gradient(40rem 30rem at -20% -10%, rgba(120, 165, 90, 0.22), transparent 60%), linear-gradient(160deg, #0d160a 0%, #17260f 55%, #253d1e 100%);
}
.boot-inner {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 28px;
  animation: boot-in 0.5s ease-out both;
}
.boot-lockup .lockup-mark { height: 72px; }
.boot-lockup .lockup-word { height: 44px; }
.boot-bar {
  position: relative;
  width: 180px;
  height: 3px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}
.boot-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  border-radius: 3px;
  background: #b5d69a;
  animation: boot-slide 1.15s ease-in-out infinite;
}
.boot-inner p {
  margin: -8px 0 0;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.72);
}
.boot-watermark {
  position: absolute;
  right: -90px;
  bottom: -80px;
  width: 420px;
  opacity: 0.06;
  pointer-events: none;
}
@keyframes boot-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(260%); }
}
@keyframes boot-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .boot-inner { animation: none; }
  .boot-bar span { animation: none; width: 100%; opacity: 0.5; }
}
@media (max-width: 640px) {
  .boot-lockup .lockup-mark { height: 56px; }
  .boot-lockup .lockup-word { height: 34px; }
  .boot-watermark { width: 190px; right: -60px; bottom: -40px; }
}
