:root {
  font-family:Inter,"Segoe UI",Arial,sans-serif;
  color:#182730;
  background:#f3f5f6;
  font-synthesis:none;
  font-size:13px;
  --line:#e1e6e9;
  --teal:#155e57;
  --muted:#687b87;
}

* {
  box-sizing:border-box;
}

body {
  margin:0;
}

button,input,select {
  font:inherit;
}

button {
  cursor:pointer;
}

button:disabled {
  cursor:default;
  opacity:.4;
}

button {
  background:#fff;
  color:#253b47;
  border:1px solid #d7dfe3;
  border-radius:6px;
  padding:9px 13px;
  font-weight:550;
  white-space:nowrap;
}

button:hover:enabled {
  background:#f1f5f5;
  border-color:#9badb5;
}

.primary {
  background:var(--teal);
  color:#fff;
  border-color:var(--teal);
}

.primary:hover:enabled {
  background:#104c46;
  border-color:#104c46;
}

button:focus-visible,input:focus-visible,select:focus-visible,.table-scroll:focus-visible {
  outline:2px solid #278f80;
  outline-offset:2px;
}

.icon-button {
  border:0;
  font-size:23px;
  background:transparent;
  padding:3px 9px;
  color:#5b727e;
  line-height:1.2;
}

.app-header {
  height:82px;
  background:#fff;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 30px;
}

.brand {
  display:flex;
  align-items:center;
  gap:12px;
}

.brand-mark {
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  border-radius:10px;
  background:#174c47;
  color:#fff;
  font-size:24px;
  font-weight:650;
}

h1 {
  font-size:22px;
  letter-spacing:-.65px;
  line-height:1.15;
  margin:0 0 5px;
  font-weight:650;
}

h1 span {
  font-weight:400;
  color:#75868c;
}

.brand p {
  margin:0;
  color:var(--muted);
  font-size:11px;
}

.brand p span {
  margin:0 5px;
}

.connection {
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  color:#566c77;
}

.connection-dot {
  width:7px;
  height:7px;
  border-radius:50%;
  background:#a9b7bf;
}

.connection-dot.online {
  background:#30966f;
}

.connection-dot.error {
  background:#cb574d;
}

main {
  padding:18px 30px 36px;
  max-width:2200px;
  margin:auto;
}

.test-notice {
  border-left:3px solid #5e8c83;
  background:#e9f1ed;
  padding:9px 12px;
  font-size:12px;
  color:#365e55;
  margin-bottom:18px;
  border-radius:0 4px 4px 0;
}

.summary {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
  margin-bottom:24px;
}

.summary-card {
  background:#fff;
  border:1px solid var(--line);
  border-radius:9px;
  padding:17px 20px;
  display:flex;
  flex-direction:column;
  min-width:0;
  text-align:left;
}

.summary-label {
  font-size:12px;
  color:#5b707c;
  display:flex;
  justify-content:space-between;
  margin-bottom:11px;
}

.summary-label span {
  font-size:15px;
  color:#85969d;
}

.summary-card strong {
  font-size:25px;
  letter-spacing:-.8px;
  font-weight:620;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

.summary-caption {
  font-size:11px;
  color:#8a989f;
  margin-top:7px;
  font-weight:400;
}

.summary-button:hover:enabled {
  background:#fbfdfc;
  border-color:#a2c2b8;
}

.cash-section {
  background:#fff;
  border:1px solid var(--line);
  border-radius:10px;
  overflow:hidden;
}

.table-toolbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:17px 18px;
}

.table-title {
  display:flex;
  align-items:center;
  gap:9px;
}

h2 {
  font-size:15px;
  font-weight:620;
  letter-spacing:-.25px;
  margin:0;
}

.table-title>span {
  background:#edf1f2;
  border-radius:5px;
  font-size:11px;
  min-width:25px;
  padding:3px 6px;
  text-align:center;
  color:#637985;
}

.table-actions {
  display:flex;
  gap:7px;
  align-items:center;
}

.table-actions button {
  font-size:12px;
  padding:8px 11px;
}

.toolbar-divider {
  width:1px;
  height:21px;
  background:var(--line);
  margin:0 3px;
}

.table-scroll {
  max-height:580px;
  overflow:auto;
  position:relative;
  scrollbar-color:#bccacf #f4f7f8;
  scrollbar-width:thin;
  border-top:1px solid var(--line);
}

#cash-table {
  border-collapse:separate;
  border-spacing:0;
  table-layout:fixed;
  width:2457px;
  font-size:12px;
}

th {
  text-align:left;
  font-weight:550;
  color:#536d7b;
  background:#f5f7f8;
}

#cash-table th {
  height:57px;
  padding:9px 9px 8px;
  border-bottom:1px solid #d4dfe3;
  border-right:1px solid var(--line);
  position:sticky;
  top:0;
  z-index:4;
  font-size:10px;
  vertical-align:top;
  white-space:nowrap;
}

.column-letter {
  display:block;
  margin-bottom:6px;
  color:#8a9aa2;
  font-size:10px;
  font-weight:500;
}

.row-index {
  width:43px;
  text-align:center!important;
  color:#93a2aa;
  font-size:10px!important;
  position:sticky;
  left:0;
  z-index:3;
  background:#f8fafb;
}

.row-index span {
  display:block;
  padding-top:13px;
}

#cash-table th.row-index {
  z-index:7;
}

#cash-table th:nth-child(2) {
  position:sticky;
  left:43px;
  z-index:6;
}

#cash-table td:nth-child(2) {
  position:sticky;
  left:43px;
  background:#fff;
  z-index:2;
  border-right-color:#cad7dc;
  box-shadow:2px 0 3px #163c4910;
}

#cash-table td {
  height:43px;
  padding:0;
  border-right:1px solid var(--line);
  border-bottom:1px solid #e7ecee;
  vertical-align:middle;
  position:relative;
}

#cash-table tr.selected td {
  background:#f5fbf8;
}

#cash-table tr.selected td:first-child {
  background:#e4f0e9;
  color:#195d4b;
  font-weight:650;
}

#cash-table tr.selected td:nth-child(2) {
  background:#eff7f2;
}

.cell-input {
  width:100%;
  height:42px;
  border:0;
  background:transparent;
  border-radius:0;
  padding:8px 8px;
  color:#20343e;
  font-size:12px;
  min-width:0;
  outline:0!important;
}

.cell-input:focus {
  background:#fff;
  box-shadow:inset 0 0 0 2px #318b79;
}

.cell-input[disabled] {
  opacity:1;
  color:#8b9ba2;
  background:#f7f9fa;
  cursor:not-allowed;
}

.cell-input.money {
  text-align:right;
  font-variant-numeric:tabular-nums;
}

.cell-input.product {
  font-weight:550;
}

.cell-input.serial {
  font-size:11px;
  letter-spacing:.1px;
}

.cell-input.extra {
  padding:8px 4px;
}

select.cell-input {
  cursor:pointer;
  font-size:11px;
  appearance:auto;
  padding-right:2px;
}

.cell-output {
  padding:9px 8px;
  display:block;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
  font-size:11px;
}

.cell-output.money {
  text-align:right;
}

.cell-date {
  color:#607783;
}

.cell-profit.negative {
  color:#b84a3b;
}

.send-header {
  color:#1c6254!important;
  background:#e8f2ed!important;
  text-align:center!important;
}

.send-cell {
  text-align:center;
  background:#f5faf7!important;
}

.send-checkbox {
  accent-color:var(--teal);
  width:17px;
  height:17px;
  cursor:pointer;
  vertical-align:middle;
  margin:0;
}

.send-checkbox:disabled {
  cursor:default;
  opacity:.45;
}

.delivery {
  display:block;
  font-size:10px;
  font-weight:500;
  line-height:1.35;
  padding:5px 8px;
  color:#8b9aa2;
}

.delivery.delivered {
  color:#2d7d56;
}

.delivery.queued {
  color:#997128;
}

.message-button {
  display:block;
  width:100%;
  height:42px;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
  text-align:left;
  border:0;
  border-radius:0;
  background:transparent;
  color:#5b7582;
  padding:9px;
  font-size:11px;
  font-weight:400;
}

.message-button:hover:enabled {
  background:#edf5f2;
}

.row-unpaid td:nth-child(9),.row-unpaid td:nth-child(10) {
  background:#fff3f0!important;
}

.row-cash td:nth-child(9),.row-cash td:nth-child(10) {
  background:#edf8ef!important;
}

.row-return td:nth-child(11) {
  background:#eff4fe!important;
}

.row-expense td:nth-child(6) {
  background:#fff6e9!important;
}

.cell-error {
  box-shadow:inset 0 -2px #ce5e51;
}

.cell-saving:after {
  content:"";
  position:absolute;
  right:3px;
  top:3px;
  width:4px;
  height:4px;
  background:#48a089;
  border-radius:50%;
}

.table-footer {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:12px 18px;
  font-size:11px;
  color:#81939c;
  border-top:1px solid var(--line);
}

#save-status.error {
  color:#b44c41;
}

#save-status.saving {
  color:#4e796e;
}

.empty-state {
  padding:42px 25px;
  text-align:left;
  max-width:450px;
}

.empty-state h3 {
  font-size:16px;
  margin:0 0 7px;
  font-weight:600;
}

.empty-state p {
  color:var(--muted);
  line-height:1.6;
  margin-bottom:17px;
}

.col-index {
  width:43px;
}

.col-product {
  width:246px;
}

.col-extra {
  width:37px;
}

.col-serial {
  width:194px;
}

.col-money {
  width:132px;
}

.col-party {
  width:129px;
}

.col-date {
  width:125px;
}

.col-status {
  width:211px;
}

.col-send {
  width:90px;
}

.col-delivery {
  width:163px;
}

.col-message {
  width:400px;
}

.journal-section {
  margin-top:25px;
}

.journal-heading {
  display:flex;
  gap:9px;
  align-items:center;
  margin-bottom:12px;
}

.journal-heading h2 {
  color:#526b77;
  font-size:12px;
}

.journal-heading>span {
  font-size:11px;
  color:#8a9ba3;
}

.journal-items {
  display:flex;
  gap:12px;
  overflow-x:auto;
  padding-bottom:7px;
}

.journal-card {
  flex:0 0 310px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:8px;
  padding:14px 16px;
}

.journal-card-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size:10px;
  color:#8b9ba3;
  margin-bottom:9px;
}

.journal-card-header span:first-child {
  color:#39805f;
}

.journal-card pre {
  font:12px/1.6 Inter,"Segoe UI",sans-serif;
  margin:0;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}

.journal-card button {
  border:0;
  padding:0;
  font-size:11px;
  color:var(--teal);
  font-weight:500;
  margin-top:11px;
}

.journal-card .journal-debt {
  margin-top:10px;
  padding-top:9px;
  border-top:1px solid #eef2f3;
  font-size:12px;
  color:#36594e;
}

dialog {
  padding:0;
  border:1px solid #d6e0e3;
  border-radius:12px;
  box-shadow:0 25px 100px #16334435;
  width:min(920px,calc(100vw - 40px));
  max-height:88vh;
  color:#20333e;
}

dialog::backdrop {
  background:#132d3b65;
  backdrop-filter:blur(2px);
}

.dialog-header {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:16px;
  padding:22px 24px;
  border-bottom:1px solid var(--line);
}

.dialog-header h2 {
  font-size:18px;
  margin-top:3px;
}

.dialog-header p {
  font-size:12px;
  color:var(--muted);
  margin:9px 0 0;
  line-height:1.5;
}

.counterparties-scroll {
  max-height:310px;
  overflow:auto;
  padding:0 24px;
}

.parties-table {
  width:100%;
  border-collapse:collapse;
  font-size:12px;
}

.parties-table th {
  font-size:10px;
  padding:12px 8px;
  line-height:1.4;
}

.parties-table td {
  padding:12px 8px;
  border-bottom:1px solid var(--line);
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

.parties-table td:not(:first-child) {
  text-align:right;
}

.party-edit {
  border:0;
  padding:0;
  color:var(--teal);
  font-size:12px;
  background:transparent;
}

.counterparties-scroll>p {
  font-size:12px;
  color:var(--muted);
  line-height:1.6;
  padding:18px 0;
}

#party-form {
  padding:20px 24px;
  background:#f8fafb;
}

#party-form h3 {
  margin:0 0 15px;
  font-size:12px;
  font-weight:600;
}

.party-form-fields {
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:15px;
}

.party-form-fields label {
  font-size:11px;
  color:#617681;
}

.party-form-fields input {
  display:block;
  width:100%;
  margin-top:7px;
  border:1px solid #d6e0e5;
  border-radius:5px;
  background:#fff;
  padding:10px;
  color:#20343e;
}

.dialog-footer {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:15px;
  margin-top:18px;
}

.dialog-footer>span {
  font-size:11px;
  color:#b44c41;
  line-height:1.5;
}

#message-dialog {
  width:min(570px,calc(100vw - 40px));
}

#message-text {
  font:14px/1.75 Inter,"Segoe UI",sans-serif;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  margin:0;
  padding:24px;
}

#toast {
  position:fixed;
  z-index:30;
  bottom:24px;
  left:50%;
  transform:translateX(-50%);
  max-width:calc(100vw - 32px);
  width:max-content;
  display:flex;
  gap:20px;
  align-items:center;
  padding:13px 16px;
  color:#fff;
  background:#8f3934;
  border-radius:8px;
  box-shadow:0 5px 24px #17334025;
  font-size:12px;
  line-height:1.5;
}

#toast[hidden],.empty-state[hidden],.journal-section[hidden] {
  display:none;
}

#close-toast {
  background:transparent;
  color:#fff;
  border:0;
  padding:0 4px;
  font-size:20px;
}

@media(min-width:1700px) {
  .table-scroll {
    max-height:calc(100vh - 380px);
  }
}

@media(max-width:850px) {
  .app-header {
    padding:0 16px;
    height:76px;
  }
  main {
    padding:15px 14px 25px;
  }
  .summary {
    gap:9px;
    grid-template-columns:repeat(2,minmax(0,1fr));
    margin-bottom:18px;
  }
  .summary-card {
    padding:15px;
  }
  .summary-card strong {
    font-size:23px;
  }
  .table-toolbar {
    align-items:flex-start;
    padding:14px;
    gap:12px;
    flex-wrap:wrap;
  }
  .table-actions {
    flex-wrap:wrap;
    gap:6px;
  }
  .table-actions button {
    padding:8px;
  }
  .table-title {
    min-height:30px;
  }
  .test-notice {
    font-size:11px;
    line-height:1.6;
  }
  .table-scroll {
    max-height:65vh;
  }
  .party-form-fields {
    grid-template-columns:1fr;
  }
  .connection {
    font-size:10px;
    gap:6px;
  }
  .brand p {
    font-size:10px;
  }
  .brand-mark {
    width:32px;
    height:32px;
    font-size:21px;
  }
  h1 {
    font-size:20px;
  }
  .dialog-header {
    padding:19px;
  }
  .dialog-header h2 {
    font-size:16px;
  }
  .counterparties-scroll {
    padding:0 16px;
  }
  #party-form {
    padding:18px;
  }
  .dialog-footer {
    align-items:flex-start;
  }
  .table-footer {
    padding:11px 14px;
    font-size:10px;
  }
  .toolbar-divider {
    display:none;
  }
}

.auth-pending .app-header,.auth-pending main,.logged-out .app-header,.logged-out main {
  display:none;
}

.login-screen {
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
  background:#edf2f0;
}

.login-screen[hidden] {
  display:none;
}

.login-card {
  width:min(380px,100%);
  background:#fff;
  padding:34px;
  border:1px solid #dbe5e0;
  border-radius:12px;
  box-shadow:0 14px 55px #2443360c;
}

.login-card .brand-mark {
  margin-bottom:22px;
}

.login-card>p {
  font-size:12px;
  color:var(--muted);
  line-height:1.6;
  margin-bottom:25px;
}

.login-card label {
  display:block;
  font-size:12px;
  color:#546d79;
  margin-top:16px;
}

.login-card label input {
  display:block;
  width:100%;
  border:1px solid #d3dfe3;
  border-radius:5px;
  padding:11px;
  margin-top:7px;
  color:#203e49;
  background:#fff;
}

.login-card>.primary {
  width:100%;
  padding:11px;
  margin-top:10px;
}

.login-card #login-error {
  color:#b84a3b;
  margin:12px 0 0;
  font-size:12px;
  min-height:16px;
}

.logout {
  font-size:11px;
  padding:5px 8px;
  border:0;
  background:transparent;
  color:#667c86;
}

.queue-tools {
  display:flex;
  gap:12px;
  align-items:center;
}

.queue-tools button {
  font-size:10px;
  padding:3px 6px;
  border:0;
  background:transparent;
  color:var(--teal);
}

.queue-tools button[hidden] {
  display:none;
}

