:root {
  color-scheme: light;
  --bg: #edf1f7;
  --ink: #101126;
  --muted: #70758a;
  --line: rgba(18, 20, 38, 0.12);
  --glass: rgba(255, 255, 255, 0.68);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --accent-dark: #3328ca;
  --accent : #121423;
  --green: #047857;
  --red: #b42318;
  --shadow: 0 22px 70px rgba(31, 41, 55, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 5%, rgba(255, 255, 255, 0.95), transparent 28rem),
    linear-gradient(135deg, #eef4fb 0%, #f9fafc 48%, #e7edf8 100%);
  color: var(--ink);
}

[x-cloak] { display: none !important; }

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(26px) saturate(145%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 760;
  font-size: 18px;
}

.brand.centered { justify-content: center; }

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #111423;
  color: white;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 12px 30px rgba(17, 20, 35, 0.2);
}

.nav-stack { display: grid; gap: 8px; }

.nav-item,
.nav-subitem {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 11px 13px;
  color: #34374d;
  background: transparent;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.nav-submenu { display: grid; gap: 4px; padding-left: 14px; }
.nav-subitem { padding: 9px 13px; font-size: 14px; }
.nav-item:hover,
.nav-subitem:hover {
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.nav-item.is-active,
.nav-subitem.is-active {
  background: var(--accent);
  color: white;
}

.nav-item.is-active:hover,
.nav-subitem.is-active:hover {
  background: var(--accent);
  color: white;
}
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; }
.subtle { color: var(--muted); }
.full { text-align: left; }

.content {
  padding: 34px;
  max-width: 1480px;
  width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  letter-spacing: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.glass-panel,
.auth-card {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(145%);
}

.glass-panel {
  padding: 22px;
  margin-bottom: 20px;
  overflow: visible;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  overflow: visible;
}

.data-table th,
.data-table td {
  padding: 22px 24px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-weight: 650;
  font-size: 16px;
}

.data-table tr.clickable-row {
  cursor: pointer;
}

.data-table tr.clickable-row td {
  transition: background-color 160ms ease, color 160ms ease;
}

.data-table tr.clickable-row:hover td,
.data-table tr.clickable-row:focus td {
  background: rgba(16, 17, 38, 0.045);
}

.data-table tr.clickable-row:focus {
  outline: none;
}

.data-table tr.clickable-row:focus-visible td {
  background: rgba(16, 17, 38, 0.055);
  box-shadow: inset 0 0 0 2px rgba(79, 70, 229, 0.26);
}

.empty { text-align: center; color: var(--muted); padding: 34px !important; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-top: 18px;
}

.pagination-arrow {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--glass-strong);
  color: var(--ink);
  text-decoration: none;
  font-size: 0;
  line-height: 0;
}

.pagination-arrow::before {
  content: "";
  width: 12px;
  height: 12px;
  border-top: 3px solid currentColor;
  border-right: 3px solid currentColor;
}

.pagination-arrow-prev::before {
  transform: translate(3px, 5px) rotate(-135deg);
}

.pagination-arrow-next::before {
  transform: translate(-3px, 5px) rotate(45deg);
}

.pagination-arrow:not(.is-disabled):hover,
.pagination-arrow:not(.is-disabled):focus {
  outline: none;
  border-color: rgba(79, 70, 229, 0.38);
  background: rgba(255, 255, 255, 0.96);
  color: var(--accent-dark);
}

.pagination-arrow.is-disabled {
  opacity: 0.36;
  cursor: default;
}

.pagination-status {
  color: var(--muted);
  font-weight: 720;
}

.row-actions {
  position: relative;
  white-space: nowrap;
  text-align: right;
  min-width: 210px;
  overflow: visible;
}

.row-actions.menu-only {
  width: 48px;
  min-width: 48px;
  padding-left: 8px;
  padding-right: 12px;
}

.row-action-links {
  display: inline-flex;
  align-items: center;
  gap: 28px;
  vertical-align: middle;
}

.row-menu {
  position: relative;
  z-index: 20;
  display: inline-block;
  margin-left: 30px;
  vertical-align: middle;
}

.row-actions.menu-only .row-menu {
  margin-left: 0;
}

.row-menu.is-open {
  z-index: 200;
}

.menu-trigger {
  width: 24px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.menu-trigger img {
  width: 24px;
  height: 24px;
  display: block;
  object-fit: contain;
  opacity: 1;
}

.menu-trigger:hover,
.menu-trigger:focus {
  outline: none;
  background: transparent;
}

.menu-trigger:hover img,
.menu-trigger:focus img {
  opacity: 1;
}

.menu-tooltip {
  position: absolute;
  z-index: 70;
  right: -20px;
  bottom: calc(100% + 8px);
  padding: 6px 9px;
  border-radius: 7px;
  background: #171717;
  color: white;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  box-shadow: 0 10px 26px rgba(16, 17, 38, 0.18);
}

.menu-tooltip::after {
  content: "";
  position: absolute;
  right: 27px;
  top: 100%;
  border: 7px solid transparent;
  border-top-color: #171717;
}

.row-menu-popover {
  position: absolute;
  z-index: 60;
  top: calc(100% + 12px);
  right: -10px;
  min-width: 160px;
  padding: 10px;
  border: 1px solid rgba(16, 17, 38, 0.07);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(31, 41, 55, 0.15);
  backdrop-filter: blur(26px) saturate(145%);
}

.menu-delete {
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--red);
  font: inherit;
  font-size: 16px;
  font-weight: 780;
  text-align: left;
  cursor: pointer;
}

.menu-delete:hover,
.menu-delete:focus {
  outline: none;
  background: rgba(180, 35, 24, 0.1);
}

.link { color: var(--accent-dark); font-weight: 650; text-decoration: none; }

.pdf-link,
.pdf-link:hover,
.pdf-link:focus {
  color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--glass-strong);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

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

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -8px 0 18px;
}

.search-field {
  flex: 1;
  min-width: 220px;
}

.search-field .form-control {
  min-height: 46px;
  border-radius: 14px;
  background: var(--glass-strong);
}

.confirm-dialog .button {
  min-width: 146px;
  min-height: 48px;
  border-radius: 16px;
  font-size: 17px;
}

.confirm-dialog .button:not(.danger) {
  border-color: rgba(18, 20, 35, 0.14);
  background: white;
  box-shadow: none;
  color: var(--ink);
}

.confirm-dialog .button:not(.danger):hover,
.confirm-dialog .button:not(.danger):focus {
  outline: none;
  background: #f7f8fb;
  color: var(--ink);
}

.button.primary {
  border-color: transparent;
  background: var(--accent);
  color: white;
}

.button.primary:hover,
.button.primary:focus {
  outline: none;
  background: #1b1e33;
  color: white;
}

.button.danger {
  border-color: transparent;
  background: var(--red);
  color: white;
}

.button.danger:hover,
.button.danger:focus {
  outline: none;
  background: #971f16;
  color: white;
}

.modal-backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(181, 203, 232, 0.36);
  backdrop-filter: blur(14px) saturate(120%);
  white-space: normal;
}

.confirm-dialog {
  width: min(520px, calc(100vw - 48px));
  display: grid;
  gap: 20px;
  color: var(--ink);
  text-align: left;
}

.confirm-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
  padding: 28px 34px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(247, 249, 252, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 22px 64px rgba(65, 90, 130, 0.2);
}

.confirm-copy {
  display: grid;
  align-content: center;
  gap: 12px;
}

.confirm-copy strong {
  color: var(--red);
  font-size: 27px;
  line-height: 1.1;
}

.confirm-copy span {
  max-width: 420px;
  color: #41465b;
  font-size: 15px;
  line-height: 1.35;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.form-grid { display: grid; gap: 16px; }
.document-editor .recipient-panel,
.document-editor .options-panel,
.document-editor .tax-panel {
  align-content: start;
}
.form-grid.wide { max-width: 1080px; }
.form-section { display: grid; gap: 18px; }
.two-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

label {
  display: grid;
  gap: 7px;
  color: #1d2034;
  font-weight: 650;
}

.form-control,
.auth-card input {
  width: 100%;
  border: 1px solid rgba(16, 17, 38, 0.16);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  padding: 11px 12px;
  font: inherit;
}

select.form-control {
  appearance: none;
  min-height: 0;
  padding-right: 42px;
  background-image:
    linear-gradient(45deg, transparent 50%, #101126 50%),
    linear-gradient(135deg, #101126 50%, transparent 50%);
  background-position:
    calc(100% - 21px) calc(50% - 4px),
    calc(100% - 14px) calc(50% - 4px);
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
}

.numbering-row select.form-control {
  height: 42px;
}

.form-control:focus,
.auth-card input:focus {
  outline: 3px solid rgba(248, 204, 93, 0.62);
  border-color: rgba(16, 17, 38, 0.48);
  background: rgba(255, 255, 255, 0.76);
}

textarea.form-control { resize: vertical; }
.compact { padding: 9px 10px; }

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

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  margin-top: 25px;
}

.section-heading h2,
.glass-panel h2 {
  margin: 0 0 10px;
  font-size: 22px;
}

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

.line-items {
  display: grid;
  gap: 0px;
  overflow-x: auto;
  padding-bottom: 0px;
  padding-top: 5px;
}

.line-item {
  display: grid;
  grid-template-columns: 24px minmax(220px, 440px) 90px 140px 110px 130px minmax(90px, 110px) 52px;
  gap: 12px;
  align-items: end;
  min-width: 100%;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  position: relative;
}

.line-item + .line-item {
  margin-top: -8px;
}

.line-item.has-column-labels {
  padding-top: 12px;
}

.line-item.is-dragging {
  opacity: 0.68;
  box-shadow: 0 18px 50px rgba(31, 41, 55, 0.18);
}

.drag-handle {
  width: 24px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  align-self: end;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #7a8093;
  cursor: grab;
  padding: 0;
  touch-action: none;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle:hover,
.drag-handle:focus {
  outline: none;
  background: rgba(16, 17, 38, 0.06);
  color: var(--ink);
}

.drag-handle span,
.drag-handle span::before,
.drag-handle span::after {
  width: 4px;
  height: 4px;
  display: block;
  border-radius: 999px;
  background: currentColor;
}

.drag-handle span {
  position: relative;
}

.drag-handle span::before,
.drag-handle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.drag-handle span::before {
  top: -8px;
}

.drag-handle span::after {
  top: 8px;
}

.line-item-field-label {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.line-item.has-column-labels .line-item-field-label {
  position: static;
  inline-size: auto;
  block-size: auto;
  overflow: visible;
  clip: auto;
  color: #1d2034;
  font-weight: 650;
  white-space: normal;
}

.line-item textarea.form-control {
  min-height: 128px;
}

.product-field { position: relative; }
.product-field .product-search-input {
  padding-left: 42px;
  background: rgba(255, 255, 255, 0.76);
  max-width: 440px;
}
.product-field::before {
  content: "";
  position: absolute;
  left: 13px;
  bottom: 13px;
  width: 15px;
  height: 15px;
  border: 2px solid #7a8093;
  border-radius: 999px;
  pointer-events: none;
}
.product-field::after {
  content: "";
  position: absolute;
  left: 28px;
  bottom: 11px;
  width: 8px;
  height: 2px;
  background: #7a8093;
  transform: rotate(45deg);
  transform-origin: left center;
  pointer-events: none;
}

.product-suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: grid;
  gap: 2px;
  max-height: 238px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(16, 17, 38, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(24px) saturate(145%);
  box-shadow: 0 16px 40px rgba(31, 41, 55, 0.16);
}

.product-suggestions[hidden] { display: none; }

.product-suggestions button {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 720;
  text-align: left;
  cursor: pointer;
}

.product-suggestions button:hover {
  background: rgba(79, 70, 229, 0.1);
}

.product-suggestions span {
  color: var(--muted);
  font-weight: 650;
}

.description-popover {
  display: none;
  grid-column: 2 / -1;
  padding-top: 2px;
}

.line-item.is-editing-description .description-popover {
  display: block;
}

.line-add { margin-top: 14px; }

.amount-cell {
  display: grid;
  gap: 7px;
  min-height: 46px;
  align-content: end;
}

.amount-cell span {
  color: #1d2034;
  font-weight: 650;
}

.amount-cell strong {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.44);
  white-space: nowrap;
}

.price-mode-pill {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(16, 17, 38, 0.06);
  margin-left: auto;
  width: max-content;
}

.price-mode-pill span {
  padding: 8px 16px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
}

.price-mode-pill .active {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(31, 41, 55, 0.12);
}

.line-item input[type="checkbox"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.settings-form {
  margin-bottom: 20px;
}

.settings-footer-grid {
  margin-bottom: 24px;
}

.template-default-form {
  margin-bottom: 20px;
}

.default-template-choice {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  cursor: pointer;
}

.default-template-choice input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.template-actions {
  margin-top: 18px;
}

.numbering-grid {
  display: grid;
  gap: 14px;
  margin: 18px 0 24px;
}

.numbering-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

.numbering-row strong {
  padding-bottom: 12px;
  font-size: 17px;
}

.numbering-row.contact-numbering-row {
  grid-template-columns: minmax(150px, 0.7fr) minmax(0, 1fr);
  column-gap: 10;
  max-width: 500px;
}

.toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px 18px;
  align-items: center;
  margin-bottom: 17px;
}

.toggle-row h2 {
  grid-column: 1;
  margin: 0;
}

.toggle-row .muted {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
}

.toggle-row label {
  display: flex;
  align-items: center;
  grid-column: 2;
  grid-row: 2;
  gap: 12px;
}

.toggle-row .button {
  grid-column: 3;
  grid-row: 2;
}

.toggle-input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

.icon-button {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font: inherit;
  font-size: 23px;
  cursor: pointer;
}

.delete-line:hover {
  color: var(--red);
  background: rgba(180, 35, 24, 0.08);
}

.line-item.is-deleted {
  display: none;
}

.totals-panel {
  margin-left: auto;
  max-width: 380px;
  padding: 18px;
  display: grid;
  gap: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
}

.totals-panel div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.totals-panel .grand {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 18px;
}

.status {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.paid { color: var(--green); background: rgba(4, 120, 87, 0.12); }
.status.not_paid { color: var(--red); background: rgba(180, 35, 24, 0.12); }

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

.stat {
  display: grid;
  gap: 10px;
}

.stat span { color: var(--muted); }
.stat strong { font-size: 34px; }

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

.auth-card {
  width: min(420px, 100%);
  padding: 30px;
}

.auth-card h1 {
  text-align: center;
  margin: 26px 0;
}

.messages { margin-bottom: 16px; }
.message { padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.8); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .content { padding: 22px; }
  .editor-grid, .two-cols, .stats-grid { grid-template-columns: 1fr; }
  .line-item { grid-template-columns: 1fr; }
  .drag-handle { justify-self: start; }
  .amount-cell { gap: 7px; align-content: end; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .toggle-row { grid-template-columns: 1fr; }
  .toggle-row h2,
  .toggle-row .muted,
  .toggle-row label,
  .toggle-row .button {
    grid-column: 1;
    grid-row: auto;
  }
}

@media (max-width: 700px) {
  .search-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-bar .button {
    width: 100%;
  }

  .confirm-dialog {
    width: min(420px, calc(100vw - 36px));
    gap: 16px;
  }

  .confirm-card {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 24px 20px;
    text-align: center;
  }

  .confirm-copy strong { font-size: 24px; }
  .confirm-copy span { font-size: 14px; }

  .confirm-actions {
    width: 100%;
    gap: 14px;
  }

  .confirm-dialog .button {
    min-width: 0;
    width: 100%;
    min-height: 46px;
    font-size: 16px;
  }

  .confirm-actions > .button,
  .confirm-actions form {
    flex: 1;
  }
}
