/* ShahrVam v559 — root workflow and visible UI corrections.
   Loaded last on purpose: these rules repair current runtime surfaces without
   reviving archived/legacy stylesheets. */

/* ---------- Sales expert: visible row identity + preliminary information ---------- */
body[data-page="sales-operations"] .sm559-expert-table{min-width:1040px!important}
body[data-page="sales-operations"] .sm559-expert-table .sm559-row-number{width:48px;min-width:48px;text-align:center;font-weight:900;color:#526f82}
body[data-page="sales-operations"] .sm559-national-input{width:118px;max-width:100%;min-height:30px!important;height:30px!important;margin:4px auto 0!important;padding:2px 7px!important;text-align:center!important;direction:ltr;font-variant-numeric:tabular-nums;border-radius:8px!important;background:rgba(255,255,255,.82)!important}
body[data-page="sales-operations"] .sm559-no-answer-count{display:inline-flex;align-items:center;justify-content:center;margin-top:4px;padding:2px 7px;border:1px solid #e8c9a8;border-radius:999px;background:#fff3e5;color:#8b5a29;font-size:10px;font-weight:900;white-space:nowrap}
body[data-page="sales-operations"] .sm559-preliminary-btn{white-space:nowrap}
body[data-page="sales-operations"] .sm559-customer-summary{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:10px}
body[data-page="sales-operations"] .sm559-customer-summary>div{min-width:0;padding:8px 10px;border:1px solid #e1e8ed;border-radius:10px;background:#f9fbfc}
body[data-page="sales-operations"] .sm559-customer-summary small{display:block;margin-bottom:2px;color:#788b98;font-size:10.5px;font-weight:800}
body[data-page="sales-operations"] .sm559-customer-summary b{display:block;overflow-wrap:anywhere;color:#294e65;font-size:12px}
body[data-page="sales-operations"] .sm559-initial-notes{margin-top:8px;padding:9px 10px;border:1px solid #dbe6ec;border-radius:10px;background:#fff;line-height:1.85;white-space:pre-wrap}

/* ---------- Internal tickets: one reliable vertical scroll + always reachable submit ---------- */
#it393-root .it393-dialog{max-height:calc(100vh - 20px)!important;height:min(790px,calc(100vh - 20px))!important}
#it393-root .it393-work,#it393-root .it393-main,#it393-root .it393-create{min-height:0!important}
#it393-root .it393-main{overflow:hidden!important}
#it393-root .it393-create{grid-template-rows:auto minmax(0,1fr) auto!important;overflow:hidden!important}
#it393-root .it393-create-grid{min-height:0!important;overflow-y:auto!important;overflow-x:hidden!important;overscroll-behavior:contain;padding-bottom:12px!important}
#it393-root .it393-create-card{min-height:min-content!important;overflow:visible!important}
#it393-root .it393-create>footer{position:relative!important;z-index:5;flex:none!important;padding:9px 12px!important;background:#fff!important;box-shadow:0 -1px 0 #d7e1e3}
#it393-root .it559-person-search{display:grid;gap:5px;margin-bottom:8px}
#it393-root .it559-person-search input{min-height:42px!important}
#it393-root .it559-person-search small{min-height:18px;color:#72858c;font-size:11px;font-weight:600}
@media (max-height:700px){
  #it393-root .it393-dialog{height:calc(100vh - 8px)!important;max-height:calc(100vh - 8px)!important}
  #it393-root .it393-head{min-height:46px!important;padding-block:6px!important}
  #it393-root .it393-create>header{padding-block:7px!important}
  #it393-root .it393-create-grid{padding:8px!important;gap:8px!important}
  #it393-root .it393-create-card{padding:10px 12px!important}
  #it393-root .it393-create>footer{padding:7px 10px!important}
}
@media (max-width:980px){
  #it393-root .it393-create-grid{display:block!important}
  #it393-root .it393-create-card+ .it393-create-card{margin-top:10px}
}

/* ---------- Deputy assistant number inventory: repair table geometry + compact rows ---------- */
body[data-page="lead-import"] .lead-v370-table-wrap{overflow:auto!important;min-height:220px!important}
body[data-page="lead-import"] table.lead-v370-table{display:table!important;width:100%!important;min-width:860px!important;border-collapse:separate!important;border-spacing:0!important;table-layout:fixed!important}
body[data-page="lead-import"] .lead-v370-table>thead{display:table-header-group!important}
body[data-page="lead-import"] .lead-v370-table>tbody{display:table-row-group!important}
body[data-page="lead-import"] #page-content .lead-v370-table>thead>tr,
body[data-page="lead-import"] #page-content .lead-v370-table>tbody>tr{display:table-row!important;height:34px!important;min-height:34px!important;padding:0!important}
body[data-page="lead-import"] #page-content .lead-v370-table>thead>tr>th,
body[data-page="lead-import"] #page-content .lead-v370-table>tbody>tr>td{display:table-cell!important;float:none!important;position:static!important;box-sizing:border-box!important;height:34px!important;min-height:34px!important;padding:2px 6px!important;vertical-align:middle!important;line-height:1.25!important;white-space:nowrap!important}
body[data-page="lead-import"] #page-content .lead-v370-table>thead>tr>th{height:34px!important;font-size:10.5px!important}
body[data-page="lead-import"] #page-content .lead-v370-table>tbody>tr>td{font-size:10.5px!important}
body[data-page="lead-import"] .lead-v370-table .lead-v370-check{width:40px!important;min-width:40px!important;max-width:40px!important}
body[data-page="lead-import"] .lead-v370-table .lead-v370-phone{min-width:0!important;font-size:11px!important}
body[data-page="lead-import"] .lead-v370-table .lead-v376-row-icon{width:27px!important;height:27px!important;min-width:27px!important}
body[data-page="lead-import"] .lead-v370-table .badge{min-height:22px!important;padding-block:2px!important}
body[data-page="lead-import"] #page-content .lead-v370-table input[type="checkbox"]{width:18px!important;height:18px!important;min-width:18px!important;min-height:18px!important;margin:0!important;padding:0!important}
body[data-page="lead-import"] #page-content .lead-v370-table .lead-v376-row-icon{width:27px!important;height:27px!important;min-width:27px!important;min-height:27px!important;padding:0!important}
body[data-page="lead-import"] #page-content .lead-v370-table .so-badge,
body[data-page="lead-import"] #page-content .lead-v370-table .badge{min-height:22px!important;height:auto!important;padding:2px 7px!important;font-size:10.5px!important;line-height:1.2!important}
body[data-page="lead-import"] .lead-v370-pagination select{width:72px!important;min-width:72px!important}
body[data-page="lead-import"] .lead-v370-pagination{position:relative!important;z-index:2}

/* Allocation statistics are intentionally compact; detail stays in the same workflow. */
body[data-page="lead-import"] .lead-v559-allocation-stats{margin:0 0 9px;overflow:hidden}
body[data-page="lead-import"] .lead-v559-allocation-stats>header{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:7px 11px;border-bottom:1px solid #e5ebef;background:#fbfcfd}
body[data-page="lead-import"] .lead-v559-allocation-stats h2{margin:0;font-size:13px;color:#294f67}
body[data-page="lead-import"] .lead-v559-allocation-stats small{display:block;color:#748995;font-size:10px;font-weight:850}
body[data-page="lead-import"] .lead-v559-allocation-stats p{margin:1px 0 0;color:#8a9aa3;font-size:10px}
body[data-page="lead-import"] .lead-v559-allocation-stats .table-wrap{max-height:190px;overflow:auto}
body[data-page="lead-import"] .lead-v559-allocation-stats table{width:100%;min-width:520px;margin:0;border-collapse:collapse}
body[data-page="lead-import"] .lead-v559-allocation-stats th,
body[data-page="lead-import"] .lead-v559-allocation-stats td{height:31px!important;padding:3px 8px!important;text-align:center!important;font-size:10.5px!important;border-bottom:1px solid #eef2f4}
body[data-page="lead-import"] .lead-v559-allocation-stats td:first-child,
body[data-page="lead-import"] .lead-v559-allocation-stats th:first-child{text-align:right!important}
body[data-page="lead-import"] .lead-v559-selected-manager-stats{display:block;min-height:16px;margin-top:2px;color:#567386;font-size:9.5px;font-weight:800;text-align:center}

/* On phones, preserve one coherent horizontal table rather than breaking header/body into unrelated blocks. */
@media (max-width:700px){
  body[data-page="lead-import"] table.lead-v370-table{min-width:760px!important}
  body[data-page="lead-import"] .lead-v370-table-wrap{max-height:none!important;-webkit-overflow-scrolling:touch}
  body[data-page="lead-import"] .lead-v559-allocation-stats .table-wrap{-webkit-overflow-scrolling:touch}
}

/* ---------- Post-credit supervisor: dense but complete operational row ---------- */
body[data-page="sales-operations"] .sm559-supervisor-customer-meta{display:flex;flex-wrap:wrap;gap:4px 7px;margin-top:3px;color:#647c8b;font-size:10px}
body[data-page="sales-operations"] .sm559-product-interest{display:inline-flex;align-items:center;max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ---------- Mobile fixes for changed sales surfaces ---------- */
@media (max-width:700px){
  body[data-page="sales-operations"] .sm559-customer-summary{grid-template-columns:1fr}
  body[data-page="sales-operations"] .sm559-expert-table{min-width:820px!important}
  body[data-page="sales-operations"] .sm559-national-input{width:104px}
}

/* ---------- HR attendance: visible, auditable manual correction workflow ---------- */
body[data-page="attendance"] .hr559-manual-head{border-color:#b7cbd7!important;background:#f8fbfc!important;color:#244e67!important}
body[data-page="attendance"] .hr559-manual-tool,
body[data-page="attendance"] .hr559-day-edit{display:inline-flex;align-items:center;justify-content:center;gap:6px;border:1px solid #c9d9e2;border-radius:9px;background:#f8fbfc;color:#28536b;font:inherit;font-weight:800;cursor:pointer}
body[data-page="attendance"] .hr559-manual-tool{min-height:38px;padding:7px 11px}
body[data-page="attendance"] .hr559-day-edit{min-height:30px;padding:4px 8px;font-size:10.5px}
body[data-page="attendance"] .hr559-manual-tool svg,
body[data-page="attendance"] .hr559-day-edit svg{width:16px;height:16px;flex:none}
body[data-page="attendance"] .v328-attendance-day-card.is-manual-corrected{border-color:#b9cfdc!important;box-shadow:inset 3px 0 0 #6f93a8}
body[data-page="attendance"] .hr559-manual-correction-badge{display:inline-flex;align-items:center;width:max-content;margin-top:4px;padding:2px 7px;border:1px solid #c8d9e2;border-radius:999px;background:#f3f8fa;color:#43697f;font-size:9.5px;font-weight:900}
body[data-page="attendance"] .hr559-manual-meta{display:block;margin-top:5px;color:#6c818e;font-size:9.5px;line-height:1.6}
.hr559-manual-editor{display:grid;gap:12px;min-width:0}
.hr559-manual-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;padding:10px 12px;border:1px solid #dce6eb;border-radius:12px;background:#f8fafb}
.hr559-manual-heading>div:first-child{min-width:0;display:grid;gap:3px}
.hr559-manual-heading b{color:#244b63;font-size:13px}
.hr559-manual-heading small{color:#748994;font-size:10.5px;line-height:1.6}
.hr559-manual-heading .field{width:min(210px,100%);margin:0}
.hr559-manual-loading{display:flex;align-items:center;justify-content:center;gap:8px;min-height:120px;color:#657d8b;font-weight:800}
.hr559-manual-source{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:12px}
.hr559-manual-source>div{display:grid;gap:3px;min-width:0;padding:10px 11px;border:1px solid #dfe8ed;border-radius:11px;background:#fbfcfd}
.hr559-manual-source small{color:#738893;font-size:10px;font-weight:800}
.hr559-manual-source b{direction:ltr;text-align:right;color:#244d65;font-size:14px;font-variant-numeric:tabular-nums}
.hr559-manual-source span{color:#84959d;font-size:9.5px;overflow-wrap:anywhere}
.hr559-manual-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding:12px;border:1px solid #dfe8ed;border-radius:12px;background:#fff}
.hr559-manual-form .field{margin:0;min-width:0}
.hr559-manual-form .field.full{grid-column:1/-1}
.hr559-manual-form input[type="time"]{direction:ltr;text-align:center;font-variant-numeric:tabular-nums}
.hr559-manual-history-section{margin-top:12px;border:1px solid #dfe8ed;border-radius:12px;overflow:hidden;background:#fff}
.hr559-manual-history-section>header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 11px;border-bottom:1px solid #e7edf0;background:#f8fafb}
.hr559-manual-history-section>header b{font-size:11.5px;color:#31566d}
.hr559-manual-history-section>header small{font-size:9.5px;color:#738995}
.hr559-manual-history{display:grid;max-height:210px;overflow:auto}
.hr559-manual-history article{display:grid;gap:4px;padding:8px 11px;border-bottom:1px solid #edf1f3}
.hr559-manual-history article:last-child{border-bottom:0}
.hr559-manual-history article>div{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.hr559-manual-history article b{direction:ltr;color:#294f66;font-size:11px}
.hr559-manual-history article p{margin:0;color:#4f6877;font-size:10.5px;line-height:1.65}
.hr559-manual-history article small{color:#82939b;font-size:9.5px}
.hr559-manual-empty{padding:14px;text-align:center;color:#7a8e98;font-size:10.5px}
@media (max-width:700px){
  .hr559-manual-heading{align-items:stretch;flex-direction:column}
  .hr559-manual-heading .field{width:100%}
  .hr559-manual-source,.hr559-manual-form{grid-template-columns:1fr}
  .hr559-manual-form .field.full{grid-column:auto}
}

/* ---------- v559 mobile: operational rows become usable cards, not crushed desktop tables ---------- */
@media (max-width:700px){
  body[data-page="sales-operations"] .sm148-contact-table-wrap{overflow:visible!important}
  body[data-page="sales-operations"] table.sm559-expert-table,
  body[data-page="sales-operations"] table.sm148-supervisor-contact-table{display:block!important;width:100%!important;min-width:0!important;border:0!important;background:transparent!important}
  body[data-page="sales-operations"] .sm559-expert-table>thead,
  body[data-page="sales-operations"] .sm148-supervisor-contact-table>thead{display:none!important}
  body[data-page="sales-operations"] .sm559-expert-table>tbody,
  body[data-page="sales-operations"] .sm148-supervisor-contact-table>tbody{display:grid!important;gap:10px!important;width:100%!important}
  body[data-page="sales-operations"] .sm559-expert-table>tbody>tr.sm148-contact-row,
  body[data-page="sales-operations"] .sm148-supervisor-contact-table>tbody>tr.sm148-contact-row{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;gap:8px 10px!important;width:100%!important;min-width:0!important;height:auto!important;padding:10px!important;border:1px solid #dce6eb!important;border-radius:13px!important;background:#fff!important;box-shadow:none!important}
  body[data-page="sales-operations"] .sm559-expert-table>tbody>tr.sm148-contact-row>td,
  body[data-page="sales-operations"] .sm148-supervisor-contact-table>tbody>tr.sm148-contact-row>td{display:flex!important;min-width:0!important;height:auto!important;min-height:0!important;padding:0!important;border:0!important;white-space:normal!important;flex-direction:column!important;align-items:stretch!important;justify-content:flex-start!important;text-align:right!important;overflow:visible!important}
  body[data-page="sales-operations"] .sm559-expert-table>tbody>tr.sm148-contact-row>td::before,
  body[data-page="sales-operations"] .sm148-supervisor-contact-table>tbody>tr.sm148-contact-row>td::before{content:attr(data-label);display:block;margin-bottom:4px;color:#7a8e9a;font-size:9px;font-weight:900;line-height:1.3}
  body[data-page="sales-operations"] .sm559-expert-table>tbody>tr.sm148-contact-row>td:nth-last-child(1),
  body[data-page="sales-operations"] .sm148-supervisor-contact-table>tbody>tr.sm148-contact-row>td:nth-last-child(1){grid-column:1/-1!important;padding-top:7px!important;border-top:1px solid #edf1f3!important}
  body[data-page="sales-operations"] .sm559-expert-table .sm148-row-actions,
  body[data-page="sales-operations"] .sm148-supervisor-contact-table .sm148-row-actions{justify-content:flex-start!important;gap:8px!important;flex-wrap:wrap!important}
  body[data-page="sales-operations"] .sm559-expert-table .sm559-row-number{width:auto!important;min-width:0!important;text-align:right!important}
  body[data-page="sales-operations"] .sm559-national-input{width:100%!important;max-width:160px!important;margin:5px 0 0 auto!important}
  body[data-page="sales-operations"] .sm148-contact-status{width:100%!important;max-width:none!important}
  body[data-page="sales-operations"] .sm148-followup-card,
  body[data-page="sales-operations"] .sm148-case-link{width:100%!important;max-width:none!important}

  /* Deputy-assistant inventory: one number = one compact touch-friendly card. */
  body[data-page="lead-import"] .lead-v370-table-wrap{overflow:visible!important;min-height:0!important}
  body[data-page="lead-import"] table.lead-v370-table{display:block!important;width:100%!important;min-width:0!important;border:0!important;background:transparent!important}
  body[data-page="lead-import"] .lead-v370-table>thead{display:none!important}
  body[data-page="lead-import"] .lead-v370-table>tbody{display:grid!important;gap:8px!important;width:100%!important}
  body[data-page="lead-import"] .lead-v370-table>tbody>tr{display:grid!important;grid-template-columns:44px minmax(0,1fr) minmax(0,1fr)!important;gap:7px 9px!important;width:100%!important;height:auto!important;min-height:0!important;padding:9px!important;border:1px solid #dce6eb!important;border-radius:12px!important;background:#fff!important}
  body[data-page="lead-import"] .lead-v370-table>tbody>tr>td{display:flex!important;min-width:0!important;width:auto!important;max-width:none!important;height:auto!important;min-height:0!important;padding:0!important;border:0!important;white-space:normal!important;flex-direction:column!important;align-items:flex-start!important;justify-content:flex-start!important;text-align:right!important}
  body[data-page="lead-import"] .lead-v370-table>tbody>tr>td::before{content:attr(data-label);display:block;margin-bottom:3px;color:#7c909b;font-size:8.5px;font-weight:900}
  body[data-page="lead-import"] .lead-v370-table>tbody>tr>td.lead-v370-check{grid-row:1/span 2;align-items:center!important;justify-content:center!important;width:44px!important;min-width:44px!important}
  body[data-page="lead-import"] .lead-v370-table>tbody>tr>td.lead-v370-check::before{content:'';display:none}
  body[data-page="lead-import"] .lead-v370-table>tbody>tr>td:nth-child(3){grid-column:2/4}
  body[data-page="lead-import"] .lead-v370-table>tbody>tr>td:nth-child(5),
  body[data-page="lead-import"] .lead-v370-table>tbody>tr>td:nth-child(7){grid-column:2/4}
  body[data-page="lead-import"] .lead-v370-table>tbody>tr>td:nth-child(8){grid-column:1/-1;align-items:flex-end!important;padding-top:5px!important;border-top:1px solid #edf1f3!important}
  body[data-page="lead-import"] .lead-v370-table .lead-v370-phone{font-size:12px!important}
  body[data-page="lead-import"] .lead-v370-pagination{align-items:stretch!important;gap:8px!important;flex-wrap:wrap!important}
  body[data-page="lead-import"] .lead-v370-page-nav{width:100%!important;justify-content:space-between!important}
}
