/* Shared dialog design */
.app-modal {
  width: min(92vw, 1040px);
  max-width: 92vw;
  max-height: min(92dvh, 900px);
  padding: 0;
  overflow: auto;
  border: 1px solid #c9d9fb;
  border-radius: 24px;
  background: #f9fbff;
  box-shadow: 0 35px 100px #061d4b80;
  color: #10254a;
}
.app-modal::backdrop { background: #081d43aa; backdrop-filter: blur(6px); }
.app-modal, .app-modal * { box-sizing: border-box; }
.app-modal > .party-form-wrap, .app-modal > .purchase-modal {
  width: 100%;
  max-height: none;
  overflow: visible;
}
.app-modal .modal-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 112px;
  padding: 20px 28px;
  border: 0;
  background: linear-gradient(120deg,#0656d4 0%,#3569ec 48%,#8faafd 100%);
  color: #fff;
  isolation: isolate;
  overflow: hidden;
}
.app-modal .modal-header::after {
  content: "";
  position: absolute;
  inset: 0 0 0 55%;
  z-index: -1;
  background: linear-gradient(135deg,transparent 0 30%,#ffffff1b 30% 60%,#ffffff12 60%);
}
.modal-title-group { display:flex; align-items:center; gap:20px; min-width:0; }
.modal-title-icon {
  display:grid;
  place-items:center;
  width:64px;
  height:64px;
  flex:none;
  border-radius:50%;
  background:#ffffff29;
  box-shadow:inset 0 0 0 1px #ffffff25;
}
.modal-title-icon svg { width:33px; height:33px; }
.modal-title-copy { min-width:0; }
.app-modal .modal-header h2 {
  margin:0;
  color:#fff;
  font-size:clamp(23px,2.7vw,31px);
  font-weight:800;
  line-height:1.1;
  letter-spacing:-.035em;
}
.modal-subtitle { margin:8px 0 0; color:#eaf1ff; font-size:14px; }
.app-modal .modal-close-button,
.app-modal .modal-header [data-close] {
  display:grid;
  place-items:center;
  width:44px;
  height:44px;
  min-height:44px;
  flex:none;
  padding:0;
  border:0;
  border-radius:50%;
  background:#ffffffb8;
  color:#09255b;
  font-size:27px;
  font-weight:400;
  line-height:1;
}
.app-modal .modal-header [data-close]:hover { background:#fff; transform:scale(1.04); }
.app-modal form { margin:0; }
.app-modal .party-form,
.app-modal .purchase-form {
  min-width:0;
  padding:28px 30px 32px;
  background:#f9fbff;
}
.app-modal .party-form {
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:20px 24px;
}
.app-modal .party-form>*, .app-modal .purchase-form>* { min-width:0; }
.app-modal .modal-section-title {
  grid-column:1/-1;
  display:flex;
  align-items:center;
  gap:12px;
  min-height:43px;
  padding:0 0 12px;
  margin:0 0 4px;
  border-bottom:1px solid #e2eaf6;
}
.app-modal .modal-section-title span { color:#1267ed; font-size:23px; }
.app-modal .modal-section-title h3 { margin:0; font-size:19px; font-weight:780; color:#14366d; }
.app-modal .party-form label,
.app-modal .purchase-fields label,
.app-modal .purchase-line label {
  display:grid;
  align-content:start;
  gap:8px;
  min-width:0;
  color:#152d54;
  font-size:13px;
  font-weight:740;
}
.app-modal input:not([type="hidden"]),
.app-modal select,
.app-modal textarea {
  width:100%;
  min-width:0;
  min-height:48px;
  padding:10px 13px;
  border:1px solid #c8d5e9;
  border-radius:9px;
  background:#fff;
  color:#14294d;
  font-size:14px;
  font-weight:500;
  box-shadow:0 1px 2px #17396909;
  transition:border-color .15s,box-shadow .15s;
}
.app-modal textarea { min-height:94px; resize:vertical; }
.app-modal input::placeholder,.app-modal textarea::placeholder { color:#8a9bb2; }
.app-modal input:focus,.app-modal select:focus,.app-modal textarea:focus {
  outline:none;
  border-color:#286dff;
  box-shadow:0 0 0 3px #2e70ff26;
}
.app-modal input[readonly],.app-modal select:disabled { background:#f1f5fb; color:#5f718c; }
.app-modal label small { min-height:0; font-size:11px; font-weight:550; color:#d2324e; }
.app-modal .party-form .wide { grid-column:1/-1; }
.app-modal .party-type-field {
  order:-1;
  display:flex;
  align-items:end;
  gap:9px;
  min-width:0;
  margin:0;
  padding:0;
  border:0;
}
.app-modal .party-form>.modal-section-title { order:-2; }
.app-modal .party-type-field legend {
  width:100%;
  padding:0 0 8px;
  color:#152d54;
  font-size:13px;
  font-weight:740;
}
.app-modal .party-type-field label {
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  flex:1;
  min-height:48px;
  padding:8px 10px;
  border:1px solid #c8d5e9;
  border-radius:9px;
  background:#fff;
  color:#183457;
  cursor:pointer;
}
.app-modal .party-type-field label:has(input:checked) {
  border-color:#286dff;
  background:#edf4ff;
  color:#0755d7;
  box-shadow:0 0 0 2px #286dff1e;
}
.app-modal .party-type-field input[type="radio"] {
  width:17px;
  height:17px;
  min-width:17px;
  min-height:17px;
  margin:0;
  padding:0;
  accent-color:#1267ed;
  box-shadow:none;
}
.app-modal .purchase-form { gap:22px; }
.app-modal .purchase-fields { grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px 24px; }
.app-modal .purchase-form>div:has(>h3),
.app-modal .purchase-form>section {
  padding:20px;
  border:1px solid #dfe8f6;
  border-radius:16px;
  background:#fff;
  box-shadow:0 5px 18px #254b7c09;
}
.app-modal .purchase-form>div:has(>h3)>h3,
.app-modal .purchase-form>section>h3 {
  margin:0 0 17px;
  padding-bottom:12px;
  border-bottom:1px solid #e6edf7;
  font-size:18px;
}
.app-modal .purchase-line { border-color:#dfe8f6; background:#f8fbff; border-radius:12px; }
.app-modal .purchase-line button,
.app-modal [data-add-line],
.app-modal [data-add-onp] {
  padding:9px 13px;
  border:1px solid #bdd2f2;
  border-radius:8px;
  background:#edf5ff;
  color:#1164d5;
  font-size:12px;
  font-weight:750;
}
.app-modal [data-add-line],.app-modal [data-add-onp] { margin-top:12px; }
.app-modal .modal-error:not(:empty) {
  margin:0 30px 20px;
  padding:11px 14px;
  border:1px solid #f6bdca;
  border-radius:9px;
  background:#fff0f3;
}
.app-modal .modal-footer {
  position:sticky;
  bottom:0;
  z-index:4;
  display:flex;
  justify-content:flex-end;
  gap:10px;
  min-height:78px;
  padding:16px 28px;
  border-top:1px solid #dfe8f6;
  background:#f8faffed;
  backdrop-filter:blur(12px);
}
.app-modal .modal-footer button {
  min-height:44px;
  padding:10px 20px;
  border:1px solid #adbfdf;
  border-radius:9px;
  background:#fff;
  color:#12315c;
  font-size:13px;
  font-weight:740;
}
.app-modal .modal-footer .button,
.app-modal .modal-footer .modal-save-button {
  border-color:#1267ef;
  background:linear-gradient(120deg,#1675f7,#0e53d9);
  color:#fff;
  box-shadow:0 5px 13px #135fe535;
}
.app-modal .modal-footer button:hover { filter:brightness(1.04); }
.app-modal .modal-footer button:disabled { opacity:.55; cursor:wait; }
@media(max-width:700px) {
  .app-modal { width:100vw; max-width:100vw; height:100dvh; max-height:100dvh; margin:0; border:0; border-radius:0; }
  .app-modal .modal-header { min-height:91px; padding:16px 18px; }
  .modal-title-group { gap:11px; }
  .modal-title-icon { width:47px; height:47px; }
  .modal-title-icon svg { width:25px; height:25px; }
  .app-modal .modal-header h2 { font-size:21px; }
  .modal-subtitle { margin-top:5px; font-size:11px; }
  .app-modal .modal-header [data-close] { width:37px; height:37px; min-height:37px; font-size:23px; }
  .app-modal .party-form,.app-modal .purchase-form { padding:19px 17px 24px; }
  .app-modal .party-form,.app-modal .purchase-fields,.app-modal .purchase-line { grid-template-columns:minmax(0,1fr); }
  .app-modal input:not([type="hidden"]),.app-modal select,.app-modal textarea { min-height:46px; font-size:16px; }
  .app-modal .modal-footer { min-height:70px; padding:12px 16px max(12px,env(safe-area-inset-bottom)); }
  .app-modal .modal-footer button { flex:1; padding-inline:9px; }
  .app-modal .purchase-form>div:has(>h3),.app-modal .purchase-form>section { padding:15px; }
  .app-modal .modal-error:not(:empty) { margin:0 17px 16px; }
}
.app-modal input.auto-reference[readonly] {
  max-width:280px;
  border-color:#c5d8f6;
  background:#eef5ff;
  color:#1453a5;
  font-size:13px;
  font-weight:750;
  letter-spacing:0;
}
.app-modal .auto-reference-hint { color:#4972aa; font-size:11px; font-weight:600; }

/* Compact dialog shell: only the form body scrolls. */
.app-modal {
  width:min(90vw,720px);
  max-width:90vw;
  max-height:min(84dvh,740px);
  overflow:hidden;
  border-radius:17px;
}
.app-modal:has(.purchase-modal) { width:min(90vw,860px); }
.app-modal > .party-form-wrap,
.app-modal > .purchase-modal {
  display:flex;
  flex-direction:column;
  width:100%;
  max-height:min(84dvh,740px);
  min-height:0;
  overflow:hidden;
}
.app-modal .modal-header {
  position:relative;
  top:auto;
  flex:none;
  min-height:76px;
  padding:13px 20px;
}
.modal-title-group { gap:13px; }
.modal-title-icon { width:43px; height:43px; }
.modal-title-icon svg { width:23px; height:23px; }
.app-modal .modal-header h2 { font-size:21px; }
.modal-subtitle { margin-top:3px; font-size:11px; }
.app-modal .modal-header [data-close] {
  width:36px;
  height:36px;
  min-height:36px;
  font-size:22px;
}
.app-modal form,
.app-modal .purchase-form {
  display:flex;
  flex:1 1 auto;
  flex-direction:column;
  min-height:0;
  padding:0;
  overflow:hidden;
}
.app-modal .modal-scroll-body {
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  overscroll-behavior:contain;
  padding:20px 22px 24px;
  scrollbar-width:thin;
  scrollbar-color:#9db4d5 transparent;
}
.app-modal .modal-scroll-body::-webkit-scrollbar { width:8px; }
.app-modal .modal-scroll-body::-webkit-scrollbar-thumb {
  border-radius:8px;
  background:#a9bbd5;
}
.app-modal .party-form {
  padding:0;
  gap:15px 18px;
  background:transparent;
}
.app-modal .party-form-wrap > .party-form {
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  padding:20px 22px;
}
.app-modal .modal-section-title {
  min-height:auto;
  margin:0 0 3px;
  padding:0 0 9px;
}
.app-modal .modal-section-title h3 { font-size:16px; }
.app-modal .modal-section-title span { font-size:18px; }
.app-modal .modal-scroll-body > .modal-section-title { margin-bottom:15px; }
.app-modal .purchase-fields { gap:15px 18px; }
.app-modal .purchase-form > .modal-section-title { display:none; }
.app-modal .modal-scroll-body > div:not(.modal-section-title):has(>h3),
.app-modal .modal-scroll-body > section {
  margin-top:18px;
  padding:16px;
  border:1px solid #dfe8f6;
  border-radius:12px;
  background:#fff;
}
.app-modal .modal-scroll-body > div:not(.modal-section-title):has(>h3) > h3,
.app-modal .modal-scroll-body > section > h3 {
  margin:0 0 13px;
  padding-bottom:9px;
  border-bottom:1px solid #e6edf7;
  font-size:16px;
}
.app-modal input:not([type="hidden"]),
.app-modal select { min-height:42px; }
.app-modal .modal-footer {
  position:relative;
  bottom:auto;
  flex:none;
  min-height:62px;
  padding:10px 18px;
  background:#f8faff;
}
.app-modal .modal-footer button { min-height:39px; padding:8px 15px; }
.app-modal .modal-error:not(:empty) { margin:15px 0 0; }
@media(max-width:700px) {
  .app-modal,
  .app-modal:has(.purchase-modal) {
    width:100vw;
    max-width:100vw;
    height:100dvh;
    max-height:100dvh;
    margin:0;
    border:0;
    border-radius:0;
  }
  .app-modal > .party-form-wrap,.app-modal > .purchase-modal {
    height:100dvh;
    max-height:100dvh;
  }
  .app-modal .modal-header { min-height:69px; padding:11px 14px; }
  .app-modal .modal-header h2 { font-size:18px; }
  .app-modal .modal-scroll-body { padding:16px 14px 20px; }
  .app-modal .party-form-wrap > .party-form { padding:16px 14px; }
  .app-modal .party-form,.app-modal .purchase-fields,.app-modal .purchase-line {
    grid-template-columns:minmax(0,1fr);
  }
  .app-modal .modal-footer { padding:10px 12px max(10px,env(safe-area-inset-bottom)); }
}

.app-modal:has(> .trade-entry-modal) {
  width: min(94vw, 940px);
  max-width: 94vw;
}
.app-modal.form-dialog .modal-header {
  gap: 16px;
  min-height: 66px;
  padding: 12px 20px;
  border-bottom: 1px solid #dbe6f3;
  background: #fff;
}
.app-modal.form-dialog .modal-header::before,
.app-modal.form-dialog .modal-header::after,
.app-modal.form-dialog .modal-subtitle {
  display: none;
}
.app-modal.form-dialog .modal-header h2 {
  margin: 0;
  color: #132846;
  font-size: clamp(1.125rem, 2.65vw, 1.5rem);
  line-height: 1.2;
}
.app-modal.form-dialog .modal-title-icon {
  width: 40px;
  height: 40px;
  border: 1px solid #cfe4ff;
  border-radius: 12px;
  background: #eaf4ff;
  color: #1464d2;
}
.app-modal.form-dialog .modal-header [data-close] {
  flex: 0 0 36px;
  border: 1px solid #e0e9f6;
  border-radius: 10px;
  background: #f4f7fc;
  color: #27456f;
}
.app-modal.form-dialog form { gap: 0; }
.app-modal.form-dialog .modal-scroll-body {
  padding: 14px 20px 18px;
  background: #f2f6fc;
  scroll-padding: 12px;
}
.app-modal.form-dialog .modal-scroll-body > .form-panel {
  margin: 0;
  padding: 14px;
  border: 1px solid #dae5f3;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 7px #173d6909;
}
.app-modal.form-dialog .form-panel + .form-panel { margin-top: 10px; }
.form-dialog :is(.order-section-heading, .form-section-bar) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.form-dialog :is(.order-section-heading, .form-section-bar) h3 {
  margin: 0;
  color: #192e4e;
  font-size: .975rem;
  line-height: 1.3;
}
.trade-entry-modal .order-section-heading p,
.trade-entry-modal .order-empty {
  margin: 4px 0 0;
  color: #506582;
  font-size: .8125rem;
  line-height: 1.45;
}
.app-modal .trade-entry-modal .order-meta {
  grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr));
  gap: 9px 12px;
  margin-top: 11px;
}
.app-modal .trade-entry-modal .auto-reference { width: 100%; }
.trade-entry-modal .order-readonly-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid #e0e9f5;
  border-radius: 8px;
  background: #f8faff;
}
.trade-entry-modal .order-readonly-meta dt { color: #506582; font-size: .8125rem; }
.trade-entry-modal .order-readonly-meta dd { margin: 3px 0 0; color: #192e4e; font-weight: 650; overflow-wrap: anywhere; }
.app-modal .trade-entry-modal .order-sale-fields { gap: 9px 12px; margin-top: 9px; }
.trade-entry-modal .sale-paid-choice {
  display: flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  min-height: 42px;
  margin-top: 8px;
  padding: 7px 10px;
  border: 1px solid #d1e1f7;
  border-radius: 8px;
  background: #f2f7ff;
  color: #17355f;
  font-weight: 650;
  cursor: pointer;
}
.trade-entry-modal .sale-paid-choice input { width: 17px; height: 17px; margin: 0; accent-color: #1267e9; }
.trade-entry-modal .sale-paid-note { margin: 6px 0 0; }
.trade-entry-modal .order-totals-table th small { display: block; margin-top: 2px; color: #506582; text-transform: none; }
.trade-entry-modal .auto-reference-hint { display: none; }
.app-modal.form-dialog :is(.party-form, .purchase-fields, .purchase-line, .supplier-bank-row) label {
  min-width: 0;
  gap: 5px;
  color: #304968;
  font-size: .8125rem;
  line-height: 1.25;
}
.app-modal.form-dialog input:not([type="hidden"], [type="checkbox"], [type="radio"]),
.app-modal.form-dialog select {
  width: 100%;
  min-height: 40px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: .9375rem;
}
.trade-entry-modal .purchase-lines:not(:empty) {
  gap: 9px;
  margin-top: 10px;
}
.app-modal .trade-entry-modal :is(.order-product-line, .order-fee-line, .stock-purchase-line) {
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid #e0e9f5;
  border-radius: 9px;
  background: #f8faff;
}
.app-modal .trade-entry-modal .order-product-line {
  grid-template-columns: minmax(0, 2.3fr) minmax(0, .85fr) minmax(0, .9fr) minmax(0, 1.2fr) minmax(0, 1.15fr) 36px;
}
.app-modal .trade-entry-modal .stock-purchase-line {
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, .95fr)) repeat(2, minmax(0, 1.2fr));
}
.app-modal .trade-entry-modal .stock-purchase-meta {
  grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 1fr));
  gap: 9px 12px;
}
.form-dialog .form-section-bar:has(+ .stock-advance-line),
.form-dialog .form-section-bar:has(+ [data-advance-rows]:not(:empty)) { margin-bottom: 10px; }
.app-modal .trade-entry-modal .order-fee-line {
  grid-template-columns: minmax(0, 1fr) minmax(110px, .36fr) 36px;
}
.trade-entry-modal .order-availability {
  grid-column: 1 / -1;
  margin: 0;
  color: #415f82;
  font-size: .75rem;
}
.trade-entry-modal .order-stock-info:not([hidden]) {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  font-size: .75rem;
  line-height: 1.4;
}
.trade-entry-modal .order-stock-lot {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #dce7f5;
  border-radius: 8px;
  background: #fff;
  color: #415f82;
  overflow-wrap: anywhere;
}
.trade-entry-modal .order-stock-meta,
.trade-entry-modal .order-stock-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.trade-entry-modal .order-stock-meta { justify-content: space-between; }
.trade-entry-modal .order-stock-meta strong { color: #192e4e; }
.trade-entry-modal .order-stock-levels { margin-top: 5px; }
.trade-entry-modal .order-stock-levels span:last-child { color: #1558b6; }
.trade-entry-modal .order-stock-warning { display: block; margin-top: 4px; color: #8a4b13; font-weight: 600; }
.app-modal .trade-entry-modal .order-add,
.app-modal .trade-entry-modal .order-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid #c9ddf7;
  border-radius: 8px;
  background: #f0f6ff;
  color: #1558b6;
  font-size: .8125rem;
  font-weight: 700;
}
.trade-entry-modal .order-add span { font-size: 1.1rem; line-height: 1; }
.trade-entry-modal .order-add[data-add-line] { margin-top: 9px; }
.app-modal .trade-entry-modal .order-add:enabled:hover { background: #e4efff; }
.app-modal .trade-entry-modal .order-remove {
  width: 100%;
  min-height: 40px;
  padding: 0;
  border-color: #e4dfeb;
  background: #fff;
  color: #81516a;
  font-size: 1.15rem;
}
.app-modal .trade-entry-modal .order-remove:enabled:hover { background: #fceef3; }
.app-modal .trade-entry-modal .order-remove:disabled { visibility: hidden; }
.app-modal.form-dialog .modal-footer {
  gap: 9px;
  min-height: 61px;
  padding-inline: 20px;
  border-top: 1px solid #dce7f5;
  background: #fff;
}
.app-modal.form-dialog .modal-footer button { min-height: 42px; }

.trade-entry-modal .order-totals-scroll {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid #dce7f5;
  border-radius: 9px;
}
.trade-entry-modal .order-recap-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 0;
}
.trade-entry-modal .order-recap-meta > div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #dce7f5;
  border-radius: 8px;
  background: #f8faff;
}
.trade-entry-modal .order-recap-meta dt { color: #506582; font-size: .8125rem; }
.trade-entry-modal .order-recap-meta dd {
  margin: 3px 0 0;
  color: #192e4e;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.trade-entry-modal .order-recap-meta .order-recap-purchase-total { background: #e7f1ff; border-color: #cfdef6; }
.trade-entry-modal .order-recap-purchase-total dd { color: #1558b6; }
.trade-entry-modal .order-recap-purchase-total small { display: block; margin-top: 2px; color: #415f82; font-weight: 500; }
.trade-entry-modal .order-totals-table {
  width: 100%;
  border-collapse: collapse;
  color: #192e4e;
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
}
.trade-entry-modal .order-totals-table :is(th, td) {
  padding: 8px 10px;
  border-bottom: 1px solid #e5edf7;
  text-align: right;
  white-space: nowrap;
}
.trade-entry-modal .order-totals-table th:first-child {
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
.trade-entry-modal .order-totals-table :is(thead, tfoot) { background: #f2f6fc; font-weight: 700; }
.trade-entry-modal .order-totals-table .order-totals-empty { text-align: left; color: #506582; white-space: normal; }
.trade-entry-modal .order-totals-unit { color: #506582; }
.trade-entry-modal .order-totals-grand { background: #e7f1ff; color: #1558b6; }
.trade-entry-modal .order-totals-grand :is(th, td) { border-bottom: 0; }
.trade-entry-modal .order-footer-total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 9px;
  margin-right: auto;
  align-self: center;
  color: #415f82;
  font-size: .8125rem;
}
.trade-entry-modal .order-footer-total output {
  color: #1558b6;
  font-size: .975rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}


.app-modal.form-dialog .modal-scroll-body > .party-form {
  display: grid;
  gap: 11px 14px;
}
.app-modal.form-dialog .modal-section-title {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0 0 8px;
}
.app-modal.form-dialog .modal-section-title h3 {
  color: #192e4e;
  font-size: .975rem;
}
.app-modal.form-dialog .modal-scroll-body > section > h3,
.app-modal.form-dialog .supplier-bank-heading {
  margin: 0 0 10px;
  padding: 0 0 8px;
  border-bottom: 1px solid #e0e9f5;
  color: #192e4e;
  font-size: .975rem;
}
.app-modal.form-dialog .supplier-bank-heading h3 { color: inherit; font-size: inherit; }
.app-modal.form-dialog :is(.purchase-line, .supplier-bank-row) {
  border-color: #e0e9f5;
  border-radius: 9px;
  background: #f8faff;
}
.app-modal.form-dialog .party-form label > small:empty { display: none; }
.app-modal.form-dialog .party-type-field label { min-height: 40px; border-radius: 8px; }
.app-modal.form-dialog .party-type-field legend { padding-bottom: 5px; font-size: .8125rem; }
.app-modal.form-dialog textarea { border-radius: 8px; font-size: .9375rem; }
.app-modal.form-dialog .form-panel p:not(.order-availability) {
  color: #506582;
  font-size: .8125rem;
  line-height: 1.45;
}
.app-modal.form-dialog .form-panel button:not([type="submit"]):not(.order-remove) {
  min-height: 36px;
  border-radius: 8px;
  font-size: .8125rem;
}
.app-modal.form-dialog .form-panel :is([data-add-line], [data-add-onp], [data-add-advance], [data-add-bank]) {
  border: 1px solid #c9ddf7;
  background: #f0f6ff;
  color: #1558b6;
  padding: 6px 10px;
  font-weight: 700;
}
.app-modal.form-dialog .modal-header [data-close]:hover { background: #e9f2ff; }
.app-modal.form-dialog :focus-visible { outline: 2px solid #216bdb; outline-offset: 2px; }

@media (max-width: 760px) {
  .app-modal .trade-entry-modal .order-product-line {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
  }
  .app-modal .trade-entry-modal .stock-purchase-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trade-entry-modal :is(.order-product-line, .stock-purchase-line) > label:first-child { grid-column: 1 / -1; }
  .trade-entry-modal .order-product-line > label:nth-of-type(4) { grid-column: 1; }
}
@media (max-width: 700px) {
  .app-modal:has(> .trade-entry-modal) { width: 100vw; max-width: 100vw; }
  .app-modal.form-dialog .modal-header,
  .app-modal.form-dialog .modal-footer { padding-inline: 12px; }
  .app-modal.form-dialog .modal-scroll-body { padding: 12px; }
  .app-modal.form-dialog .modal-scroll-body > .form-panel { padding: 11px; }
  .app-modal .trade-entry-modal :is(.order-meta, .stock-purchase-meta) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trade-entry-modal .order-readonly-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trade-entry-modal .order-readonly-meta > div:first-child { grid-column: 1 / -1; }
  .trade-entry-modal :is(.order-meta, .stock-purchase-meta) > label:first-of-type { grid-column: 1 / -1; }
  .app-modal.form-dialog input:not([type="hidden"], [type="checkbox"], [type="radio"]),
  .app-modal.form-dialog select { min-height: 44px; font-size: 1rem; }
  .app-modal.form-dialog .modal-footer button { flex: 0 0 auto; min-height: 44px; }
  .app-modal.form-dialog .modal-footer [type="submit"] { flex: 1; }
  .app-modal.form-dialog .modal-footer:has(.order-footer-total) { flex-wrap: wrap; }
  .trade-entry-modal .order-footer-total { flex: 0 0 100%; justify-content: space-between; }
  .trade-entry-modal .order-recap-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trade-entry-modal .order-recap-purchase-total { grid-column: 1 / -1; }
  .trade-entry-modal .order-totals-table :is(th, td) { padding: 7px 6px; }
  .trade-entry-modal .order-totals-table thead th { white-space: normal; }
  .trade-entry-modal .order-totals-unit { display: block; }
}

/* Forms embedded in a page use the same surfaces as the dialogs. */
.form-page-card {
  border: 1px solid #dae5f3;
  border-radius: 15px;
  background: #f2f6fc;
  box-shadow: 0 10px 32px #173d6914;
  overflow: hidden;
}
.login-card.form-page-card {
  width: min(100%, 460px);
  padding: 0;
}
.form-page-card .form-page-header {
  background: #fff;
  border-bottom: 1px solid #dbe6f3;
  color: #132846;
  padding: 14px 18px;
}
.login-card .form-page-header > div {
  display: flex;
  align-items: center;
  gap: 12px;
}
.login-card .form-page-header .brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  margin: 0;
  border: 1px solid #cfe4ff;
  border-radius: 12px;
  background: #eaf4ff;
  color: #1464d2;
}
.login-card .form-page-header h1 {
  margin: 0;
  font-size: clamp(1.2rem, 4.5vw, 1.55rem);
  line-height: 1.2;
}
.login-card .form-page-intro {
  margin: 14px 16px 10px;
  color: #506582;
  font-size: .875rem;
}
.login-card .form-page-intro p { margin: 0; }
.form-page-fields {
  min-width: 0;
  margin: 14px 16px;
  padding: 14px;
  border: 1px solid #dae5f3;
  border-radius: 12px;
  background: #fff;
}
.login-card .form-page-fields { display: grid; gap: 12px; margin-top: 0; }
.form-page-card .form-page-fields label {
  display: grid;
  min-width: 0;
  gap: 5px;
  margin: 0;
  color: #304968;
  font-size: .8125rem;
  font-weight: 700;
}
.form-page-card .form-page-fields :is(input, select, textarea) {
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid #c8d5e9;
  border-radius: 8px;
  background: #fff;
  color: #14294d;
  font-size: .9375rem;
}
.form-page-card .form-page-fields :is(input, select, textarea):focus-visible {
  outline: 2px solid #216bdb;
  outline-offset: 2px;
}
.form-page-footer {
  display: flex;
  justify-content: flex-end;
  padding: 10px 16px;
  border-top: 1px solid #dce7f5;
  background: #fff;
}
.form-page-footer .button { min-height: 42px; }
.company-settings { margin-bottom: 22px; }
.company-settings .form-page-fields { gap: 11px 14px; }
.form-page-message:empty { display: none; }
.form-page-message:not(:empty) { margin: 0 16px 12px; padding: 0; }
.form-page-message.is-success { color: #14744b; }

.module-content #report-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin: 12px 16px;
}
.module-content #report-filter label {
  display: grid;
  gap: 5px;
  width: auto;
  color: #304968;
  font-size: .8125rem;
  font-weight: 700;
}
.module-content #report-filter :is(input, select, button) { min-height: 40px; }
@media (max-width: 700px) {
  .app-modal.form-dialog textarea,
  .form-page-card .form-page-fields :is(input, select, textarea) { font-size: 1rem; }
  .form-page-card .form-page-fields input { min-height: 44px; }
  .module-content #report-filter label { flex: 1 1 130px; }
}
