.referral-main-button{
  color:#fff;
  border-color:transparent;
  background:linear-gradient(125deg,#08765e,#0b9f78);
  box-shadow:0 9px 22px rgba(4,126,94,.2);
}
.referral-main-button:hover{background:linear-gradient(125deg,#06644f,#078b69);transform:translateY(-1px)}
.referral-modal{
  position:fixed;
  inset:0;
  z-index:1300;
  display:grid;
  place-items:center;
  padding:0;
}
.referral-backdrop{
  position:absolute;
  inset:0;
  border:0;
  background:rgba(3,31,69,.68);
  backdrop-filter:blur(11px);
}
.referral-card{
  position:relative;
  z-index:1;
  width:100vw;
  height:100vh;
  max-height:100vh;
  overflow:auto;
  overscroll-behavior:contain;
  background:#f8fcfe;
  border:1px solid rgba(176,216,230,.75);
  border-radius:0;
  box-shadow:0 26px 70px rgba(1,31,68,.28);
  font-family:Arial,"Tahoma",sans-serif;
}
.referral-header{
  position:sticky;
  top:0;
  z-index:3;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:20px;
  padding:24px 26px 21px;
  color:#fff;
  background:
    radial-gradient(circle at 8% 0%,rgba(49,214,167,.25),transparent 34%),
    linear-gradient(120deg,#063f91,#087fba 58%,#058765);
  box-shadow:0 8px 22px rgba(4,52,104,.16);
}
.referral-modal.referral-normal-size{padding:22px}
.referral-modal.referral-normal-size .referral-card{
  width:min(1120px,100%);
  height:auto;
  max-height:94vh;
  border-radius:30px;
}
.referral-header h2{margin:2px 0 6px;font-size:27px;font-weight:900}
.referral-header p{margin:0;color:rgba(255,255,255,.86);font-weight:600}
.referral-header .eyebrow{color:#bff8e3;font-size:12px;letter-spacing:.04em}
.referral-header-actions{
  display:flex;
  align-items:center;
  gap:9px;
  flex:0 0 auto;
  direction:ltr;
}
.referral-size-toggle{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:43px;
  padding:0 14px;
  border:1px solid rgba(255,255,255,.38);
  border-radius:13px;
  color:#fff;
  background:rgba(255,255,255,.13);
  font:800 14px/1 Arial,"Tahoma",sans-serif;
  cursor:pointer;
}
.referral-size-toggle:hover{background:rgba(255,255,255,.23)}
.referral-size-toggle>span:first-child{font-size:21px;line-height:1}
.referral-close{
  flex:0 0 auto;
  width:43px;
  height:43px;
  border:1px solid rgba(255,255,255,.38);
  border-radius:13px;
  color:#fff;
  background:rgba(255,255,255,.13);
  font-size:29px;
  line-height:1;
}
.referral-close:hover{background:rgba(255,255,255,.23)}
.referral-form{padding:24px}
.referral-form-section{
  padding:22px;
  margin-bottom:20px;
  border:1px solid #d8e9ef;
  border-radius:22px;
  background:#fff;
  box-shadow:0 9px 24px rgba(5,64,103,.055);
}
.referral-section-heading{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:20px;
}
.referral-section-heading>span{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  border-radius:12px;
  color:#fff;
  background:linear-gradient(135deg,#075bb8,#079978);
  font-weight:900;
}
.referral-section-heading h3{margin:0;color:#073f83;font-size:20px}
.referral-section-heading p{margin:3px 0 0;color:#668090;font-size:13px}
.referral-general-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:15px;
}
.referral-general-grid label,
.referral-row-field{
  display:flex;
  flex-direction:column;
  gap:7px;
  min-width:0;
}
.referral-general-grid label>span,
.referral-row-field>span{
  color:#234d68;
  font-size:13px;
  font-weight:900;
}
.referral-general-grid input,
.referral-general-grid textarea,
.referral-row-field input,
.referral-row-field textarea,
.referral-row-field select{
  width:100%;
  min-height:49px;
  padding:11px 13px;
  border:1px solid #c8dce5;
  border-radius:13px;
  outline:none;
  color:#153f56;
  background:#fbfdfe;
  font:900 13px/1.55 Arial,"Tahoma",sans-serif;
  transition:border-color .16s ease,box-shadow .16s ease,background .16s ease;
}
.referral-signature-select{
  min-width:0;
  height:49px;
  padding-inline-start:13px;
  padding-inline-end:34px;
  direction:rtl;
  text-align:right;
  cursor:pointer;
}
.referral-general-grid textarea,
.referral-row-field textarea{resize:vertical;min-height:82px}
.referral-general-grid input:focus,
.referral-general-grid textarea:focus,
.referral-row-field input:focus,
.referral-row-field textarea:focus,
.referral-row-field select:focus{
  border-color:#0795b7;
  background:#fff;
  box-shadow:0 0 0 4px rgba(7,149,183,.11);
}
.referral-wide-field{grid-column:1/-1}
.referral-rows-editor{display:grid;gap:13px}
.referral-editor-row{
  padding:15px;
  border:1px solid #d9e8ed;
  border-radius:17px;
  background:linear-gradient(145deg,#fbfeff,#f2f9f8);
}
.referral-editor-row.referral-stage-hidden{display:none}
.referral-editor-row-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:12px;
}
.referral-editor-row-head strong{color:#07599b;font-size:18px;font-weight:900}
.referral-editor-row-grid{
  display:grid;
  grid-template-columns:.82fr 1.1fr 1.65fr .95fr 1fr;
  gap:11px;
  align-items:start;
}
.referral-row-field textarea{min-height:66px}
.referral-combobox-control{position:relative}
.referral-combobox-control>input{padding-inline-end:50px}
.referral-combobox-toggle{
  position:absolute;
  inset-inline-end:6px;
  top:6px;
  z-index:2;
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  padding:0;
  border:1px solid #b8d8e3;
  border-radius:10px;
  color:#075f8d;
  background:#eaf7fb;
  font:900 24px/1 Arial,sans-serif;
}
.referral-combobox-toggle:hover{color:#fff;background:#087fad;border-color:#087fad}
.referral-sender-menu{
  position:absolute;
  z-index:20;
  top:calc(100% + 7px);
  right:0;
  left:0;
  max-height:250px;
  overflow:auto;
  padding:7px;
  border:1px solid #b8d8e3;
  border-radius:14px;
  background:#fff;
  box-shadow:0 16px 34px rgba(4,54,88,.2);
}
.referral-sender-option{
  display:block;
  width:100%;
  padding:10px 12px;
  border:0;
  border-bottom:1px solid #e5eff3;
  border-radius:8px;
  color:#174c67;
  background:#fff;
  text-align:right;
  font:900 13px/1.45 Arial,sans-serif;
}
.referral-sender-option:last-child{border-bottom:0}
.referral-sender-option:hover,
.referral-sender-option:focus{color:#fff;background:#087f9d;outline:none}
.referral-sender-menu-empty{margin:0;padding:10px;color:#6d8490;text-align:center;font-weight:700}
.referral-auto-field[readonly]{
  color:#075a49;
  background:#edf9f5;
  border-color:#a9ddca;
  cursor:default;
  white-space:pre-line;
}
textarea.referral-auto-field[readonly]{min-height:96px;line-height:1.55}

.referral-gm-reason{
  display:grid;
  gap:12px;
  padding:13px;
  border:1px solid #c8dce5;
  border-radius:14px;
  background:linear-gradient(145deg,#fbfdfe,#f4fafc);
}
.referral-gm-reason.hidden{display:none}
.referral-gm-control{
  display:flex;
  flex-direction:column;
  gap:7px;
  min-width:0;
}
.referral-gm-control>span{
  color:#234d68;
  font-size:13px;
  font-weight:900;
}
.referral-gm-control input,
.referral-gm-control select,
.referral-gm-control textarea{
  width:100%;
  min-height:49px;
  padding:11px 13px;
  border:1px solid #c8dce5;
  border-radius:13px;
  outline:none;
  color:#153f56;
  background:#fff;
  font:900 13px/1.55 Arial,"Tahoma",sans-serif;
}
.referral-gm-control textarea{min-height:72px;resize:vertical}
.referral-gm-control input:focus,
.referral-gm-control select:focus,
.referral-gm-control textarea:focus{
  border-color:#0795b7;
  box-shadow:0 0 0 4px rgba(7,149,183,.11);
}
.referral-gm-details{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:11px;
}
.referral-gm-details.hidden{display:none}
.referral-gm-control-full{grid-column:1/-1}

.referral-form-actions{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  padding:2px 2px 4px;
}
.referral-save-note{
  margin-inline-end:auto;
  color:#67808e;
  font-size:13px;
  font-weight:700;
}
.referral-excel-button{
  min-width:210px;
  color:#fff;
  border-color:transparent;
  background:linear-gradient(120deg,#08765e,#0b9f78);
  box-shadow:0 10px 24px rgba(4,126,94,.18);
}
.referral-excel-button:hover{background:linear-gradient(120deg,#06644f,#078b69)}
.referral-excel-button:disabled{opacity:.68;cursor:wait;transform:none}
.referral-print-button{
  min-width:230px;
  color:#fff;
  border-color:transparent;
  background:linear-gradient(120deg,#074995,#087fbd);
  box-shadow:0 10px 24px rgba(5,76,148,.2);
}
.referral-print-button:hover{background:linear-gradient(120deg,#063c7d,#0670aa)}
.referral-print-sheet{display:none}

@media(max-width:820px){
  .referral-modal{padding:0}
  .referral-card{width:100vw;height:100vh;max-height:100vh;border-radius:0}
  .referral-modal.referral-normal-size{padding:8px}
  .referral-modal.referral-normal-size .referral-card{width:100%;height:auto;max-height:96vh;border-radius:22px}
  .referral-header{padding:19px 17px}
  .referral-header h2{font-size:23px}
  .referral-form{padding:14px}
  .referral-form-section{padding:16px;border-radius:18px}
  .referral-general-grid{grid-template-columns:1fr}
  .referral-wide-field{grid-column:1}
  .referral-editor-row-grid{grid-template-columns:1fr 1fr}
  .referral-row-field-reason{grid-column:1/-1}
  .referral-form-actions{display:grid;grid-template-columns:1fr}
  .referral-form-actions .button{width:100%}
  .referral-save-note{margin:0;text-align:center;order:3}
}
@media(max-width:480px){
  .referral-size-toggle{width:43px;padding:0}
  .referral-size-label{display:none}
  .referral-editor-row-grid{grid-template-columns:1fr}
  .referral-row-field-reason{grid-column:1}
  .referral-gm-details{grid-template-columns:1fr}
}

@media print{
  @page{size:A4 portrait;margin:8mm}
  body.printing-referral{background:#fff!important}
  body.printing-referral>*{display:none!important}
  body.printing-referral>#referralPrintArea{
    display:block!important;
    width:100%!important;
    max-width:none!important;
    min-height:0!important;
    margin:0!important;
    padding:0!important;
    color:#111!important;
    background:#fff!important;
    font-family:Arial,"Tahoma",sans-serif!important;
  }
  .referral-print-letterhead{
    display:flex!important;
    align-items:center!important;
    justify-content:flex-start!important;
    gap:4mm!important;
    min-height:25mm!important;
    margin:0 7mm 3mm!important;
    direction:rtl!important;
  }
  .referral-letterhead-logo{
    width:31mm!important;
    height:25mm!important;
    flex:0 0 31mm!important;
    overflow:hidden!important;
    background:#fff!important;
  }
  .referral-letterhead-logo img{
    display:block!important;
    width:31mm!important;
    height:auto!important;
    margin:0!important;
    transform:translateY(-1mm)!important;
  }
  .referral-letterhead-copy{
    display:flex!important;
    flex-direction:column!important;
    align-items:flex-start!important;
    gap:1.2mm!important;
    color:#111!important;
    text-align:right!important;
    font-size:14px!important;
    font-weight:900!important;
    line-height:1.35!important;
  }
  .referral-letterhead-copy strong{
    display:block!important;
    font-size:14px!important;
    font-weight:900!important;
    white-space:nowrap!important;
  }
  .referral-print-sheet h1{
    margin:0 0 7mm!important;
    text-align:center!important;
    color:#111!important;
    font-size:26px!important;
    font-weight:900!important;
    letter-spacing:.08em!important;
  }
  .referral-document-details{
    display:grid!important;
    gap:4.2mm!important;
    margin:0 7mm 5mm!important;
    font-size:14px!important;
    font-weight:900!important;
  }
  .referral-document-line{
    display:grid!important;
    grid-template-columns:max-content minmax(0,1fr)!important;
    align-items:end!important;
    gap:2.5mm!important;
    min-height:7mm!important;
  }
  .referral-document-line-paired{
    grid-template-columns:max-content minmax(34mm,1fr) max-content minmax(26mm,.72fr)!important;
  }
  .document-label{
    white-space:nowrap!important;
    color:#111!important;
    font-weight:600!important;
  }
  .document-value{
    display:block!important;
    min-height:6mm!important;
    padding:0 2mm 1mm!important;
    border-bottom:1px dotted #555!important;
    color:#000!important;
    font-size:14px!important;
    font-weight:900!important;
    line-height:1.35!important;
    white-space:pre-wrap!important;
    overflow-wrap:anywhere!important;
  }
  .referral-print-table{
    display:table!important;
    width:calc(100% - 10mm)!important;
    margin:0 5mm!important;
    border:1px solid #444!important;
    border-collapse:collapse!important;
    table-layout:fixed!important;
    direction:rtl!important;
    font-size:14px!important;
    font-weight:900!important;
  }
  .referral-print-table thead{display:table-header-group!important}
  .referral-print-table tbody{display:table-row-group!important}
  .referral-print-table tr{display:table-row!important;height:29mm!important;break-inside:avoid!important}
  .referral-print-table thead tr{height:10mm!important}
  .referral-print-table th,
  .referral-print-table td{
    display:table-cell!important;
    padding:2.2mm 2mm!important;
    border:1px solid #555!important;
    color:#111!important;
    background:#fff!important;
    text-align:center!important;
    vertical-align:top!important;
    font-size:14px!important;
    font-weight:900!important;
    line-height:1.5!important;
    white-space:pre-wrap!important;
    overflow-wrap:anywhere!important;
  }
  .referral-print-table th{
    vertical-align:middle!important;
    font-weight:900!important;
  }
  .referral-print-table td{
    text-align:right!important;
    direction:rtl!important;
  }
  .referral-print-table th:nth-child(1),
  .referral-print-table td:nth-child(1){width:14%!important}
  .referral-print-table th:nth-child(2),
  .referral-print-table td:nth-child(2){width:19%!important}
  .referral-print-table th:nth-child(3),
  .referral-print-table td:nth-child(3){width:35%!important}
  .referral-print-table th:nth-child(4),
  .referral-print-table td:nth-child(4){
    width:15%!important;
    white-space:nowrap!important;
    direction:ltr!important;
  }
  .referral-print-table th:nth-child(5),
  .referral-print-table td:nth-child(5){width:17%!important}
  .referral-print-table td:nth-child(5){
    padding:2.5mm 1.5mm 11mm!important;
    text-align:center!important;
    vertical-align:top!important;
    direction:rtl!important;
    font-size:12px!important;
    line-height:1.45!important;
    white-space:pre-line!important;
  }
  body.printing-referral>#referralPrintArea *{
    font-family:Arial,"Tahoma",sans-serif!important;
    font-weight:600!important;
  }
  body.printing-referral>#referralPrintArea h1,
  body.printing-referral>#referralPrintArea th{
    font-weight:700!important;
  }
  body.printing-referral>#referralPrintArea h1{
    font-size:28px!important;
  }
  body.printing-referral>#referralPrintArea .referral-letterhead-copy,
  body.printing-referral>#referralPrintArea .referral-letterhead-copy strong,
  body.printing-referral>#referralPrintArea .referral-document-details,
  body.printing-referral>#referralPrintArea .document-label,
  body.printing-referral>#referralPrintArea .document-value,
  body.printing-referral>#referralPrintArea .referral-print-table,
  body.printing-referral>#referralPrintArea .referral-print-table th,
  body.printing-referral>#referralPrintArea .referral-print-table td{
    font-size:16px!important;
  }
  body.printing-referral>#referralPrintArea .referral-print-table td:nth-child(5){
    font-size:13.5px!important;
  }
}
