:root {
  color-scheme: light;
  --bg: #f8f4e8;
  --panel: #fffdf6;
  --ink: #2c2622;
  --muted: #5c5646;
  --line: #d8d2bc;
  --line-strong: #c8c1a8;
  --accent: #1da1c9;
  --accent-dark: #1588a8;
  --accent-light: #e0f4fb;
  --green-dark: #1a3a1f;
  --green-mid: #2d5c35;
  --green-light: #4a8a54;
  --green-pale: #d8ecda;
  --gold: #a27c1a;
  --gold-light: #c49a2a;
  --gold-pale: #f0e6c8;
  --ivory: #f8f4e8;
  --ivory-dark: #ede8d5;
  --good: #2d5c35;
  --warn: #a27c1a;
  --soft: #fbf8ef;
}

/* Sales Contract approval status and revision history. */
.sales-order-approval-panel {
  margin: 10px 12px;
  padding: 12px 14px;
  border: 1px solid #c9c4b2;
  border-left: 4px solid #2ba4be;
  border-radius: 8px;
  background: #fbfaf2;
  color: var(--green-dark);
}

.sales-order-approval-panel.is-draft {
  border-left-color: #9a957f;
}

.sales-order-approval-current,
.sales-order-approval-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sales-order-approval-current > div {
  display: grid;
  gap: 2px;
}

.sales-order-approval-panel small {
  color: #63706b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .07em;
}

.sales-order-approval-panel p {
  margin: 6px 0 0;
  color: #5d6159;
  font-size: 12px;
}

.sales-order-approval-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-top: 10px;
  padding: 8px 11px;
  border: 1px solid #8ea8b5;
  border-radius: 7px;
  background: #eef6f8;
  color: #214d60;
  text-decoration: none;
}

.sales-order-approval-link > span {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.sales-order-approval-link strong {
  font-size: 12px;
  line-height: 1.25;
}

.sales-order-approval-link small {
  overflow-wrap: anywhere;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: none;
}

.sales-order-approval-link b {
  flex: 0 0 auto;
  font-size: 17px;
}

.sales-order-approval-link:hover,
.sales-order-approval-link:focus-visible {
  border-color: var(--accent-dark);
  background: #e2f1f5;
  outline: 2px solid transparent;
}

.sales-order-approval-link.is-compact {
  min-height: 40px;
  margin-top: 8px;
  padding: 6px 9px;
  background: #f6faf9;
}

.approval-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid #aeb5b1;
  border-radius: 999px;
  background: #eef0ed;
  color: #48534f;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .05em;
  white-space: nowrap;
}

.approval-state-pending { border-color: #c59a3b; background: #fff4d8; color: #795a13; }
.approval-state-approved { border-color: #6e91a6; background: #e5f0f6; color: #355d72; }
.approval-state-rejected { border-color: #bd7777; background: #fae8e8; color: #8d3333; }
.approval-state-invalidated { border-color: #b3aa99; background: #eeeae1; color: #685f50; }

.sales-order-approval-history {
  margin-top: 10px;
  border-top: 1px solid #ddd8c7;
  padding-top: 8px;
}

.sales-order-approval-history > summary {
  min-height: 34px;
  cursor: pointer;
  font-weight: 800;
}

.sales-order-approval-history-row {
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid #ddd8c7;
  border-radius: 6px;
  background: #fff;
}

.sales-order-approval-history-row details {
  margin-top: 7px;
}

.sales-order-approval-history-row summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.sales-order-approval-history-row ul {
  display: grid;
  gap: 5px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.sales-order-approval-history-row li {
  display: grid;
  grid-template-columns: minmax(95px, .45fr) minmax(0, 1fr);
  gap: 8px;
  padding-top: 5px;
  border-top: 1px solid #eeeadd;
  font-size: 11px;
}

.sales-order-approval-history-row li span {
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .sales-order-approval-panel {
    margin: 8px 10px;
    padding: 11px 12px;
  }

  .sales-order-approval-current {
    align-items: flex-start;
  }

  .sales-order-approval-history > summary {
    display: flex;
    align-items: center;
    min-height: 44px;
  }

  .sales-order-approval-history-row li {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .sales-order-approval-link,
  .sales-order-approval-link.is-compact {
    min-height: 44px;
  }
}

/* Commission tracking: scoped phone layout with enough selector weight to
   prevent shared table sizing from forcing cards into fixed-height rows. */
@media (max-width:700px) {
  .content-grid.commission-tracking-mode,
  .content-grid.commission-tracking-mode.awaiting-detail-selection {
    display:block;
    width:100%;
    min-width:0;
    overflow:visible;
  }
  .content-grid.commission-tracking-mode .list-panel {
    width:100%;
    height:auto;
    min-height:0;
    max-height:none;
    overflow:visible;
  }
  .content-grid.commission-tracking-mode .table-wrap {
    width:100%;
    max-height:none;
    overflow:visible;
  }
  .content-grid.commission-tracking-mode table,
  .content-grid.commission-tracking-mode tbody {
    display:block;
    width:100%;
    min-width:0;
  }
  .content-grid.commission-tracking-mode tbody tr,
  .content-grid.commission-tracking-mode tbody td {
    box-sizing:border-box;
    width:auto;
    min-width:0;
    max-width:none;
    height:auto;
    max-height:none;
    white-space:normal;
    overflow:visible;
  }
  .content-grid.commission-tracking-mode .commission-export-toolbar-row {
    display:block;
    margin:8px;
    padding:0;
    border:1px solid #d4ceba;
    border-radius:11px;
    background:#fffdf7;
    box-shadow:0 2px 7px rgba(31,54,37,.07);
  }
  .content-grid.commission-tracking-mode .commission-export-toolbar-row>td {
    display:block;
    width:100%;
    padding:0!important;
  }
  .content-grid.commission-tracking-mode .commission-export-toolbar {
    display:grid;
    grid-template-columns:1fr;
    gap:10px;
    padding:11px;
  }
  .content-grid.commission-tracking-mode .commission-export-toolbar>div:first-child {
    display:grid;
    gap:3px;
    padding-bottom:8px;
    border-bottom:1px solid #ded9c5;
  }
  .content-grid.commission-tracking-mode .commission-export-toolbar>div:first-child strong { font-size:15px; }
  .content-grid.commission-tracking-mode .commission-export-toolbar>div:first-child span { font-size:12px; line-height:1.35; }
  .content-grid.commission-tracking-mode .commission-export-actions {
    display:grid;
    grid-template-columns:minmax(0,.72fr) minmax(0,1.28fr);
    gap:8px;
    width:100%;
  }
  .content-grid.commission-tracking-mode .commission-export-actions label {
    grid-column:1/-1;
    display:grid;
    gap:5px;
  }
  .content-grid.commission-tracking-mode .commission-export-actions input {
    box-sizing:border-box;
    width:100%;
    min-height:46px;
    font-size:16px;
  }
  .content-grid.commission-tracking-mode .commission-export-actions button {
    box-sizing:border-box;
    width:100%;
    min-width:0;
    min-height:46px;
    white-space:normal;
  }
  .content-grid.commission-tracking-mode .commission-invoice-group {
    display:block;
    margin:12px 8px 0!important;
    padding:0;
    border:1px solid #9fb9aa!important;
    border-top:4px solid #269ab6!important;
    border-radius:12px 12px 0 0!important;
    background:#eef4e9;
    box-shadow:0 2px 7px rgba(31,54,37,.08);
    overflow:hidden;
  }
  .content-grid.commission-tracking-mode .commission-invoice-group>td {
    display:block;
    width:100%;
    padding:0!important;
    background:transparent;
    border:0!important;
  }
  .content-grid.commission-tracking-mode .commission-invoice-group td>div {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:9px;
    min-height:0;
    padding:11px;
  }
  .content-grid.commission-tracking-mode .commission-invoice-identity {
    display:grid;
    grid-template-columns:26px minmax(0,1fr);
    align-items:start;
    gap:9px;
    min-height:44px;
  }
  .content-grid.commission-tracking-mode .commission-invoice-identity input {
    width:24px;
    height:24px;
    margin:1px 0 0;
  }
  .content-grid.commission-tracking-mode .commission-invoice-identity b { font-size:16px; line-height:1.2; }
  .content-grid.commission-tracking-mode .commission-invoice-identity small { margin-top:3px; font-size:11px; line-height:1.35; }
  .content-grid.commission-tracking-mode .commission-invoice-totals {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:3px;
    padding:9px 10px;
    border:1px solid #d8ddcd;
    border-radius:8px;
    background:#fffdf7;
  }
  .content-grid.commission-tracking-mode .commission-invoice-totals strong { font-size:15px; }
  .content-grid.commission-tracking-mode .commission-invoice-totals span { font-size:11px; line-height:1.35; }
  .content-grid.commission-tracking-mode .commission-invoice-group button {
    box-sizing:border-box;
    width:100%;
    min-width:0;
    min-height:46px;
    font-size:13px;
  }
  .content-grid.commission-tracking-mode .commission-item-line {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:0 10px;
    margin:0 8px!important;
    padding:9px 11px!important;
    border:1px solid #d4ceba!important;
    border-top:0!important;
    border-radius:0!important;
    background:#fffdf7;
    box-shadow:none;
  }
  .content-grid.commission-tracking-mode .commission-item-line:last-child {
    margin-bottom:12px!important;
    border-radius:0 0 12px 12px!important;
    box-shadow:0 3px 7px rgba(31,54,37,.07);
  }
  .content-grid.commission-tracking-mode .commission-item-line>td {
    display:block!important;
    width:auto!important;
    min-width:0!important;
    max-width:none!important;
    height:auto!important;
    padding:7px 2px!important;
    border:0!important;
    line-height:1.3;
    overflow-wrap:anywhere;
  }
  .content-grid.commission-tracking-mode .commission-item-line>td::before {
    display:block;
    margin-bottom:4px;
    color:#6a685f;
    font-size:9px;
    font-weight:800;
    letter-spacing:.05em;
    text-transform:uppercase;
  }
  .content-grid.commission-tracking-mode .commission-item-line>td:first-child {
    grid-column:1/-1;
    display:flex!important;
    align-items:center;
    justify-content:space-between;
    min-height:38px!important;
    padding:2px 2px 7px!important;
    border-bottom:1px solid #e2dece!important;
  }
  .content-grid.commission-tracking-mode .commission-item-line>td:first-child::before {
    margin:0;
    content:"Select item";
  }
  .content-grid.commission-tracking-mode .commission-item-line>td:first-child input { width:24px; height:24px; margin:0; }
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(2),
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(3) { grid-column:1/-1; }
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(2) b { font-size:15px; color:#173d27; }
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(2) span,
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(3) span { font-size:11px; line-height:1.35; }
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(4),
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(5),
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(6),
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(7),
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(8) {
    grid-column:auto;
    padding:8px 7px!important;
    border-left:2px solid #d9e4da!important;
    font-variant-numeric:tabular-nums;
  }
  .content-grid.commission-tracking-mode .commission-item-line>td:nth-child(7) b { color:#173d27; font-size:14px; }
  .content-grid.commission-tracking-mode .commission-status,
  .content-grid.commission-tracking-mode .commission-registered { max-width:100%; }
}

/* Commission sub-ledger: traceable invoice-line earnings and settlements. */
.commission-tracking-summary-strip .metric strong { font-variant-numeric:tabular-nums; }
.commission-status { display:inline-flex; align-items:center; min-height:20px; padding:2px 7px; border-radius:999px; border:1px solid #c9c5b5; background:#efeee7; color:#514f46; font-size:11px; font-weight:800; white-space:nowrap; }
.commission-status.paid { border-color:#9db6a6; background:#e2eee5; color:#205a39; }
.commission-status.part-paid { border-color:#d6bf82; background:#fff3ce; color:#765817; }
.commission-status.unpaid { border-color:#d6a7a7; background:#f9e6e4; color:#8c2929; }
.commission-status.overpaid { border-color:#b99ac8; background:#f0e5f5; color:#633178; }
.commission-money { display:block; text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
.commission-detail-card,.commission-edit-card,.commission-payment-card { margin:0 0 12px; padding:12px; border:1px solid #d2cdb9; border-radius:10px; background:#fffdf7; box-shadow:0 1px 4px rgba(42,52,38,.06); }
.commission-detail-card>header { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; margin-bottom:10px; }
.commission-detail-card>header div { min-width:0; }
.commission-detail-card>header small,.commission-detail-card>header strong { display:block; }
.commission-detail-card>header strong { margin-top:2px; overflow-wrap:anywhere; color:#16462d; }
.commission-facts { display:grid; grid-template-columns:1fr 1fr; gap:0; margin:0; border-top:1px solid #e0dccb; }
.commission-facts>div { padding:8px 6px; border-bottom:1px solid #e7e3d4; }
.commission-facts dt { color:#6a685f; font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.04em; }
.commission-facts dd { margin:3px 0 0; overflow-wrap:anywhere; }
.commission-edit-card h2,.commission-payment-card h2 { margin:0 0 5px; font-size:16px; color:#16462d; }
.commission-edit-card p { margin:0 0 9px; color:#666459; font-size:12px; }
.commission-edit-card label,.commission-payment-form label { display:grid; gap:4px; margin:8px 0; font-size:11px; font-weight:800; color:#5c5a50; }
.commission-edit-card input,.commission-edit-card textarea,.commission-payment-form input { box-sizing:border-box; width:100%; min-height:38px; padding:8px 9px; border:1px solid #c9c4af; border-radius:6px; background:#fff; color:#262820; font:inherit; font-size:13px; }
.commission-edit-card button,.commission-payment-card button { min-height:38px; padding:7px 12px; }
.commission-payment-list { display:grid; gap:6px; margin:8px 0 12px; }
.commission-payment-list article { display:grid; gap:2px; padding:8px 9px; border-left:3px solid #2a9eb8; background:#f3f7f1; }
.commission-payment-list article span,.commission-payment-list article small { font-size:11px; color:#666459; }
.commission-payment-form { display:grid; grid-template-columns:1fr 1fr; gap:0 8px; }
.commission-payment-form .wide { grid-column:1/-1; }
.commission-control-note { display:block; margin-top:7px; color:#6a685f; line-height:1.35; }
.commission-export-toolbar-row td { padding:8px 10px!important; background:#f5f0df; }
.commission-export-toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.commission-export-toolbar>div { display:flex; align-items:center; gap:9px; min-width:0; }
.commission-export-toolbar>div:first-child { display:grid; gap:2px; }
.commission-export-toolbar span { color:#686459; font-size:11px; }
.commission-export-toolbar button { min-height:38px; padding:7px 12px; }
.commission-export-actions label { display:flex; align-items:center; gap:5px; color:#5e5b51; font-size:10px; font-weight:800; text-transform:uppercase; }
.commission-export-actions input { box-sizing:border-box; width:180px; min-height:38px; padding:7px 9px; border:1px solid #c9c4af; border-radius:6px; background:#fff; color:#262820; font-size:13px; text-transform:none; }
.commission-destination-overlay { position:fixed; inset:0; z-index:1200; display:grid; place-items:center; padding:18px; background:rgba(21,42,30,.42); }
.commission-destination-dialog { box-sizing:border-box; width:min(520px,100%); padding:18px; border:1px solid #cfc8af; border-top:4px solid #25a3bd; border-radius:12px; background:#fffdf5; box-shadow:0 18px 48px rgba(22,42,30,.28); color:#183f2b; }
.commission-destination-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.commission-destination-head small { color:#259db5; font-size:10px; font-weight:800; letter-spacing:.08em; }
.commission-destination-head h3 { margin:3px 0 0; font-family:Georgia,serif; font-size:22px; line-height:1.1; }
.commission-destination-head>button { width:40px; min-width:40px; height:40px; padding:0; border-radius:50%; font-size:22px; }
.commission-destination-summary { display:flex; justify-content:space-between; gap:12px; margin:14px 0 8px; padding:10px 12px; border:1px solid #d7dfd3; border-radius:8px; background:#edf6ed; }
.commission-destination-dialog>p { margin:0 0 12px; color:#656157; font-size:12px; line-height:1.4; }
.commission-destination-options { display:grid; gap:8px; }
.commission-destination-options>button { display:grid; gap:3px; width:100%; min-height:58px; padding:10px 13px; text-align:left; border-radius:8px; }
.commission-destination-options b { color:#173f2a; font-size:14px; }
.commission-destination-options span { color:#686459; font-size:11px; font-weight:500; }
.commission-invoice-group td { padding:0!important; background:#e8eee4; border-top:2px solid #278aa5!important; }
.commission-invoice-group td>div { display:grid; grid-template-columns:minmax(260px,1.3fr) minmax(230px,1fr) auto; align-items:center; gap:12px; min-height:54px; padding:7px 10px; }
.commission-invoice-group label { display:flex; align-items:center; gap:9px; min-width:0; cursor:pointer; }
.commission-invoice-group label span { display:grid; gap:1px; min-width:0; }
.commission-invoice-group label small { color:#686459; font-weight:500; overflow-wrap:anywhere; }
.commission-invoice-totals { display:grid; gap:2px; min-width:0; font-variant-numeric:tabular-nums; }
.commission-invoice-totals strong { color:#173d27; font-size:13px; }
.commission-invoice-totals span { color:#686459; font-size:10px; }
.commission-invoice-group button { min-width:132px; min-height:38px; padding:7px 10px; border-color:#718b78; background:#fffdf5; color:#173d27; font-weight:800; }
.commission-invoice-group input,.commission-item-line input { width:19px; height:19px; accent-color:#197b99; }
.commission-item-line td { vertical-align:top; padding:7px 8px; }
.commission-item-line td:first-child { width:34px; text-align:center; }
.commission-item-line td:nth-child(2) { min-width:220px; }
.commission-item-line td span,.commission-item-line td small { display:block; margin-top:2px; color:#69665b; font-size:10px; line-height:1.3; }
.commission-item-line.registered { background:#f1f0e9; color:#68665e; }
.commission-registered { display:inline-flex!important; width:max-content; padding:2px 7px; border:1px solid #9db6a6; border-radius:999px; background:#e2eee5; color:#205a39!important; font-weight:800; }

@media (max-width:700px) {
  .commission-tracking-mode .content-grid { display:block; }
  .commission-tracking-mode .list-panel,.commission-tracking-mode .detail-panel { width:100%; min-width:0; }
  .commission-tracking-mode .table-wrap { overflow:visible; }
  .commission-tracking-mode table,.commission-tracking-mode tbody { display:block; min-width:0; width:100%; }
  .commission-tracking-mode thead { display:none; }
  .commission-tracking-mode tbody tr { display:grid; grid-template-columns:1fr 1fr; gap:0; margin:0 8px 10px; padding:9px 10px; border:1px solid #d4ceba; border-radius:10px; background:#fffdf7; box-shadow:0 2px 6px rgba(34,50,34,.06); }
  .commission-tracking-mode tbody td { display:grid; grid-template-columns:minmax(88px,.75fr) minmax(0,1.25fr); align-items:start; gap:7px; min-width:0; padding:5px 3px; border:0; white-space:normal; overflow-wrap:anywhere; }
  .commission-tracking-mode tbody td::before { content:attr(data-label); color:#6a685f; font-size:10px; font-weight:800; letter-spacing:.03em; text-transform:uppercase; }
  .commission-tracking-mode tbody td:nth-child(3),.commission-tracking-mode tbody td:nth-child(4),.commission-tracking-mode tbody td:nth-child(6),.commission-tracking-mode tbody td:nth-child(7),.commission-tracking-mode tbody td:nth-child(15) { grid-column:1/-1; }
  .commission-tracking-mode tbody td:nth-child(5),.commission-tracking-mode tbody td:nth-child(8),.commission-tracking-mode tbody td:nth-child(9) { display:none; }
  .commission-tracking-mode .commission-money { text-align:left; }
  .commission-tracking-mode .detail-panel { margin-top:10px; }
  .commission-facts,.commission-payment-form { grid-template-columns:1fr; }
  .commission-payment-form .wide { grid-column:auto; }
  .commission-edit-card input,.commission-edit-card textarea,.commission-payment-form input { min-height:44px; font-size:16px; }
  .commission-edit-card button,.commission-payment-card button { width:100%; min-height:46px; }
  .commission-tracking-mode .commission-export-toolbar-row,.commission-tracking-mode .commission-invoice-group,.commission-tracking-mode .commission-item-line { display:block; grid-template-columns:none; margin:0 8px; padding:0; border-radius:0; box-shadow:none; }
  .commission-tracking-mode .commission-export-toolbar-row td,.commission-tracking-mode .commission-invoice-group td { display:block; padding:0; }
  .commission-export-toolbar { align-items:stretch; padding:9px; }
  .commission-export-toolbar,.commission-export-toolbar>div:last-child { display:grid; grid-template-columns:1fr; }
  .commission-export-toolbar>div:last-child { grid-template-columns:minmax(0,.7fr) minmax(0,1.3fr); }
  .commission-export-toolbar button { min-height:44px; }
  .commission-destination-overlay { align-items:end; padding:0; }
  .commission-destination-dialog { width:100%; padding:15px 14px calc(15px + env(safe-area-inset-bottom)); border-radius:16px 16px 0 0; }
  .commission-destination-head h3 { font-size:20px; }
  .commission-destination-options>button { min-height:56px; }
  .commission-invoice-group { margin-top:10px!important; border:1px solid #bfc8b8!important; border-radius:10px 10px 0 0!important; overflow:hidden; }
  .commission-invoice-group td>div { grid-template-columns:minmax(0,1fr) auto; align-items:start; min-height:52px; padding:9px; }
  .commission-invoice-group label { min-height:44px; }
  .commission-invoice-totals { grid-column:1/-1; padding:8px 10px; border-radius:7px; background:#f7f5e9; }
  .commission-invoice-totals strong { font-size:14px; }
  .commission-invoice-group button { grid-column:1/-1; width:100%; min-height:44px; }
  .commission-invoice-group input,.commission-item-line input { width:22px; height:22px; }
  .commission-tracking-mode .commission-item-line { display:grid; grid-template-columns:1fr 1fr; gap:0 8px; padding:8px 10px; border:1px solid #d4ceba; border-top:0; background:#fffdf7; }
  .commission-tracking-mode .commission-item-line:last-of-type { border-radius:0 0 10px 10px; }
  .commission-tracking-mode .commission-item-line td { display:grid!important; grid-template-columns:minmax(76px,.65fr) minmax(0,1.35fr); gap:7px; width:auto; min-width:0; padding:5px 2px; }
  .commission-tracking-mode .commission-item-line td::before { content:attr(data-label); color:#6a685f; font-size:10px; font-weight:800; text-transform:uppercase; }
  .commission-tracking-mode .commission-item-line td:first-child { grid-column:1/-1; display:flex!important; justify-content:flex-end; min-height:32px; }
  .commission-tracking-mode .commission-item-line td:first-child::before { margin-right:auto; }
  .commission-tracking-mode .commission-item-line td:nth-child(2),.commission-tracking-mode .commission-item-line td:nth-child(7) { grid-column:1/-1; }
}

/* Sales Orders: dedicated, uncluttered outstanding-summary experience on phones. */
@media (max-width: 700px) {
  .main.sales-order-mobile-page.sales-order-outstanding-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 139;
    background: rgba(18, 37, 25, 0.38);
    backdrop-filter: blur(2px);
  }

  .main.sales-order-mobile-page.sales-order-outstanding-open {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sales-order-outstanding-summary {
    position: fixed;
    inset: max(8px, env(safe-area-inset-top)) 0 0;
    z-index: 140;
    display: block;
    width: 100%;
    max-height: none;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-radius: 16px 16px 0 0;
    background: #f7f4e9;
    box-shadow: 0 -12px 35px rgba(18, 37, 25, 0.24);
  }

  .sales-order-outstanding-summary .so-outstanding-head {
    position: sticky;
    top: 0;
    z-index: 3;
    min-height: 66px;
    padding: 10px 14px;
    border-top: 4px solid var(--accent);
    box-shadow: 0 3px 10px rgba(28, 51, 33, 0.08);
  }

  .sales-order-outstanding-summary .so-outstanding-head strong {
    font-size: 19px;
    line-height: 1.12;
  }

  .sales-order-outstanding-summary .so-outstanding-head > button {
    min-width: 70px;
    min-height: 44px;
  }

  .sales-order-outstanding-summary .so-outstanding-kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
  }

  .sales-order-outstanding-summary .so-outstanding-kpis > span {
    min-width: 0;
    padding: 9px 10px;
    border-radius: 9px;
    background: #fffdf7;
    box-shadow: 0 1px 2px rgba(28, 51, 33, 0.04);
    font-size: 11px;
  }

  .sales-order-outstanding-summary .so-outstanding-kpis b {
    display: block;
    margin-bottom: 2px;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
  }

  .sales-order-outstanding-summary .so-outstanding-kpis .so-outstanding-values {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
  }

  .sales-order-outstanding-summary .so-outstanding-values span {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
  }

  .sales-order-outstanding-summary .so-outstanding-values b {
    display: inline;
    margin: 0;
    font-size: 13px;
  }

  .sales-order-outstanding-summary .so-outstanding-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 12px 12px;
  }

  .sales-order-outstanding-summary .so-outstanding-tabs > button,
  .sales-order-outstanding-summary .so-outstanding-export-actions button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  .sales-order-outstanding-summary .so-outstanding-export-actions {
    display: contents;
  }

  .sales-order-outstanding-summary .so-outstanding-ai {
    gap: 10px;
    margin: 0 12px 12px;
    padding: 12px;
    border: 1px solid #c7d8ca;
    border-radius: 12px;
    background: #eef5ef;
    box-shadow: 0 2px 8px rgba(28, 51, 33, 0.06);
  }

  .sales-order-outstanding-summary .so-outstanding-ai-title {
    align-items: flex-start;
  }

  .sales-order-outstanding-summary .so-outstanding-ai-title strong {
    font-size: 15px;
    line-height: 1.2;
  }

  .sales-order-outstanding-summary .so-outstanding-ai form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .sales-order-outstanding-summary .so-outstanding-ai input {
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 16px;
  }

  .sales-order-outstanding-summary .so-outstanding-ai form button {
    width: 100%;
  }

  .sales-order-outstanding-summary .so-outstanding-ai-prompts {
    display: flex;
    grid-template-columns: none;
    flex-wrap: nowrap;
    gap: 7px;
    padding-bottom: 2px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .sales-order-outstanding-summary .so-outstanding-ai-prompts::-webkit-scrollbar {
    display: none;
  }

  .sales-order-outstanding-summary .so-outstanding-ai-prompts button {
    flex: 0 0 auto;
    min-width: 128px;
    padding: 7px 12px;
    scroll-snap-align: start;
  }

  .so-mobile-breakdown {
    margin: 0 12px;
  }

  .so-mobile-breakdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 50px;
    padding: 10px 13px;
    border-color: var(--green-dark);
    border-radius: 10px;
    background: #fffdf7;
    color: var(--green-dark);
    font-weight: 800;
    text-align: left;
  }

  .so-mobile-breakdown-toggle b {
    font-size: 22px;
    line-height: 1;
  }

  .so-mobile-breakdown-list {
    display: grid;
    gap: 9px;
    padding-top: 9px;
  }

  .so-mobile-breakdown-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #d5cfbc;
    border-radius: 11px;
    background: #fffdf7;
    box-shadow: 0 2px 6px rgba(28, 51, 33, 0.05);
  }

  .so-mobile-breakdown-card > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
  }

  .so-mobile-breakdown-card > header > div,
  .so-mobile-breakdown-secondary {
    display: grid;
    min-width: 0;
    gap: 2px;
  }

  .so-mobile-breakdown-card header span,
  .so-mobile-breakdown-secondary span,
  .so-mobile-breakdown-metrics span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .so-mobile-breakdown-card header strong {
    color: var(--green-dark);
    font-size: 14px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .so-mobile-breakdown-contract {
    padding: 7px 8px;
    border-radius: 7px;
    background: #edf3e9;
    color: #314936;
    font-size: 12px;
    font-weight: 700;
    overflow-wrap: anywhere;
  }

  .so-mobile-breakdown-secondary strong {
    font-size: 12px;
    overflow-wrap: anywhere;
  }

  .so-mobile-breakdown-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .so-mobile-breakdown-metrics > div {
    box-sizing: border-box;
    min-width: 0;
    padding: 8px;
    border-left: 2px solid #d7e2d9;
  }

  .so-mobile-breakdown-metrics > div:nth-child(3) {
    grid-column: 1 / -1;
  }

  .so-mobile-breakdown-metrics strong,
  .so-mobile-breakdown-metrics small {
    display: block;
    font-variant-numeric: tabular-nums;
  }

  .so-mobile-breakdown-metrics strong {
    margin-top: 3px;
    color: #243d2b;
    font-size: 13px;
    overflow-wrap: anywhere;
  }

  .so-mobile-breakdown-metrics small {
    color: var(--muted);
    font-size: 10px;
  }

  .so-mobile-breakdown-card.is-kiv {
    border-color: #cc8f8f;
    background: #fff7f7;
  }

  .so-mobile-breakdown-card.is-kiv .so-mobile-breakdown-metrics > div:nth-child(2) strong {
    color: #9b1c1c;
    text-decoration: line-through;
  }

  .so-mobile-breakdown-card > p {
    margin: 0;
    color: #9b1c1c;
    font-size: 11px;
  }
}

/* Shared mobile workspace rules. Keep this block last so new modules inherit
   the same touch, list, detail and entry behavior without module-specific CSS. */
@media (max-width: 700px) {
  html,
  body {
    min-height: 100vh;
  }

  button,
  input,
  select,
  textarea,
  .nav-btn,
  .nav-sub-btn,
  .app-tab {
    touch-action: manipulation;
  }

  button,
  .nav-btn,
  .nav-sub-btn {
    min-height: 42px;
  }

  .app-tabs {
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .app-tab {
    min-height: 38px;
    height: auto;
    padding: 8px 13px;
    line-height: 1.15;
    scroll-snap-align: start;
  }

  .main {
    padding: 6px;
    gap: 6px;
  }

  .topbar {
    gap: 6px;
    padding: 8px;
  }

  .topbar h1 {
    font-size: clamp(21px, 6vw, 28px);
    line-height: 1.1;
    overflow-wrap: anywhere;
  }

  .top-actions,
  .top-actions button,
  .top-actions .search input,
  .fy-session-bar,
  .fy-badge {
    min-height: 42px;
  }

  .summary-strip,
  .summary-strip:has(.gl-report-metric),
  .summary-strip.bank-reconcile-summary-strip,
  .summary-strip.stock-card-summary-strip,
  .summary-strip.invoice-listing-summary-strip,
  .summary-strip.trial-balance-summary-strip,
  .summary-strip.income-statement-summary-strip {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .summary-strip::-webkit-scrollbar {
    display: none;
  }

  .summary-strip > .metric,
  .summary-strip > .gl-report-metric,
  .summary-strip > .bank-reconcile-metric {
    flex: 0 0 min(48vw, 210px);
    min-height: 64px;
  }

  .metric strong,
  .money-metric strong {
    font-size: 16px;
  }

  .panel-head {
    min-height: 44px;
    padding: 9px 10px;
  }

  .panel-head button,
  .panel-head .detail-toggle {
    min-height: 38px;
  }

  .content-grid.mobile-detail-selected .detail-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 40;
    min-height: 0;
    max-height: min(70vh, 560px);
    margin: 0;
    box-shadow: 0 8px 28px rgba(20, 45, 35, 0.3);
  }

  .content-grid.mobile-detail-selected .detail-panel .panel-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel);
  }

  .content-grid.mobile-detail-selected .detail-panel .detail-body {
    max-height: calc(min(70vh, 560px) - 54px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .list-panel {
    min-height: 220px;
  }

  .table-wrap,
  .detail-scroll,
  .detail-body {
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap {
    overscroll-behavior-x: contain;
  }

  table {
    min-width: 640px;
  }

  th,
  td {
    min-height: 36px;
    height: 36px;
    padding: 7px 8px;
    font-size: 13px;
  }

  .record-form,
  .form-fields,
  .transaction-grid,
  .bank-cash-grid {
    min-width: 0;
  }

  .form-fields {
    gap: 9px;
    padding: 9px;
  }

  .form-field label,
  .transaction-grid label,
  .bank-cash-grid label {
    font-size: 12px;
    line-height: 1.2;
  }

  .form-field input,
  .form-field select,
  .form-field textarea,
  .transaction-grid input,
  .transaction-grid select,
  .transaction-grid textarea,
  .bank-cash-grid input,
  .bank-cash-grid select,
  .bank-cash-grid textarea {
    min-height: 44px;
    padding: 9px 10px;
    font-size: 16px;
    line-height: 1.25;
  }

  .form-field textarea,
  .transaction-grid textarea,
  .bank-cash-grid textarea {
    min-height: 96px;
  }

  .line-head,
  .bank-cash-line-head,
  .attachment-panel-head,
  .supplier-invoice-quick-panel {
    gap: 6px;
    padding: 8px;
  }

  .line-actions,
  .attachment-actions,
  .editor-actions {
    gap: 6px;
  }

  .line-actions button,
  .attachment-actions button,
  .editor-actions button {
    min-height: 44px;
    padding: 9px 10px;
    white-space: normal;
  }

  .editor-overlay {
    padding: 0;
  }

  .editor-dialog,
  .editor-dialog.bank-cash-dialog {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
  }

  .editor-head {
    min-height: 58px;
    padding: 9px 12px;
  }

  .editor-head h2 {
    font-size: 22px;
    overflow-wrap: anywhere;
  }

  .editor-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    grid-template-columns: minmax(0, 1fr) repeat(2, auto);
    background: var(--panel);
  }

  .po-line-scroll,
  .statement-table-wrap,
  .note-table-wrap,
  .payment-table-wrap,
  .po-import-table-wrap,
  .payment-picker-table-wrap {
    max-width: 100%;
    overscroll-behavior-x: contain;
  }

  .po-line-editor,
  .journal-line-editor,
  .bank-payment-line-editor,
  .po-line-editor:not(.bank-payment-line-editor):not(.journal-line-editor),
  .si-line-editor {
    max-width: none;
  }

  #formStatus {
    line-height: 1.35;
  }
}

.warning-text {
  background: #fff1b8;
  border: 1px solid #d89b28;
  color: #7a3200;
  display: inline-block;
  padding: 4px 8px;
}

@media (max-width: 430px) {
  .top-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .top-actions .search,
  .top-actions button {
    grid-column: 1;
  }

  .fy-session-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  .content-grid.mobile-detail-selected .detail-panel {
    left: 4px;
    right: 4px;
    bottom: 4px;
  }

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

.report-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.report-controls label {
  display: grid;
  gap: 3px;
  min-width: 130px;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
}

.report-controls input {
  min-height: 34px;
  border: 1px solid var(--border);
  background: #fffdf4;
  padding: 6px 8px;
  font: inherit;
  text-transform: none;
}

.report-controls .ageing-party-filter {
  min-width: 190px;
}

.ageing-filter-card {
  grid-column: 1 / -1;
  padding: 8px 10px;
  background: linear-gradient(#fbf8ef, var(--gold-pale));
  border-bottom: 1px solid var(--line);
}

.ageing-controls {
  display: grid;
  grid-template-columns:
    minmax(120px, 140px)
    minmax(180px, 220px)
    minmax(180px, 1fr)
    minmax(160px, 200px)
    minmax(160px, 200px)
    auto;
  gap: 8px;
  align-items: end;
}

.ageing-controls label {
  min-width: 0;
}

.report-controls.ageing-controls .ageing-party-filter {
  min-width: 0;
}

.ageing-controls input,
.ageing-controls select {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--border);
  background: #fffdf4;
  padding: 5px 7px;
  font: inherit;
  text-transform: none;
}

.ageing-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: end;
  white-space: nowrap;
}

.report-controls .ageing-report-actions button {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 0.8rem;
}

.ageing-metric {
  min-height: 48px;
}

.summary-strip:has(.statement-filter-card) {
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  align-items: stretch;
}

.summary-strip:has(.statement-filter-card) .statement-filter-card {
  padding: 7px 9px;
}

.summary-strip:has(.statement-filter-card) .ageing-controls {
  grid-template-columns:
    minmax(112px, 0.55fr)
    minmax(112px, 0.55fr)
    minmax(220px, 1.4fr)
    minmax(150px, 0.9fr)
    minmax(150px, 0.9fr)
    minmax(88px, 0.45fr);
}

.summary-strip:has(.statement-filter-card) .ageing-report-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  align-items: center;
  padding-top: 2px;
}

.summary-strip:has(.statement-filter-card) .statement-metric {
  min-height: 48px;
}

.summary-strip:has(.statement-filter-card) .money-metric {
  min-width: 170px;
}

.money-metric strong {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  font-size: clamp(16px, 1.25vw, 20px);
}

.report-controls .ageing-party-filter input {
  width: 100%;
}

.report-controls .ageing-party-filter .lookup-status {
  min-height: 14px;
  text-transform: none;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.report-controls button {
  min-height: 34px;
}

.inline-action {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: 8px;
  padding: 3px 8px;
  font-size: 0.75rem;
  vertical-align: middle;
}

.utility-module-mode {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
}

.utility-tool-row td {
  padding: 0;
  border: 0;
}

.recurring-dashboard-prompt {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid #b9c98c;
  background: #f3f7e8;
  color: var(--green-dark);
}
.recurring-dashboard-head,
.recurring-dashboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.recurring-dashboard-head span,
.recurring-dashboard-row span {
  display: block;
  color: #6b6a5f;
  font-size: 12px;
}
.recurring-dashboard-list { display: grid; gap: 6px; margin-top: 8px; }
.recurring-dashboard-row {
  padding: 7px 8px;
  border-top: 1px solid rgba(33, 67, 40, .15);
}
.recurring-dashboard-row button { white-space: nowrap; }

.recurring-source-actions { display: flex; align-items: end; gap: 6px; flex-wrap: wrap; }
.recurring-source-actions button { min-height: 36px; padding: 7px 10px; border: 1px solid #b6ad8e; background: #f5f0df; color: #29452e; border-radius: 4px; cursor: pointer; font-weight: 700; }
.recurring-source-preview { display: grid; gap: 3px; padding: 9px 11px; border: 1px solid #c9d8bd; background: #f3f7e8; color: #29452e; }
.recurring-source-preview span { color: #69705f; font-size: 12px; }

.utility-tool-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.utility-tool-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.utility-tool-head h2 {
  margin: 0;
  color: var(--green-dark);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 24px;
}

.utility-pill {
  border: 1px solid var(--line-strong);
  background: var(--accent-light);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 8px;
  white-space: nowrap;
}

.utility-form-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(220px, 1fr) minmax(160px, 240px);
  gap: 8px;
  align-items: end;
}

.utility-form-grid label {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.utility-form-grid input,
.utility-form-grid select {
  min-height: 34px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  padding: 5px 8px;
  font: inherit;
}

.utility-status {
  min-height: 20px;
  color: var(--muted);
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.user-profile-layout {
  display: grid;
  grid-template-columns: minmax(260px, .85fr) minmax(360px, 1.15fr);
  gap: 12px;
}

.user-profile-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fffdf6;
  box-shadow: 0 2px 8px rgba(32, 55, 37, .05);
}

.user-profile-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.user-profile-card-head h3 {
  margin: 2px 0 0;
  color: var(--green-dark);
  font-size: 17px;
}

.user-profile-fields {
  display: grid;
  gap: 9px;
}

.user-profile-fields label,
.user-signature-picker {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.user-profile-fields input,
.user-signature-picker input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 7px 9px;
  color: var(--ink);
  font: inherit;
}

.user-profile-fields input[readonly] {
  background: #f1f2e9;
  color: var(--muted);
}

.signature-state {
  padding: 4px 8px;
  border: 1px solid #c7c5b7;
  border-radius: 999px;
  background: #f1efe7;
  color: #69685e;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.signature-state.saved {
  border-color: #9fc1a5;
  background: #eaf4e8;
  color: var(--green-dark);
}

.user-signature-preview {
  display: grid;
  place-items: center;
  min-height: 112px;
  margin-bottom: 10px;
  padding: 10px;
  overflow: hidden;
  border: 1px dashed #9fb3a1;
  background-color: #faf9f2;
  background-image: linear-gradient(45deg, #f0eee5 25%, transparent 25%), linear-gradient(-45deg, #f0eee5 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0eee5 75%), linear-gradient(-45deg, transparent 75%, #f0eee5 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.user-signature-preview img {
  display: block;
  max-width: 100%;
  width: auto;
  max-height: 100px;
  object-fit: contain;
}

.user-signature-empty {
  display: grid;
  gap: 4px;
  padding: 10px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 253, 246, .88);
}

.user-signature-empty span,
.user-signature-picker small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  text-transform: none;
}

.user-signature-draw {
  display: grid;
  gap: 7px;
  margin: 10px 0;
}

.user-signature-draw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-signature-draw-head > div {
  display: grid;
  gap: 2px;
}

.user-signature-draw-head span {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.user-signature-draw-head small,
.user-signature-draw > small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.user-signature-draw-head button {
  min-height: 34px;
  padding: 5px 10px;
  white-space: nowrap;
}

#utilitySignaturePad {
  display: block;
  width: 100%;
  height: 140px;
  box-sizing: border-box;
  border: 1px solid #8fa293;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .75);
  cursor: crosshair;
  touch-action: none;
}

.user-signature-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.user-signature-divider::before,
.user-signature-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.user-profile-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.user-profile-actions button {
  min-height: 40px;
}

.user-password-card {
  margin-top: 2px;
}

.ai-memory-intro {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.ai-memory-form {
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.4fr) minmax(150px, 190px);
}

.ai-memory-list {
  display: grid;
  gap: 7px;
}

.ai-memory-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.75fr) minmax(240px, 1.5fr) auto auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fffdf7;
}

.ai-memory-alias,
.ai-memory-target {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ai-memory-alias span,
.ai-memory-target span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ai-memory-alias strong,
.ai-memory-target strong {
  overflow-wrap: anywhere;
  color: var(--green-dark);
}

.ai-memory-source,
.ai-memory-locked {
  padding: 4px 7px;
  border: 1px solid #c9d9c8;
  border-radius: 999px;
  background: #edf6ea;
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.ai-memory-source.preset,
.ai-memory-locked {
  border-color: #d7c99f;
  background: #f7f0d9;
  color: #6d5520;
}

.ai-memory-row button {
  min-height: 36px;
  padding: 7px 10px;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .ai-memory-panel {
    padding: 12px;
  }

  .ai-memory-panel .utility-tool-head {
    align-items: center;
  }

  .ai-memory-panel .utility-tool-head h2 {
    font-size: 21px;
  }

  .ai-memory-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .ai-memory-form input,
  .ai-memory-form select {
    min-height: 44px;
    font-size: 16px;
  }

  .ai-memory-form button {
    min-height: 44px;
  }

  .ai-memory-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 8px;
  }

  .ai-memory-target {
    grid-column: 1 / -1;
  }

  .ai-memory-source {
    justify-self: end;
  }

  .ai-memory-locked,
  .ai-memory-row button {
    grid-column: 2;
    justify-self: end;
    min-height: 44px;
  }
}

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

.utility-note-grid div {
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 10px;
  min-width: 0;
}

.utility-note-grid strong,
.utility-note-grid span {
  display: block;
}

.utility-note-grid span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Recurring tools must keep long descriptions inside their own columns. */
.recurring-tool-panel,
.recurring-template-form,
.recurring-source-preview,
.recurring-list,
.recurring-row {
  min-width: 0;
  max-width: 100%;
}

.recurring-tool-panel p,
.recurring-tool-panel strong,
.recurring-tool-panel span,
.recurring-tool-panel h3,
.recurring-tool-panel button,
.recurring-source-preview,
.recurring-row {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.recurring-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.recurring-row > div {
  min-width: 0;
  flex: 1 1 auto;
}

.recurring-row button {
  flex: 0 0 auto;
}

.bank-reconcile-metric {
  grid-column: 1 / -1;
  min-width: 0;
}

.bank-reconcile-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 10px;
  align-items: end;
}

.bank-reconcile-tabs {
  align-self: end;
}

.bank-reconcile-import-grid {
  display: grid;
  grid-template-columns: 120px minmax(135px, 165px) minmax(210px, 1fr) auto auto;
  gap: 7px;
  align-items: end;
}

.bank-reconcile-import-grid label,
.bank-reconcile-paste {
  display: grid;
  gap: 3px;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
}

.bank-reconcile-import-grid input {
  width: 100%;
  min-width: 0;
  height: 30px;
  font-size: 13px;
  text-transform: none;
  font-weight: 500;
}

.bank-reconcile-import-grid button {
  min-height: 30px;
  white-space: nowrap;
}

.bank-reconcile-file-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.bank-reconcile-file-row button {
  min-height: 30px;
}

.bank-reconcile-file-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
}

.bank-reconcile-paste summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--green-dark);
  text-transform: none;
}

.bank-reconcile-paste textarea {
  min-height: 78px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.reconcile-score {
  display: inline-flex;
  min-width: 34px;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: #f7f2df;
  padding: 2px 5px;
  font-weight: 700;
}

.reconcile-score.good {
  background: #dff0df;
  color: #0c5f24;
}

.reconcile-score.warn {
  background: #fff2c4;
  color: #7c5600;
}

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

.inline-link-btn {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  box-shadow: none;
  padding: 0;
  min-height: auto;
  font-weight: 700;
  text-decoration: underline;
}

.bank-reconcile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.bank-reconcile-table-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.bank-reconcile-best-match .bank-reconcile-match-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: #f7fbef;
  padding: 9px;
}

.bank-reconcile-match-card strong,
.bank-reconcile-match-card span,
.bank-reconcile-match-card small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.bank-reconcile-match-card span {
  margin-top: 2px;
}

.bank-reconcile-match-card small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.3;
}

.summary-strip.bank-reconcile-summary-strip {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  align-items: stretch;
}

.summary-strip.bank-reconcile-summary-strip .metric {
  min-height: 48px;
}

.summary-strip.bank-reconcile-summary-strip .bank-reconcile-metric {
  min-height: auto;
}

.summary-strip.bank-reconcile-summary-strip .bank-reconcile-metric strong {
  width: 100%;
}

.gl-report-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  align-items: stretch;
  min-width: 0;
  width: 100%;
}

.gl-report-metric strong {
  width: 100%;
}

.compact-report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.compact-report-tabs button,
.gl-report-actions button {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.gl-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 6px;
  align-items: end;
  min-width: 0;
}

.gl-filter-grid label {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.gl-filter-grid input,
.gl-filter-grid select {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  background: #fffdf4;
  padding: 5px 7px;
  color: var(--ink);
  font: inherit;
}

.gl-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}

.stock-card-report-panel {
  width: 100%;
  max-width: none;
}

.stock-card-summary-strip {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: stretch;
}

.stock-card-summary-strip .gl-report-metric {
  grid-column: 1 / -1;
}

.stock-card-filter-grid {
  grid-template-columns:
    minmax(100px, 0.55fr)
    minmax(100px, 0.55fr)
    minmax(150px, 0.75fr)
    minmax(150px, 0.8fr)
    minmax(150px, 0.8fr)
    minmax(210px, 1.15fr)
    minmax(180px, 1fr);
}

.stock-card-filter-grid label {
  min-width: 0;
}

.stock-card-filter-grid select {
  width: 100%;
}

.invoice-listing-filter-grid {
  grid-template-columns:
    minmax(96px, 0.45fr)
    minmax(96px, 0.45fr)
    minmax(104px, 0.5fr)
    minmax(160px, 0.65fr)
    minmax(180px, 0.9fr)
    minmax(180px, 0.9fr)
    minmax(220px, 1fr);
  align-items: end;
}

.invoice-listing-filter-grid label {
  min-width: 0;
}

.invoice-listing-filter-grid input,
.invoice-listing-filter-grid select {
  min-height: 28px;
  padding: 4px 6px;
}

.invoice-listing-filter-grid .lookup-status {
  min-height: 0;
  line-height: 1;
}

.invoice-listing-filter-grid .invoice-party-range {
  gap: 2px;
}

.trial-balance-summary-strip {
  grid-template-columns:
    minmax(720px, 4fr)
    repeat(4, minmax(92px, 0.7fr));
}

.trial-balance-summary-strip .gl-report-metric {
  overflow: visible;
}

.trial-balance-summary-strip .metric:not(.gl-report-metric) {
  padding: 7px 8px;
}

.trial-balance-summary-strip .metric:not(.gl-report-metric) strong {
  font-size: 15px;
  line-height: 1.1;
  white-space: nowrap;
  overflow-wrap: normal;
}

.trial-balance-report-panel {
  gap: 6px;
}

.trial-balance-filter-grid {
  grid-template-columns:
    minmax(118px, 0.75fr)
    minmax(118px, 0.75fr)
    minmax(150px, 1fr)
    minmax(150px, 1fr)
    minmax(112px, auto)
    minmax(178px, auto);
  align-items: end;
}

.trial-balance-actions {
  flex-wrap: nowrap;
  align-items: end;
}

.income-statement-summary-strip {
  grid-template-columns:
    minmax(720px, 4fr)
    repeat(4, minmax(90px, 0.62fr));
}

.income-statement-filter-grid {
  grid-template-columns:
    minmax(118px, 0.8fr)
    minmax(118px, 0.8fr)
    minmax(132px, 0.8fr)
    minmax(150px, 0.9fr);
  align-items: end;
}

.income-statement-actions {
  grid-column: 1 / -1;
  flex-wrap: nowrap;
  align-items: end;
  justify-content: flex-start;
  padding-top: 2px;
}

.income-statement-actions button {
  white-space: nowrap;
  min-width: 66px;
}

.income-preview-toggle {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  align-items: center;
  gap: 4px;
  min-height: 30px;
}

.income-preview-toggle span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.income-preview-toggle button {
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--green-dark);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.income-preview-toggle button.active {
  border-color: var(--accent);
  background: var(--blue-pale);
  color: var(--accent-dark);
}

.fy-roll-forward-summary-strip {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.fy-roll-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.fy-roll-actions button {
  min-height: 30px;
  padding: 5px 10px;
  white-space: nowrap;
}

.gl-filter-grid .compact-check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding-top: 0;
  padding-bottom: 3px;
}

.gl-filter-grid .compact-check-label input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.gl-filter-grid .compact-check-label span {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: none;
}

.stock-card-filter-grid .lookup-status {
  min-height: 14px;
  text-transform: none;
  font-size: 0.65rem;
}

.stock-card-report-panel .gl-report-actions {
  margin-top: 8px;
  align-items: center;
}

.stock-card-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .stock-card-filter-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 900px) {
  .gl-filter-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .gl-report-actions {
    justify-content: flex-start;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(29, 161, 201, 0.12), rgba(237, 232, 213, 0.94) 42%, rgba(216, 236, 218, 0.72)),
    var(--bg);
  color: var(--ink);
  font-family: "DM Sans", Arial, Helvetica, sans-serif;
  font-size: 14px;
}

.app-tabs {
  display: flex;
  gap: 4px;
  min-height: 42px;
  padding: 8px 14px 0;
  background: var(--green-dark);
  border-bottom: 3px solid var(--accent);
}

.app-tab {
  min-width: 150px;
  height: 34px;
  border-color: rgba(255, 255, 255, 0.25);
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  letter-spacing: 0.08em;
}

.app-tab.active {
  background: var(--ivory);
  color: var(--green-dark);
  border-color: var(--line-strong);
}

button,
input {
  font: inherit;
}

button {
  height: 32px;
  border: 1px solid #a89f84;
  border-radius: 3px;
  background: linear-gradient(#fffdf7 0%, #f3eddc 48%, #dfd6be 100%);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(83, 72, 48, 0.18),
    0 1px 0 rgba(83, 72, 48, 0.35);
  transform: translateY(0);
  transition: background 80ms ease, border-color 80ms ease, box-shadow 80ms ease, transform 80ms ease;
}

button:hover,
button:focus {
  border-color: #776a48;
  background: linear-gradient(#fff9e9 0%, #eee4cc 48%, #d7cbb0 100%);
  color: var(--ink);
  outline: 1px solid rgba(29, 161, 201, 0.22);
  outline-offset: 1px;
}

button:active,
button.is-pressed {
  transform: translateY(1px);
  background: linear-gradient(#d7cbb0 0%, #eee4cc 100%);
  box-shadow:
    inset 0 2px 4px rgba(44, 38, 34, 0.24),
    inset 0 1px 0 rgba(44, 38, 34, 0.12);
}

button:disabled {
  cursor: not-allowed;
  color: rgba(44, 38, 34, 0.45);
  background: linear-gradient(#f3f0e6, #dfdac8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.fy-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(248, 244, 232, 0.96);
}

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

.fy-login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-top: 4px solid var(--accent);
  box-shadow: 0 12px 36px rgba(44, 38, 34, 0.18);
}

.fy-login-card label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.fy-login-card input,
.fy-login-card select {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--ink);
  padding: 6px 8px;
  font: inherit;
  text-transform: none;
}

.fy-login-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.fy-login-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.fy-login-buttons button {
  min-width: 86px;
}

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

.app-shell.module-menu-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(180deg, var(--ivory) 0, var(--ivory-dark) 52%, var(--accent-light) 100%);
  border-right: 1px solid var(--line-strong);
  padding: 16px 12px;
  transition: opacity 140ms ease, transform 160ms ease, padding 160ms ease, border-color 160ms ease;
}

.app-shell.module-menu-collapsed .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
  padding-left: 0;
  padding-right: 0;
  border-color: transparent;
}

.brand {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 8px 16px;
  border-bottom: 1px solid var(--line-strong);
}

.brand::before {
  content: none;
}

.brand-logo {
  width: 48px;
  max-height: 48px;
  object-fit: contain;
  grid-row: span 2;
}

.brand strong {
  font-size: 22px;
  color: var(--green-dark);
  font-family: "Playfair Display", Georgia, serif;
  line-height: 1;
}

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

#moduleNav {
  display: grid;
  gap: 4px;
  padding-top: 12px;
}

.nav-btn {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 6px 9px;
  text-align: left;
}

.nav-btn.active {
  border-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-light), #fffdf6);
  color: var(--accent-dark);
  box-shadow: inset 4px 0 0 var(--accent);
}

.nav-btn small {
  color: var(--muted);
  font-size: 11px;
}

.nav-group {
  border: 1px solid var(--line-strong);
  background: rgba(255, 253, 246, 0.74);
}

.nav-group.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.nav-group-title {
  align-items: center;
  background: linear-gradient(90deg, #e7d9b8 0%, #f6f0dc 58%, #fffdf6 100%);
  border-bottom: 1px solid var(--line);
  border-left: 0;
  border-right: 0;
  border-top: 0;
  color: #143f2a;
  display: grid;
  grid-template-columns: 1fr auto;
  font-weight: 900;
  gap: 8px;
  letter-spacing: 0.08em;
  min-height: 38px;
  padding: 9px 10px 9px 15px;
  position: relative;
  text-align: left;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
  text-transform: uppercase;
  width: 100%;
}

.nav-group-title::before {
  background: var(--accent);
  bottom: 7px;
  content: "";
  left: 7px;
  position: absolute;
  top: 7px;
  width: 3px;
}

.nav-group-title:hover,
.nav-group-title:focus {
  background: linear-gradient(90deg, #dfcda5 0%, #f2e8cd 58%, #fffaf0 100%);
}

.nav-group-copy {
  display: block;
  min-width: 0;
}

.nav-group-copy > span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-group-arrow {
  align-items: center;
  background: #fffdf6;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--accent);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  height: 22px;
  justify-content: center;
  line-height: 1;
  width: 22px;
}

.nav-group-items {
  display: grid;
  gap: 3px;
  padding: 5px;
}

.nav-group-items[hidden] {
  display: none;
}

.nav-sub-btn {
  border-color: transparent;
  min-height: 34px;
  padding-left: 12px;
}

.nav-sub-btn.active {
  border-color: var(--accent);
}

.main {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
  gap: 10px;
}

/* The dashboard is a full-page view, so it must be allowed to grow and scroll.
   Transaction workspaces retain the contained list/detail scrolling above. */
.main.dashboard-page {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.main.dashboard-page .dashboard-view {
  min-height: min-content;
}

.topbar,
.summary-strip,
.list-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(13, 79, 57, 0.08);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 14px 16px;
  border-top: 4px solid var(--accent);
}

.topbar > div:first-of-type {
  flex: 1 1 auto;
  min-width: 160px;
}

.module-menu-btn {
  flex: 0 0 auto;
  align-self: center;
  min-width: 92px;
  height: 34px;
  border-color: var(--accent);
  background: linear-gradient(#e7f9fb, var(--accent-light));
  color: var(--accent-dark);
}

.fy-session-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
}

.fy-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 230px;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  background: var(--accent-light);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fy-session-bar button {
  min-width: 72px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
}

h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: 0;
  color: var(--green-dark);
  font-family: "Playfair Display", Georgia, serif;
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 7px;
}

.search {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.search input {
  width: min(32vw, 360px);
  height: 30px;
  border: 1px solid var(--line-strong);
  padding: 4px 8px;
  background: #fffdf6;
  color: var(--ink);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 1px;
  overflow: visible;
}

.supplier-invoice-quick-panel {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  background: #eef7ef;
  color: var(--green-dark);
  font-size: 13px;
}

.supplier-invoice-quick-panel[hidden] {
  display: none;
}

.supplier-invoice-quick-panel .quick-select-left,
.supplier-invoice-quick-panel .quick-select-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.supplier-invoice-quick-panel .quick-select-left span {
  padding-right: 8px;
  border-right: 1px solid rgba(26, 75, 45, 0.2);
}

.supplier-invoice-quick-panel .quick-select-left span:last-child {
  border-right: 0;
}

.supplier-invoice-quick-panel button {
  min-height: 28px;
  padding: 4px 9px;
}

.quick-select-col {
  width: 24px !important;
  min-width: 24px !important;
  max-width: 24px !important;
  padding-left: 2px !important;
  padding-right: 2px !important;
  text-align: center;
}

.quick-select-col input[type="checkbox"] {
  width: 13px;
  height: 13px;
  margin: 0;
  vertical-align: middle;
}

.summary-strip:has(.gl-report-metric) {
  grid-template-columns:
    minmax(500px, 2fr)
    repeat(auto-fit, minmax(112px, 1fr));
  align-items: stretch;
}

.metric {
  padding: 6px 8px;
  background: linear-gradient(#fbf8ef, var(--gold-pale));
  border-right: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 2px;
  color: var(--green-dark);
  font-size: 16px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.wide-metric {
  grid-column: span 1;
  min-width: 0;
}

.summary-strip:has(.gl-report-metric) .wide-metric {
  grid-column: span 1;
}

.summary-strip:has(.gl-report-metric) .metric:not(.gl-report-metric) strong {
  font-size: clamp(15px, 1.1vw, 18px);
}

.summary-strip.bank-reconcile-summary-strip {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  align-items: stretch;
}

.summary-strip.bank-reconcile-summary-strip .bank-reconcile-metric {
  grid-column: 1 / -1;
}

.summary-strip.bank-reconcile-summary-strip .metric:not(.bank-reconcile-metric) {
  min-height: 48px;
}

.summary-strip.stock-card-summary-strip {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.summary-strip.stock-card-summary-strip .gl-report-metric {
  grid-column: 1 / -1;
  overflow: visible;
}

.summary-strip.invoice-listing-summary-strip {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

.summary-strip.invoice-listing-summary-strip .gl-report-metric {
  grid-column: 1 / -1;
  overflow: visible;
}

.summary-strip.invoice-listing-summary-strip .invoice-listing-report-metric {
  min-height: 0;
  padding: 6px 8px;
}

.summary-strip.invoice-listing-summary-strip .invoice-listing-report-metric > span {
  margin-bottom: 3px;
}

.summary-strip.invoice-listing-summary-strip .invoice-listing-panel-wrap {
  display: block;
  font-size: inherit;
  line-height: 1;
}

.summary-strip.invoice-listing-summary-strip .invoice-listing-filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 5px;
}

.invoice-listing-actions {
  grid-column: auto;
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 5px;
  padding: 0;
}

.invoice-listing-actions button {
  min-width: 54px;
  min-height: 28px;
  padding: 4px 8px;
}

.summary-strip.invoice-listing-summary-strip .invoice-listing-filter-grid label:nth-last-of-type(1) {
  min-width: min(220px, 100%);
}

.invoice-listing-total-chips {
  display: grid;
  grid-template-columns: repeat(5, minmax(82px, 1fr));
  gap: 4px;
  margin-top: 5px;
}

.invoice-listing-total-chips div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 4px 7px;
  border: 1px solid rgba(198, 190, 164, 0.85);
  background: rgba(255, 253, 246, 0.72);
}

.invoice-listing-total-chips span {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-listing-total-chips b {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.invoice-listing-panel {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.invoice-listing-panel .gl-report-actions {
  align-self: end;
  padding-bottom: 0;
}

.summary-strip.trial-balance-summary-strip {
  grid-template-columns:
    minmax(720px, 4fr)
    repeat(4, minmax(92px, 0.7fr));
}

.summary-strip.trial-balance-summary-strip .gl-report-metric {
  grid-column: span 1;
  overflow: visible;
}

.summary-strip.income-statement-summary-strip {
  grid-template-columns:
    minmax(720px, 4fr)
    repeat(4, minmax(90px, 0.62fr));
}

.summary-strip.income-statement-summary-strip .gl-report-metric {
  grid-column: span 1;
  overflow: visible;
}

@media (max-width: 1100px) {
  .summary-strip:has(.gl-report-metric) {
    grid-template-columns: 1fr;
  }

  .utility-module-mode {
    grid-template-columns: 1fr;
  }

  .utility-form-grid,
  .utility-note-grid {
    grid-template-columns: 1fr;
  }

  .user-profile-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-strip.trial-balance-summary-strip,
  .summary-strip.income-statement-summary-strip {
    grid-template-columns: 1fr;
  }

  .trial-balance-filter-grid,
  .income-statement-filter-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .summary-strip:has(.statement-filter-card) .ageing-controls {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .summary-strip:has(.statement-filter-card) .ageing-report-actions {
    justify-content: flex-start;
  }

  .bank-cash-form .bank-cash-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    grid-template-areas:
      "voucher date type"
      "bank ref currency"
      "payto payto rate"
      "account account cleared"
      "remarks remarks remarks";
  }

  .bank-reconcile-panel,
  .bank-reconcile-import-grid,
  .summary-strip.bank-reconcile-summary-strip {
    grid-template-columns: 1fr;
  }

  .bank-reconcile-tabs {
    justify-content: flex-start;
  }
}

.po-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
}

.po-view-tabs button {
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--green-dark);
  min-height: 26px;
  padding: 3px 7px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.po-view-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 10px;
  min-height: 0;
}
.content-grid.dashboard-mode {
  display: none !important;
}

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

.content-grid.awaiting-detail-selection {
  grid-template-columns: minmax(0, 1fr);
}

.content-grid.awaiting-detail-selection .detail-panel {
  display: none;
}

.content-grid.detail-expanded .list-panel {
  display: none;
}

.content-grid.statement-report-mode {
  grid-template-columns: minmax(0, 1fr);
}

.content-grid.statement-report-mode .detail-panel {
  display: none;
}

.content-grid.statement-report-mode .list-panel {
  min-height: 0;
}

.list-panel,
.detail-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#fffdf6, var(--ivory-dark));
}

.panel-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.record-range {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.record-pager {
  display: inline-flex;
  gap: 5px;
  margin-left: 10px;
  vertical-align: middle;
}

.record-pager button {
  min-height: 24px;
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.2;
}

.panel-tool-btn {
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--green-dark);
  padding: 5px 9px;
  font-weight: 800;
  cursor: pointer;
}

.panel-tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

#loadState {
  color: var(--accent-dark);
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  min-height: 0;
  overscroll-behavior: contain;
}

table {
  min-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  height: 27px;
  padding: 4px 7px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #eee8d8;
  min-width: 150px;
  max-width: 360px;
  overflow: visible;
  white-space: nowrap;
  text-overflow: clip;
}

.table-wrap > table th,
.table-wrap > table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.income-statement-preview-row > td {
  padding: 0;
  border: 0;
  background: #fffdf6;
  white-space: normal;
  overflow: visible;
}

.income-statement-preview {
  max-width: 860px;
  margin: 14px auto 22px;
  padding: 18px 22px 24px;
  background: #fffdf6;
  border: 1px solid var(--line);
  color: #111;
  font-family: "Courier New", monospace;
  font-size: 13px;
}

.income-statement-empty-preview {
  max-width: 620px;
  margin: 28px auto;
  padding: 22px 24px;
  border: 1px solid var(--line);
  background: #fffdf6;
  text-align: center;
}

.income-statement-empty-preview strong,
.income-statement-empty-preview span {
  display: block;
}

.income-statement-empty-preview strong {
  color: var(--green-dark);
  font-size: 18px;
}

.income-statement-empty-preview span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.income-statement-preview-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #111;
}

.income-statement-preview-head strong,
.income-statement-preview-head span {
  display: block;
}

.income-statement-preview-head span {
  margin-top: 4px;
  font-weight: 700;
}

.income-statement-preview-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
}

.income-statement-preview-table th,
.income-statement-preview-table td {
  height: auto;
  padding: 3px 4px;
  border: 0;
  background: transparent;
  color: #111;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.income-statement-preview-table th {
  border-bottom: 1px solid #111;
  text-align: left;
  font-weight: 700;
}

.income-statement-preview-table th:nth-child(1),
.income-statement-preview-table td:nth-child(1) {
  width: 18%;
}

.income-statement-preview-table th:nth-child(2),
.income-statement-preview-table td:nth-child(2) {
  width: 58%;
}

.income-statement-preview-table th:nth-child(3),
.income-statement-preview-table td:nth-child(3) {
  width: 24%;
  text-align: right;
  white-space: nowrap;
}

.balance-sheet-preview-table th:nth-child(1),
.balance-sheet-preview-table td:nth-child(1) {
  width: 17%;
}

.balance-sheet-preview-table th:nth-child(2),
.balance-sheet-preview-table td:nth-child(2) {
  width: 52%;
  text-align: left;
}

.balance-sheet-preview-table th:nth-child(3),
.balance-sheet-preview-table td:nth-child(3) {
  width: 9%;
  text-align: left;
  white-space: nowrap;
}

.balance-sheet-preview-table th:nth-child(4),
.balance-sheet-preview-table td:nth-child(4) {
  width: 22%;
  text-align: right;
  white-space: nowrap;
}

.income-statement-preview-table .statement-section td {
  padding-top: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.income-statement-preview-table .statement-total td {
  padding-top: 5px;
  border-top: 1px solid #777;
  font-weight: 700;
}

th:first-child,
td:first-child {
  min-width: 130px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--accent-light);
  color: #111;
  font-size: 12px;
  text-align: left;
}

.sort-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.sort-header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.15;
}

.sort-header small {
  min-width: 10px;
  color: var(--accent);
  font-size: 11px;
  text-align: right;
}

.sort-header.active {
  color: var(--green-dark);
}

tbody tr {
  cursor: pointer;
}

tbody tr:nth-child(even) {
  background: var(--soft);
}

tbody tr.selected {
  background: var(--green-pale);
}

tbody tr.sales-order-kiv-row,
tbody tr.sales-order-kiv-row:nth-child(even) {
  background: #fff0f0;
  color: #611818;
}

tbody tr.sales-order-kiv-row.selected {
  background: #ffe0e0;
}

tbody tr.sales-order-kiv-row td:first-child {
  border-left: 5px solid #a51d1d;
}

tbody tr.sales-order-complete-row,
tbody tr.sales-order-complete-row:nth-child(even) {
  background: #e3edf4;
  color: #29495d;
}

tbody tr.sales-order-complete-row.selected {
  background: var(--green-pale);
  color: var(--green-dark);
}

tbody tr.sales-order-complete-row td:first-child {
  border-left: 5px solid #708fa3;
}

tbody tr.sales-order-closed-row,
tbody tr.sales-order-closed-row:nth-child(even) {
  background: #f2e8e8;
  color: #5e3b3b;
}

tbody tr.sales-order-closed-row.selected {
  background: var(--green-pale);
  color: var(--green-dark);
}

tbody tr.sales-order-closed-row td:first-child {
  border-left: 5px solid #8b4a4a;
}

.sales-order-list-document {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
}

.so-approval-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 2px 6px;
  border: 1px solid #a8a392;
  border-radius: 999px;
  background: #efede4;
  color: #5e5a4e;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .02em;
  line-height: 1;
  white-space: nowrap;
}

.so-approval-approved {
  border-color: #64879c;
  background: #e3eff5;
  color: #315c72;
}

.so-approval-pending {
  border-color: #b98d31;
  background: #fff2ce;
  color: #76540d;
}

.so-approval-rejected {
  border-color: #b96d6d;
  background: #fae7e7;
  color: #8a3333;
}

.so-kiv-hold-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid #741313;
  border-radius: 4px;
  background: linear-gradient(#bd3030, #8f1818);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(116, 19, 19, 0.24);
}

.so-complete-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 2px 6px;
  border: 1px solid #56768b;
  border-radius: 4px;
  background: #6f8fa4;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
}

.so-closed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 3px 8px;
  border: 1px solid #713838;
  border-radius: 4px;
  background: #8b4a4a;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Keep the closed status compact beside the Sales Order number. */
.sales-order-list-document .so-closed-badge {
  min-height: 18px;
  padding: 2px 6px;
  font-size: 9px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.sales-order-kiv-hold-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px;
  padding: 12px 14px;
  border: 1px solid #c96565;
  border-left: 6px solid #8f1818;
  border-radius: 5px;
  background: linear-gradient(90deg, #fff0f0, #fff8f3);
  color: #681919;
  box-shadow: 0 3px 10px rgba(116, 19, 19, 0.12);
}

.sales-order-kiv-hold-banner > div {
  display: grid;
  gap: 2px;
}

.sales-order-kiv-hold-banner strong {
  font-size: 14px;
  line-height: 1.2;
}

.sales-order-kiv-hold-banner small {
  color: #854040;
  font-size: 11px;
}

[data-sales-order-kiv-editor-banner][hidden] {
  display: none;
}

.sales-order-closed-banner,
.sales-order-close-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid #c8a7a7;
  border-left: 5px solid #8b4a4a;
  border-radius: 5px;
  background: #fff7f7;
  color: #5e2f2f;
}

.sales-order-closed-banner > div,
.sales-order-close-action > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.sales-order-closed-banner small,
.sales-order-close-action small {
  color: #765858;
  font-size: 10px;
}

.sales-order-closed-banner p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.35;
}

.sales-order-close-action button {
  min-height: 36px;
  flex: 0 0 auto;
}

.sales-order-close-action.within-tolerance {
  border-color: #a9becb;
  border-left-color: #6f8fa4;
  background: #f3f8fa;
  color: #314e60;
}

.sales-order-close-action.within-tolerance small {
  color: #536c7b;
}

.sales-order-completed-banner,
.sales-order-complete-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
  padding: 9px 12px;
  border: 1px solid #a9becb;
  border-left: 5px solid #6f8fa4;
  border-radius: 5px;
  background: #f3f8fa;
  color: #314e60;
}

.sales-order-completed-banner > div,
.sales-order-complete-action > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.sales-order-completed-banner small,
.sales-order-complete-action small {
  color: #536c7b;
  font-size: 10px;
}

.sales-order-complete-action button {
  min-height: 36px;
  flex: 0 0 auto;
}

.sales-order-close-backdrop {
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 35, 27, 0.58);
}

.sales-order-close-dialog {
  box-sizing: border-box;
  width: min(100%, 520px);
  max-height: min(620px, calc(100dvh - 36px));
  overflow: auto;
  padding: 18px;
  border: 1px solid #bba9a0;
  border-top: 5px solid #8b4a4a;
  border-radius: 8px;
  background: #fffdf6;
  color: var(--ink);
  box-shadow: 0 16px 45px rgba(18, 32, 24, 0.3);
}

.sales-order-close-dialog header,
.sales-order-close-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sales-order-close-dialog header small {
  color: #9b2c2c;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}

.sales-order-close-dialog h2 {
  margin: 2px 0 0;
  border: 0;
  padding: 0;
  font-size: 22px;
}

.sales-order-close-dialog > p {
  margin: 14px 0;
  color: #594f48;
  font-size: 13px;
  line-height: 1.45;
}

.sales-order-close-dialog label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 800;
}

.sales-order-close-dialog label span {
  color: #9b2c2c;
  font-size: 10px;
  text-transform: uppercase;
}

.sales-order-close-dialog textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 105px;
  resize: vertical;
  padding: 11px;
  border: 1px solid #bdb39e;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.sales-order-close-status {
  min-height: 20px;
  padding: 6px 0;
  color: #8a2c2c;
  font-size: 12px;
}

.sales-order-close-dialog footer {
  justify-content: flex-end;
}

.sales-order-close-dialog footer button,
.sales-order-close-x {
  min-height: 40px;
  padding: 8px 14px;
}

.sales-order-close-x {
  min-width: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
}

.sales-contract-approval-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 14000;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 22px;
  background: rgba(15, 36, 25, 0.58);
  opacity: 0;
  backdrop-filter: blur(2px);
  transition: opacity 140ms ease;
}

.sales-contract-approval-confirm-backdrop.is-visible { opacity: 1; }

.sales-contract-approval-confirm-dialog {
  box-sizing: border-box;
  width: min(100%, 520px);
  overflow: hidden;
  border: 1px solid #b7b39f;
  border-top: 5px solid var(--cyan);
  border-radius: 12px;
  background: #fffdf6;
  color: var(--ink);
  box-shadow: 0 22px 60px rgba(10, 28, 18, 0.34);
  transform: translateY(8px) scale(.985);
  transition: transform 160ms ease;
}

.sales-contract-approval-confirm-backdrop.is-visible .sales-contract-approval-confirm-dialog {
  transform: translateY(0) scale(1);
}

.sales-contract-approval-confirm-dialog > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 15px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf8 0%, #f2edda 100%);
}

.sales-contract-approval-confirm-dialog header small {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}

.sales-contract-approval-confirm-dialog h2 {
  margin: 3px 0 0;
  padding: 0;
  border: 0;
  color: var(--green-dark);
  font: 700 24px/1.15 Georgia, serif;
}

.sales-contract-approval-confirm-x {
  flex: 0 0 auto;
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}

.sales-contract-approval-confirm-content { padding: 17px 20px 18px; }

.sales-contract-approval-confirm-content > p {
  margin: 0 0 14px;
  color: #526057;
  font-size: 13px;
  line-height: 1.5;
}

.sales-contract-approval-confirm-summary {
  display: grid;
  gap: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid #d8d7c8;
  border-radius: 8px;
  background: #f8f8ee;
}

.sales-contract-approval-confirm-summary > div {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 10px 12px;
}

.sales-contract-approval-confirm-summary > div + div { border-top: 1px solid #dfdfd2; }

.sales-contract-approval-confirm-summary dt,
.sales-contract-approval-confirm-summary dd { margin: 0; }

.sales-contract-approval-confirm-summary dt {
  color: #687269;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sales-contract-approval-confirm-summary dd {
  min-width: 0;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.sales-contract-approval-confirm-dialog > footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 13px 20px 18px;
  border-top: 1px solid var(--line);
  background: #f5f1e3;
}

.sales-contract-approval-confirm-dialog > footer button { min-height: 44px; }

.sales-contract-approval-confirm-submit {
  border-color: #173f28;
  background: var(--green-dark);
  color: #fff;
  font-weight: 800;
  box-shadow: inset 0 1px rgba(255, 255, 255, .24);
}

.sales-contract-approval-confirm-submit:hover,
.sales-contract-approval-confirm-submit:focus-visible {
  background: #0d4b28;
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .sales-contract-approval-confirm-backdrop,
  .sales-contract-approval-confirm-dialog { transition: none; }
}

tbody tr.po-fully-utilised {
  background: #f4ecd9;
  color: #655b48;
}

tbody tr.po-fully-utilised:nth-child(even) {
  background: #efe4cc;
}

tbody tr.po-fully-utilised td:first-child {
  border-left: 3px solid #c99a45;
  font-weight: 700;
}

.closed-chip {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid #d0aa62;
  background: rgba(255, 249, 232, 0.75);
  color: #76551c;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  vertical-align: middle;
}

tbody tr.po-fully-utilised.selected {
  background: #d7eacb;
  color: var(--green-dark);
}

tbody tr.invoice-no-lines {
  background: #fff6d8;
}

tbody tr.invoice-no-lines:nth-child(even) {
  background: #fff0c2;
}

tbody tr.invoice-no-lines td:first-child {
  border-left: 3px solid #d69b2c;
  font-weight: 700;
}

tbody tr.invoice-no-lines.selected {
  background: #d7eacb;
}

.no-lines-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid #d69b2c;
  background: #fff9e8;
  color: #7b5510;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  vertical-align: middle;
}

.detail-body {
  overflow: auto;
  padding: 10px;
  overscroll-behavior: contain;
}

.field-group {
  margin-bottom: 13px;
}

.field-group h2 {
  margin: 0 0 7px;
  font-size: 13px;
  color: var(--green-dark);
  border-left: 4px solid var(--accent);
  padding-left: 7px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(94px, 35%) minmax(0, 1fr);
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.detail-grid dt,
.detail-grid dd {
  min-height: 24px;
  margin: 0;
  padding: 4px 7px;
  background: #fff;
}

.detail-grid dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-grid dd {
  overflow-wrap: anywhere;
}

.selection-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.selection-summary-grid div {
  border: 1px solid var(--line);
  background: #fffdf6;
  padding: 7px 8px;
}

.selection-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.selection-summary-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--green-dark);
  font-size: 14px;
  line-height: 1.15;
}

.selection-warning {
  margin: 0 0 8px;
  padding: 7px 8px;
  border: 1px solid #d2a94b;
  background: #fff4cf;
  color: #725200;
  font-weight: 700;
}

.selection-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
}

.selection-action-row button {
  min-height: 30px;
}

.selection-invoice-wrap {
  max-height: 360px;
}

.selection-invoice-wrap th:last-child,
.selection-invoice-wrap td:last-child {
  text-align: right;
  white-space: nowrap;
}

.supplier-payment-selection-summary .wide {
  grid-column: 1 / -1;
}

.selection-payment-wrap {
  max-height: 360px;
}

.selection-payment-wrap table {
  min-width: 660px;
}

.selection-payment-wrap th:last-child,
.selection-payment-wrap td:last-child {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  .supplier-payment-selection-detail .selection-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .supplier-payment-selection-detail .selection-action-row button {
    min-height: 44px;
  }
  .selection-payment-wrap {
    max-height: 44dvh;
  }
}

.audit-payload {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  background: #fbfaf2;
  border: 1px solid var(--line);
  font: 12px/1.45 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
}

.detail-main-value {
  display: block;
}

.account-name-hint {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
}

.related-group {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.related-table-wrap {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
}

.related-table {
  min-width: 720px;
}

.related-table th,
.related-table td {
  height: 26px;
  font-size: 12px;
}

.related-table th {
  background: var(--green-pale);
}

.related-empty {
  border: 1px solid var(--line);
  background: #fff;
}

.editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 10px;
  background: rgba(26, 58, 31, 0.35);
}

.editor-overlay[hidden] {
  display: none;
}

.editor-dialog {
  width: min(1540px, 99vw);
  max-height: 97vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: 0 16px 60px rgba(44, 38, 34, 0.28);
}

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 14px 16px;
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#fffdf6, var(--ivory-dark));
}

.editor-head h2 {
  margin: 0;
  color: var(--green-dark);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 22px;
}

.record-form {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.form-fields {
  overflow: auto;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 10px 14px;
}

.form-field {
  position: relative;
  display: grid;
  gap: 4px;
}

.form-field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.form-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.form-field small {
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 700;
}

.form-field .account-name-hint {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--ink);
  padding: 5px 7px;
  font: inherit;
}

.form-field input[list],
.form-field input[data-lookup-list] {
  border-color: #aeb8a2;
  background-image: linear-gradient(90deg, #fffdf6 0%, #fffdf6 calc(100% - 28px), #eef6e8 calc(100% - 28px));
}

.po-line-editor input[data-lookup-list] {
  border-color: #aeb8a2;
  background-image: linear-gradient(90deg, #fffdf6 0%, #fffdf6 calc(100% - 24px), #eef6e8 calc(100% - 24px));
}

.form-field input[list]:focus,
.form-field input[data-lookup-list]:focus,
.po-line-editor input[data-lookup-list]:focus,
.form-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 159, 194, 0.15);
  outline: none;
}

.lookup-dropdown {
  position: fixed;
  z-index: 10000;
  display: none;
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  box-shadow: 0 10px 22px rgba(16, 45, 28, 0.2);
}

.lookup-dropdown.open {
  display: block;
}

.lookup-helper-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-strong);
  background: #edf6ea;
  color: var(--green-dark);
  font-size: 11px;
}

.lookup-helper-heading span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.lookup-option {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fffdf6;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.lookup-option-inline {
  grid-template-columns: minmax(92px, 130px) 1fr;
  align-items: baseline;
  column-gap: 14px;
}

.lookup-option:last-child {
  border-bottom: 0;
}

.lookup-option:hover,
.lookup-option.active {
  background: #d9f3f6;
}

.lookup-option-value {
  color: var(--green-dark);
  font-weight: 800;
}

.lookup-option-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lookup-option-inline .lookup-option-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.lookup-empty {
  padding: 9px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 700px) {
  .lookup-dropdown {
    border: 2px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(16, 45, 28, 0.3);
  }

  .lookup-helper-heading {
    min-height: 34px;
    padding: 7px 9px;
  }

  .lookup-option {
    min-height: 48px;
    padding: 9px;
  }

  .lookup-option-inline {
    grid-template-columns: minmax(70px, 96px) minmax(0, 1fr);
    column-gap: 8px;
  }

  .lookup-option-value {
    font-size: 14px;
  }

  .lookup-option-inline .lookup-option-label {
    overflow: visible;
    font-size: 13px;
    line-height: 1.25;
    text-overflow: clip;
    white-space: normal;
  }

  .lookup-dropdown.lookup-dropdown-products {
    max-height: 210px;
    border-width: 1px;
    border-radius: 6px;
  }

  .lookup-dropdown-products .lookup-helper-heading {
    min-height: 28px;
    padding: 4px 8px;
  }

  .lookup-dropdown-products .lookup-option {
    min-height: 44px;
    gap: 0;
    padding: 5px 8px;
  }

  .lookup-dropdown-products .lookup-option-inline {
    grid-template-columns: minmax(64px, 88px) minmax(0, 1fr);
    column-gap: 7px;
  }

  .lookup-dropdown-products .lookup-option-value {
    font-size: 13px;
  }

  .lookup-dropdown-products .lookup-option-inline .lookup-option-label {
    font-size: 12px;
    line-height: 1.15;
  }
}

.form-field .lookup-status {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
}

.form-field .lookup-status.matched {
  color: #16804a;
}

.form-field .lookup-status.missing {
  color: #a36800;
}

.lookup-quick-add {
  margin-left: 6px;
  padding: 2px 7px;
  border: 1px solid var(--accent);
  background: #e4f7fb;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.lookup-quick-add:hover {
  background: #d1f0f6;
}

.quick-add-backdrop {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(15, 45, 28, 0.22);
}

.quick-add-panel {
  width: min(520px, calc(100vw - 28px));
  border: 1px solid var(--line-strong);
  border-top: 4px solid var(--accent);
  background: #fffdf6;
  box-shadow: 0 18px 40px rgba(16, 45, 28, 0.28);
  padding: 14px 16px;
  display: grid;
  gap: 12px;
}

.quick-add-panel-full {
  width: min(1180px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  align-self: stretch;
  grid-template-rows: auto 1fr auto auto;
}

.quick-add-master-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 10px 12px;
  align-content: start;
}

.quick-add-title {
  display: grid;
  gap: 2px;
}

.quick-add-title span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.quick-add-title strong {
  color: var(--green-dark);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 24px;
}

.quick-add-panel label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.quick-add-panel input {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--ink);
  padding: 6px 8px;
  font: inherit;
}

.quick-add-panel textarea {
  min-height: 76px;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--ink);
  padding: 6px 8px;
  font: inherit;
}

.quick-add-extra-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-add-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quick-add-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: -14px;
  margin: 0 -16px -14px;
  padding: 10px 16px;
  background: #ebe4d2;
  border-top: 1px solid var(--line);
}

.quick-add-actions button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(#fffdf6, #ebe4d2);
  color: var(--ink);
  padding: 6px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.quick-add-actions button:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 3px rgba(16, 45, 28, 0.25);
}

.form-field textarea {
  min-height: 70px;
  resize: vertical;
}

.form-field.readonly input {
  background: #eee8d8;
}

.form-tool-strip {
  align-items: center;
  background: #f2ead4;
  border: 1px solid var(--line);
  display: flex;
  gap: 16px;
  grid-column: 1 / -1;
  justify-content: space-between;
  padding: 14px 16px;
}

.form-tool-strip span {
  color: var(--muted);
  display: block;
  font-size: 0.9rem;
  margin-top: 3px;
}

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

.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: var(--ivory-dark);
}

/* Keep the desktop Sales Order action bar above its wide scrollable line editor. */
.editor-dialog.sales-order-dialog .form-fields {
  position: relative;
  z-index: 0;
}

.editor-dialog.sales-order-dialog .editor-actions {
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

.editor-dialog.sales-order-dialog #saveRecordBtn {
  position: relative;
  z-index: 11;
  pointer-events: auto;
}

#formStatus {
  color: var(--muted);
  flex: 1;
  font-weight: 700;
  min-width: 0;
}

#editorAddLineBtn {
  margin-left: auto;
}

.empty {
  padding: 20px;
  color: var(--muted);
}

.transaction-line-wrap {
  max-height: 360px;
}

.transaction-line-table {
  min-width: 1040px;
}

.transaction-line-table td,
.transaction-line-table th {
  min-width: 110px;
}

.transaction-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.transaction-section-title.tab-only {
  justify-content: flex-end;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  background: #fffdf6;
}

.transaction-section-title h3 {
  margin: 0;
}

.editor-inline-tabs {
  display: flex;
  gap: 4px;
}

.editor-inline-tab {
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--green-dark);
  padding: 4px 11px;
  font-weight: 800;
  cursor: pointer;
}

.editor-inline-tab.active {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: #fffdf6;
}

.editor-inline-tab:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hidden-section {
  display: none;
}

.statement-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.statement-summary div {
  border: 1px solid var(--line);
  background: #fffdf6;
  padding: 8px 10px;
}

.statement-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.statement-summary strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.15;
  white-space: nowrap;
}

.statement-summary .final-balance {
  background: var(--green-pale);
}

.statement-table-wrap {
  margin-top: 12px;
  overflow: auto;
  max-height: 430px;
}

.statement-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: fixed;
}

.statement-table th,
.statement-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  background: #fffdf6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.statement-table th {
  background: var(--blue-pale);
  text-align: left;
}

.statement-table th:nth-child(1),
.statement-table td:nth-child(1) { width: 94px; }

.statement-table th:nth-child(2),
.statement-table td:nth-child(2) { width: 112px; }

.statement-table th:nth-child(3),
.statement-table td:nth-child(3) { width: 145px; }

.statement-table th:nth-child(4),
.statement-table td:nth-child(4) {
  width: auto;
}

.statement-table th:nth-child(5),
.statement-table td:nth-child(5),
.statement-table th:nth-child(6),
.statement-table td:nth-child(6),
.statement-table th:nth-child(7),
.statement-table td:nth-child(7) { width: 105px; }

.statement-table .statement-ref-cell {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: normal;
}

.statement-table .statement-details-cell {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.25;
}

.note-info-group {
  padding-top: 8px;
}

.note-summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.note-summary-row div {
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px 7px;
  min-width: 0;
}

.note-summary-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.note-summary-row strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.15;
  white-space: nowrap;
}

.note-table-wrap {
  max-height: 132px;
  overflow: auto;
}

.note-info-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.note-info-table th,
.note-info-table td {
  min-width: 0;
  height: 23px;
  padding: 3px 6px;
  white-space: nowrap;
}

.note-info-table th:nth-child(1),
.note-info-table td:nth-child(1) { width: 48px; }

.note-info-table th:nth-child(2),
.note-info-table td:nth-child(2) { width: 78px; }

.note-info-table th:nth-child(3),
.note-info-table td:nth-child(3) { width: 74px; }

.note-info-table th:nth-child(4),
.note-info-table td:nth-child(4),
.note-info-table th:nth-child(5),
.note-info-table td:nth-child(5),
.note-info-table th:nth-child(6),
.note-info-table td:nth-child(6) {
  width: 78px;
}

.note-info-table th:nth-child(7),
.note-info-table td:nth-child(7) { width: 50px; }

.payment-table-wrap {
  margin-top: 8px;
  max-height: 150px;
  overflow: auto;
}

.payment-table {
  width: 100%;
  min-width: 610px;
  table-layout: fixed;
}

.payment-table th,
.payment-table td {
  min-width: 0;
  height: 22px;
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.payment-table th:nth-child(1),
.payment-table td:nth-child(1) {
  width: 92px;
}

.payment-table th:nth-child(2),
.payment-table td:nth-child(2) {
  width: 88px;
}

.payment-table th:nth-child(3),
.payment-table td:nth-child(3) {
  width: 52px;
}

.payment-table th:nth-child(4),
.payment-table td:nth-child(4) {
  width: 82px;
}

.payment-table th:nth-child(5),
.payment-table td:nth-child(5) {
  width: 92px;
}

.payment-table th:nth-child(6),
.payment-table td:nth-child(6) {
  width: 66px;
}

.payment-table th:nth-child(7),
.payment-table td:nth-child(7) {
  width: 92px;
}

.payment-table .numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.payment-card-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.settlement-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.settlement-summary-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px 7px;
}

.settlement-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.settlement-summary-grid strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.15;
  white-space: nowrap;
}

.settlement-summary-grid .final-balance {
  background: var(--green-pale);
  border-color: #bfd4b9;
}

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

.sales-order-qty-grid strong {
  font-size: 12px;
}

.sales-order-qty-grid .sales-order-progress-cell {
  background: #f7f3e5;
  border-color: #d8cfaf;
}

.sales-order-qty-grid .sales-order-progress-cell.overload {
  background: #fff0e8;
  border-color: #e4b29b;
}

.sales-order-qty-grid .sales-order-progress-cell.overload strong,
.so-mobile-progress-spot strong.overload {
  color: #9a3e16;
}

.sales-order-tolerance-note {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
  padding: 6px 8px;
  border: 1px solid #d8cfaf;
  background: #f7f3e5;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.sales-order-tolerance-note strong {
  color: var(--green-dark);
}

.sales-order-statement-title {
  margin-top: 12px;
}

.sales-order-statement-actions {
  margin: 0 0 7px;
  justify-content: flex-start;
}

.sales-order-statement-actions button {
  min-height: 28px;
  padding: 4px 9px;
}

.sales-order-statement-table {
  width: 520px;
  min-width: 520px;
  table-layout: fixed;
}

.sales-order-statement-table th,
.sales-order-statement-table td {
  white-space: nowrap;
}

.sales-order-statement-table th:nth-child(1) { width: 86px; }
.sales-order-statement-table th:nth-child(2) { width: 118px; }
.sales-order-statement-table th:nth-child(3) { width: 82px; }
.sales-order-statement-table th:nth-child(4) { width: 52px; }

.sales-order-statement-table th:nth-child(3),
.sales-order-statement-table td:nth-child(3) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.compact-empty {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 7px;
  font-size: 12px;
}

.payment-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  padding: 8px;
}

.payment-card h3 {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 13px;
  line-height: 1.2;
}

.compact-grid {
  font-size: 12px;
}

.compact-grid dt,
.compact-grid dd {
  padding: 4px 6px;
}

.po-import-table-wrap {
  margin-top: 8px;
  max-height: 170px;
  overflow-y: auto;
  overflow-x: hidden;
}

.po-import-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.po-import-table th,
.po-import-table td {
  min-width: 0;
  height: 24px;
  padding: 4px 6px;
  overflow-wrap: normal;
  word-break: normal;
}

.po-import-table th:nth-child(1),
.po-import-table td:nth-child(1) {
  width: 36%;
}

.po-import-table th:nth-child(2),
.po-import-table td:nth-child(2) {
  width: 26%;
}

.po-import-table th:nth-child(3),
.po-import-table td:nth-child(3) {
  width: 38%;
}

.po-import-table th {
  font-size: 11px;
}

.po-import-table td {
  font-size: 11px;
}

.po-import-table .numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.transaction-footnote {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 700;
}

.transaction-form-fields {
  display: block;
}

.transaction-editor {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.transaction-section {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fffdf6;
}

.transaction-section h3 {
  margin: 0;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#fbf8ef, var(--gold-pale));
  color: var(--green-dark);
  font-size: 14px;
}

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

.transaction-grid .form-field {
  align-content: start;
  gap: 5px;
}

.transaction-grid .form-field label {
  min-height: 14px;
  line-height: 1.2;
}

.transaction-grid .form-field input,
.transaction-grid .form-field textarea,
.transaction-grid .form-field select {
  line-height: 1.25;
}

.transaction-grid .form-field input,
.transaction-grid .form-field select {
  height: 34px;
}

.sales-order-commission-print .sales-order-commission-check {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.transaction-grid .sales-order-commission-print .sales-order-commission-check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0;
  padding: 0;
}

.sales-order-commission-print .sales-order-commission-check > span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.sales-order-kiv-status .sales-order-kiv-check {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 6px 9px;
  border: 1px solid #d5a4a4;
  background: #fff7f7;
  color: #8f1d1d;
  font-size: 12px;
  font-weight: 800;
}

.transaction-grid .sales-order-kiv-status .sales-order-kiv-check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0;
  padding: 0;
}

.sales-order-kiv-status .sales-order-kiv-check > span {
  color: #8f1d1d;
  font-size: 12px;
  font-weight: 900;
}

.transaction-grid .wide {
  grid-column: span 2;
}

.bank-cash-form {
  padding: 6px 8px;
}

.editor-dialog.bank-cash-dialog {
  width: min(1540px, 99vw);
  max-height: 97vh;
}

.editor-dialog.bank-cash-dialog .editor-head {
  padding: 8px 12px;
}

.editor-dialog.bank-cash-dialog .editor-head h2 {
  font-size: 21px;
}

.editor-dialog.bank-cash-dialog .editor-actions {
  padding: 7px 10px;
}

.bank-cash-form .transaction-editor {
  gap: 8px;
}

.bank-cash-form .transaction-section {
  overflow: visible;
}

.bank-cash-form .bank-cash-header-section {
  background: linear-gradient(#f8fff6, #d7f3df);
}

.bank-cash-form .bank-cash-grid {
  grid-template-columns: 1fr 1.05fr 1.12fr 1fr 1.15fr 1fr;
  grid-template-areas:
    "voucher date type bank ref currency"
    "payto payto payto rate account cleared"
    "remarks remarks remarks remarks account cleared";
  gap: 6px 10px;
  padding: 8px 10px 7px;
  align-items: start;
}

.bank-cash-form .transaction-grid .form-field {
  gap: 2px;
  min-width: 0;
  align-self: start;
}

.bank-cash-form .bank-field-voucher { grid-area: voucher; }
.bank-cash-form .bank-field-date { grid-area: date; }
.bank-cash-form .bank-field-type { grid-area: type; }
.bank-cash-form .bank-field-bank { grid-area: bank; }
.bank-cash-form .bank-field-ref { grid-area: ref; }
.bank-cash-form .bank-field-currency { grid-area: currency; }
.bank-cash-form .bank-field-payto { grid-area: payto; }
.bank-cash-form .bank-field-rate { grid-area: rate; }
.bank-cash-form .bank-field-account { grid-area: account; }
.bank-cash-form .bank-field-cleared { grid-area: cleared; }
.bank-cash-form .bank-field-remarks { grid-area: remarks; }

.bank-cash-form .transaction-grid .form-field label,
.bank-cash-form .transaction-grid .form-field span {
  min-height: 12px;
  color: #4f594b;
  font-size: 10px;
  line-height: 1.05;
  text-transform: uppercase;
}

.bank-cash-form .transaction-grid .form-field input,
.bank-cash-form .transaction-grid .form-field select {
  height: 28px;
  min-height: 28px;
  padding: 3px 6px;
}

.bank-cash-form .transaction-grid .form-field textarea {
  height: 42px;
  min-height: 42px;
  padding: 4px 6px;
  resize: vertical;
}

.bank-cash-form .form-field .lookup-status,
.bank-cash-form .form-field .account-name-hint {
  margin-top: 1px;
  font-size: 9px;
  line-height: 1.1;
}

.bank-cash-form .line-head {
  align-items: center;
  min-height: 34px;
  padding-right: 8px;
}

.bank-cash-form .line-head h3 {
  padding: 7px 9px;
  font-size: 13px;
}

.bank-cash-form .line-actions {
  align-items: center;
  gap: 6px;
  margin-right: 0;
  max-width: none;
}

.bank-cash-form .line-actions button,
.bank-cash-form .voucher-print-option {
  min-height: 28px;
}

.bank-cash-form .voucher-print-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.bank-cash-form .voucher-print-option input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.bank-cash-form .po-line-scroll {
  max-height: min(51vh, 520px);
}

.bank-cash-form .po-line-editor {
  min-width: 1260px;
}

.bank-cash-form .po-line-editor th,
.bank-cash-form .po-line-editor td {
  padding: 2px;
  vertical-align: middle;
}

.bank-cash-form .po-line-editor th {
  font-size: 11px;
  line-height: 1.1;
}

.bank-cash-form .po-line-editor input,
.bank-cash-form .po-line-editor select {
  min-height: 28px;
  height: 28px;
  padding: 3px 5px;
}

.bank-cash-form .po-line-editor textarea {
  min-height: 44px;
  padding: 4px 5px;
  resize: vertical;
}

.bank-cash-form .bank-payment-line-editor td:nth-child(4) {
  vertical-align: top;
}

.bank-cash-form .bank-col-serial { width: 42px; }
.bank-cash-form .bank-col-account { width: 126px; }
.bank-cash-form .bank-col-account-name { width: 170px; }
.bank-cash-form .bank-col-description { width: 360px; }
.bank-cash-form .bank-col-amount { width: 120px; }
.bank-cash-form .bank-col-gst-code { width: 144px; }
.bank-cash-form .bank-col-gst-percent { width: 72px; }
.bank-cash-form .bank-col-gst-amount { width: 92px; }
.bank-cash-form .bank-col-gst-only { width: 70px; }
.bank-cash-form .bank-col-total { width: 92px; }
.bank-cash-form .bank-col-action { width: 72px; }

.bank-cash-form .account-name-cell {
  font-size: 12px;
  line-height: 1.18;
}

.bank-cash-form .po-total-bar {
  padding: 7px 10px;
}

.bank-cash-form .po-total-bar span {
  font-size: 13px;
}

.posting-account-panel {
  grid-column: 1 / -1;
  border: 1px solid var(--line-strong);
  background: #f6f1df;
  padding: 10px;
}

.posting-account-panel h4 {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 14px;
  letter-spacing: 0;
}

.posting-account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px 10px;
}

.posting-account-grid .form-field {
  margin: 0;
}

.line-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#fbf8ef, var(--gold-pale));
}

.line-head h3 {
  border-bottom: 0;
  background: transparent;
}

.line-head button {
  margin-right: 10px;
}

.line-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  margin-right: 10px;
  max-width: calc(100% - 190px);
}

.line-actions button {
  margin-right: 0;
  white-space: nowrap;
}

.batch-gst-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.batch-gst-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

#batchPoGstCode,
#batchQuotationGstCode,
#batchCustomerInvoiceGstCode {
  min-width: 150px;
  height: 32px;
  border: 1px solid var(--line-strong);
  background: #fffbc7;
  color: var(--green-dark);
  font: inherit;
  font-weight: 700;
}

.document-print-control {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 3px 7px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.46);
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 700;
}

.document-print-control > span {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 2px;
}

.document-print-control label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  line-height: 1;
}

.document-print-control input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--teal);
}

.po-line-scroll {
  overflow: auto;
  max-width: 100%;
}

.po-line-editor {
  width: 100%;
  min-width: 1220px;
  table-layout: fixed;
}

.po-line-editor th,
.po-line-editor td {
  height: auto;
  min-width: 0;
  max-width: none;
  padding: 3px;
  vertical-align: top;
}

.po-line-editor .po-col-serial { width: 54px; }
.po-line-editor .po-col-product { width: 118px; }
.po-line-editor .po-col-so { width: 64px; }
.po-line-editor .po-col-details { width: 340px; }
.po-line-editor .po-col-pack-bales { width: 76px; }
.po-line-editor .po-col-qty { width: 98px; }
.po-line-editor .po-col-uom { width: 70px; }
.po-line-editor .po-col-price { width: 104px; }
.po-line-editor .po-col-gst-code { width: 92px; }
.po-line-editor .po-col-gst-percent { width: 70px; }
.po-line-editor .po-col-gst-amount { width: 92px; }
.po-line-editor .po-col-account { width: 98px; }
.po-line-editor .po-col-gst-only { width: 70px; }
.po-line-editor .po-col-total { width: 104px; }
.po-line-editor .po-col-action { width: 74px; }

.customer-invoice-line-editor th:first-child {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  text-align: center;
}

.quote-line-editor th,
.quote-line-editor td {
  text-align: left;
  vertical-align: top;
}

.quote-line-editor th:nth-child(1),
.quote-line-editor td:nth-child(1),
.quote-line-editor th:nth-child(10),
.quote-line-editor td:nth-child(10) {
  text-align: center;
}

.quote-line-editor th:nth-child(4),
.quote-line-editor td:nth-child(4),
.quote-line-editor th:nth-child(6),
.quote-line-editor td:nth-child(6),
.quote-line-editor th:nth-child(8),
.quote-line-editor td:nth-child(8),
.quote-line-editor th:nth-child(9),
.quote-line-editor td:nth-child(9) {
  text-align: right;
}

.quote-line-editor input,
.quote-line-editor textarea {
  display: block;
}

.quote-line-editor .number-input,
.quote-line-editor .line-total {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.quote-line-editor .line-total {
  padding: 10px 7px 3px;
  white-space: nowrap;
}

.quote-line-editor .line-delete {
  width: 100%;
  min-width: 0;
}

.si-line-editor {
  min-width: 1280px;
}

.quote-line-editor .po-col-details,
.si-line-editor .po-col-details {
  width: 360px;
}

.line-sales-order-cell {
  min-width: 62px;
  white-space: nowrap;
  vertical-align: top;
}

.line-apply-sales-order {
  min-width: 36px;
  max-width: 42px;
  padding: 3px 5px;
  font-size: 11px;
  line-height: 1.1;
}

.line-clear-sales-order {
  min-width: 20px;
  margin-left: 2px;
  padding: 3px 4px;
  border-color: #c9b975;
  color: #8a4b00;
  font-size: 11px;
  line-height: 1.1;
}

.sales-order-tag-summary {
  margin: 0 0 6px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: #f8f5df;
  color: var(--ink);
  font-size: 12px;
}

.sales-order-tag-summary strong {
  display: inline-block;
  margin-right: 8px;
  color: var(--green);
}

.sales-order-tag-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  vertical-align: middle;
}

.sales-order-tag-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  max-width: 260px;
  padding: 3px 7px;
  border: 1px solid #c9b975;
  background: #fffbea;
  white-space: nowrap;
}

.sales-order-tag-chip b {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sales-order-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 32, 20, 0.62);
}

.sales-order-picker {
  width: min(920px, calc(100vw - 36px));
  min-width: 0;
  max-height: min(680px, calc(100vh - 36px));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #b8b198;
  border-top: 4px solid var(--accent);
  border-radius: 10px;
  background: #fffdf6;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.sales-order-picker-head,
.sales-order-picker-foot {
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #f7f2e2;
  border-bottom: 1px solid var(--line);
}

.sales-order-picker-head > div {
  min-width: 0;
  flex: 1;
}

.sales-order-picker-head > button {
  flex: 0 0 auto;
}

.sales-order-picker-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.sales-order-picker-head h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--green);
}

.sales-order-picker-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.sales-order-picker-status {
  padding: 8px 12px;
  border-bottom: 1px solid #cbd8ca;
  background: #edf6ee;
  color: var(--green);
  font-weight: 700;
}

.sales-order-picker-body {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: auto;
  padding: 10px 12px 12px;
  background: #f1ede0;
}

.sales-order-picker-entry {
  min-width: 0;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  margin: 0 0 7px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fffef9;
  box-shadow: 0 1px 3px rgba(35, 46, 32, 0.08);
}

.sales-order-picker-row {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: auto;
  min-height: 44px;
  display: grid;
  grid-template-columns: 145px 82px 82px minmax(170px, 1fr) 120px 56px;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 0;
  background: #fffef9;
  color: var(--ink);
  line-height: 1.2;
  text-align: left;
  box-shadow: none;
}

.sales-order-picker-row > span {
  min-width: 0;
}

.sales-order-picker-row:hover,
.sales-order-picker-row:focus {
  background: #eaf8fb;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.sales-order-picker-entry.sales-order-picker-kiv {
  border-color: #d99a9a;
  background: #fff1f1;
}

.sales-order-picker-entry.sales-order-picker-kiv .sales-order-picker-row {
  background: #fff1f1;
}

.sales-order-picker-entry.sales-order-picker-kiv .sales-order-picker-row:hover,
.sales-order-picker-entry.sales-order-picker-kiv .sales-order-picker-row:focus {
  background: #ffe5e5;
}

.sales-order-picker-apply-all {
  align-self: stretch;
  min-width: 82px;
  min-height: 34px;
  margin: 7px;
  padding: 5px 9px;
  border: 1px solid var(--green-mid);
  border-radius: 6px;
  background: #eef6ee;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: none;
}

.sales-order-picker-apply-all:hover,
.sales-order-picker-apply-all:focus {
  background: var(--green-dark);
  color: #fff;
}

.so-picker-kiv-badge {
  display: inline-block;
  margin-left: 0;
  padding: 2px 5px;
  border-radius: 3px;
  background: #a92a2a;
  color: #fff;
  font-size: 10px;
}

.so-picker-doc {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  color: var(--green);
  font-weight: 800;
  white-space: normal;
}

.so-picker-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.so-picker-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.so-picker-number small {
  display: block;
  margin-top: 2px;
  color: #a92a2a;
  font-size: 10px;
  font-weight: 700;
}

.supplier-note-line-editor {
  min-width: 980px;
}

.bank-payment-line-editor {
  min-width: 1450px;
}

.bank-payment-line-editor .bank-col-serial { width: 48px; }
.bank-payment-line-editor .bank-col-account { width: 132px; }
.bank-payment-line-editor .bank-col-account-name { width: 220px; }
.bank-payment-line-editor .bank-col-description { width: 320px; }
.bank-payment-line-editor .bank-col-amount { width: 120px; }
.bank-payment-line-editor .bank-col-gst-code { width: 160px; }
.bank-payment-line-editor .bank-col-gst-percent { width: 76px; }
.bank-payment-line-editor .bank-col-gst-amount { width: 108px; }
.bank-payment-line-editor .bank-col-gst-only { width: 78px; }
.bank-payment-line-editor .bank-col-total { width: 108px; }
.bank-payment-line-editor .bank-col-action { width: 90px; }

.journal-line-editor {
  min-width: 940px;
}

.journal-line-editor .bank-col-serial { width: 54px; }
.journal-line-editor .bank-col-account { width: 118px; }
.journal-line-editor .bank-col-account-name { width: 240px; }
.journal-line-editor .bank-col-description { width: auto; }
.journal-line-editor .bank-col-amount { width: 120px; }
.journal-line-editor .bank-col-action { width: 74px; }

.bank-payment-line-editor th,
.bank-payment-line-editor td,
.journal-line-editor th,
.journal-line-editor td {
  vertical-align: top;
}

.bank-payment-line-editor .serial-cell,
.journal-line-editor .serial-cell {
  text-align: center;
  font-weight: 800;
  color: var(--green-dark);
}

.bank-payment-line-editor .account-name-cell,
.journal-line-editor .account-name-cell {
  font-size: 13px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.bank-payment-line-editor textarea[name="bank_line_description"] {
  min-height: 74px;
}

.bank-payment-line-editor select[name="bank_line_gst_code"] {
  overflow: hidden;
  text-overflow: ellipsis;
}

.bank-payment-line-editor .allocation-delete {
  width: 100%;
  min-width: 0;
  padding-left: 6px;
  padding-right: 6px;
}

.note-allocation-editor {
  min-width: 880px;
}

.note-allocation-editor th,
.note-allocation-editor td {
  text-align: left;
  vertical-align: middle;
}

.note-allocation-editor .number-input,
.note-allocation-editor .allocation-total,
.supplier-note-line-editor .number-input,
.supplier-note-line-editor .line-total {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.po-line-serial {
  color: var(--green-dark);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: #f5f1e4;
  text-align: center;
  position: relative;
}

.po-line-editor input,
.po-line-editor textarea,
.po-line-editor select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  padding: 3px 5px;
  font: inherit;
}

.po-line-editor .line-serial-input {
  min-height: 30px;
  text-align: center;
  font-weight: 800;
  color: var(--green-dark);
  background: #fffdf6;
  padding-left: 15px;
  padding-right: 2px;
}

.line-drag-handle {
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  min-width: 13px;
  height: 24px;
  min-height: 24px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  font: inherit;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
  z-index: 1;
}

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

.line-drag-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.draggable-line-row.dragging-line-row {
  opacity: 0.55;
}

.draggable-line-row.drag-over-line-row td {
  box-shadow: inset 0 2px 0 var(--accent);
}

.po-line-editor textarea {
  min-height: 64px;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.po-line-editor .number-input,
.line-total {
  text-align: right;
}

.supplier-payment-allocation-editor {
  min-width: 980px;
}

.voucher-print-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 8px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.voucher-print-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--green-dark);
}

.attachment-panel {
  border: 1px solid var(--line);
  background: rgba(250, 247, 231, 0.88);
  padding: 9px 10px;
}

.attachment-head,
.attachment-actions,
.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attachment-head {
  justify-content: space-between;
  margin-bottom: 7px;
}

.attachment-head strong {
  color: var(--green-dark);
}

.attachment-head span,
.attachment-item small,
.attachment-empty {
  color: var(--muted);
  font-size: 11px;
}

.attachment-actions {
  margin-bottom: 7px;
}

.attachment-actions input[type="file"] {
  flex: 1 1 auto;
}

.attachment-dropzone {
  border: 1px dashed var(--line-strong);
  background: rgba(232, 247, 242, 0.65);
  color: var(--green-dark);
  min-height: 34px;
  display: grid;
  place-items: center;
  margin: 0 0 7px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.attachment-dropzone.is-dragging {
  border-color: var(--accent);
  background: rgba(214, 244, 252, 0.9);
  color: var(--accent);
}

.attachment-dropzone.disabled {
  opacity: 0.55;
  background: rgba(240, 236, 218, 0.75);
  color: var(--muted);
}

.attachment-list {
  display: grid;
  gap: 4px;
}

.attachment-item {
  justify-content: space-between;
  border-top: 1px solid rgba(190, 181, 151, 0.55);
  padding-top: 4px;
}

.attachment-item span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  line-height: 20px;
  text-align: center;
  color: #7a1e1e;
  border-color: #b58b8b;
  background: #fff6f1;
}

.supplier-payment-allocation-editor th,
.supplier-payment-allocation-editor td {
  padding: 4px 5px;
  vertical-align: middle;
  text-align: left;
}

.supplier-payment-allocation-editor th {
  height: 30px;
  line-height: 1.15;
  white-space: nowrap;
}

.supplier-payment-allocation-editor input {
  height: 32px;
  min-height: 32px;
  line-height: 1.2;
}

.supplier-payment-allocation-editor .number-input,
.supplier-payment-allocation-editor .allocation-settled,
.supplier-payment-allocation-editor td:nth-child(3) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.supplier-payment-allocation-editor th:nth-child(1),
.supplier-payment-allocation-editor td:nth-child(1) { width: 132px; }

.supplier-payment-allocation-editor th:nth-child(2),
.supplier-payment-allocation-editor td:nth-child(2) { width: 112px; }

.supplier-payment-allocation-editor th:nth-child(3),
.supplier-payment-allocation-editor td:nth-child(3),
.supplier-payment-allocation-editor th:nth-child(4),
.supplier-payment-allocation-editor td:nth-child(4),
.supplier-payment-allocation-editor th:nth-child(5),
.supplier-payment-allocation-editor td:nth-child(5),
.supplier-payment-allocation-editor th:nth-child(6),
.supplier-payment-allocation-editor td:nth-child(6),
.supplier-payment-allocation-editor th:nth-child(7),
.supplier-payment-allocation-editor td:nth-child(7),
.supplier-payment-allocation-editor th:nth-child(8),
.supplier-payment-allocation-editor td:nth-child(8) {
  width: 112px;
}

.supplier-payment-allocation-editor th:nth-child(9),
.supplier-payment-allocation-editor td:nth-child(9) {
  width: 76px;
}

.customer-receipt-allocation-editor {
  min-width: 1080px;
  table-layout: fixed;
}

.customer-receipt-allocation-editor th,
.customer-receipt-allocation-editor td {
  padding: 5px 6px;
}

.customer-receipt-allocation-editor th:nth-child(1),
.customer-receipt-allocation-editor td:nth-child(1) { width: 130px; }

.customer-receipt-allocation-editor th:nth-child(2),
.customer-receipt-allocation-editor td:nth-child(2) { width: 108px; }

.customer-receipt-allocation-editor th:nth-child(3),
.customer-receipt-allocation-editor td:nth-child(3) { width: 118px; }

.customer-receipt-allocation-editor th:nth-child(4),
.customer-receipt-allocation-editor td:nth-child(4),
.customer-receipt-allocation-editor th:nth-child(5),
.customer-receipt-allocation-editor td:nth-child(5) {
  width: 104px;
}

.customer-receipt-allocation-editor th:nth-child(6),
.customer-receipt-allocation-editor td:nth-child(6) {
  width: 88px;
}

.customer-receipt-allocation-editor th:nth-child(7),
.customer-receipt-allocation-editor td:nth-child(7) {
  width: 112px;
}

.customer-receipt-allocation-editor th:nth-child(8),
.customer-receipt-allocation-editor td:nth-child(8) {
  width: 190px;
}

.customer-receipt-allocation-editor th:nth-child(9),
.customer-receipt-allocation-editor td:nth-child(9) {
  width: 82px;
}

.customer-receipt-allocation-editor .lookup-note {
  margin-top: 3px;
  line-height: 1.15;
  white-space: normal;
}

.customer-receipt-allocation-editor input[name="receipt_allocation_debit_account"] {
  min-width: 148px;
}

.customer-receipt-allocation-editor .receipt-fx-net-cell input[name="receipt_fx_net"] {
  min-width: 70px;
}

.po-total-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 22px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--ivory-dark);
  color: var(--green-dark);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.po-total-bar .total-inline-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
}

.po-total-bar .total-inline-input input {
  width: 96px;
  min-height: 28px;
  padding: 4px 6px;
  text-align: right;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.po-total-bar .negative-money {
  color: #a43d2e;
}

.wbs-picker-dialog {
  width: min(1120px, calc(100vw - 24px));
  max-height: 90vh;
}

.wbs-picker-body {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.wbs-picker-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 180px)) minmax(220px, 1fr) minmax(128px, auto) minmax(118px, auto);
  gap: 8px;
  align-items: end;
}

.wbs-picker-controls label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.wbs-picker-controls input {
  height: 34px;
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  padding: 4px 7px;
  font: inherit;
}

.wbs-picker-controls .wbs-toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px;
  height: 34px;
  border: 1px solid var(--line-strong);
  background: var(--ivory-dark);
  padding: 4px 10px;
  color: var(--ink);
  font-size: 13px;
  text-transform: none;
  white-space: nowrap;
}

.wbs-picker-controls .wbs-toggle input {
  width: auto;
  height: auto;
  padding: 0;
}

.wbs-picker-status,
.wbs-empty {
  color: var(--muted);
  font-weight: 700;
  padding: 6px 0;
}

.wbs-picker-status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.wbs-date-sort-btn {
  min-width: 72px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--ivory-dark);
  color: var(--green-dark);
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .wbs-date-sort-btn {
    min-width: 68px;
    min-height: 44px;
    padding: 7px 8px;
    font-size: 12px;
  }
}

.wbs-bulk-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}

.wbs-bulk-actions + button {
  margin-left: 0;
}

#importSelectedWbsBtn {
  min-width: 112px;
  white-space: nowrap;
  text-align: center;
}

.wbs-ticket-list {
  display: grid;
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 4px;
}

.wbs-ticket-card {
  border: 1px solid var(--line);
  background: var(--soft);
}

.po-picker-controls {
  grid-template-columns: minmax(260px, 1fr) auto auto;
}

@media (max-width: 820px) {
  .wbs-picker-dialog {
    width: calc(100vw - 16px);
  }

  .wbs-picker-controls,
  .po-picker-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wbs-picker-controls label:nth-child(3),
  .wbs-picker-controls > button {
    grid-column: 1 / -1;
  }

  .wbs-picker-controls .wbs-toggle {
    justify-content: start;
  }

  .wbs-picker-dialog .editor-actions {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 8px;
  }

  .wbs-picker-dialog .editor-actions > span {
    flex: 1 0 100%;
  }

  .wbs-bulk-actions {
    flex: 1 1 auto;
    justify-content: flex-start;
    margin-left: 0;
  }

  #importSelectedWbsBtn {
    margin-left: auto;
    width: auto;
  }

  .wbs-ticket-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px 8px;
    padding: 9px 10px;
  }

  .wbs-ticket-head > :nth-child(3) {
    grid-column: 2 / 3;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wbs-ticket-head > :nth-child(4),
  .wbs-ticket-head > :nth-child(5) {
    grid-column: 2 / 3;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: normal;
  }

  .wbs-ticket-head > :nth-child(6) {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    justify-self: end;
    white-space: nowrap;
  }

  .wbs-item {
    grid-template-columns: auto 34px minmax(0, 1fr) auto;
    gap: 5px 8px;
    padding: 9px 10px 9px 30px;
  }

  .wbs-item > :nth-child(3) {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .wbs-item > :nth-child(4),
  .wbs-item > :nth-child(5) {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
  }

  .wbs-item > :nth-child(6) {
    grid-column: 4 / 5;
    grid-row: 1 / 3;
    align-self: center;
    justify-self: end;
    white-space: nowrap;
    font-weight: 800;
  }
}

@media (max-width: 560px) {
  .wbs-picker-dialog {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-left: 0;
    border-right: 0;
  }

  .wbs-picker-dialog .editor-head {
    min-height: 54px;
    padding: 9px 12px;
  }

  .wbs-picker-dialog .editor-head h2 {
    font-size: 25px;
    line-height: 1.05;
  }

  .wbs-picker-dialog .form-fields {
    padding: 8px;
  }

  .wbs-picker-body {
    gap: 8px;
    overflow: hidden;
  }

  .wbs-picker-controls,
  .po-picker-controls {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .wbs-picker-controls label {
    gap: 2px;
    font-size: 10px;
  }

  .wbs-picker-controls input,
  .wbs-picker-controls .wbs-toggle,
  .wbs-picker-controls > button {
    min-height: 40px;
    height: auto;
    font-size: 15px;
  }

  .wbs-picker-controls input {
    text-align: left;
    padding: 7px 10px;
  }

  .wbs-picker-controls label:nth-child(1),
  .wbs-picker-controls label:nth-child(2) {
    display: inline-grid;
    width: calc(50% - 4px);
    vertical-align: top;
  }

  .wbs-picker-controls label:nth-child(2) {
    margin-left: 4px;
  }

  .wbs-picker-status,
  .wbs-empty {
    max-height: 76px;
    overflow: auto;
    padding: 7px 8px;
    border: 1px solid var(--line);
    background: #fffdf6;
    font-size: 13px;
    line-height: 1.35;
  }

  .wbs-ticket-list {
    max-height: none;
    min-height: 0;
    padding-right: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .wbs-ticket-card {
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(16, 45, 28, 0.08);
  }

  .wbs-ticket-head {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 9px 9px;
  }

  .wbs-ticket-head input,
  .wbs-item input {
    width: 18px;
    height: 18px;
  }

  .wbs-ticket-head > :nth-child(2) {
    color: var(--green-dark);
    font-size: 15px;
  }

  .wbs-ticket-head > :nth-child(3) {
    font-size: 14px;
    font-weight: 800;
  }

  .wbs-ticket-head > :nth-child(4),
  .wbs-ticket-head > :nth-child(5) {
    display: inline-block;
    grid-column: 2 / 3;
    font-size: 11px;
  }

  .wbs-ticket-head > :nth-child(6) {
    font-size: 12px;
  }

  .wbs-item {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    padding: 9px 9px 9px 26px;
  }

  .wbs-item > :nth-child(2) {
    display: none;
  }

  .wbs-item > :nth-child(3) {
    grid-column: 2 / 3;
    font-size: 14px;
    line-height: 1.25;
  }

  .wbs-item > :nth-child(4),
  .wbs-item > :nth-child(5) {
    grid-column: 2 / 3;
    font-size: 11px;
  }

  .wbs-item > :nth-child(6) {
    grid-column: 3 / 4;
    grid-row: 1 / 4;
    font-size: 13px;
  }

  .wbs-picker-dialog .editor-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .wbs-picker-dialog .editor-actions > span {
    display: block;
    max-height: 54px;
    overflow: auto;
    padding: 7px 8px;
    border: 1px solid var(--line);
    background: #fffdf6;
    font-size: 13px;
    line-height: 1.3;
  }

  .wbs-picker-dialog .editor-actions > span br {
    display: none;
  }

  .wbs-bulk-actions,
  .wbs-bulk-actions button {
    width: 100%;
    min-width: 0;
  }

  .wbs-bulk-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  #importSelectedWbsBtn {
    width: 100%;
    min-width: 0;
  }
}

/* Dedicated phone ticket renderer. Keep independent from desktop WBS rows. */
@media (max-width: 560px) {
  #wbsTicketList > .wbs-mobile-ticket-card {
    display: block !important;
    min-width: 0;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    border: 1px solid #cfc6ac;
    border-radius: 11px;
    background: #fffdf7;
    color: #2c332b;
    box-shadow: 0 2px 7px rgba(28, 51, 33, 0.09);
  }

  #wbsTicketList > .wbs-mobile-ticket-card:has(.wbs-ticket-check:checked) {
    border-color: #3d9eae;
    box-shadow: 0 0 0 2px rgba(39, 157, 178, 0.13), 0 2px 7px rgba(28, 51, 33, 0.09);
  }

  .wbs-mobile-ticket-summary {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    min-height: 88px;
    padding: 12px;
    background: linear-gradient(135deg, #eee6d0 0%, #fffdf7 76%);
  }

  .wbs-mobile-ticket-select {
    display: grid !important;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 9px;
    min-width: 0;
    align-items: start;
    color: #2c332b;
  }

  .wbs-mobile-ticket-select > input {
    display: block !important;
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    opacity: 1;
    accent-color: #218aa0;
  }

  .wbs-mobile-ticket-select > span,
  .wbs-mobile-ticket-select strong,
  .wbs-mobile-ticket-select small {
    display: block !important;
    min-width: 0;
    opacity: 1;
    color: inherit;
  }

  .wbs-mobile-ticket-select strong {
    overflow: hidden;
    color: #173f29;
    font-size: 15px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wbs-mobile-ticket-select small {
    margin-top: 4px;
    overflow: hidden;
    color: #535044;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wbs-mobile-ticket-summary > .wbs-ticket-count {
    display: block !important;
    align-self: start;
    padding: 4px 8px;
    border-radius: 999px;
    background: #dcefe9;
    color: #235f42;
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .wbs-mobile-ticket-meta {
    display: flex !important;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-left: 33px;
    color: #6a6556;
    font-size: 11px;
    font-weight: 700;
  }

  .wbs-mobile-ticket-meta span,
  .wbs-mobile-ticket-meta time {
    display: block !important;
    opacity: 1;
    color: inherit;
  }

  .wbs-mobile-ticket-card > .wbs-ticket-mobile-toggle {
    display: flex !important;
    min-height: 44px;
    opacity: 1;
  }

  .wbs-mobile-ticket-card > .wbs-mobile-ticket-items {
    display: none !important;
  }

  .wbs-mobile-ticket-card.is-expanded > .wbs-mobile-ticket-items {
    display: block !important;
  }

  .wbs-mobile-ticket-items > .wbs-mobile-item-row {
    display: grid !important;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    grid-template-rows: auto;
    gap: 9px;
    min-width: 0;
    min-height: 68px;
    align-items: start;
    padding: 11px 12px;
    border-top: 1px solid #e4dcc8;
    background: #fff;
    color: #2c332b;
  }

  .wbs-mobile-item-row > input {
    display: block !important;
    grid-column: 1;
    grid-row: 1;
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    opacity: 1;
    accent-color: #218aa0;
  }

  .wbs-mobile-item-copy,
  .wbs-mobile-item-values,
  .wbs-mobile-item-copy strong,
  .wbs-mobile-item-copy small,
  .wbs-mobile-item-values b,
  .wbs-mobile-item-values small {
    display: block !important;
    opacity: 1;
  }

  .wbs-mobile-item-copy {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0;
  }

  .wbs-mobile-item-copy strong {
    color: #2c332b;
    font-size: 13px;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .wbs-mobile-item-copy small {
    margin-top: 5px;
    color: #6b675a;
    font-size: 11px;
    line-height: 1.2;
  }

  .wbs-mobile-item-values {
    grid-column: 3 !important;
    grid-row: 1 !important;
    min-width: 82px;
    text-align: right;
  }

  .wbs-mobile-item-values b {
    color: #1d4b2b;
    font-size: 12px;
    white-space: nowrap;
  }

  .wbs-mobile-item-values small {
    margin-top: 5px;
    color: #706b5e;
    font-size: 11px;
    white-space: nowrap;
  }
}

.permission-panel {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fffdf4;
}

.permission-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.permission-panel-head strong {
  color: var(--green);
  font-size: 14px;
}

.permission-panel-head span,
.permission-check small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.permission-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
}

.permission-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-width: 0;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.permission-check input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.permission-check strong,
.permission-check small {
  display: block;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.permission-check strong {
  line-height: 1.2;
}

@media (max-width: 720px) {
  .permission-panel {
    padding: 8px;
  }

  .permission-panel-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .permission-check-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.permission-check-locked {
  opacity: .78;
}

.utility-mini-table tr[data-utility-user-row] {
  cursor: pointer;
}

.utility-mini-table tr[data-utility-user-row]:hover td {
  background: #eef8fb;
}

.po-picker-row {
  display: grid;
  grid-template-columns: 120px 100px 110px repeat(3, minmax(105px, 1fr)) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--ivory-dark);
}

.po-picker-row strong,
.po-picker-row b {
  color: var(--green-dark);
}

.po-picker-row span,
.po-picker-row b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wbs-ticket-head,
.wbs-item {
  display: grid;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
}

.wbs-ticket-head {
  grid-template-columns: auto 92px minmax(180px, 1.4fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr) auto;
  background: var(--ivory-dark);
  font-weight: 700;
}

.wbs-ticket-items {
  display: grid;
}

.wbs-item {
  grid-template-columns: auto 54px minmax(260px, 1fr) 96px 112px 96px 96px;
  border-top: 1px solid var(--line);
}

.wbs-item-weight,
.wbs-item-rate {
  justify-self: end;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wbs-item-serial {
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
}

.wbs-item small {
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

.payment-invoice-picker-dialog {
  width: min(1280px, 96vw);
}

.payment-picker-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.payment-picker-toolbar label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.payment-picker-toolbar input,
.payment-picker-table input {
  border: 1px solid var(--line-strong);
  background: #fffdf6;
  color: var(--ink);
  font: inherit;
}

.payment-picker-toolbar input {
  height: 36px;
  padding: 5px 8px;
}

.payment-picker-sort {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.payment-picker-sort button {
  height: 36px;
  padding: 0 12px;
}

.payment-picker-sort button.is-active {
  border-color: var(--cyan);
  background: #dff4f8;
  color: var(--cyan-dark);
}

.payment-picker-table-wrap {
  max-height: 54vh;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fffdf6;
  position: relative;
}

.payment-picker-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  table-layout: fixed;
}

.payment-picker-table th,
.payment-picker-table td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
  vertical-align: middle;
}

.payment-picker-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--header-blue);
  font-weight: 700;
  box-shadow: 0 1px 0 var(--line-strong);
}

.payment-picker-table .table-sort-button {
  width: 100%;
  height: auto;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.payment-picker-table .table-sort-button.is-active {
  color: var(--green-dark);
}

.payment-picker-table th:first-child,
.payment-picker-table td:first-child {
  width: 36px;
  text-align: center;
}

.payment-picker-table th:nth-child(2) { width: 150px; }
.payment-picker-table th:nth-child(3) { width: 112px; }
.payment-picker-table th:nth-child(5),
.payment-picker-table th:nth-child(6) { width: 140px; }

.payment-picker-table tr.same-supplier {
  background: #f6f0dc;
}

.payment-picker-table tr:hover {
  background: #e7f5ec;
}

.payment-picker-table strong,
.payment-picker-table b {
  color: var(--green-dark);
}

.payment-picker-table small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payment-picker-table .payment-picker-amount {
  width: 100%;
  height: 32px;
  padding: 3px 7px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.payment-picker-empty {
  padding: 20px !important;
  color: var(--muted);
  font-weight: 700;
  text-align: center !important;
}

.payment-picker-footer {
  justify-content: space-between;
}

.payment-picker-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  color: var(--green-dark);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.module-menu-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .app-shell.module-menu-collapsed .sidebar {
    display: none;
  }

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 9px 10px;
  }

  .topbar .eyebrow {
    margin-bottom: 1px;
    font-size: 10px;
  }

  .topbar h1 {
    font-size: 21px;
    line-height: 1.05;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
  }

  .top-actions button {
    min-width: 0;
  }

  .top-actions .search {
    grid-column: 1 / -1;
  }

  .module-menu-btn {
    align-self: stretch;
    height: 30px;
  }

  .search input {
    width: 100%;
  }

  .main {
    grid-template-rows: auto auto auto;
    overflow: auto;
    padding: 10px;
  }

  .summary-strip {
    grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  }

  .summary-strip:has(.statement-filter-card) {
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  }

  .ageing-controls {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .summary-strip:has(.statement-filter-card) .ageing-controls {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .ageing-report-actions {
    justify-content: flex-start;
  }

  .content-grid {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .list-panel {
    height: min(58vh, 520px);
    min-height: 260px;
  }

  .content-grid.awaiting-detail-selection .list-panel {
    height: min(72vh, 680px);
  }

  .detail-panel {
    min-height: 240px;
  }

  .table-wrap,
  .detail-scroll {
    max-height: none;
  }

  .form-fields {
    grid-template-columns: 1fr;
  }

  .transaction-grid {
    grid-template-columns: 1fr;
  }

  .transaction-grid .wide {
    grid-column: auto;
  }

  .editor-overlay {
    place-items: start center;
    padding: 8px;
    overflow: auto;
  }

  .editor-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .editor-head {
    position: sticky;
    top: 0;
    z-index: 3;
  }

  .editor-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
  }
}

@media (max-width: 620px) {
  .ageing-controls {
    grid-template-columns: 1fr;
  }

  .summary-strip:has(.statement-filter-card),
  .summary-strip:has(.statement-filter-card) .ageing-controls {
    grid-template-columns: 1fr;
  }

  .ageing-report-actions,
  .report-controls .ageing-report-actions button {
    width: 100%;
  }
}

@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body {
    font-size: 13px;
    background:
      linear-gradient(135deg, rgba(29, 161, 201, 0.1), rgba(237, 232, 213, 0.96) 44%, rgba(216, 236, 218, 0.76)),
      var(--bg);
  }

  .app-tabs {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    min-height: 42px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding: 7px 8px 0;
    gap: 5px;
  }

  .app-tabs::-webkit-scrollbar {
    display: none;
  }

  .app-tab {
    flex: 0 0 auto;
    min-width: 118px;
    height: 34px;
    padding: 0 12px;
    font-size: 13px;
    letter-spacing: 0.05em;
  }

  .app-shell,
  .app-shell.module-menu-collapsed {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    height: auto;
    min-height: calc(100dvh - 42px);
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    max-height: 48dvh;
    overflow: auto;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .app-shell.module-menu-collapsed .sidebar {
    display: none;
  }

  .brand {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 9px;
    padding: 7px 6px 10px;
  }

  .brand-logo {
    width: 38px;
    max-height: 38px;
  }

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

  .brand span {
    font-size: 11px;
    line-height: 1.2;
  }

  #moduleNav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    padding-top: 8px;
  }

  .nav-group-title,
  .nav-btn,
  .nav-sub-btn {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 13px;
    line-height: 1.15;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .nav-group-title {
    min-height: 38px;
    padding-left: 15px;
  }

  .nav-group-items {
    gap: 4px;
    padding: 5px;
  }

  .main {
    width: 100%;
    min-width: 0;
    min-height: auto;
    overflow: visible;
    padding: 8px;
    gap: 8px;
  }

  .topbar {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .module-menu-btn {
    width: 100%;
    height: 34px;
    justify-content: center;
  }

  .topbar h1 {
    font-size: 24px;
    line-height: 1.05;
  }

  .fy-session-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .fy-badge {
    max-width: none;
    width: 100%;
    min-width: 0;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
  }

  .top-actions .search {
    grid-column: 1 / -1;
  }

  .top-actions button {
    min-width: 0;
    width: 100%;
    min-height: 36px;
    padding-left: 6px;
    padding-right: 6px;
    white-space: normal;
    line-height: 1.1;
  }

  .search input {
    width: 100%;
    height: 36px;
    font-size: 16px;
  }

  .summary-strip,
  .summary-strip:has(.gl-report-metric),
  .summary-strip.bank-reconcile-summary-strip,
  .summary-strip.stock-card-summary-strip,
  .summary-strip.invoice-listing-summary-strip,
  .summary-strip.trial-balance-summary-strip,
  .summary-strip.income-statement-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
  }

  .metric {
    min-height: 48px;
    padding: 7px 8px;
  }

  .metric strong,
  .money-metric strong {
    font-size: 15px;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .gl-report-metric,
  .bank-reconcile-metric,
  .stock-card-summary-strip .gl-report-metric,
  .invoice-listing-summary-strip .gl-report-metric,
  .trial-balance-summary-strip .gl-report-metric,
  .income-statement-summary-strip .gl-report-metric {
    grid-column: 1 / -1;
  }

  .gl-filter-grid,
  .stock-card-filter-grid,
  .invoice-listing-filter-grid,
  .trial-balance-filter-grid,
  .income-statement-filter-grid,
  .bank-reconcile-panel,
  .bank-reconcile-import-grid,
  .utility-module-mode,
  .utility-form-grid,
  .utility-note-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .gl-report-actions,
  .stock-card-actions,
  .trial-balance-actions,
  .income-statement-actions,
  .fy-roll-actions,
  .bank-reconcile-actions,
  .bank-reconcile-table-actions,
  .ageing-report-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 7px;
  }

  .gl-report-actions button,
  .stock-card-actions button,
  .trial-balance-actions button,
  .income-statement-actions button,
  .fy-roll-actions button,
  .bank-reconcile-actions button,
  .ageing-report-actions button {
    width: 100%;
    min-width: 0;
  }

  .content-grid,
  .content-grid.awaiting-detail-selection,
  .content-grid.detail-expanded,
  .content-grid.statement-report-mode {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    min-height: 0;
    overflow: visible;
  }

  .list-panel,
  .content-grid.awaiting-detail-selection .list-panel {
    height: auto;
    min-height: 260px;
    max-height: none;
  }

  .detail-panel {
    min-height: 220px;
    max-height: 48dvh;
  }

  .content-grid.detail-expanded .detail-panel {
    max-height: none;
  }

  .panel-head {
    min-height: 40px;
    padding: 8px;
  }

  .panel-head span,
  #sourceLabel,
  #detailKey {
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 720px;
  }

  th,
  td {
    min-width: 112px;
    max-width: 240px;
    height: 30px;
    padding: 5px 7px;
  }

  .quick-select-col,
  .quick-select-col input[type="checkbox"] {
    min-width: 28px !important;
  }

  .detail-body {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Keep WBS browsing anchored on the ticket list. The selected ticket opens
     as a compact sheet instead of forcing the page to scroll to the detail. */
  .content-grid.wbs-ticket-inbox-mode.wbs-ticket-selected .detail-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 40;
    min-height: 0;
    max-height: min(68dvh, 560px);
    margin: 0;
    box-shadow: 0 8px 28px rgba(20, 45, 35, 0.3);
  }

  .content-grid.wbs-ticket-inbox-mode.wbs-ticket-selected .detail-panel .detail-body {
    max-height: calc(min(68dvh, 560px) - 52px);
  }

  .content-grid.wbs-ticket-inbox-mode.wbs-ticket-selected .detail-panel .panel-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel);
  }

  /* The WBS inbox is a scanning table. Keep every accounting field available,
     but use deliberate compact widths so more ticket context fits on a phone. */
  .content-grid.wbs-ticket-inbox-mode .table-wrap table {
    width: 900px;
    min-width: 900px;
    table-layout: fixed;
    font-size: 11.5px;
  }

  .content-grid.wbs-ticket-inbox-mode .table-wrap th,
  .content-grid.wbs-ticket-inbox-mode .table-wrap td {
    min-width: 0;
    max-width: none;
    height: 28px;
    padding: 4px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
  }

  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(1),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(1) { width: 76px; }
  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(2),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(2) { width: 88px; }
  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(3),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(3) { width: 168px; }
  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(4),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(4) { width: 82px; }
  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(5),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(5) { width: 80px; }
  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(6),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(6) { width: 54px; }
  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(7),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(7) { width: 88px; }
  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(8),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(8) { width: 78px; }
  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(9),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(9) { width: 82px; }
  .content-grid.wbs-ticket-inbox-mode .table-wrap th:nth-child(10),
  .content-grid.wbs-ticket-inbox-mode .table-wrap td:nth-child(10) { width: 104px; }

  .content-grid.wbs-ticket-inbox-mode .sort-header {
    min-height: 28px;
    padding: 2px 0;
    font-size: 11.5px;
  }

  .editor-overlay {
    align-items: stretch;
    justify-items: stretch;
    padding: 0;
  }

  .editor-dialog,
  .editor-dialog.bank-cash-dialog {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-left: 0;
    border-right: 0;
  }

  .editor-head {
    min-height: 60px;
    padding: 10px 12px;
  }

  .editor-head h2 {
    font-size: 22px;
    line-height: 1.05;
  }

  .record-form {
    min-height: 0;
  }

  .form-fields {
    padding: 10px;
  }

  .transaction-grid,
  .bank-cash-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .form-field input,
  .form-field select,
  .form-field textarea,
  .transaction-grid input,
  .transaction-grid select,
  .transaction-grid textarea {
    min-height: 38px;
    font-size: 16px;
  }

  .line-head,
  .bank-cash-line-head,
  .attachment-panel-head,
  .supplier-invoice-quick-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
  }

  .line-actions,
  .attachment-actions,
  .supplier-invoice-quick-panel .quick-select-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 7px;
    max-width: none;
    margin-right: 0;
  }

  .line-actions button,
  .attachment-actions button,
  .editor-actions button {
    width: 100%;
    min-width: 0;
  }

  .po-line-scroll,
  .statement-table-wrap,
  .note-table-wrap,
  .payment-table-wrap,
  .po-import-table-wrap,
  .payment-picker-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .po-line-editor,
  .journal-line-editor,
  .bank-payment-line-editor {
    min-width: 860px;
  }

  .po-line-editor:not(.bank-payment-line-editor):not(.journal-line-editor) {
    min-width: 940px;
  }

  .si-line-editor {
    min-width: 1020px;
  }

  .po-line-editor .po-col-details {
    width: 300px;
  }

  .quote-line-editor .po-col-details,
  .si-line-editor .po-col-details {
    width: 320px;
  }

  .line-head h3 {
    padding: 8px 10px 0;
  }

  .line-actions .batch-gst-control,
  .line-actions #batchCustomerInvoiceGstCode,
  .line-actions #batchPoGstCode,
  .line-actions #batchQuotationGstCode {
    width: 100%;
    min-width: 0;
  }

  .document-print-control {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 6px 8px;
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
  }

  .document-print-control > span {
    grid-row: span 2;
    align-self: center;
    margin-right: 0;
  }

  .quote-line-editor textarea,
  .si-line-editor textarea {
    min-height: 72px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .quote-line-editor input,
  .quote-line-editor select,
  .quote-line-editor textarea,
  .si-line-editor input,
  .si-line-editor select,
  .si-line-editor textarea {
    width: 100%;
  }

  .editor-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 7px;
    padding: 8px 10px;
  }

  #formStatus {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 430px) {
  .app-tab {
    min-width: 112px;
    font-size: 12px;
  }

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

  .line-actions button {
    min-height: 36px;
    padding: 7px 8px;
  }

  .document-print-control {
    grid-template-columns: auto 1fr 1fr 1fr 1fr;
    align-items: center;
  }

  .document-print-control > span {
    grid-row: auto;
  }

  .po-line-editor:not(.bank-payment-line-editor):not(.journal-line-editor) {
    min-width: 820px;
  }

  .si-line-editor {
    min-width: 900px;
  }

  .quote-line-editor .po-col-details,
  .si-line-editor .po-col-details {
    width: 300px;
  }

  .po-total-bar {
    position: sticky;
    left: 0;
    justify-content: flex-start;
    gap: 18px;
    overflow-x: auto;
    white-space: nowrap;
  }

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

  .summary-strip,
  .summary-strip:has(.gl-report-metric),
  .summary-strip.bank-reconcile-summary-strip,
  .summary-strip.stock-card-summary-strip,
  .summary-strip.invoice-listing-summary-strip,
  .summary-strip.trial-balance-summary-strip,
  .summary-strip.income-statement-summary-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .top-actions,
  .gl-report-actions,
  .stock-card-actions,
  .trial-balance-actions,
  .income-statement-actions,
  .fy-roll-actions,
  .bank-reconcile-actions,
  .bank-reconcile-table-actions,
  .ageing-report-actions,
  .line-actions,
  .attachment-actions,
  .supplier-invoice-quick-panel .quick-select-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .fy-session-bar {
    grid-template-columns: minmax(0, 1fr);
  }

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

/* Compact transaction browsing summary: keep space for the entry list. */
.summary-strip.transaction-summary-strip {
  grid-template-columns: minmax(170px, 1.05fr) minmax(92px, 0.62fr) repeat(4, minmax(84px, 0.56fr)) minmax(116px, 0.75fr) minmax(72px, 0.45fr);
  align-items: stretch;
  gap: 1px;
}

.summary-strip.transaction-summary-strip .metric {
  min-height: 40px;
  padding: 5px 8px;
}

.summary-strip.transaction-summary-strip .metric span {
  font-size: 9.5px;
  line-height: 1.05;
}

.summary-strip.transaction-summary-strip .metric strong {
  margin-top: 1px;
  font-size: 14px;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

.summary-strip.transaction-summary-strip .wide-metric {
  min-width: 0;
}

.so-outstanding-open {
  min-height: 25px;
  padding: 3px 8px;
  border-color: var(--green-dark);
  background: var(--green-dark);
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
}

.sales-order-outstanding-summary {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: 0 6px 20px rgba(35, 55, 38, 0.1);
}

.main.sales-order-outstanding-open {
  grid-template-rows: auto auto minmax(250px, 48vh) minmax(190px, 1fr);
}

.sales-order-outstanding-summary[hidden] {
  display: none;
}

.so-outstanding-head,
.so-outstanding-kpis,
.so-outstanding-tabs {
  display: flex;
  align-items: center;
}

.so-outstanding-head {
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#fffdf6, var(--ivory-dark));
}

.so-outstanding-head > div {
  display: grid;
  gap: 2px;
}

.so-outstanding-head strong {
  color: var(--green-dark);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 18px;
}

.so-outstanding-kpis {
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.so-outstanding-kpis > span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--muted);
  font-size: 12px;
}

.so-outstanding-kpis b {
  color: var(--green-dark);
  font-size: 14px;
}

.so-outstanding-values {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.so-outstanding-tabs {
  gap: 6px;
  padding: 8px 12px;
}

.so-outstanding-export-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
}

.so-outstanding-export-actions button {
  border-color: var(--green-dark);
  background: #fff;
  color: var(--green-dark);
}

.so-outstanding-tabs button.active {
  border-color: var(--green-dark);
  background: var(--green-dark);
  color: #fff;
}

.so-outstanding-filter {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f3f7f1;
}

.so-outstanding-filter label {
  font-weight: 800;
  color: var(--green-dark);
}

.so-outstanding-filter > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.so-outstanding-filter input {
  min-width: 0;
  min-height: 36px;
}

.so-outstanding-filter small {
  color: var(--muted);
  white-space: nowrap;
}

.so-outstanding-ai {
  display: grid;
  gap: 7px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  background: #f2f7f2;
}

.so-outstanding-ai-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--green-dark);
}

.so-outstanding-ai-title span {
  padding: 2px 7px;
  border: 1px solid #a9c6b1;
  border-radius: 999px;
  background: #fff;
  color: #486452;
  font-size: 10px;
  white-space: nowrap;
}

.so-outstanding-ai form {
  display: flex;
  gap: 7px;
}

.so-outstanding-ai input {
  min-width: 0;
  flex: 1;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  background: #fff;
}

.so-outstanding-ai form button {
  border-color: var(--green-dark);
  background: var(--green-dark);
  color: #fff;
  white-space: nowrap;
}

.so-outstanding-ai-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.so-outstanding-ai-prompts button {
  min-height: 32px;
  padding: 5px 9px;
  border-color: #a9c6b1;
  border-radius: 999px;
  background: #fff;
  color: var(--green-dark);
  font-size: 11px;
}

.so-outstanding-ai-answer {
  display: grid;
  gap: 4px;
  padding: 8px 9px;
  border-left: 3px solid var(--accent);
  background: #fff;
  color: #25372b;
  font-size: 12px;
  line-height: 1.45;
}

.so-outstanding-ai-answer small {
  color: var(--muted);
}

.so-outstanding-ai-references {
  display: grid;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px solid #dce8df;
}

.so-outstanding-ai-references > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.so-outstanding-ai-references > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.so-outstanding-ai-references button {
  min-height: 32px;
  padding: 4px 8px;
  border-color: #8fb79b;
  background: #edf6ef;
  color: var(--green-dark);
  font-size: 11px;
}

.so-outstanding-ai-error {
  color: #9b1c1c;
  font-size: 12px;
}

.so-outstanding-table-wrap {
  min-height: 0;
  max-height: none;
  overflow: auto;
  border-top: 1px solid var(--line);
}

#soOutstandingFilteredResults {
  min-width: 0;
  min-height: 0;
}

.so-outstanding-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

.so-outstanding-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #c9cbc9;
  color: #171b18;
  text-align: left;
  text-transform: uppercase;
}

.so-outstanding-table th,
.so-outstanding-table td {
  padding: 7px 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}

.so-outstanding-table td:nth-child(2) {
  max-width: 390px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.so-pivot-group-cell small {
  display: block;
  max-width: 180px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  white-space: normal;
}

.so-outstanding-table td.so-pivot-item-text {
  min-width: 230px;
  max-width: 360px;
  white-space: pre-line;
  overflow-wrap: anywhere;
  line-height: 1.25;
  vertical-align: top;
}

.so-pivot-contract {
  font-weight: 700;
}

.so-pivot-detail-row:nth-child(even) td {
  background-color: #f3f3ee;
}

.so-pivot-aggregate td {
  vertical-align: top;
}

.so-pivot-aggregate .so-pivot-group-cell small,
.so-aggregate-kiv-held {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.so-pivot-price-summary {
  max-width: 190px;
  white-space: normal;
}

.so-aggregate-kiv-held {
  color: #9b1c1c;
  white-space: normal;
}

@media (max-width: 700px) {
  .so-mobile-breakdown-card.has-kiv {
    border-color: #cc8f8f;
    background: #fff8f8;
  }
}

/* Keep every transaction editor's Save action clear of the floating AI controls. */
.editor-overlay:not([hidden]) ~ .accpro-ai-launcher,
.editor-overlay:not([hidden]) ~ .accpro-ai-panel {
  display: none !important;
}

/* Mobile editor safeguard for older layout wrappers. */
@media (max-width: 700px) {
  .editor-overlay:not([hidden]) ~ .accpro-ai-launcher,
  .editor-overlay:not([hidden]) ~ .accpro-ai-panel {
    display: none !important;
  }
}

@media (max-width: 700px) {
  .so-outstanding-filter {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 9px 12px;
  }

  .so-outstanding-filter input,
  .so-outstanding-filter button {
    min-height: 44px;
  }

  .so-outstanding-filter small {
    white-space: normal;
  }
}

/* Mobile SO summary: line-by-line contract detail inside each consolidated card. */
@media (max-width: 700px) {
  .so-mobile-contract-lines {
    display: grid;
    gap: 7px;
    padding-top: 9px;
    border-top: 1px solid #ddd7c5;
  }

  .so-mobile-contract-lines-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--green-dark);
  }

  .so-mobile-contract-lines-title span {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .so-mobile-contract-lines-title b {
    min-width: 24px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #dcebdd;
    font-size: 11px;
    text-align: center;
  }

  .so-mobile-contract-line {
    display: grid;
    gap: 7px;
    padding: 9px;
    border: 1px solid #d6dece;
    border-radius: 8px;
    background: #f2f7ef;
  }

  .so-mobile-contract-line.is-kiv {
    border-color: #d5a0a0;
    background: #fff3f3;
  }

  .so-mobile-contract-line-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 7px;
  }

  .so-mobile-contract-line-head > strong {
    min-width: 0;
    color: #28462f;
    font-size: 12px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .so-mobile-contract-line-detail {
    display: grid;
    gap: 2px;
  }

  .so-mobile-contract-line-detail span,
  .so-mobile-contract-line-values span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .so-mobile-contract-line-detail b {
    font-size: 11px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .so-mobile-contract-line-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .so-mobile-contract-line-values > div {
    display: grid;
    min-width: 0;
    gap: 2px;
    padding-left: 7px;
    border-left: 2px solid #ccdbce;
  }

  .so-mobile-contract-line-values > div:nth-child(3) {
    grid-column: 1 / -1;
  }

  .so-mobile-contract-line-values b,
  .so-mobile-contract-line-values s {
    color: #294330;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
  }

  .so-mobile-contract-line-values s {
    color: #9b1c1c;
  }

  .so-mobile-contract-line.is-kiv .so-mobile-contract-line-values > div:nth-child(2) b {
    color: #9b1c1c;
  }
}

.so-pivot-subtotal td {
  padding-top: 5px;
  padding-bottom: 5px;
  border-color: #303432;
  background: #404543 !important;
  color: #fff;
  font-weight: 800;
}

.so-pivot-grand-total td {
  border-color: #747800;
  background: #f0f500 !important;
  color: #111;
  font-size: 13px;
  font-weight: 900;
}

.so-pivot-subtotal td:first-child,
.so-pivot-grand-total td:first-child {
  text-align: left;
}

.so-outstanding-table .number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.so-outstanding-table .outstanding-balance {
  background: #e8f3e8;
  color: var(--green-dark);
  font-weight: 800;
}

.so-outstanding-table .so-pivot-kiv td {
  background: #fde8e8 !important;
  color: #9b1c1c;
}

.so-outstanding-table .so-pivot-kiv .outstanding-balance span {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

/* Desktop Sales Order quick glance: scan first, disclose contract detail on demand. */
@media (min-width: 701px) {
  .main.sales-order-outstanding-open {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .main.sales-order-outstanding-open > .content-grid {
    display: none;
  }

  #soOutstandingFilteredResults {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }

  .sales-order-outstanding-summary {
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    border-radius: 7px;
    box-shadow: 0 8px 24px rgba(35, 55, 38, 0.13);
  }

  .sales-order-outstanding-summary .so-outstanding-head {
    min-height: 56px;
    padding: 10px 15px;
  }

  .sales-order-outstanding-summary .so-outstanding-head strong {
    font-size: 21px;
    line-height: 1.08;
  }

  .sales-order-outstanding-summary .so-outstanding-head small {
    color: var(--muted);
    font-size: 11px;
  }

  .sales-order-outstanding-summary .so-outstanding-kpis {
    display: grid;
    grid-template-columns: minmax(150px, .75fr) minmax(135px, .65fr) minmax(135px, .65fr) minmax(280px, 1.6fr);
    gap: 9px;
    padding: 10px 15px;
    background: #f5f2e8;
  }

  .sales-order-outstanding-summary .so-outstanding-kpis > span {
    display: grid;
    min-width: 0;
    min-height: 68px;
    align-content: center;
    gap: 1px;
    padding: 8px 12px;
    border: 1px solid #d9d2bc;
    border-radius: 7px;
    background: #fffdf7;
    box-shadow: 0 1px 3px rgba(28, 51, 33, 0.05);
  }

  .sales-order-outstanding-summary .so-outstanding-kpis > span.so-kpi-primary {
    border-left: 4px solid var(--accent);
  }

  .sales-order-outstanding-summary .so-outstanding-kpis small {
    color: #687064;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
  }

  .sales-order-outstanding-summary .so-outstanding-kpis b {
    font-size: 23px;
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
  }

  .sales-order-outstanding-summary .so-outstanding-kpis em {
    color: var(--muted);
    font-size: 10px;
    font-style: normal;
  }

  .sales-order-outstanding-summary .so-outstanding-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: center;
    column-gap: 14px;
  }

  .sales-order-outstanding-summary .so-outstanding-values > small,
  .sales-order-outstanding-summary .so-outstanding-values > em {
    grid-column: 1 / -1;
  }

  .sales-order-outstanding-summary .so-outstanding-values > span {
    display: flex;
    flex-wrap: wrap;
    grid-column: 1 / -1;
    gap: 8px 18px;
  }

  .sales-order-outstanding-summary .so-outstanding-values > span > span {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    color: #263c2b;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
  }

  .sales-order-outstanding-summary .so-outstanding-values > span b {
    font-size: 12px;
  }

  .sales-order-outstanding-summary .so-outstanding-tabs {
    padding: 8px 15px;
    background: #fffdf7;
  }

  .sales-order-outstanding-summary .so-outstanding-tabs > button {
    min-width: 108px;
  }

  .sales-order-outstanding-summary .so-outstanding-filter {
    padding: 7px 15px;
  }

  .sales-order-outstanding-summary .so-outstanding-table {
    min-width: 1080px;
  }

  .sales-order-outstanding-summary .so-outstanding-table th {
    height: 31px;
    padding: 6px 10px;
    background: #d7ddd7;
    color: #27332a;
    font-size: 10px;
    letter-spacing: .03em;
  }

  .sales-order-outstanding-summary .so-outstanding-table td {
    padding: 8px 10px;
    white-space: normal;
    vertical-align: middle;
  }

  .sales-order-outstanding-summary .so-outstanding-table th:nth-child(n+4),
  .sales-order-outstanding-summary .so-outstanding-table td:nth-child(n+4) {
    text-align: right;
  }

  .sales-order-outstanding-summary .so-pivot-aggregate:hover td,
  .sales-order-outstanding-summary .so-pivot-aggregate.is-expanded td {
    background: #f0f5ed;
  }

  .sales-order-outstanding-summary .so-pivot-aggregate.so-pivot-kiv:hover td,
  .sales-order-outstanding-summary .so-pivot-aggregate.so-pivot-kiv.is-expanded td {
    background: #fde8e8;
  }

  .sales-order-outstanding-summary .so-pivot-group-cell > button {
    display: grid;
    grid-template-columns: 25px minmax(0, 1fr);
    align-items: center;
    width: 100%;
    min-height: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--green-dark);
    text-align: left;
  }

  .sales-order-outstanding-summary .so-pivot-group-cell > button:hover {
    background: transparent;
  }

  .sales-order-outstanding-summary .so-pivot-group-cell i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1px solid #9caa98;
    border-radius: 50%;
    background: #fff;
    color: var(--green-dark);
    font-size: 15px;
    font-style: normal;
    line-height: 1;
  }

  .sales-order-outstanding-summary .so-pivot-group-cell strong {
    display: block;
    line-height: 1.2;
  }

  .sales-order-outstanding-summary .so-pivot-group-cell small {
    max-width: none;
    font-size: 9px;
  }

  .sales-order-outstanding-summary .so-pivot-drilldown > td {
    padding: 10px 12px 12px;
    background: #e9eee7 !important;
  }

  .so-desktop-contract-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
    gap: 9px;
  }

  .so-desktop-contract-card {
    display: grid;
    gap: 7px;
    min-width: 0;
    padding: 10px 11px;
    border: 1px solid #cbd4c7;
    border-radius: 7px;
    background: #fffdf7;
    box-shadow: 0 1px 3px rgba(28, 51, 33, .05);
  }

  .so-desktop-contract-card.is-kiv {
    border-color: #d6a1a1;
    background: #fff6f6;
  }

  .so-desktop-contract-card header,
  .so-desktop-contract-card header > div,
  .so-desktop-contract-card p {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .so-desktop-contract-card header {
    justify-content: space-between;
  }

  .so-desktop-contract-card header strong {
    color: var(--green-dark);
    font-size: 13px;
  }

  .so-desktop-contract-card header span,
  .so-desktop-contract-card p span {
    color: var(--muted);
    font-size: 10px;
  }

  .so-desktop-contract-card header button {
    min-height: 28px;
    padding: 3px 9px;
    border-color: #8da08d;
    background: #fff;
    color: var(--green-dark);
    font-size: 10px;
  }

  .so-desktop-contract-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .so-desktop-contract-card p {
    justify-content: space-between;
    margin: 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #e1decf;
  }

  .so-desktop-contract-card dl {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin: 0;
  }

  .so-desktop-contract-card dl > div {
    min-width: 0;
    padding-left: 7px;
    border-left: 2px solid #d4dfd0;
  }

  .so-desktop-contract-card dt {
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
  }

  .so-desktop-contract-card dd {
    display: grid;
    gap: 1px;
    margin: 2px 0 0;
    color: #263c2b;
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .so-desktop-contract-card dd small {
    color: #a02727;
    font-size: 9px;
  }
}

@media (max-width: 700px) {
  .sales-order-outstanding-summary .so-outstanding-head small {
    display: none;
  }

  .sales-order-outstanding-summary .so-outstanding-kpis > span > small,
  .sales-order-outstanding-summary .so-outstanding-kpis > span > em {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-style: normal;
  }
}

.so-kiv-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 5px;
  border: 1px solid #b72b2b;
  border-radius: 8px;
  background: #fff;
  color: #a51d1d;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.25;
  vertical-align: 1px;
}

.so-outstanding-loading {
  padding: 18px;
  color: var(--muted);
  font-weight: 700;
}

.compact-view-tabs {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 4px;
}

.compact-view-tabs button {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 12px;
}

.panel-head h3,
#recordCount {
  min-width: 0;
}

#recordCount {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  line-height: 1.2;
}

.record-count-main,
.record-range,
.record-pager {
  display: inline-flex;
  align-items: center;
}

.record-range {
  margin-left: 0;
}

.record-pager {
  margin-left: 0;
  gap: 4px;
}

.record-pager button {
  min-height: 22px;
  padding: 2px 8px;
}

@media (max-width: 900px) {
  .summary-strip.transaction-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .main.sales-order-mobile-page.sales-order-outstanding-open {
    grid-template-rows: auto minmax(300px, 62dvh) minmax(280px, auto);
  }

  .sales-order-outstanding-summary {
    max-height: 62dvh;
    overflow: hidden;
  }

  .so-outstanding-head,
  .so-outstanding-kpis,
  .so-outstanding-tabs {
    padding-left: 9px;
    padding-right: 9px;
  }

  .so-outstanding-head strong {
    font-size: 17px;
  }

  .so-outstanding-table-wrap {
    max-height: none;
  }

  .so-outstanding-export-actions {
    width: 100%;
    margin-left: 0;
  }

  .so-outstanding-ai {
    padding-left: 9px;
    padding-right: 9px;
  }

  .so-outstanding-ai form {
    align-items: stretch;
  }

  .so-outstanding-ai form button,
  .so-outstanding-ai-prompts button,
  .so-outstanding-ai-references button {
    min-height: 44px;
  }

  .so-outstanding-ai-prompts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .so-outstanding-ai-prompts button {
    min-width: 0;
    padding-right: 5px;
    padding-left: 5px;
    white-space: normal;
  }

  .so-outstanding-export-actions button {
    flex: 1;
  }

  .sales-order-tag-summary {
    font-size: 13px;
  }

  .sales-order-tag-summary strong,
  .sales-order-tag-chips {
    display: flex;
  }

  .sales-order-tag-chips {
    margin-top: 5px;
  }

  .sales-order-picker-backdrop {
    align-items: flex-start;
    padding: 8px;
  }

  .sales-order-picker {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 10px;
  }

  .sales-order-picker-head {
    align-items: flex-start;
  }

  .sales-order-picker-head p {
    max-width: none;
  }

  .sales-order-picker-entry {
    grid-template-columns: 1fr;
  }

  .sales-order-picker-row {
    grid-template-columns: 1fr;
    gap: 4px;
    font-size: 14px;
  }

  .so-picker-number {
    text-align: left;
  }

  .sales-order-picker-apply-all {
    min-height: 44px;
    margin: 0 8px 8px;
  }
}

/* Cash and Bank Vouchers: shared phone-first editor. Desktop layouts are unchanged. */
@media (max-width: 700px) {
  .editor-dialog.cash-voucher-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .editor-dialog.cash-voucher-dialog .editor-head {
    position: relative;
    z-index: 4;
    min-height: 68px;
    padding: 10px 14px;
  }

  .editor-dialog.cash-voucher-dialog .editor-head h2 {
    font-size: clamp(22px, 6vw, 27px);
    line-height: 1.05;
  }

  .bank-cash-form.cash-voucher-form {
    padding: 10px 10px 18px;
    overflow-x: hidden;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor {
    gap: 12px;
    width: 100%;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .transaction-section {
    min-width: 0;
    overflow: visible;
    border: 1px solid #d2cdbb;
    border-radius: 12px;
    background: #fffdf6;
    box-shadow: 0 2px 8px rgba(29, 75, 43, 0.06);
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .bank-cash-header-section {
    background: linear-gradient(145deg, #f8fff6 0%, #e6f5e8 100%);
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .bank-cash-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "voucher date"
      "type currency"
      "bank ref"
      "payto payto"
      "rate account"
      "cleared cleared"
      "remarks remarks";
    gap: 11px 10px;
    padding: 13px;
    align-items: start;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .transaction-grid .form-field {
    gap: 5px;
    min-width: 0;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .transaction-grid .form-field label,
  .bank-cash-form.cash-voucher-form .cash-voucher-editor .transaction-grid .form-field > span {
    min-height: 0;
    color: #435044;
    font-size: 11px;
    font-weight: 850;
    line-height: 1.15;
    letter-spacing: 0.035em;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .transaction-grid .form-field input,
  .bank-cash-form.cash-voucher-form .cash-voucher-editor .transaction-grid .form-field select {
    width: 100%;
    height: 45px;
    min-height: 45px;
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 16px;
    line-height: normal;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .transaction-grid .form-field textarea {
    width: 100%;
    height: 72px;
    min-height: 72px;
    padding: 10px;
    border-radius: 7px;
    font-size: 16px;
    line-height: 1.3;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .form-field .lookup-status,
  .bank-cash-form.cash-voucher-form .cash-voucher-editor .form-field .account-name-hint {
    margin-top: 0;
    font-size: 11px;
    line-height: 1.25;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .attachment-panel {
    padding: 13px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .attachment-panel-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .attachment-panel-head strong {
    color: var(--green-dark);
    font-size: 16px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankCashAttachmentStatus {
    color: #667066;
    font-size: 12px;
    line-height: 1.3;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .attachment-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankCashAttachmentFile {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 44px;
    padding: 5px;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fff;
    font-size: 13px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankCashAttachmentFile::file-selector-button {
    min-height: 32px;
    margin-right: 8px;
    border: 1px solid #aaa38e;
    border-radius: 6px;
    background: #f4efdf;
    color: #283728;
    font-weight: 750;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .attachment-actions button {
    width: 100%;
    min-height: 44px;
    padding: 7px 9px;
    white-space: normal;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #extractBankCashAiBtn {
    border-color: #1d4b2b;
    background: #1d4b2b;
    color: #fff;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankCashAttachmentDrop {
    display: none;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .bank-cash-line-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 0;
    padding: 12px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .bank-cash-line-head h3 {
    padding: 0;
    font-size: 17px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .line-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .voucher-print-option {
    grid-column: 1 / -1;
    min-height: 38px;
    padding: 6px 9px;
    border: 1px solid #d8d2bf;
    border-radius: 7px;
    background: #f8f4e8;
    white-space: normal;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .voucher-print-option input {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .line-actions button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 7px;
    white-space: normal;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #addBankPaymentLineBtn {
    grid-column: 1 / -1;
    border-color: #1d4b2b;
    background: #1d4b2b;
    color: #fff;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .po-line-scroll {
    max-height: none;
    overflow: visible;
    border: 0;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .bank-payment-line-editor {
    display: block;
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .bank-payment-line-editor colgroup,
  .bank-cash-form.cash-voucher-form .cash-voucher-editor .bank-payment-line-editor thead {
    display: none;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody {
    display: grid;
    gap: 11px;
    padding: 0 11px 12px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    padding: 12px;
    border: 1px solid #d3cdb9;
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    background: #fffefa;
    box-shadow: 0 2px 7px rgba(29, 75, 43, 0.06);
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td {
    display: grid;
    align-content: start;
    gap: 5px;
    min-width: 0;
    min-height: 0;
    height: auto;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td::before {
    color: #59635a;
    font-size: 10px;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: 0.045em;
    text-transform: uppercase;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(1) {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    gap: 7px;
    color: var(--green-dark);
    font-size: 16px;
    font-weight: 900;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(1)::before { content: "Line"; }
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(2)::before { content: attr(data-mobile-label); }
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(3)::before { content: "Account Name"; }
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(4)::before { content: "Description"; }
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(5)::before { content: "Amount"; }
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(6)::before { content: "GST Code"; }
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(7)::before { content: "GST %"; }
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(8)::before { content: "GST Amount"; }
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(9)::before { content: "GST Only"; }
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(10)::before { content: "Line Total"; }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(3),
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(4),
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody td:nth-child(11) {
    grid-column: 1 / -1;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody input,
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody select {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    padding: 8px 9px;
    border-radius: 7px;
    font-size: 16px;
    line-height: normal;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody textarea {
    width: 100%;
    min-height: 70px;
    padding: 9px;
    border-radius: 7px;
    font-size: 16px;
    line-height: 1.3;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody .account-name-cell {
    min-height: 44px;
    padding: 10px;
    border: 1px solid #d8d3c2;
    border-radius: 7px;
    background: #f3f7ee;
    color: #314431;
    font-size: 14px;
    line-height: 1.25;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody .center-cell {
    align-content: start;
    justify-items: start;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody .center-cell input[type="checkbox"] {
    width: 24px;
    height: 24px;
    min-height: 24px;
    margin: 6px 0;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody .bank-line-total {
    min-height: 44px;
    padding: 11px 10px;
    border: 1px solid #b7cbb8;
    border-radius: 7px;
    background: #e9f5e8;
    color: var(--green-dark);
    font-size: 16px;
    font-weight: 900;
    text-align: right;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #bankPaymentLineBody .allocation-delete {
    width: 100%;
    min-height: 42px;
    border-color: #d7aaa6;
    background: #fff5f3;
    color: #8f1d1d;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .po-total-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    padding: 0;
    overflow: hidden;
    border-top: 1px solid #d2cdbb;
    border-radius: 0 0 11px 11px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .po-total-bar span {
    display: grid;
    gap: 3px;
    min-width: 0;
    padding: 10px 6px;
    border-right: 1px solid #ddd7c5;
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
    text-transform: uppercase;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .po-total-bar span:last-child {
    border-right: 0;
    background: #e1f1df;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .po-total-bar strong {
    overflow-wrap: anywhere;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
  }

  .editor-dialog.cash-voucher-dialog .editor-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }

  .editor-dialog.cash-voucher-dialog .editor-actions #formStatus {
    min-width: 0;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .editor-dialog.cash-voucher-dialog .editor-actions button {
    min-width: 72px;
    min-height: 44px;
    padding: 7px 10px;
  }
}

@media (max-width: 360px) {
  .bank-cash-form.cash-voucher-form .cash-voucher-editor .bank-cash-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "voucher"
      "date"
      "type"
      "currency"
      "bank"
      "ref"
      "payto"
      "rate"
      "account"
      "cleared"
      "remarks";
  }

  .editor-dialog.cash-voucher-dialog .editor-actions button {
    min-width: 66px;
    padding-right: 7px;
    padding-left: 7px;
  }
}

/* Auto Cashier receipt capture and approval controls. */
.cashier-review-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid #9cc8ae;
  border-radius: 8px;
  background: #eef8ef;
  color: #304b36;
  font-size: 12px;
  line-height: 1.3;
}

.cashier-review-note strong {
  flex: 0 0 auto;
  color: #17612f;
  text-transform: uppercase;
}

.cashier-pack-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.cashier-pack-option input {
  width: 18px;
  height: 18px;
  margin: 0;
}

@media (max-width: 700px) {
  .bank-cash-form.cash-voucher-form .cash-voucher-editor #captureCashReceiptBtn {
    grid-column: 1 / -1;
    min-height: 48px;
    border-color: #1685a0;
    background: #e7f7fb;
    color: #14596a;
    font-size: 15px;
    font-weight: 900;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor #captureCashReceiptBtn::before {
    content: "◉";
    margin-right: 7px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .cashier-review-note {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    width: 100%;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .cashier-pack-option {
    width: 100%;
    min-height: 44px;
    padding: 7px 9px;
    border: 1px solid #d8d2bf;
    border-radius: 7px;
    background: #fffdf6;
    font-size: 13px;
  }

  .bank-cash-form.cash-voucher-form .cash-voucher-editor .cashier-pack-option input {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
  }
}

/* ACCPRO AI Assistant: branded, read-only co-worker panel. */
.accpro-ai-launcher {
  position: fixed;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 12990;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 112px;
  min-height: 58px;
  padding: 5px 14px 5px 5px;
  border: 2px solid #b98b27;
  border-radius: 999px;
  background: linear-gradient(145deg, #fffdf6, #efe5c9);
  color: var(--green-dark);
  box-shadow: 0 9px 26px rgba(16, 45, 28, 0.28);
  font: inherit;
  font-weight: 900;
}

.accpro-ai-launcher[hidden],
.accpro-ai-panel[hidden] {
  display: none;
}

.accpro-ai-avatar {
  position: relative;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border: 2px solid #c69b38;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 2px #fff;
}

.accpro-ai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: none;
}

.accpro-ai-avatar-large {
  flex-basis: 52px;
  width: 52px;
  height: 52px;
}

.accpro-ai-panel {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: 13000;
  width: min(420px, calc(100vw - 36px));
  height: min(650px, calc(100dvh - 112px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  border: 1px solid #b99f65;
  border-top: 4px solid var(--accent);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(13, 39, 22, 0.34);
}

.accpro-ai-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #fffdf6, #f0ead7);
}

.accpro-ai-head > div {
  min-width: 0;
}

.accpro-ai-head .eyebrow {
  display: block;
  color: var(--accent-dark);
  font-size: 9px;
  font-weight: 900;
}

.accpro-ai-head strong,
.accpro-ai-head small {
  display: block;
}

.accpro-ai-head strong {
  color: var(--green-dark);
  font-size: 16px;
}

.accpro-ai-head small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.accpro-ai-head button {
  min-height: 40px;
  padding: 7px 10px;
}

.accpro-ai-messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px;
  background:
    radial-gradient(circle at 90% 6%, rgba(198, 155, 56, 0.12), transparent 28%),
    linear-gradient(#fbfaf4, #f2f4eb);
  -webkit-overflow-scrolling: touch;
}

.accpro-ai-message {
  width: fit-content;
  max-width: 88%;
  margin: 0 0 12px;
  padding: 9px 11px;
  border: 1px solid #d7cfb8;
  border-radius: 13px 13px 13px 4px;
  background: #fffdf7;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(33, 54, 38, 0.08);
}

.accpro-ai-message.user {
  margin-left: auto;
  border-color: #bfd7c4;
  border-radius: 13px 13px 4px 13px;
  background: #e8f3e6;
}

.accpro-ai-message.error {
  border-color: #dba6a6;
  background: #fff1ef;
}

.accpro-ai-message > span {
  display: block;
  margin-bottom: 3px;
  color: var(--accent-dark);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.accpro-ai-message > div {
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.ai-answer-summary {
  margin: 0;
  color: var(--green-dark);
  font-weight: 900;
  line-height: 1.32;
}

.ai-answer-points {
  display: grid;
  gap: 4px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.ai-answer-points li {
  position: relative;
  padding-left: 13px;
  line-height: 1.35;
}

.ai-answer-points li::before {
  position: absolute;
  left: 1px;
  color: var(--accent-dark);
  content: "•";
  font-weight: 900;
}

.ai-answer-notes {
  display: grid;
  gap: 2px;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid #e3ddcd;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.ai-answer-notes b {
  color: var(--ink);
  font-size: 9px;
  text-transform: uppercase;
}

.accpro-ai-draft-note {
  display: grid;
  gap: 3px;
  margin-top: 7px;
  padding: 7px 8px;
  border: 1px solid #d7c98f;
  border-radius: 7px;
  background: #fff9df;
  color: #5a4b1d;
  font-size: 10px;
  line-height: 1.3;
}

.accpro-ai-draft-note.missing {
  border-color: #d6b5a5;
  background: #fff4ed;
  color: #71331f;
}

.accpro-ai-draft-note b {
  font-size: 9px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.accpro-ai-review-draft {
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  border-color: var(--green-dark);
  border-radius: 8px;
  background: var(--green-dark);
  color: #fff;
  font-weight: 900;
}

.accpro-ai-message > small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.accpro-ai-message-references {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 0;
}

.accpro-ai-message-references b {
  flex: 0 0 100%;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.accpro-ai-message-references em {
  padding: 3px 6px;
  border: 1px solid #cadacb;
  border-radius: 999px;
  background: #edf6ea;
  color: var(--green-dark);
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.accpro-ai-thinking {
  display: inline-block;
  margin-left: 4px;
  color: #b98b27;
  letter-spacing: 2px;
  animation: accpro-ai-pulse 1.1s ease-in-out infinite;
}

@keyframes accpro-ai-pulse {
  50% { opacity: 0.3; }
}

.accpro-ai-prompts {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 9px 10px 7px;
  border-top: 1px solid var(--line);
  background: #f7f3e7;
  scrollbar-width: none;
}

.accpro-ai-prompts::-webkit-scrollbar {
  display: none;
}

.accpro-ai-prompts button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 11px;
}

.accpro-ai-form {
  display: grid;
  gap: 5px;
  padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fffdf6;
}

.accpro-ai-form label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.accpro-ai-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.accpro-ai-form input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  padding: 9px 11px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.accpro-ai-form button {
  min-width: 72px;
  min-height: 44px;
  border-color: var(--green-dark);
  border-radius: 9px;
  background: var(--green-dark);
  color: #fff;
  font-weight: 900;
}

@media (max-width: 700px) {
  .accpro-ai-launcher {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    min-width: 104px;
    min-height: 56px;
  }

  .accpro-ai-panel {
    inset: auto 0 0;
    width: 100vw;
    height: min(84dvh, 720px);
    max-height: calc(100dvh - 48px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }

  .accpro-ai-head button,
  .accpro-ai-prompts button {
    min-height: 44px;
  }

  .accpro-ai-message {
    max-width: 92%;
  }

  .accpro-ai-review-draft {
    min-height: 44px;
  }
}

/* Compact presentation for the initial ACCPRO AI release. */
.accpro-ai-launcher {
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  width: 52px;
  min-width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 3px;
  justify-content: center;
  border-width: 1px;
  box-shadow: 0 6px 18px rgba(16, 45, 28, 0.24);
}

.accpro-ai-launcher .accpro-ai-avatar {
  flex-basis: 44px;
  width: 44px;
  height: 44px;
}

.accpro-ai-launcher-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.accpro-ai-panel {
  right: 12px;
  bottom: 74px;
  width: min(360px, calc(100vw - 24px));
  height: min(500px, calc(100dvh - 94px));
  border-top-width: 3px;
  border-radius: 14px;
  box-shadow: 0 15px 44px rgba(13, 39, 22, 0.28);
}

.accpro-ai-head {
  gap: 7px;
  padding: 7px 8px;
}

.accpro-ai-head .accpro-ai-avatar-large {
  flex-basis: 40px;
  width: 40px;
  height: 40px;
}

.accpro-ai-head .eyebrow {
  display: none;
}

.accpro-ai-head strong {
  font-size: 14px;
}

.accpro-ai-head small {
  font-size: 9px;
}

.accpro-ai-head button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

.accpro-ai-messages {
  padding: 9px 8px;
}

.accpro-ai-message {
  max-width: 90%;
  margin-bottom: 8px;
  padding: 7px 9px;
  border-radius: 10px 10px 10px 3px;
  box-shadow: 0 2px 7px rgba(33, 54, 38, 0.06);
}

.accpro-ai-message.user {
  border-radius: 10px 10px 3px 10px;
}

.accpro-ai-prompts {
  gap: 4px;
  padding: 6px;
}

.accpro-ai-prompts button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 10px;
}

.accpro-ai-form {
  gap: 0;
  padding: 6px 7px max(7px, env(safe-area-inset-bottom));
}

.accpro-ai-form label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.accpro-ai-form input,
.accpro-ai-form button {
  min-height: 42px;
}

.accpro-ai-form button {
  min-width: 62px;
}

@media (max-width: 700px) {
  .accpro-ai-launcher {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: 50px;
    min-width: 50px;
    height: 50px;
    min-height: 50px;
  }

  .accpro-ai-panel {
    inset: auto 6px max(6px, env(safe-area-inset-bottom));
    width: calc(100vw - 12px);
    height: min(68dvh, 580px);
    max-height: calc(100dvh - 64px);
    border: 1px solid #b99f65;
    border-top: 3px solid var(--accent);
    border-radius: 14px;
  }

  .accpro-ai-head button,
  .accpro-ai-prompts button,
  .accpro-ai-form input,
  .accpro-ai-form button {
    min-height: 44px;
  }

  .accpro-ai-head button {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }
}

/* Final mobile WBS picker overrides: keep ticket importing usable on phones. */
@media (max-width: 560px) {
  .wbs-picker-dialog {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-left: 0;
    border-right: 0;
  }

  .wbs-picker-dialog .editor-head {
    min-height: 54px;
    padding: 9px 12px;
  }

  .wbs-picker-dialog .editor-head h2 {
    font-size: 25px;
    line-height: 1.05;
  }

  .wbs-picker-dialog .form-fields {
    padding: 8px;
  }

  .wbs-picker-body {
    gap: 8px;
    min-height: 0;
    overflow: hidden;
  }

  .wbs-picker-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .wbs-picker-controls label {
    gap: 2px;
    font-size: 10px;
  }

  .wbs-picker-controls label:nth-child(3),
  .wbs-picker-controls .wbs-toggle,
  .wbs-picker-controls > button {
    grid-column: 1 / -1;
  }

  .wbs-picker-controls input,
  .wbs-picker-controls .wbs-toggle,
  .wbs-picker-controls > button {
    min-height: 40px;
    height: auto;
    font-size: 15px;
  }

  .wbs-picker-status,
  .wbs-empty {
    max-height: 76px;
    overflow: auto;
    padding: 7px 8px;
    border: 1px solid var(--line);
    background: #fffdf6;
    font-size: 13px;
    line-height: 1.35;
  }

  .wbs-ticket-list {
    max-height: none;
    min-height: 0;
    padding-right: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .wbs-ticket-card {
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(16, 45, 28, 0.08);
  }

  .wbs-ticket-head {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 9px;
  }

  .wbs-ticket-head input,
  .wbs-item input {
    width: 18px;
    height: 18px;
  }

  .wbs-ticket-head > :nth-child(2) {
    color: var(--green-dark);
    font-size: 15px;
  }

  .wbs-ticket-head > :nth-child(3) {
    grid-column: 2 / 3;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 800;
  }

  .wbs-ticket-head > :nth-child(4),
  .wbs-ticket-head > :nth-child(5) {
    grid-column: 2 / 3;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    white-space: normal;
  }

  .wbs-ticket-head > :nth-child(6) {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    justify-self: end;
    white-space: nowrap;
    font-size: 12px;
  }

  .wbs-item {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 9px 9px 9px 26px;
  }

  .wbs-item > :nth-child(2) {
    display: none;
  }

  .wbs-item > :nth-child(3) {
    grid-column: 2 / 3;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.25;
  }

  .wbs-item > :nth-child(4),
  .wbs-item > :nth-child(5) {
    grid-column: 2 / 3;
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
  }

  .wbs-item > :nth-child(6) {
    grid-column: 3 / 4;
    grid-row: 1 / 4;
    align-self: center;
    justify-self: end;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 800;
  }

  .wbs-item > :nth-child(7) {
    display: none;
  }

  .wbs-picker-dialog .editor-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .wbs-picker-dialog .editor-actions > span {
    display: block;
    max-height: 54px;
    overflow: auto;
    padding: 7px 8px;
    border: 1px solid var(--line);
    background: #fffdf6;
    font-size: 13px;
    line-height: 1.3;
  }

  .wbs-picker-dialog .editor-actions > span br {
    display: none;
  }

  .wbs-bulk-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
    margin-left: 0;
  }

  .wbs-bulk-actions button,
  #importSelectedWbsBtn {
    width: 100%;
    min-width: 0;
  }
}

/* Final shared mobile polish. Keep this last so every present and future
   module inherits the same compact, touch-friendly workspace. */
@media (max-width: 700px) {
  button,
  input,
  select,
  textarea,
  .nav-btn,
  .nav-sub-btn,
  .app-tab {
    touch-action: manipulation;
  }

  button,
  .nav-btn,
  .nav-sub-btn {
    min-height: 42px;
  }

  .main {
    padding: 6px;
    gap: 6px;
  }

  .topbar {
    gap: 6px;
    padding: 8px;
  }

  .topbar h1 {
    font-size: clamp(21px, 6vw, 28px);
    line-height: 1.1;
    overflow-wrap: anywhere;
  }

  .top-actions button,
  .search input,
  .fy-badge {
    min-height: 42px;
  }

  .summary-strip,
  .summary-strip:has(.gl-report-metric),
  .summary-strip.bank-reconcile-summary-strip,
  .summary-strip.stock-card-summary-strip,
  .summary-strip.invoice-listing-summary-strip,
  .summary-strip.trial-balance-summary-strip,
  .summary-strip.income-statement-summary-strip {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .summary-strip > .metric,
  .summary-strip > .gl-report-metric,
  .summary-strip > .bank-reconcile-metric {
    flex: 0 0 min(48vw, 210px);
    min-height: 64px;
  }

  .metric strong,
  .money-metric strong {
    font-size: 16px;
  }

  .content-grid.mobile-detail-selected .detail-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 40;
    min-height: 0;
    max-height: min(70vh, 560px);
    margin: 0;
    box-shadow: 0 8px 28px rgba(20, 45, 35, 0.3);
  }

  .content-grid.mobile-detail-selected .detail-panel .panel-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel);
  }

  .content-grid.mobile-detail-selected .detail-panel .detail-body {
    max-height: calc(min(70vh, 560px) - 54px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .list-panel {
    min-height: 220px;
  }

  .table-wrap,
  .detail-scroll,
  .detail-body {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  th,
  td {
    min-height: 36px;
    height: 36px;
    padding: 7px 8px;
    font-size: 13px;
  }

  .form-field input,
  .form-field select,
  .form-field textarea,
  .transaction-grid input,
  .transaction-grid select,
  .transaction-grid textarea,
  .bank-cash-grid input,
  .bank-cash-grid select,
  .bank-cash-grid textarea {
    min-height: 44px;
    padding: 9px 10px;
    font-size: 16px;
    line-height: 1.25;
  }

  .form-field textarea,
  .transaction-grid textarea,
  .bank-cash-grid textarea {
    min-height: 96px;
  }

  .editor-overlay {
    padding: 0;
  }

  .editor-dialog,
  .editor-dialog.bank-cash-dialog {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
  }

  .editor-head {
    min-height: 58px;
    padding: 9px 12px;
  }

  .editor-head h2 {
    font-size: 22px;
    overflow-wrap: anywhere;
  }

  .editor-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    background: var(--panel);
  }

  .line-actions button,
  .attachment-actions button,
  .editor-actions button {
    min-height: 44px;
    padding: 9px 10px;
    white-space: normal;
  }
}

@media (max-width: 430px) {
  .top-actions,
  .editor-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .content-grid.mobile-detail-selected .detail-panel {
    left: 4px;
    right: 4px;
    bottom: 4px;
  }
}
/* Dashboard landing screen */
.dashboard-hidden { display: none !important; }
.dashboard-view { padding: 18px; background: #f8f5e9; color: #29452e; }
.dashboard-hero { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 20px 22px; border: 1px solid #ddd6bd; background: linear-gradient(135deg, #fffdf5, #eef7f4); }
.dashboard-hero h2 { margin: 3px 0 4px; font-size: 26px; }
.dashboard-hero p:not(.eyebrow) { margin: 0; color: #6a6a58; }
.dashboard-period { display: flex; align-items: end; gap: 8px; }
.dashboard-period label { display: grid; gap: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: #69705f; }
.dashboard-period input { min-width: 145px; }
.dashboard-period button, .dashboard-panel-head button, .dashboard-shortcuts button, .dashboard-empty button { border: 1px solid #b6ad8e; background: #f5f0df; color: #29452e; border-radius: 4px; padding: 9px 13px; font-weight: 700; cursor: pointer; }
.dashboard-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.dashboard-kpi { min-height: 112px; padding: 15px; border: 1px solid #ddd6bd; border-top: 4px solid #1d9fbd; background: #fffdf6; }
.dashboard-kpi span, .dashboard-kpi small { display: block; color: #6c705e; }
.dashboard-kpi span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.dashboard-kpi strong { display: block; margin: 12px 0 3px; font-size: 23px; color: #1e4c2b; }
.dashboard-kpi small { font-size: 11px; }
.dashboard-kpi-purchases { border-top-color: #d59a2a; }
.dashboard-kpi-expenses { border-top-color: #c36a55; }
.dashboard-kpi-receipts { border-top-color: #438c64; }
.dashboard-kpi-payments { border-top-color: #735b9d; }
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 14px; margin-top: 14px; }
.dashboard-panel { border: 1px solid #ddd6bd; background: #fffdf6; padding: 17px; }
.dashboard-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #e3ddc9; padding-bottom: 11px; margin-bottom: 12px; }
.dashboard-panel-head h3 { margin: 3px 0 0; font-size: 18px; }
.dashboard-expense-analysis { margin-top: 14px; }
.dashboard-expense-layout { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: 22px; align-items: center; }
.dashboard-pie { width: 190px; aspect-ratio: 1; border-radius: 50%; border: 10px solid #fffdf6; box-shadow: 0 0 0 1px #ddd6bd; margin: auto; }
.dashboard-expense-legend { display: grid; gap: 10px; }
.dashboard-expense-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; }
.dashboard-expense-row > i { width: 10px; height: 10px; border-radius: 50%; background: var(--expense-color); }
.dashboard-expense-row span { min-width: 0; }
.dashboard-expense-row strong, .dashboard-expense-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-expense-row small { margin-top: 2px; color: #777963; font-size: 11px; }
.dashboard-expense-row b { text-align: right; font-size: 13px; }
.dashboard-unit { color: #7d836f; font-size: 12px; font-weight: 700; }
.dashboard-bars { display: grid; gap: 14px; }
.dashboard-bar-row { display: grid; grid-template-columns: 90px minmax(60px, 1fr) 100px; gap: 10px; align-items: center; font-size: 12px; }
.dashboard-bar-row strong { text-align: right; font-size: 12px; }
.dashboard-bar { height: 9px; overflow: hidden; background: #e8eadc; border-radius: 10px; }
.dashboard-bar i { display: block; height: 100%; background: #239cb2; border-radius: inherit; }
.dashboard-recurring-list, .dashboard-recent-list { display: grid; gap: 8px; }
.dashboard-recurring-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid #eee9da; }
.dashboard-recurring-row:last-child { border-bottom: 0; }
.dashboard-recurring-row strong, .dashboard-recurring-row span { display: block; }
.dashboard-recurring-row span { margin-top: 3px; color: #777963; font-size: 12px; }
.dashboard-recurring-row em { display: block; margin-bottom: 5px; color: #777963; font-size: 11px; font-style: normal; text-align: right; }
.dashboard-recurring-row em.is-due { color: #b34e36; font-weight: 700; }
.dashboard-recurring-row button { padding: 6px 10px; border: 1px solid #b6ad8e; background: #f5f0df; border-radius: 4px; cursor: pointer; }
.dashboard-recurring-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.dashboard-recurring-actions button:disabled { cursor: wait; opacity: .65; }
.dashboard-empty { padding: 18px 3px; color: #727663; }
.dashboard-empty button { display: block; margin-top: 12px; }
.dashboard-recent { margin-top: 14px; }
.dashboard-recent-list > div { display: grid; grid-template-columns: 96px 112px 150px minmax(0, 1fr) 110px; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid #eee9da; }
.dashboard-recent-list .dashboard-recent-head { padding: 0 0 7px; border-bottom: 1px solid #d9d2ba; color: #727563; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.dashboard-recent-type { color: #6b725f; font-size: 12px; }
.dashboard-recent-list b { text-align: right; }
.dashboard-shortcuts { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.dashboard-loading, .dashboard-error { padding: 36px; border: 1px solid #ddd6bd; background: #fffdf6; color: #69705f; }
@media (max-width: 900px) {
  .dashboard-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-columns { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .dashboard-view { padding: 10px; }
  .dashboard-hero { display: grid; padding: 15px; }
  .dashboard-hero h2 { font-size: 22px; }
  .dashboard-period { align-items: stretch; }
  .dashboard-period input { min-width: 0; flex: 1; }
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .dashboard-kpi { min-height: 100px; padding: 12px; }
  .dashboard-kpi strong { font-size: 18px; }
  .dashboard-bar-row { grid-template-columns: 78px minmax(40px, 1fr) 82px; gap: 6px; }
  .dashboard-recent-list > div { grid-template-columns: 1fr auto; gap: 4px 8px; }
  .dashboard-recent-list .dashboard-recent-head { display: none; }
  .dashboard-recent-list > div span:nth-child(4) { grid-column: 1 / -1; }
  .dashboard-recent-list b { grid-column: 2; grid-row: 1; }
  .dashboard-shortcuts button { flex: 1 1 45%; }
  .dashboard-expense-layout { grid-template-columns: 1fr; gap: 14px; }
  .dashboard-pie { width: 160px; }
}

/* Sales Orders mobile status workspace. Desktop and other modules are unchanged. */
.sales-order-mobile-orders,
.sales-order-mobile-detail {
  display: none;
}

@media (max-width: 700px) {
  .main.sales-order-mobile-page {
    gap: 8px;
    padding: 8px;
    overflow-y: auto;
    background: #f7f3e7;
  }

  .sales-order-mobile-page .topbar {
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-top-width: 3px;
    box-shadow: none;
  }

  .sales-order-mobile-page .topbar > div:first-of-type {
    min-width: 150px;
  }

  .sales-order-mobile-page .topbar h1 {
    font-size: 25px;
    line-height: 1.05;
  }

  .sales-order-mobile-page .topbar .eyebrow,
  .sales-order-mobile-page .fy-session-bar,
  .sales-order-mobile-page > .summary-strip,
  .sales-order-mobile-page .top-actions > button {
    display: none !important;
  }

  .sales-order-mobile-page .module-menu-btn {
    min-width: 44px;
    width: 44px;
    height: 44px;
    padding: 4px;
    overflow: hidden;
    color: transparent;
    position: relative;
  }

  .sales-order-mobile-page .module-menu-btn::after {
    content: "Menu";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--green-dark);
    font-size: 11px;
    font-weight: 800;
  }

  .sales-order-mobile-page .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    flex: 1 0 100%;
    width: 100%;
  }

  .sales-order-mobile-page .top-actions > #addBtn,
  .sales-order-mobile-page .top-actions > #refreshBtn {
    display: block !important;
    min-height: 44px;
    padding: 9px 14px;
    white-space: nowrap;
  }

  .sales-order-mobile-page .top-actions > #addBtn {
    border-color: var(--green-dark);
    background: var(--green-dark);
    color: #fff;
  }

  .sales-order-mobile-page .top-actions > #refreshBtn {
    min-width: 96px;
    border-color: #bdb6a3;
    background: linear-gradient(180deg, #fffef8, #ebe5d4);
    color: var(--green-dark);
  }

  .sales-order-mobile-page .search {
    width: 100%;
  }

  .sales-order-mobile-page .search span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .sales-order-mobile-page .search input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 16px;
  }

  .content-grid.sales-order-mobile-mode,
  .content-grid.sales-order-mobile-mode.awaiting-detail-selection,
  .content-grid.sales-order-mobile-mode.mobile-detail-selected {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    overflow: visible;
  }

  .content-grid.sales-order-mobile-mode .list-panel,
  .content-grid.sales-order-mobile-mode.awaiting-detail-selection .list-panel {
    display: block;
    min-height: 0;
    height: auto;
    overflow: hidden;
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  .content-grid.sales-order-mobile-mode .list-panel > .panel-head,
  .content-grid.sales-order-mobile-mode .list-panel > .table-wrap,
  .content-grid.sales-order-mobile-mode .detail-panel > .panel-head,
  .content-grid.sales-order-mobile-mode .sales-order-desktop-detail {
    display: none;
  }

  .content-grid.sales-order-mobile-mode .detail-panel,
  .content-grid.sales-order-mobile-mode.mobile-detail-selected .detail-panel {
    display: block;
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: auto;
    min-height: 0;
    max-height: none;
    margin: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  .content-grid.sales-order-mobile-mode .detail-body,
  .content-grid.sales-order-mobile-mode.mobile-detail-selected .detail-panel .detail-body {
    max-height: none;
    padding: 0;
    overflow: visible;
  }

  .sales-order-mobile-orders,
  .sales-order-mobile-detail {
    display: block;
  }

  .sales-order-mobile-orders {
    padding: 0;
  }

  .so-mobile-view-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 9px;
    padding: 4px;
    border: 1px solid #d3ccb5;
    border-radius: 7px;
    background: #eee8d7;
  }

  .so-mobile-view-tabs button {
    min-width: 0;
    min-height: 40px;
    padding: 7px 5px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    box-shadow: none;
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
  }

  .so-mobile-view-tabs button.active {
    border-color: var(--green-dark);
    background: var(--green-dark);
    color: #fff;
  }

  .so-mobile-view-tabs button:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 1px;
  }

  .so-mobile-list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 2px 7px;
    color: var(--green-dark);
  }

  .so-mobile-list-heading strong {
    font-size: 16px;
  }

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

  .so-mobile-list-heading > div {
    display: flex;
    align-items: center;
    gap: 7px;
  }

  .so-mobile-list-heading button {
    min-height: 32px;
    padding: 5px 9px;
    border-color: var(--green-dark);
    background: var(--green-dark);
    color: #fff;
    font-size: 12px;
  }

  .so-mobile-order-strip {
    display: flex;
    align-items: stretch;
    gap: 9px;
    width: 100%;
    padding: 0 2px 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .so-mobile-order-strip::-webkit-scrollbar {
    display: none;
  }

  .so-mobile-order-card {
    position: relative;
    box-sizing: border-box;
    flex: 0 0 min(76vw, 286px);
    height: 148px;
    min-height: 148px;
    padding: 14px 14px 34px;
    overflow: hidden;
    scroll-snap-align: start;
    text-align: left;
    border: 1px solid #cfc8ad;
    border-radius: 5px;
    background: #fffdf6;
    color: var(--green-dark);
  }

  .so-mobile-order-card.selected {
    border: 2px solid var(--green-dark);
    background: #f3f8ec;
  }

  .so-mobile-order-card.kiv-held,
  .so-mobile-order-card.kiv-held.selected {
    border: 2px solid #a51d1d;
    padding-top: 42px;
    background: #fff0f0;
    color: #681919;
  }

  .so-mobile-order-card.completed {
    border: 2px solid #708fa3;
    padding-top: 35px;
    background: #e3edf4;
    color: #29495d;
  }

  .so-mobile-order-card.completed.selected {
    border-color: var(--green-dark);
    background: #f3f8ec;
    color: var(--green-dark);
  }

  .so-mobile-order-card.closed,
  .so-mobile-order-card.closed.selected {
    border: 2px solid #8b4a4a;
    padding-top: 35px;
    background: #f7eded;
    color: #5e3b3b;
  }

  .so-mobile-order-card .so-kiv-hold-badge {
    position: absolute;
    inset: 0 0 auto;
    display: inline-flex;
    width: auto;
    min-height: 29px;
    margin: 0;
    border: 0;
    border-radius: 3px 3px 0 0;
    color: #fff;
    font-size: 10px;
    box-shadow: none;
  }

  .so-mobile-order-card .so-complete-badge {
    position: absolute;
    inset: 0 0 auto;
    display: inline-flex;
    width: auto;
    min-height: 22px;
    margin: 0;
    border: 0;
    border-radius: 3px 3px 0 0;
    color: #fff;
    font-size: 9px;
  }

  .so-mobile-order-card .so-closed-badge {
    position: absolute;
    inset: 0 0 auto;
    width: auto;
    min-height: 22px;
    border: 0;
    border-radius: 3px 3px 0 0;
  }

  .so-mobile-order-card strong,
  .so-mobile-order-card span,
  .so-mobile-order-card small,
  .so-mobile-order-card time {
    display: block;
  }

  .so-mobile-order-card strong {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    font-size: 17px;
    line-height: 1.2;
  }

  .so-mobile-order-card strong .so-mobile-document-no {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: inherit;
    font: inherit;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .so-mobile-order-card strong .so-approval-badge {
    flex: 0 0 auto;
    min-height: 19px;
    margin: 0;
    padding: 2px 7px;
    font-size: 9px;
  }

  .so-mobile-order-card span {
    margin-top: 7px;
    font-size: 15px;
    font-weight: 800;
  }

  .so-mobile-order-card small {
    height: 26px;
    min-height: 26px;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
    overflow: hidden;
  }

  .so-mobile-order-card time {
    position: absolute;
    bottom: 10px;
    left: 14px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
  }

  .sales-order-mobile-detail {
    background: #fffdf6;
    border: 1px solid #d8d1b9;
  }

  .sales-order-mobile-detail .sales-order-kiv-hold-banner {
    margin: 10px;
    align-items: flex-start;
  }

  .so-mobile-selected-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 14px;
    border-bottom: 1px solid #ddd6bd;
  }

  .so-mobile-selected-head strong,
  .so-mobile-selected-head span {
    display: block;
  }

  .so-mobile-selected-head strong {
    color: var(--green-dark);
    font-size: 20px;
    line-height: 1.15;
  }

  .so-mobile-selected-head span,
  .so-mobile-selected-head time {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
  }

  .so-mobile-selected-head time {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .so-mobile-progress-panel {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 15px 12px;
    border-bottom: 1px solid #ddd6bd;
  }

  .so-mobile-tolerance-note {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid #d8cfaf;
    background: #f7f3e5;
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
  }

  .so-mobile-tolerance-note strong {
    color: var(--green-dark);
    text-align: right;
  }

  .so-mobile-progress-spot {
    display: grid;
    align-content: center;
    min-height: 92px;
    padding: 8px;
    border: 1px solid #d9d3bd;
    text-align: center;
    background: #fbfaf3;
  }

  .so-mobile-progress-spot strong,
  .so-mobile-progress-spot span {
    display: block;
  }

  .so-mobile-progress-spot strong {
    color: var(--green-dark);
    font-size: 24px;
    font-variant-numeric: tabular-nums;
  }

  .so-mobile-progress-spot strong.overload {
    font-size: 16px;
    line-height: 1.2;
  }

  .so-mobile-progress-spot span {
    margin-top: 1px;
    color: var(--muted);
    font-size: 12px;
  }

  .so-mobile-progress-spot progress,
  .so-mobile-line-progress {
    width: 100%;
    height: 7px;
    margin-top: 8px;
    border: 0;
    border-radius: 6px;
    overflow: hidden;
    accent-color: #1593a8;
    background: #e5e2d8;
  }

  .so-mobile-progress-spot progress::-webkit-progress-bar,
  .so-mobile-line-progress::-webkit-progress-bar {
    background: #e5e2d8;
  }

  .so-mobile-progress-spot progress::-webkit-progress-value,
  .so-mobile-line-progress::-webkit-progress-value {
    background: #1593a8;
  }

  .so-mobile-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .so-mobile-metrics > div {
    min-width: 0;
    padding: 5px 7px;
    border-left: 1px solid #ddd6bd;
  }

  .so-mobile-metrics > div:first-child {
    border-left: 0;
  }

  .so-mobile-metrics span,
  .so-mobile-metrics strong,
  .so-mobile-metrics small {
    display: block;
  }

  .so-mobile-metrics span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .so-mobile-metrics strong {
    margin-top: 5px;
    color: var(--ink);
    font-size: clamp(15px, 4.2vw, 19px);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .so-mobile-metrics small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
  }

  .so-mobile-metrics .balance strong,
  .so-mobile-metrics .balance small {
    color: #2c7634;
  }

  .so-mobile-tabs {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fffdf6;
    border-bottom: 1px solid #d8d1b9;
  }

  .so-mobile-tabs button {
    min-height: 48px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    font-weight: 800;
  }

  .so-mobile-tabs button.active {
    border-bottom-color: var(--green-dark);
    color: var(--green-dark);
  }

  .so-mobile-tabs button span {
    display: inline-block;
    min-width: 20px;
    margin-left: 4px;
    padding: 1px 5px;
    border-radius: 10px;
    background: #e8eadc;
    font-size: 11px;
  }

  .so-mobile-tab-panel {
    padding: 0 12px;
  }

  .so-mobile-tab-panel[hidden] {
    display: none;
  }

  .so-mobile-item-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 8px;
    padding: 13px 0;
    border-bottom: 1px solid #e3ddca;
  }

  .so-mobile-item-name {
    grid-column: 1 / -1;
  }

  .so-mobile-item-name strong,
  .so-mobile-item-name span,
  .so-mobile-item-row > div > span,
  .so-mobile-item-row > div > strong {
    display: block;
  }

  .so-mobile-item-name strong {
    color: var(--green-dark);
    font-size: 15px;
  }

  .so-mobile-item-name span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.3;
  }

  .so-mobile-item-row > div > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .so-mobile-item-row > div > strong {
    margin-top: 3px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
  }

  .so-mobile-item-row .balance strong {
    color: #2c7634;
  }

  .so-mobile-line-progress {
    grid-column: 1 / -1;
    margin-top: 2px;
  }

  .so-mobile-invoice-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 64px;
    padding: 10px 0;
    border-bottom: 1px solid #e3ddca;
  }

  .so-mobile-invoice-row strong,
  .so-mobile-invoice-row span {
    display: block;
  }

  .so-mobile-invoice-row span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
  }

  .so-mobile-invoice-row > div:last-child {
    text-align: right;
  }

  .so-mobile-empty {
    padding: 28px 8px;
    color: var(--muted);
    text-align: center;
    font-size: 14px;
  }

  .so-mobile-export-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px 0;
  }

  .so-mobile-export-actions button,
  .so-mobile-actions button {
    min-height: 46px;
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 800;
  }

  .so-mobile-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #d8d1b9;
    background: #fffdf6;
  }

  .so-mobile-actions .primary-action {
    grid-column: 1 / -1;
    border-color: #087f8f;
    background: #087f8f;
    color: #fff;
  }

  .so-mobile-actions .danger-action {
    border-color: #b22b2b;
    background: #fff8f5;
    color: #982020;
  }

  .so-mobile-actions > .sales-order-close-action {
    grid-column: 1 / -1;
    margin: 0;
    align-items: stretch;
    flex-direction: column;
  }

  .so-mobile-actions > .sales-order-close-action button {
    width: 100%;
    min-height: 46px;
  }

  .so-mobile-actions > .sales-order-complete-action {
    grid-column: 1 / -1;
    margin: 0;
    align-items: stretch;
    flex-direction: column;
  }

  .so-mobile-actions > .sales-order-complete-action button {
    width: 100%;
    min-height: 46px;
  }

  .sales-order-completed-banner {
    align-items: flex-start;
    margin: 8px 12px;
  }

  .sales-order-closed-banner {
    align-items: flex-start;
    margin: 8px 12px;
  }

  .sales-order-close-backdrop {
    align-items: end;
    padding: 0;
  }

  .sales-order-close-dialog {
    width: 100%;
    max-height: min(86dvh, 680px);
    padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 14px 14px 0 0;
  }

  .sales-order-close-dialog textarea {
    min-height: 120px;
    font-size: 16px;
  }

  .sales-order-close-dialog footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .sales-contract-approval-confirm-backdrop {
    align-items: end;
    padding: 0;
  }

  .sales-contract-approval-confirm-dialog {
    width: 100%;
    max-height: min(88dvh, 680px);
    overflow-y: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 16px 16px 0 0;
  }

  .sales-contract-approval-confirm-dialog > header { padding: 16px 16px 13px; }
  .sales-contract-approval-confirm-dialog h2 { font-size: 22px; }
  .sales-contract-approval-confirm-content { padding: 15px 16px; }

  .sales-contract-approval-confirm-summary > div {
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 10px;
  }

  .sales-contract-approval-confirm-dialog > footer {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  .sales-contract-approval-confirm-dialog > footer { grid-template-columns: 1fr; }
  .sales-contract-approval-confirm-submit { grid-row: 1; }
}

/* Mobile module navigation: a compact, touch-native single-open accordion.
   Desktop navigation keeps its existing grid and interaction. */
@media (max-width: 700px) {
  .sidebar {
    max-height: min(64dvh, 590px);
    padding: 8px 10px 12px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: #f7f3e7;
  }

  #moduleNav {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    padding-top: 8px;
  }

  .nav-group {
    align-self: start;
    overflow: hidden;
    border: 1px solid #d8d0b8;
    border-radius: 9px;
    background: #fffdf7;
    box-shadow: 0 1px 2px rgba(27, 55, 36, 0.08);
  }

  .nav-group.active {
    border-color: #58aeba;
    box-shadow: 0 0 0 1px rgba(37, 157, 178, 0.16), 0 2px 5px rgba(27, 55, 36, 0.08);
  }

  .nav-group-title {
    min-height: 48px;
    padding: 10px 10px 10px 17px;
    border: 0;
    border-radius: 0;
    background: linear-gradient(180deg, #fffdf8 0%, #f5efdf 100%);
    font-size: 13px;
    line-height: 1.2;
    letter-spacing: 0.055em;
    text-shadow: none;
  }

  .nav-group-title:hover,
  .nav-group-title:focus {
    background: linear-gradient(180deg, #fffdf8 0%, #eee5cf 100%);
  }

  .nav-group.active .nav-group-title {
    background: linear-gradient(90deg, #e8f5f2 0%, #fffdf8 76%);
  }

  .nav-group-title::before {
    top: 11px;
    bottom: 11px;
    left: 8px;
    width: 3px;
    border-radius: 3px;
  }

  .nav-group-arrow {
    position: relative;
    width: 28px;
    height: 28px;
    border-color: #c9c0aa;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.82);
    font-size: 0;
  }

  .nav-group-arrow::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translate(-1px, -1px);
  }

  .nav-group.collapsed .nav-group-arrow::before {
    transform: rotate(-45deg) translate(-1px, -1px);
  }

  .nav-group-items {
    gap: 0;
    padding: 4px 8px 8px;
    border-top: 1px solid #e6deca;
    background: #fffdf8;
  }

  .nav-sub-btn {
    min-height: 46px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #ece5d3;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: 14px;
    line-height: 1.2;
  }

  .nav-sub-btn:last-child {
    border-bottom: 0;
  }

  .nav-sub-btn.active {
    border-color: transparent;
    border-radius: 6px;
    background: #e7f3e9;
    color: #173f29;
    box-shadow: inset 4px 0 0 #279db2;
  }
}

.wbs-ticket-mobile-toggle {
  display: none;
}

/* Phone layout shared by Sales Invoice and Purchase Order WBS imports. */
@media (max-width: 560px) {
  .wbs-picker-overlay {
    place-items: start stretch;
    padding: 0;
    background: #f5f1e5;
  }

  .wbs-picker-dialog {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border: 0;
    box-shadow: none;
  }

  .wbs-picker-dialog .editor-head {
    min-height: 68px;
    align-items: center;
    padding: 10px 12px;
    border-top-width: 3px;
  }

  .wbs-picker-dialog .editor-head .eyebrow {
    margin-bottom: 2px;
    font-size: 10px;
  }

  .wbs-picker-dialog .editor-head h2 {
    max-width: 270px;
    font-size: 22px;
    line-height: 1.05;
  }

  .wbs-picker-dialog .editor-head button {
    min-width: 72px;
    min-height: 42px;
    border-radius: 7px;
  }

  .wbs-picker-body {
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 9px;
    min-height: 0;
    overflow: hidden;
    padding: 10px;
    background: #f7f3e8;
  }

  .wbs-picker-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid #ddd5bf;
    border-radius: 10px;
    background: #fffdf7;
    box-shadow: 0 1px 3px rgba(29, 54, 35, 0.07);
  }

  .wbs-picker-controls label {
    min-width: 0;
    gap: 4px;
    font-size: 10px;
    letter-spacing: 0.04em;
  }

  .wbs-picker-controls label:nth-child(1),
  .wbs-picker-controls label:nth-child(2) {
    display: grid;
    width: auto;
    margin: 0;
  }

  .wbs-picker-controls label:nth-child(3) {
    grid-column: 1 / -1;
  }

  .wbs-picker-controls .wbs-toggle {
    grid-column: 1 / 2;
    justify-content: start;
  }

  .wbs-picker-controls > button {
    grid-column: 2 / 3;
  }

  .wbs-picker-controls input,
  .wbs-picker-controls .wbs-toggle,
  .wbs-picker-controls > button {
    width: 100%;
    min-height: 44px;
    height: 44px;
    border-radius: 7px;
    font-size: 14px;
  }

  .wbs-picker-controls input {
    padding: 8px 9px;
    text-align: left;
  }

  .wbs-picker-controls .wbs-toggle {
    padding: 7px 9px;
    white-space: normal;
  }

  .wbs-picker-controls .wbs-toggle input {
    width: 20px;
    height: 20px;
    min-height: 0;
    accent-color: #218aa0;
  }

  .wbs-picker-controls > button {
    border-color: #1e5b35;
    background: #1d4b2b;
    color: #fff;
    font-weight: 800;
  }

  .wbs-picker-status,
  .wbs-empty {
    max-height: 58px;
    margin: 0;
    padding: 8px 10px;
    overflow: auto;
    border: 1px solid #ddd5bf;
    border-radius: 8px;
    background: #fffdf7;
    font-size: 12px;
    line-height: 1.3;
  }

  .wbs-ticket-list {
    align-content: start;
    gap: 10px;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 2px 14px;
    scroll-padding-bottom: 14px;
    -webkit-overflow-scrolling: touch;
  }

  .wbs-ticket-card {
    overflow: hidden;
    border: 1px solid #d6ceb7;
    border-radius: 10px;
    background: #fffdf7;
    box-shadow: 0 2px 6px rgba(28, 51, 33, 0.08);
  }

  .wbs-ticket-card:has(.wbs-ticket-check:checked) {
    border-color: #59aebb;
    box-shadow: 0 0 0 1px rgba(39, 157, 178, 0.14), 0 2px 6px rgba(28, 51, 33, 0.08);
  }

  .wbs-ticket-head {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    gap: 3px 8px;
    min-height: 82px;
    padding: 11px 12px 9px;
    background: linear-gradient(135deg, #f1ead7 0%, #fffdf7 78%);
  }

  .wbs-ticket-head input {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: start;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    accent-color: #218aa0;
  }

  .wbs-ticket-head .wbs-ticket-number {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    overflow: hidden;
    color: #173f29;
    font-size: 15px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wbs-ticket-head .wbs-ticket-count {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    padding: 3px 7px;
    border-radius: 999px;
    background: #dcefe9;
    color: #235f42;
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .wbs-ticket-head .wbs-ticket-party {
    grid-column: 2 / -1;
    grid-row: 2;
    min-width: 0;
    overflow: hidden;
    color: #3c3a32;
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wbs-ticket-head .wbs-ticket-vehicle,
  .wbs-ticket-head .wbs-ticket-date {
    grid-row: 3;
    color: #6c6758;
    font-size: 11px;
    font-weight: 700;
  }

  .wbs-ticket-head .wbs-ticket-vehicle {
    grid-column: 2;
  }

  .wbs-ticket-head .wbs-ticket-date {
    grid-column: 3;
    justify-self: end;
    text-align: right;
  }

  .wbs-ticket-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border: 0;
    border-top: 1px solid #e4dcc8;
    border-radius: 0;
    background: #fffdf7;
    color: #216076;
    font-size: 12px;
    font-weight: 800;
    text-align: left;
  }

  .wbs-ticket-mobile-toggle i {
    width: 8px;
    height: 8px;
    margin-right: 3px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
  }

  .wbs-ticket-mobile-toggle[aria-expanded="true"] i {
    transform: rotate(225deg);
  }

  .wbs-ticket-card .wbs-ticket-items {
    display: none;
    border-top: 1px solid #e4dcc8;
    background: #f8f5eb;
  }

  .wbs-ticket-card.is-expanded .wbs-ticket-items {
    display: grid;
  }

  .wbs-item {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    gap: 3px 8px;
    min-height: 78px;
    padding: 10px 12px;
    border-top: 1px solid #e4dcc8;
    background: #fff;
  }

  .wbs-item:first-child {
    border-top: 0;
  }

  .wbs-item input {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: start;
    width: 20px;
    height: 20px;
    accent-color: #218aa0;
  }

  .wbs-item .wbs-item-serial {
    display: none;
  }

  .wbs-item .wbs-item-description {
    grid-column: 2 / -1;
    grid-row: 1;
    min-width: 0;
    color: #2c332b;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .wbs-item .wbs-item-sku,
  .wbs-item .wbs-item-pack {
    grid-column: 2;
    color: #6b675a;
    font-size: 11px;
    line-height: 1.2;
    white-space: normal;
  }

  .wbs-item .wbs-item-sku {
    grid-row: 2;
  }

  .wbs-item .wbs-item-pack {
    grid-row: 3;
  }

  .wbs-item .wbs-item-weight,
  .wbs-item .wbs-item-rate {
    grid-column: 3;
    justify-self: end;
    font-size: 12px;
    white-space: nowrap;
  }

  .wbs-item .wbs-item-weight {
    grid-row: 2;
    color: #1d4b2b;
  }

  .wbs-item .wbs-item-rate {
    display: block;
    grid-row: 3;
    color: #706b5e;
  }

  .wbs-picker-dialog .editor-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    border-top-color: #d6ceb7;
    background: #efe9d8;
    box-shadow: 0 -4px 14px rgba(28, 51, 33, 0.08);
  }

  .wbs-picker-dialog .editor-actions > span {
    max-height: 44px;
    padding: 6px 8px;
    overflow: auto;
    border: 0;
    border-radius: 6px;
    background: rgba(255, 253, 247, 0.82);
    font-size: 11px;
    line-height: 1.25;
  }

  .wbs-bulk-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .wbs-bulk-actions button,
  #importSelectedWbsBtn {
    min-height: 42px;
    border-radius: 7px;
  }

  #importSelectedWbsBtn {
    border-color: #1d4b2b;
    background: #1d4b2b;
    color: #fff;
    font-weight: 900;
  }
}

/* Customer Invoice: keep native iOS select text vertically centred and fully visible. */
@media (max-width: 700px) {
  #recordForm .form-field select[name="invoice_class"],
  #recordForm .form-field select[name="document_style"] {
    height: 46px;
    min-height: 46px;
    padding-top: 0;
    padding-bottom: 0;
    line-height: normal;
  }
}

/* Sales Order: keep native iOS select text vertically centred and fully visible. */
@media (max-width: 700px) {
  #recordForm .form-field select[name="shipment_terms"],
  #recordForm .form-field select[name="partial_shipment"] {
    height: 46px;
    min-height: 46px;
    padding-top: 0;
    padding-bottom: 0;
    line-height: normal;
  }
}

/* Customer and Supplier Invoices: keep all three mobile view buttons fully visible. */
@media (max-width: 700px) {
  .summary-strip.customer-invoice-summary-strip .wide-metric,
  .summary-strip.supplier-invoice-summary-strip .wide-metric {
    flex: 0 0 min(82vw, 320px);
  }

  .summary-strip.customer-invoice-summary-strip .wide-metric strong,
  .summary-strip.supplier-invoice-summary-strip .wide-metric strong {
    overflow: visible;
    text-overflow: clip;
  }

  .summary-strip.customer-invoice-summary-strip .wide-metric .compact-view-tabs,
  .summary-strip.supplier-invoice-summary-strip .wide-metric .compact-view-tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) auto;
    width: 100%;
  }

  .summary-strip.customer-invoice-summary-strip .wide-metric .compact-view-tabs button,
  .summary-strip.supplier-invoice-summary-strip .wide-metric .compact-view-tabs button {
    min-width: 0;
    padding-right: 8px;
    padding-left: 8px;
  }
}

/* Keep the mobile Sales Order summary sheet above earlier shared layout rules. */
@media (max-width: 700px) {
  .main.sales-order-mobile-page.sales-order-outstanding-open {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sales-order-outstanding-summary {
    display: block;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
  }
}

/* Reimbursement claims: isolated workflow styles. */
.content-grid.reimbursement-claims-mode { display:block; min-height:0; }
.reimbursement-claims-mode .detail-panel { display:none; }
.reimbursement-claims-mode .list-panel { display:block; height:auto; min-height:0; max-height:none; }
.reimbursement-claims-mode .table-wrap { width:100%; height:auto; min-height:0; max-height:none; overflow:visible; }
.reimbursement-claims-mode .table-wrap>table,
.reimbursement-claims-mode .table-wrap>table>tbody { display:block; width:100%; min-width:0; height:auto; }
.reimbursement-claims-mode .utility-tool-row { display:block; width:100%; height:auto; }
.reimbursement-claims-mode .utility-tool-row>td { display:block; box-sizing:border-box; width:100%; height:auto; min-width:0; max-width:none; padding:0; white-space:normal; vertical-align:top; overflow:visible; }
.reimbursement-portal { padding: 16px; color: #183f2a; }
.reimbursement-portal-head { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:4px 2px 16px; border-bottom:1px solid #d8d4c3; }
.reimbursement-portal-head h2,.reimbursement-editor-head h2 { margin:2px 0; font-family:Georgia,serif; color:#173d27; }
.reimbursement-portal-head p,.reimbursement-editor-head p { margin:0; color:#1698b1; font-weight:800; text-transform:uppercase; font-size:12px; letter-spacing:.04em; }
.reimbursement-portal-head span { color:#666; }
.reimbursement-head-actions { display:flex; align-items:center; gap:8px; }
.reimbursement-head-actions a {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-sizing:border-box;
  min-height:44px;
  padding:9px 15px;
  border:1px solid #a89f84;
  border-radius:3px;
  background:linear-gradient(#fffdf7 0%,#f3eddc 48%,#dfd6be 100%);
  color:var(--ink);
  font-weight:800;
  text-decoration:none;
  text-shadow:0 1px 0 rgba(255,255,255,.75);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.95),inset 0 -1px 0 rgba(83,72,48,.18),0 1px 0 rgba(83,72,48,.35);
}
.reimbursement-head-actions a:hover,
.reimbursement-head-actions a:focus-visible { border-color:#776a48; background:linear-gradient(#fff9e9 0%,#eee4cc 48%,#d7cbb0 100%); color:var(--ink); outline:1px solid rgba(29,161,201,.22); outline-offset:1px; }
.reimbursement-message { margin:12px 0; padding:10px 12px; border:1px solid #b9d8c1; border-radius:8px; background:#eef8ef; font-weight:700; }
.reimbursement-layout { display:grid; grid-template-columns:minmax(240px,320px) minmax(0,1fr); gap:16px; margin-top:16px; align-items:start; }
.reimbursement-layout>aside,.reimbursement-layout>main { min-width:0; }
.reimbursement-list-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.reimbursement-list-head button { min-width:44px; min-height:44px; border-radius:50%; }
.reimbursement-claim-list { min-width:0; }
.reimbursement-claim-card { display:block; width:100%; min-height:92px; margin:0 0 8px; padding:12px; text-align:left; border:1px solid #d5d0bc; border-radius:10px; background:#fffdf5; color:#243f2d; box-shadow:none; }
.reimbursement-claim-card.active { border:2px solid #1e6c43; background:#eff8ef; }
.reimbursement-card-top,.reimbursement-card-meta { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.reimbursement-card-person { display:block; margin:7px 0; color:#5f625b; }
.reimbursement-card-meta span { font-size:12px; color:#777; }
.reimbursement-status { display:inline-flex; align-items:center; min-height:28px; padding:4px 9px; border-radius:999px; background:#e5e6df; color:#4e534d; font:700 12px/1.1 Arial,sans-serif; }
.reimbursement-status.submitted { background:#fff0bf; color:#765600; }
.reimbursement-status.approved { background:#dcefe1; color:#17643b; }
.reimbursement-status.rejected { background:#f9dede; color:#9b2828; }
.reimbursement-status.approving { background:#dcecf5; color:#175f79; }
.reimbursement-welcome,.reimbursement-editor { border:1px solid #d5d0bc; border-radius:12px; background:#fffdf7; padding:16px; }
.reimbursement-welcome { text-align:center; padding:48px 20px; }
.reimbursement-camera { font-size:42px; color:#159bb5; }
.reimbursement-editor-head { display:flex; align-items:center; justify-content:space-between; gap:12px; border-bottom:1px solid #ddd8c8; padding-bottom:12px; }
.reimbursement-form-grid,.reimbursement-item-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px 12px; margin-top:14px; }
.reimbursement-form-grid label,.reimbursement-item-grid label { display:flex; flex-direction:column; min-width:0; gap:5px; font-weight:700; color:#4c554c; }
.reimbursement-form-grid .wide,.reimbursement-item-grid .wide { grid-column:1/-1; }
.reimbursement-form-grid input,.reimbursement-form-grid select,.reimbursement-form-grid textarea,.reimbursement-item-grid input,.reimbursement-item-grid select { box-sizing:border-box; width:100%; min-height:44px; padding:9px 10px; font-size:16px; border:1px solid #cbc6b5; border-radius:7px; background:#fffef9; }
.reimbursement-accounting-field span { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.reimbursement-accounting-field small { padding:2px 6px; border:1px solid #b8c9bd; border-radius:999px; color:#315b43; background:#eef6ef; font-size:10px; letter-spacing:.04em; text-transform:uppercase; }
.reimbursement-form-grid label:has(#reimbursementBank),
.reimbursement-form-grid label:has(#reimbursementReference),
.reimbursement-form-grid label:has(#reimbursementCredit) { display:none; }
.reimbursement-capture { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:16px 0; padding:14px; border:1px dashed #1f9eb7; border-radius:10px; background:#f0fafb; }
.reimbursement-capture.is-dragover { border-style:solid; background:#dff4f6; box-shadow:inset 0 0 0 2px #1f9eb7; }
.reimbursement-capture div span { display:block; margin-top:3px; color:#65706a; font-size:13px; }
.reimbursement-capture button { min-height:44px; white-space:nowrap; }
.reimbursement-item { margin-top:12px; padding:12px; border:1px solid #ddd7c5; border-radius:10px; background:#fff; }
.reimbursement-item-head { display:flex; align-items:center; justify-content:space-between; gap:12px; color:#183f2a; }
.reimbursement-item-head>strong { min-width:0; overflow-wrap:anywhere; }
.reimbursement-item-identity { display:flex; align-items:center; min-width:0; gap:8px; }
.reimbursement-item-identity strong { min-width:0; overflow-wrap:anywhere; }
.reimbursement-item-position { display:inline-flex; flex:0 0 auto; align-items:center; justify-content:center; min-width:42px; min-height:28px; padding:4px 8px; border:1px solid #9db9a5; border-radius:999px; background:#edf6ef; color:#174a2d; font:800 12px/1 Arial,sans-serif; font-variant-numeric:tabular-nums; }
.reimbursement-item-tools { display:flex; align-items:center; gap:6px; flex:0 0 auto; }
.reimbursement-item-tools button { min-height:38px; padding:7px 10px; }
.reimbursement-item-tools .reimbursement-receipt-remove { width:38px; min-width:38px; height:38px; padding:0; border:1px solid #c86a6a; border-radius:8px; background:#fff4f4; color:#9a2929; font-size:23px; font-weight:700; line-height:1; }
.reimbursement-warning,.reimbursement-rejection { margin:10px 0 0; padding:9px 11px; border-radius:7px; background:#fff3d3; color:#785d13; }
.reimbursement-rejection { display:flex; flex-direction:column; background:#fde8e8; color:#8b2929; }
.reimbursement-total,.reimbursement-voucher { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:16px; padding:12px 2px; border-top:2px solid #1d6540; font-size:18px; }
.reimbursement-voucher { border-top:1px solid #ddd8c8; font-size:15px; }
.reimbursement-voucher button { min-height:44px; color:#165f3a; font-weight:800; }
.reimbursement-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:14px; }
.reimbursement-actions button,.reimbursement-portal .primary-action { min-height:44px; padding:9px 15px; }
.reimbursement-actions .danger-action { border-color:#b84141; color:#932727; background:#fff4f4; }
.reimbursement-empty { padding:30px 14px; text-align:center; color:#696b65; }

.sales-order-document-actions { display:flex; align-items:center; flex-wrap:wrap; gap:7px; }
.sales-order-document-actions strong { margin-right:auto; }
.sales-order-primary-actions { justify-content:flex-end; flex-wrap:wrap; }
.sales-order-primary-actions #formStatus { margin-right:auto; }
.sales-order-primary-actions .approval-submit-action { border-color:#173f2c; background:#173f2c; color:#fff; font-weight:800; }
.sales-order-primary-actions .approval-submit-action:disabled { opacity:.58; }

.sales-order-payment-terms-field {
  position: relative;
  z-index: 8;
}

.sales-order-payment-terms-field > small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.sales-order-payment-terms-menu {
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 226px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--cyan);
  border-radius: 5px;
  background: #fffdf6;
  box-shadow: 0 8px 20px rgba(16, 56, 34, 0.2);
}

.sales-order-payment-terms-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
  color: var(--green-dark);
  text-align: left;
}

.sales-order-payment-terms-menu button + button {
  border-top: 1px solid var(--line);
}

.sales-order-payment-terms-menu button:hover,
.sales-order-payment-terms-menu button.is-active {
  background: var(--green-pale);
}

.sales-order-payment-terms-menu button span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.sales-order-other-information {
  display: grid;
  gap: 5px;
  padding: 0 12px 12px;
}

.sales-order-other-information textarea,
.sales-order-bottom-remarks textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 64px;
  resize: vertical;
}

.sales-order-bottom-remarks {
  display: grid;
  gap: 5px;
  padding: 12px;
  overflow: visible;
}

.sales-order-bottom-remarks label,
.sales-order-other-information {
  color: var(--ink);
  font-weight: 700;
}

.sales-order-pi-section {
  margin: 0 12px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
  overflow: visible;
}

.sales-order-pi-section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  box-sizing: border-box;
  padding: 8px 11px;
  cursor: pointer;
  color: var(--green-dark);
  background: linear-gradient(#fffdf7, #f2ecd9);
  font-weight: 800;
}

.sales-order-pi-section > summary small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.sales-order-pi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px 11px;
  padding: 11px;
  border-top: 1px solid var(--line);
}

.sales-order-pi-grid .form-field {
  min-width: 0;
}

.sales-order-pi-grid .wide {
  grid-column: span 2;
}

.sales-order-pi-grid input,
.sales-order-pi-grid select,
.sales-order-pi-grid textarea {
  box-sizing: border-box;
  width: 100%;
}

.sales-order-pi-grid textarea {
  min-height: 58px;
  resize: vertical;
}

.pi-freight-field {
  display: grid;
  gap: 5px;
}

.pi-freight-breakdown-check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.form-field .pi-freight-breakdown-check span {
  color: var(--green-dark);
  font-size: inherit;
  font-weight: inherit;
}

.sales-order-pi-grid .pi-freight-breakdown-check input {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  min-height: 17px;
  margin: 0;
  padding: 0;
}

.sales-order-pi-note {
  padding: 0 11px 10px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.sales-order-template-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 20px;
  background: rgba(19, 38, 28, 0.52);
}

.sales-order-template-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(820px, 100%);
  max-height: min(760px, calc(100dvh - 40px));
  overflow: hidden;
  border: 1px solid #bcb69f;
  border-top: 4px solid var(--cyan);
  border-radius: 10px;
  background: var(--ivory);
  box-shadow: 0 18px 50px rgba(14, 37, 24, 0.3);
}

.sales-order-template-dialog > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 13px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#fffdf7, #f1ecd9);
}

.sales-order-template-dialog > header span {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sales-order-template-dialog > header h2 {
  margin: 3px 0 2px;
  color: var(--green-dark);
  font: 700 23px/1.1 Georgia, serif;
}

.sales-order-template-dialog > header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.sales-order-template-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

.sales-order-template-list {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 10px;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sales-order-template-card {
  padding: 12px;
  border: 1px solid #d7d1bc;
  border-radius: 8px;
  background: #fffdf7;
}

.sales-order-template-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sales-order-template-card-head > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sales-order-template-card-head strong {
  color: var(--green-dark);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.sales-order-template-card-head span {
  color: var(--muted);
  font-size: 11px;
}

.sales-order-template-card-head button {
  min-height: 40px;
  color: var(--green-dark);
  white-space: nowrap;
}

.sales-order-template-items {
  display: grid;
  gap: 0;
  margin-top: 9px;
  border: 1px solid #dfe5da;
  border-radius: 6px;
  background: #f2f7ee;
}

.sales-order-template-items p {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 0;
  padding: 7px 9px;
  color: #2f4235;
  font-size: 12px;
}

.sales-order-template-items p + p {
  border-top: 1px solid #dfe5da;
}

.sales-order-template-items b {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sales-order-template-items span {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sales-order-template-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.sales-order-template-terms span {
  padding: 4px 7px;
  border: 1px solid #d6d0bb;
  border-radius: 999px;
  color: var(--muted);
  background: #f8f4e7;
  font-size: 10px;
  font-weight: 700;
}

.sales-order-template-dialog > footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--ivory-dark);
}

.sales-order-template-dialog > footer button {
  min-height: 44px;
}

.sales-order-template-dialog > footer small {
  color: var(--muted);
  line-height: 1.3;
}

/* Match the claimant portal's compact receipt card in the embedded workflow.
   The accounting-only coding fields remain available to authorised staff. */
.reimbursement-claims-page .accpro-ai-launcher,
.reimbursement-claims-page .accpro-ai-panel { display:none !important; }

@media (max-width: 700px) {
  .sales-order-template-overlay {
    place-items: center stretch;
    padding: 0;
  }
  .sales-order-template-dialog {
    width: 100%;
    max-height: 100dvh;
    height: auto;
    border-width: 4px 0 0;
    border-radius: 0;
  }
  .sales-order-template-dialog > header {
    padding: 13px 14px 11px;
  }
  .sales-order-template-dialog > header h2 {
    font-size: 21px;
  }
  .sales-order-template-list {
    gap: 8px;
    padding: 8px 10px;
  }
  .sales-order-template-card {
    align-self: start;
    padding: 9px 10px;
  }
  .sales-order-template-card-head {
    align-items: flex-start;
  }
  .sales-order-template-card-head button {
    min-height: 44px;
    padding: 8px 10px;
  }
  .sales-order-template-items p {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 6px 8px;
  }
  .sales-order-template-items span {
    white-space: normal;
  }
  .sales-order-template-dialog > footer {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
    padding-top: 8px;
  }
  .sales-order-template-dialog > footer button {
    width: 100%;
  }
  .sales-order-other-information,
  .sales-order-bottom-remarks {
    padding: 12px;
  }
  .sales-order-other-information textarea,
  .sales-order-bottom-remarks textarea {
    min-height: 82px;
    font-size: 16px;
  }
  .sales-order-pi-section {
    margin: 0 12px 12px;
  }
  .sales-order-pi-section > summary {
    min-height: 46px;
    padding: 9px 10px;
  }
  .sales-order-pi-section > summary small {
    max-width: 44%;
    text-align: right;
  }
  .sales-order-pi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }
  .sales-order-pi-grid .wide {
    grid-column: auto;
  }
  .sales-order-pi-grid input,
  .sales-order-pi-grid select,
  .sales-order-pi-grid textarea {
    min-height: 44px;
    font-size: 16px;
  }
  .pi-freight-breakdown-check {
    min-height: 44px;
    font-size: 13px;
  }
  .sales-order-pi-grid .pi-freight-breakdown-check input {
    width: 20px;
    height: 20px;
    min-height: 20px;
  }
  .sales-order-payment-terms-menu {
    top: 67px;
    max-height: 190px;
    padding: 3px;
  }
  .sales-order-payment-terms-menu button {
    min-height: 42px;
    padding: 8px 10px;
  }
  .sales-order-document-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .sales-order-document-actions strong { grid-column:1/-1; margin:0; }
  .sales-order-document-actions button { box-sizing:border-box; width:100%; min-width:0; min-height:44px; white-space:normal; }
  .sales-order-document-actions #printSalesOrderDocumentSetBtn,
  .sales-order-document-actions #addSalesOrderLineBtn { grid-column:1/-1; }
  .editor-dialog.sales-order-dialog .sales-order-primary-actions {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    gap:7px;
    padding:8px 10px max(8px,env(safe-area-inset-bottom));
  }
  .editor-dialog.sales-order-dialog .sales-order-primary-actions #formStatus {
    grid-column:1/-1;
    margin:0;
    font-size:12px;
    line-height:1.25;
  }
  .editor-dialog.sales-order-dialog .sales-order-primary-actions #saveRecordBtn,
  .editor-dialog.sales-order-dialog .sales-order-primary-actions #submitSalesContractApprovalBtn {
    box-sizing:border-box;
    width:100%;
    min-width:0;
    min-height:48px;
    margin:0;
  }
  .reimbursement-claims-mode .list-panel { height:auto !important; min-height:0 !important; }
  .reimbursement-claims-mode .table-wrap { overflow-x:hidden; overflow-y:visible; }
  .reimbursement-claims-mode .utility-tool-row,
  .reimbursement-claims-mode .utility-tool-row>td { display:block; width:100%; min-width:0; }
  .reimbursement-portal { box-sizing:border-box; width:100%; min-width:0; padding:10px 8px 86px; overflow-x:hidden; }
  .reimbursement-portal-head { display:block; padding:2px 0 12px; }
  .reimbursement-portal-head>div>span { display:none; }
  .reimbursement-portal-head h2 { margin:2px 0 0; font-size:25px; line-height:1.08; overflow-wrap:anywhere; }
  .reimbursement-head-actions { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); width:100%; margin-top:11px; }
  .reimbursement-head-actions a,
  .reimbursement-head-actions button { box-sizing:border-box; width:100%; min-width:0; min-height:44px; padding:8px; white-space:normal; }
  .reimbursement-layout { display:block; margin-top:12px; }
  .reimbursement-layout>aside,.reimbursement-layout>main { width:100%; }
  .reimbursement-list-head { margin-bottom:6px; }
  .reimbursement-claim-list { display:flex; gap:8px; width:100%; overflow-x:auto; overflow-y:hidden; padding:0 0 5px; scroll-snap-type:x mandatory; -webkit-overflow-scrolling:touch; }
  .reimbursement-claim-list>.reimbursement-empty { flex:1 0 100%; box-sizing:border-box; padding:11px 12px; border:1px dashed #d5d0bc; border-radius:9px; background:#fffdf7; text-align:left; }
  .reimbursement-claim-card { flex:0 0 min(82%,310px); margin:0; scroll-snap-align:start; }
  .reimbursement-layout>main { margin-top:10px; }
  .reimbursement-welcome { box-sizing:border-box; width:100%; min-height:0; padding:20px 14px 24px; overflow:hidden; }
  .reimbursement-welcome .reimbursement-camera { font-size:28px; line-height:1; }
  .reimbursement-welcome h3 { margin:8px 0 5px; }
  .reimbursement-welcome p { max-width:30rem; margin:0 auto 14px; line-height:1.4; white-space:normal; overflow-wrap:anywhere; }
  .reimbursement-welcome .primary-action { box-sizing:border-box; width:100%; min-height:48px; }
  .reimbursement-editor { padding:12px; }
  .reimbursement-editor-head { align-items:flex-start; }
  .reimbursement-form-grid,.reimbursement-item-grid { grid-template-columns:1fr; }
  .reimbursement-form-grid .wide,.reimbursement-item-grid .wide { grid-column:auto; }
  .reimbursement-capture { align-items:stretch; flex-direction:column; }
  .reimbursement-capture button { width:100%; }
  .reimbursement-actions { position:sticky; bottom:0; z-index:3; display:grid; grid-template-columns:1fr 1fr; padding:10px 0 max(10px,env(safe-area-inset-bottom)); background:#fffdf7; }
  .reimbursement-actions button { width:100%; min-height:48px; }
  .reimbursement-actions .reimbursement-coding-action { grid-column:1/-1; }
  .reimbursement-actions .reimbursement-delete-draft { grid-column:1/-1; }
  .reimbursement-item-head { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:start; gap:7px 10px; }
  .reimbursement-item-identity { align-items:flex-start; }
  .reimbursement-item-head>span { white-space:nowrap; font-weight:800; font-variant-numeric:tabular-nums; }
  .reimbursement-item-head>.reimbursement-item-tools { grid-column:1/-1; display:flex; width:100%; }
  .reimbursement-item-head>.reimbursement-item-tools button { width:auto; min-height:44px; }
  .reimbursement-item-head>.reimbursement-item-tools button:first-child { flex:1 1 auto; }
  .reimbursement-item-head>.reimbursement-item-tools .reimbursement-receipt-remove { flex:0 0 44px; width:44px; height:44px; }
}

/* Final cascade guard: shared phone table rules must not compress commission cards. */
@media (max-width: 700px) {
  .content-grid.commission-tracking-mode .list-panel {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }
  .content-grid.commission-tracking-mode .table-wrap {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .content-grid.commission-tracking-mode table {
    min-width: 0 !important;
    table-layout: auto !important;
  }
  .content-grid.commission-tracking-mode tbody tr,
  .content-grid.commission-tracking-mode tbody td {
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
  }
}

.customer-invoice-commission-title { display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
.customer-invoice-commission-title h2 { margin:0; }
.customer-invoice-commission-title>span { color:#686459; font-size:10px; font-weight:700; }
.customer-invoice-commission-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:9px; margin-top:8px; }
.customer-invoice-commission-card { min-width:0; padding:10px; border:1px solid #d5cfba; border-radius:8px; background:#fffdf7; }
.customer-invoice-commission-card>header { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px; }
.customer-invoice-commission-card>header>div { display:grid; min-width:0; gap:2px; }
.customer-invoice-commission-card>header>div>span { color:#686459; font-size:9px; font-weight:800; letter-spacing:.04em; text-transform:uppercase; }
.customer-invoice-commission-card>header strong { overflow-wrap:anywhere; color:#173d27; }
.customer-invoice-commission-card dl { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); margin:0; border-top:1px solid #e3decc; }
.customer-invoice-commission-card dl>div { min-width:0; padding:8px 7px 4px 0; }
.customer-invoice-commission-card dt { color:#686459; font-size:9px; font-weight:800; letter-spacing:.03em; text-transform:uppercase; }
.customer-invoice-commission-card dd { margin:3px 0 0; color:#2c3027; font-size:12px; font-weight:800; font-variant-numeric:tabular-nums; white-space:nowrap; }
.customer-invoice-commission-card .commission-outstanding dd { color:#8c2929; }
.customer-invoice-commission-card>small { display:block; margin-top:7px; padding-top:7px; border-top:1px solid #e3decc; color:#666459; line-height:1.35; overflow-wrap:anywhere; }

@media (max-width:700px) {
  .customer-invoice-commission-title { display:grid; gap:2px; }
  .customer-invoice-commission-title>span { font-size:10px; }
  .customer-invoice-commission-grid { grid-template-columns:1fr; }
  .customer-invoice-commission-card { padding:10px; }
  .customer-invoice-commission-card dl { grid-template-columns:1fr 1fr; }
  .customer-invoice-commission-card dl>div { padding:8px 6px 6px 0; }
  .customer-invoice-commission-card .commission-outstanding { grid-column:1/-1; border-top:1px solid #e8e3d2; }
  .customer-invoice-commission-card dd { font-size:13px; }
}

@media (max-width: 700px) {
  .content-grid.user-profile-mode {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .content-grid.user-profile-mode .list-panel {
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  .content-grid.user-profile-mode .detail-panel {
    display: none;
  }

  .content-grid.user-profile-mode .table-wrap {
    width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .content-grid.user-profile-mode .table-wrap > table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .content-grid.user-profile-mode .table-wrap > table > tbody,
  .content-grid.user-profile-mode .utility-tool-row,
  .content-grid.user-profile-mode .utility-tool-row > td {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    box-sizing: border-box;
  }

  .content-grid.user-profile-mode .utility-tool-panel {
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 10px;
    box-sizing: border-box;
  }

  .content-grid.user-profile-mode .utility-tool-head {
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
  }

  .content-grid.user-profile-mode .utility-tool-head h2 {
    font-size: 23px;
    line-height: 1.05;
  }

  .content-grid.user-profile-mode .utility-pill {
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .content-grid.user-profile-mode .user-profile-layout {
    gap: 10px;
  }

  .content-grid.user-profile-mode .user-profile-card {
    width: 100%;
    min-width: 0;
    padding: 12px;
    border-radius: 10px;
    box-sizing: border-box;
  }

  .content-grid.user-profile-mode .user-profile-card-head {
    align-items: center;
    margin-bottom: 9px;
  }

  .content-grid.user-profile-mode .user-profile-card-head h3 {
    font-size: 18px;
    line-height: 1.1;
  }

  .content-grid.user-profile-mode .user-profile-fields {
    gap: 8px;
  }

  .content-grid.user-profile-mode .user-profile-fields input,
  .content-grid.user-profile-mode .user-signature-picker input,
  .content-grid.user-profile-mode .user-password-card input {
    min-height: 44px;
    max-width: 100%;
    font-size: 16px;
  }

  .content-grid.user-profile-mode .user-signature-preview {
    min-height: 88px;
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 7px;
  }

  .content-grid.user-profile-mode .user-signature-preview img {
    max-width: 78%;
    max-height: 78px;
  }

  .content-grid.user-profile-mode .user-signature-picker input[type="file"] {
    padding: 5px;
    overflow: hidden;
  }

  .content-grid.user-profile-mode .user-signature-picker input[type="file"]::file-selector-button {
    min-height: 34px;
    margin-right: 8px;
    padding: 6px 10px;
    border: 1px solid #b6ad8e;
    border-radius: 7px;
    background: #f5f0df;
    color: var(--green-dark);
    font: inherit;
    font-size: 13px;
    font-weight: 800;
  }

  .content-grid.user-profile-mode .user-signature-draw-head {
    align-items: center;
  }

  .content-grid.user-profile-mode .user-signature-draw-head button {
    min-width: 92px;
    min-height: 44px;
  }

  .content-grid.user-profile-mode #utilitySignaturePad {
    height: 124px;
  }

  .content-grid.user-profile-mode .user-profile-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .content-grid.user-profile-mode .user-profile-actions button,
  .content-grid.user-profile-mode .user-password-card button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding-inline: 8px;
  }

  .content-grid.user-profile-mode .user-profile-actions button:only-child {
    grid-column: 1 / -1;
  }

  .content-grid.user-profile-mode .utility-status {
    margin-top: 4px;
    font-size: 12px;
  }

  .content-grid.user-profile-mode .user-password-card {
    margin-top: 0;
  }

  .content-grid.user-profile-mode .user-password-card .utility-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
}
