/* Shared section treatment for existing form fieldsets; login is independent. */
.portal-drawer-content form fieldset {
    box-sizing:border-box; min-width:0; height:auto!important;
    margin:0 0 16px!important; padding:18px!important;
    background:#fff; border:1px solid #e0e8ed; border-radius:12px;
    box-shadow:0 2px 5px rgba(28,55,70,.035);
}
.portal-drawer-content form fieldset > legend {
    float:inline-start; box-sizing:border-box; width:100%;
    margin:0 0 16px!important; padding:0 0 12px;
    border-bottom:1px solid #edf1f4;
    color:#29464e; font-size:14px; font-weight:700; text-align:start;
}
.portal-drawer-content form fieldset > legend + * {clear:both}
/* The customer form keeps the original nodes, names, events and permission rules. */
.portal-drawer #frm_Customer.portal-sectioned-form {
    max-width:1180px; margin:0 auto; padding:12px; border:0;
    background:transparent; box-shadow:none;
}
.portal-drawer #frm_Customer #CustomerForm,
.portal-drawer #frm_Customer #CustomerForm > tbody,
.portal-drawer #frm_Customer #CustomerForm > tbody > tr,
.portal-drawer #frm_Customer #CustomerForm > tbody > tr > td {
    display:block; width:100%!important; min-width:0!important;
    box-sizing:border-box; padding:0!important;
}
.portal-drawer #frm_Customer .portal-field-grid {display:block;width:100%;border-spacing:0}
.portal-drawer #frm_Customer .portal-field-grid > tbody {
    display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px 22px;
}
.portal-drawer #frm_Customer .portal-field-grid > tbody > tr {
    display:flex;flex-direction:column;min-width:0;gap:7px;
}
/* No !important display: inline hidden rows and later visibility changes win. */
.portal-drawer #frm_Customer .portal-field-grid > tbody > tr > td {
    display:block;width:auto;min-width:0;padding:0!important;
    text-align:start!important;white-space:normal;line-height:1.8;
}
.portal-drawer #frm_Customer .portal-field-grid > tbody > tr > td:first-child {
    color:#5a6c7d;font-size:12px;
}
.portal-drawer #frm_Customer .portal-field-grid > tbody > tr > td:first-child > div {float:none!important;display:inline}
.portal-drawer #frm_Customer .portal-field-grid input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit]),
.portal-drawer #frm_Customer .portal-field-grid select,
.portal-drawer #frm_Customer .portal-field-grid textarea {
    width:100%!important;min-height:38px;padding:7px 10px;border-radius:8px;font-size:13px;
}
.portal-drawer #frm_Customer .portal-field-grid textarea {min-height:78px;resize:vertical}
.portal-drawer #frm_Customer input[type=checkbox],
.portal-drawer #frm_Customer input[type=radio] {accent-color:#146b70;width:16px;height:16px;vertical-align:middle}
.portal-drawer #frm_Customer .portal-field-grid td:has(>input+img) {position:relative;padding-inline-end:26px!important}
.portal-drawer #frm_Customer .portal-field-grid td > input + img {position:absolute;inset-inline-end:0;top:10px}
.portal-drawer #frm_Customer .portal-field-grid tr:has(textarea),
.portal-drawer #frm_Customer .portal-field-grid tr:has(#fld_Lat) {grid-column:1 / -1}
.portal-drawer #frm_Customer #ErrorText:empty {display:none}
@media(max-width:1000px){
    .portal-drawer #frm_Customer .portal-field-grid > tbody {grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:600px){
    .portal-drawer #frm_Customer.portal-sectioned-form {padding:2px}
    .portal-drawer-content form fieldset {padding:14px!important}
    .portal-drawer #frm_Customer .portal-field-grid > tbody {grid-template-columns:minmax(0,1fr);gap:16px}
    .portal-drawer #frm_Customer .portal-field-grid input,
    .portal-drawer #frm_Customer .portal-field-grid select,
    .portal-drawer #frm_Customer .portal-field-grid textarea {font-size:16px!important}
}

.portal-drawer #frm_Customer #CustomerForm > tbody > tr > td:first-child:not([colspan]),
.portal-drawer #frm_Customer #CustomerForm > tbody > tr > td:nth-child(2) {width:100%!important}

/* Four panels share the same form; switching never clears or disables fields. */
.portal-drawer #frm_Customer [role=tabpanel][hidden] {display:none!important}
.portal-customer-tabs {display:flex;gap:6px;overflow-x:auto;background:#fff;border:1px solid #e0e8ed;border-radius:10px;margin-bottom:14px;padding:6px;scrollbar-width:thin}
.portal-drawer #frm_Customer .portal-customer-tabs button {flex:1;white-space:nowrap;border:0;border-bottom:2px solid transparent;border-radius:6px 6px 0 0;background:transparent;color:#5a6c7d;padding:12px 16px;font:inherit;cursor:pointer}
.portal-drawer #frm_Customer .portal-customer-tabs button[aria-selected=true] {color:#146b70;border-bottom-color:#146b70;background:#edf7f6;font-weight:bold}
.portal-tab-subtitle {font-size:13px;color:#365f64;margin:20px 0 14px;padding-bottom:10px;border-bottom:1px solid #edf1f4}
.portal-tab-subtitle:first-child {margin-top:0}

/* Waybill form tabs reuse its existing fieldsets without changing field names or submit behavior. */
.portal-cons-tabs {display:flex;gap:6px;overflow-x:auto;background:#fff;border:1px solid #e0e8ed;border-radius:10px;margin:0 0 14px;padding:6px;scrollbar-width:thin}
.portal-drawer #frm_Cons .portal-cons-tabs {float:none!important;clear:both!important;width:100%!important;box-sizing:border-box;direction:rtl}
.portal-drawer #frm_Cons .portal-cons-tabs button {flex:1;white-space:nowrap;border:0;border-bottom:2px solid transparent;border-radius:6px 6px 0 0;background:transparent;color:#5a6c7d;padding:12px 16px;font:inherit;cursor:pointer}
.portal-drawer #frm_Cons .portal-cons-tabs button[aria-selected=true] {color:#146b70;border-bottom-color:#146b70;background:#edf7f6;font-weight:bold}
.portal-drawer #frm_Cons .portal-cons-tabs button:focus {outline:none;box-shadow:none}
.portal-drawer #frm_Cons .portal-cons-tabs button:focus-visible {text-decoration:underline;text-underline-offset:5px}
.portal-drawer .cons-tab-navigation {display:flex;justify-content:flex-end;gap:10px;flex:0 0 auto;float:none!important;clear:both;width:100%;box-sizing:border-box;padding:12px 18px;background:#fff;border-top:1px solid #dce5eb;direction:rtl}
.portal-drawer .cons-tab-navigation button {width:110px;min-height:38px;border:1px solid #146b70;border-radius:8px;background:#146b70;color:#fff;font:inherit;cursor:pointer}
.portal-drawer .cons-tab-navigation button[data-cons-previous] {background:#fff;color:#146b70}
.portal-drawer .cons-tab-navigation button:disabled {opacity:.45;cursor:default}
.portal-drawer #frm_Cons .cons-validation-summary {float:none!important;clear:both;width:100%;box-sizing:border-box;margin:0 0 12px;padding:12px 16px;border:1px solid #efb4b4;border-inline-start:4px solid #bc3434;border-radius:8px;background:#fff2f2;color:#922828;line-height:1.8}
.portal-drawer #frm_Cons .cons-field-error {display:block;white-space:normal;color:#aa2727;font-size:12px;line-height:1.8;margin-top:5px}
.portal-drawer #frm_Cons [data-cons-invalid] {border-color:#bc3434!important;background:#fff8f8!important}
.portal-drawer #frm_Cons #cons-panel-preview {clear:both;box-sizing:border-box}
.portal-drawer #frm_Cons .cons-preview-notice {padding:12px 16px;margin:0 0 16px;background:#edf7f6;color:#365f64;border-radius:8px;line-height:1.9}
.portal-drawer #frm_Cons .cons-preview-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;float:none!important;width:100%}
.portal-drawer #frm_Cons .cons-preview-card {min-width:0;padding:18px;border:1px solid #e0e8ed;border-radius:12px;background:#fff;overflow-wrap:anywhere}
.portal-drawer #frm_Cons .cons-preview-wide {grid-column:1 / -1}
.portal-drawer #frm_Cons .cons-preview-card h3 {margin:0 0 16px;padding-bottom:12px;border-bottom:1px solid #edf1f4;color:#29464e;font-size:14px}
.portal-drawer #frm_Cons .cons-preview-card div {float:none!important;max-width:100%;box-sizing:border-box}
.portal-drawer #frm_Cons .cons-preview-card table {width:100%;max-width:100%;table-layout:fixed}
.portal-drawer #frm_Cons .cons-preview-card td {white-space:normal;vertical-align:top;padding:6px!important}
.portal-drawer #frm_Cons .cons-preview-value {display:inline-block;max-width:100%;white-space:pre-wrap;overflow-wrap:anywhere;color:#263b53;font-weight:bold;line-height:1.9}
.portal-drawer #frm_Cons .cons-preview-card img {max-width:100%}
@media(max-width:850px){.portal-drawer #frm_Cons .cons-preview-grid {grid-template-columns:minmax(0,1fr)}}
.portal-drawer #frm_Cons [data-cons-tab][hidden] {display:none!important}
.portal-drawer #frm_Cons [data-cons-tab] {box-sizing:border-box}
/* Flatten only the outer layout table; each visible section occupies one grid cell. */
.portal-drawer #frm_Cons > div:has(>.cons-layout),
.portal-drawer #frm_Cons .cons-layout {min-width:0!important;width:100%}
.portal-drawer #frm_Cons .cons-layout {display:block}
.portal-drawer #frm_Cons .cons-layout > tbody {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.portal-drawer #frm_Cons .cons-layout > tbody > tr {display:block;grid-column:1 / -1;min-width:0}
.portal-drawer #frm_Cons .cons-layout > tbody > tr > td {display:block;min-width:0}
.portal-drawer #frm_Cons .cons-layout > tbody > tr:has(>[colspan="3"]>[data-cons-tab]) > td {width:100%;box-sizing:border-box}
.portal-drawer #frm_Cons .cons-layout > tbody > .cons-parties-row,
.portal-drawer #frm_Cons .cons-layout > tbody > .cons-services-row {display:contents}
.portal-drawer #frm_Cons .cons-layout > tbody > tr[hidden],
.portal-drawer #frm_Cons .cons-layout > tbody > tr > td:has(>[data-cons-tab][hidden]),
.portal-drawer #frm_Cons .cons-layout > tbody > tr:has(>td>fieldset[style*="display:none"]) {display:none!important}
.portal-drawer #frm_Cons .cons-services-row > td:has(#cons-panel-financial) {grid-column:1 / -1}
.portal-drawer #frm_Cons [data-cons-tab] {float:none!important;width:100%!important;margin:0!important}
/* Stretch each card through its grid cell, including pairs in different legacy rows. */
.portal-drawer #frm_Cons .cons-layout > tbody > tr > td:has(>[data-cons-tab]:not([hidden])) {
    display:flex;align-items:stretch;box-sizing:border-box;min-width:0;
}
.portal-drawer #frm_Cons .cons-layout > tbody > tr > td > [data-cons-tab] {
    flex:1 1 auto;min-width:0;
}
.portal-drawer #frm_Cons :is(#SenderSection,#ReceiverSection) {table-layout:fixed}
.portal-drawer #frm_Cons :is(#SenderSection,#ReceiverSection) td:first-child:not([colspan]) {width:110px;white-space:normal}
.portal-drawer #frm_Cons :is(#SenderSection,#ReceiverSection) input:not([type=hidden]),
.portal-drawer #frm_Cons :is(#SenderSection,#ReceiverSection) textarea {width:calc(100% - 24px)!important}
.portal-drawer #frm_Cons #cons-panel-packages > table,
.portal-drawer #frm_Cons #PACKAGE_LIST {width:100%!important;box-sizing:border-box;float:none!important}
#frm_Cons .cons-package-list {display:block;width:100%;height:200px;overflow-y:auto;overflow-x:hidden;box-sizing:border-box;padding:8px;border:1px solid #cbdbe5;border-radius:8px;scrollbar-gutter:stable}
#frm_Cons .cons-package-list > .manifest_item {display:block!important;float:none!important;width:100%;box-sizing:border-box;padding:6px 8px;margin:0;font-size:20px;line-height:1.5;font-weight:600;direction:ltr;text-align:right;overflow-wrap:anywhere;border-bottom:1px solid #edf2f5}
#frm_Cons .cons-package-list > .manifest_item:last-child {border-bottom:0}
.portal-drawer #frm_Cons #Items {width:80px!important;min-width:80px;min-height:36px;direction:ltr;text-align:center;font-size:16px}
.portal-drawer #frm_Cons .cons-header-table > tbody > .cons-header-main {gap:14px}
.portal-drawer #frm_Cons .cons-schedule {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:14px 24px;width:100%}
.portal-drawer #frm_Cons .cons-schedule-time {display:grid!important;grid-template-columns:115px 110px minmax(130px,1fr);align-items:center;gap:8px;text-align:start}
.portal-drawer #frm_Cons .cons-schedule-time label {white-space:nowrap}
.portal-drawer #frm_Cons .cons-clock {display:inline-flex;align-items:center;justify-content:flex-end;gap:4px;direction:ltr}
.portal-drawer #frm_Cons .cons-time-window {display:block;min-width:0}
.portal-drawer #frm_Cons .cons-agent-pair {width:100%;table-layout:fixed}
.portal-drawer #frm_Cons .cons-agent-pair td {text-align:start!important;overflow-wrap:anywhere;white-space:normal}
.portal-drawer #frm_Cons .cons-agent-pair td:first-child {width:115px}
.portal-drawer #frm_Cons .cons-number-field {max-width:360px}
.portal-drawer #frm_Cons .cons-number-field label {display:block;text-align:start;margin-bottom:6px}
.portal-drawer #frm_Cons .cons-header-table > tbody > .cons-header-bottom {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:24px;align-items:stretch;margin-top:14px}
.portal-drawer #frm_Cons .cons-header-table > tbody > .cons-header-bottom > .cons-header-notes {
    display:flex;flex-direction:column;min-width:0;
}
.portal-drawer #frm_Cons .cons-header-notes > div:last-child {
    display:flex;flex:1 1 auto;min-height:0;
}
.portal-drawer #frm_Cons .cons-header-notes textarea {
    flex:1 1 auto;height:auto!important;min-height:120px;box-sizing:border-box;
}
.portal-drawer #frm_Cons .cons-reference {display:flex;flex-direction:column;align-items:stretch!important;text-align:start;gap:6px;margin-bottom:10px}
@media(max-width:850px){
    .portal-drawer #frm_Cons .cons-layout > tbody,
    .portal-drawer #frm_Cons .cons-schedule,
    .portal-drawer #frm_Cons .cons-header-table > tbody > .cons-header-bottom {grid-template-columns:minmax(0,1fr)}
    .portal-drawer #frm_Cons .cons-schedule-time {grid-template-columns:105px 100px minmax(0,1fr);gap:4px}
}
@media(max-width:600px){
    .portal-drawer #frm_Cons .portal-cons-tabs {margin-bottom:8px}
    .portal-drawer #frm_Cons .portal-cons-tabs button {padding:9px 10px;font-size:12px}
}

/* Legacy RTL styles float every div/fieldset; keep navigation above the panel. */
.portal-drawer #frm_Customer > .portal-customer-tabs,
.portal-drawer #frm_Customer #CustomerForm,
.portal-drawer #frm_Customer [role="tabpanel"] {
    float:none!important; clear:both!important; width:100%!important;
    box-sizing:border-box;
}
.portal-drawer .portal-drawer-content:has(#frm_Customer) {
    float:none!important; width:100%!important;
}
.portal-drawer #frm_Customer.portal-sectioned-form {
    float:none!important; width:100%!important;
}
