/* Executive UI refresh v2 — balanced desktop toolbar and mobile-first reports */
.header{display:grid!important;grid-template-columns:minmax(360px,1fr) minmax(560px,auto);align-items:center!important;padding:18px 22px!important;gap:24px!important}
.header-left{min-width:0!important;display:grid!important;grid-template-columns:auto minmax(0,1fr);align-items:center!important;gap:16px!important}
.header-left .logo img{width:auto;max-width:126px;height:34px!important}.header h1{font-family:'Be Vietnam Pro',sans-serif;font-size:20px!important;font-weight:700;line-height:1.2;letter-spacing:-.35px}.header .subtitle{font-size:12px;line-height:1.45;margin-top:4px}
.header-right{min-width:0;display:grid!important;grid-template-rows:auto auto;justify-items:end;gap:8px!important}.header-main-actions,.header-utility-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:nowrap;gap:8px;width:max-content;max-width:100%}
.header-main-actions .btn,.header-main-actions .input{height:38px!important;border-radius:10px!important;margin:0!important}.header-main-actions #cycleSelect{min-width:150px}.header-utility-actions .btn{height:34px!important;min-height:34px;border-radius:9px!important;box-shadow:none!important;margin:0!important}.header-utility-actions .update-time{font-size:11px;white-space:nowrap;margin-left:4px!important}
.btn-presentation{height:38px;padding:0 13px;display:flex;align-items:center;color:var(--text);background:var(--bg-card);border:1px solid var(--border);text-decoration:none;white-space:nowrap}.btn-presentation:hover{border-color:var(--accent);color:var(--accent)}
.tab-nav{position:sticky;top:8px;z-index:90}
#tab-report,.tab-content,.section{max-width:100%;min-width:0}#tab-report .section{overflow:hidden}#tab-report .report-chart-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-bottom:20px}#tab-report .report-chart-card{background:var(--bg-card);border-radius:12px;padding:18px;border:1px solid var(--border);position:relative;height:330px;min-width:0;overflow:hidden}#tab-report .report-chart-card h3{font-size:14px;color:var(--text-dim);margin-bottom:10px}#tab-report .report-chart-card canvas{display:block;max-width:100%!important;width:100%!important;height:calc(100% - 30px)!important}#tab-report .report-grid,#tab-report #kmVarianceSection,#tab-report #odoAnomalies{min-width:0;max-width:100%;overflow-wrap:anywhere}#tab-report table{max-width:100%}
@media(max-width:1180px){.header{grid-template-columns:1fr!important;gap:14px!important}.header-right{width:100%;justify-items:stretch}.header-main-actions,.header-utility-actions{width:100%;justify-content:flex-start;flex-wrap:wrap}.header-utility-actions .update-time{margin-left:auto!important}}
@media(max-width:768px){.app{padding:10px 10px 84px}.header{display:flex!important;flex-direction:column;align-items:stretch!important;gap:12px!important;border-radius:16px;padding:14px!important}.header-left{display:grid!important;grid-template-columns:88px minmax(0,1fr);gap:12px!important;align-items:center!important}.header-left .logo img{height:28px!important;max-width:88px!important}.header h1{font-size:16px!important;line-height:1.25}.header .subtitle{font-size:10.5px;display:block;line-height:1.35}.header-right{display:grid!important;width:100%;gap:8px!important}.header-main-actions{width:100%;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.header-main-actions>*{width:100%!important;min-width:0!important;margin:0!important;justify-content:center;font-size:11.5px!important;padding:0 7px!important}.header-main-actions #cycleSelect{grid-column:1/-1;min-width:0}.header-utility-actions{width:100%;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px}.header-utility-actions>.btn,.header-utility-actions>.notification-bell-container{width:100%!important;min-width:0;margin:0!important}.header-utility-actions>.btn{padding:0 5px!important;justify-content:center;font-size:10.5px!important}.header-utility-actions .notification-bell-container>button{width:100%!important}.header-utility-actions .update-time{grid-column:1/-1;text-align:right;margin:0!important;font-size:10px}.tab-nav{position:fixed;display:flex!important;flex-wrap:nowrap!important;overflow-x:auto;overscroll-behavior-x:contain;bottom:0;top:auto;padding:6px 6px calc(6px + env(safe-area-inset-bottom));gap:4px}.tab-btn{flex:0 0 auto!important;min-width:112px;padding:10px 8px!important;border-radius:9px}
#tab-report .section{padding:14px!important;border-radius:14px}#tab-report .section h2{font-size:17px!important;line-height:1.35;margin-bottom:14px}#tab-report .report-chart-grid{grid-template-columns:1fr;gap:12px;margin-bottom:14px}#tab-report .report-chart-card{height:300px!important;padding:14px!important}#tab-report .report-chart-card h3{font-size:12px!important;margin-bottom:8px}#tab-report .report-grid{grid-template-columns:1fr!important;gap:10px!important}#tab-report .report-card{min-width:0!important;padding:14px!important}#tab-report #kmVarianceSection,#tab-report #odoAnomalies{overflow-x:auto;-webkit-overflow-scrolling:touch}#tab-report table{min-width:640px}.detail-header{align-items:flex-start;gap:10px;flex-direction:column}.detail-header>div{width:100%;display:grid!important;grid-template-columns:1fr 1fr}.detail-header .btn{min-width:0;font-size:11px;padding:8px}}
@media(max-width:480px){.header-left{grid-template-columns:72px minmax(0,1fr)}.header-left .logo img{max-width:72px!important}.summary-cards{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important}.summary-cards .card{min-height:112px;padding:14px 10px}.summary-cards .card-value{font-size:24px}.summary-cards .card-label{font-size:10px}.summary-cards .card:last-child:nth-child(odd){grid-column:1/-1}.warehouse-grid{gap:10px}.section{padding:14px!important;border-radius:14px}.section h2{font-size:17px!important}}
/* Header redesign v3 — compact desktop, intentional mobile hierarchy */
.header-action-ai,.header-action-audit{display:flex;align-items:center;justify-content:center;height:38px;padding:0 14px;border:0;color:#fff;white-space:nowrap;font-weight:700}
.header-action-ai{background:linear-gradient(135deg,#09a8a1,#008fc7)}
.header-action-audit{background:linear-gradient(135deg,#6558e8,#8b5cf6);box-shadow:0 6px 16px rgba(101,88,232,.22)}
.ai-audit-spotlight{position:relative;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:18px;margin:14px 0 20px;padding:18px 20px;overflow:hidden;border:1px solid color-mix(in srgb,var(--accent-secondary) 32%,var(--border));border-radius:16px;background:linear-gradient(115deg,color-mix(in srgb,var(--bg-card) 93%,#00b8b0),var(--bg-card));box-shadow:0 8px 24px rgba(0,0,0,.06)}
.ai-audit-spotlight::after{content:'✦';position:absolute;right:180px;top:-42px;font-size:128px;line-height:1;color:var(--accent-secondary);opacity:.045;pointer-events:none}
.ai-audit-copy{min-width:0}.ai-audit-kicker{display:block;margin-bottom:5px;color:var(--accent-secondary);font-size:9px;font-weight:800;letter-spacing:1.4px}.ai-audit-copy h2{display:flex;align-items:center;gap:9px;margin:0 0 4px;font-size:17px;color:var(--text)}.ai-audit-copy p{margin:0;color:var(--text-dim);font-size:12px;line-height:1.5}.ai-audit-mark{display:grid;place-items:center;width:28px;height:28px;border-radius:9px;background:linear-gradient(135deg,#6558e8,#00a19a);color:#fff;font-size:14px}.ai-audit-cta{position:relative;z-index:1;display:flex;align-items:center;justify-content:space-between;gap:18px;min-width:188px;padding:11px 14px;border:0;border-radius:11px;background:linear-gradient(135deg,#00a19a,#087f79);color:#fff;font-weight:700;box-shadow:0 6px 16px rgba(0,161,154,.2)}.ai-audit-result{grid-column:1/-1;margin-top:2px;padding-top:16px;border-top:1px dashed var(--border);color:var(--text);font-size:13.5px;line-height:1.6}
@media(max-width:768px){
  .header{gap:14px!important;padding:16px!important;overflow:hidden}
  .header-left{grid-template-columns:70px minmax(0,1fr)!important;gap:12px!important;padding-bottom:13px;border-bottom:1px solid var(--border)}
  .header-left .logo img{width:70px!important;max-width:70px!important;height:auto!important}
  .header h1{font-size:15px!important;letter-spacing:-.25px;line-height:1.3}.header .subtitle{font-size:10px!important;line-height:1.45;margin-top:3px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
  .header-main-actions{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:8px!important}
  .header-main-actions #cycleSelect{grid-column:1/-1!important;height:42px!important;padding:0 12px!important;font-size:12px!important;border-radius:11px!important}
  .header-main-actions .btn,.header-main-actions a{height:42px!important;padding:0 5px!important;border-radius:11px!important;font-size:14px!important;line-height:1!important;overflow:hidden}
  .header-main-actions .btn span,.header-main-actions a:not(.btn-presentation){font-size:0}
  .header-main-actions a:not(.btn-presentation)::first-letter{font-size:14px}
  .header-main-actions .btn span{display:none}.btn-presentation{font-size:0!important}.btn-presentation::first-letter{font-size:15px}
  .header-utility-actions{display:grid!important;grid-template-columns:42px 42px minmax(0,1fr) minmax(0,1fr)!important;gap:8px!important}
  .header-utility-actions>.btn,.header-utility-actions>.notification-bell-container{height:38px!important}.header-utility-actions>.btn{font-size:11px!important;border-radius:10px!important}.header-utility-actions .update-time{grid-column:1/-1!important;text-align:right;font-size:9.5px!important;opacity:.85}
  .ai-audit-spotlight{grid-template-columns:1fr;margin:12px 0 16px;padding:15px;border-radius:15px;gap:13px}.ai-audit-spotlight::after{right:-15px;top:-20px;font-size:100px}.ai-audit-copy h2{font-size:15px}.ai-audit-copy p{font-size:11px;padding-right:8px}.ai-audit-cta{width:100%;min-width:0;height:42px}.ai-audit-result{grid-column:1}
}
@media(max-width:390px){.header{padding:13px!important}.header-left{grid-template-columns:60px minmax(0,1fr)!important}.header-left .logo img{width:60px!important}.header h1{font-size:14px!important}.header-main-actions{gap:6px!important}.header-utility-actions{grid-template-columns:38px 38px minmax(0,1fr) minmax(0,1fr)!important;gap:6px!important}}

/* Header alignment v4 */
.header .subtitle{display:flex;align-items:center;flex-wrap:wrap;gap:4px}
.header-update-time{display:inline-flex;align-items:center;color:var(--green);font-size:11px;font-weight:600;white-space:nowrap}
.header-update-time:not(:empty)::before{content:'•';margin:0 3px;color:var(--border)}
.header-main-actions{display:grid!important;grid-template-columns:160px repeat(4,142px);gap:10px!important;width:auto!important}
.header-main-actions>*{width:100%!important;min-width:0!important;height:42px!important;margin:0!important;border-radius:11px!important;justify-content:center!important;padding:0 12px!important;box-sizing:border-box;font-size:13px!important}
.header-main-actions #cycleSelect{min-width:0!important}
.header-utility-actions{display:grid!important;grid-template-columns:42px 42px 142px 142px;gap:10px!important;width:auto!important}
.header-utility-actions>.btn,.header-utility-actions>.notification-bell-container{width:100%!important;height:40px!important;margin:0!important;min-width:0!important}
.header-utility-actions>.notification-bell-container>button,.header-utility-actions>#themeBtn{width:42px!important;height:40px!important}
.header-utility-actions>.btn-refresh,.header-utility-actions>.btn-primary{display:flex!important;align-items:center;justify-content:center;gap:7px;padding:0 12px!important;border-radius:10px!important;font-size:12px!important}
.action-icon{display:inline-grid;place-items:center;font-size:17px;font-weight:800;line-height:1}.action-label{display:inline}
.ai-audit-modal{width:min(760px,94vw);max-width:760px;padding:0;overflow-y:auto;overscroll-behavior:contain}.ai-audit-modal .modal-header{position:sticky;top:0;z-index:2;margin:0;padding:20px 22px;border-bottom:1px solid var(--border);background:var(--bg-card)}.ai-audit-modal .modal-body{padding:20px 22px 26px}.ai-audit-intro{margin-bottom:16px;color:var(--text-dim);font-size:13px;line-height:1.6}.ai-audit-modal .ai-audit-result{min-height:120px;margin:0;padding:16px;border:1px solid var(--border);border-radius:12px;background:var(--bg);overflow-wrap:anywhere}.anomaly-severe{border-color:#b91c1c!important;box-shadow:inset 0 0 0 1px rgba(185,28,28,.35),0 0 18px rgba(185,28,28,.18)!important}.anomaly-severe .day-anomaly-badge{background:#b91c1c!important;color:#fff!important;font-weight:800}
@media(max-width:1420px) and (min-width:769px){.header-main-actions{grid-template-columns:150px repeat(4,124px)}.header-utility-actions{grid-template-columns:40px 40px 124px 124px}.header-main-actions>*{font-size:12px!important}.header{grid-template-columns:minmax(320px,1fr) auto!important;gap:16px!important}}
@media(max-width:1180px) and (min-width:769px){.header-main-actions{grid-template-columns:160px repeat(4,minmax(120px,1fr));width:100%!important}.header-utility-actions{grid-template-columns:42px 42px 142px 142px;justify-content:end;width:100%!important}}
@media(max-width:768px){
  .header .subtitle{display:block}.header-update-time{display:block;margin-top:4px;font-size:9.5px}.header-update-time:not(:empty)::before{content:'';margin:0}
  .header-main-actions{grid-template-columns:repeat(4,52px)!important;justify-content:center!important;gap:10px!important;width:100%!important}
  .header-main-actions #cycleSelect{grid-column:1/-1!important;width:238px!important;height:44px!important;justify-self:center!important;font-size:12px!important}
  .header-main-actions .btn,.header-main-actions a{width:52px!important;height:52px!important;min-width:52px!important;padding:0!important;border-radius:13px!important;font-size:17px!important;box-shadow:none!important}
  .header-main-actions .btn span,.header-main-actions a span{display:none!important}
  .header-utility-actions{grid-template-columns:repeat(4,52px)!important;justify-content:center!important;gap:10px!important;width:100%!important}
  .header-utility-actions>.btn,.header-utility-actions>.notification-bell-container,.header-utility-actions>.notification-bell-container>button,.header-utility-actions>#themeBtn{width:52px!important;height:52px!important;min-width:52px!important;border-radius:13px!important;padding:0!important}
  .header-utility-actions>.btn-refresh,.header-utility-actions>.btn-primary{font-size:0!important;gap:0!important}.header-utility-actions .action-icon{font-size:22px!important}.header-utility-actions .action-label{display:none!important}
  .ai-audit-modal{width:calc(100vw - 24px);max-height:88vh}.ai-audit-modal .modal-header{padding:16px}.ai-audit-modal .modal-body{padding:16px}.ai-audit-modal .modal-header h3{font-size:15px}
}
@media(max-width:390px){.header-main-actions,.header-utility-actions{grid-template-columns:repeat(4,48px)!important;gap:8px!important}.header-main-actions #cycleSelect{width:216px!important}.header-main-actions .btn,.header-main-actions a,.header-utility-actions>.btn,.header-utility-actions>.notification-bell-container,.header-utility-actions>.notification-bell-container>button,.header-utility-actions>#themeBtn{width:48px!important;height:48px!important;min-width:48px!important}}

/* Mobile layout v5: keep every control inside the card and every tab on screen. */
@media (max-width:768px) {
  .app { padding:8px 8px calc(72px + env(safe-area-inset-bottom))!important; }
  .header { padding:14px!important; gap:12px!important; overflow:visible!important; }
  .header-right { width:100%!important; min-width:0!important; }
  .header-main-actions,
  .header-utility-actions {
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    justify-content:stretch!important;
    width:100%!important;
    gap:8px!important;
  }
  .header-main-actions #cycleSelect {
    grid-column:1 / -1!important;
    justify-self:stretch!important;
    width:100%!important;
    max-width:none!important;
    height:42px!important;
  }
  .header-main-actions .btn,
  .header-main-actions a,
  .header-utility-actions>.btn,
  .header-utility-actions>.notification-bell-container,
  .header-utility-actions>.notification-bell-container>button {
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    height:46px!important;
  }
  .notif-dropdown { right:0!important; max-width:calc(100vw - 28px)!important; }
  .tab-nav {
    left:0!important; right:0!important; width:100%!important;
    display:flex!important;
    overflow:visible!important;
    box-sizing:border-box!important;
    padding:6px 5px calc(6px + env(safe-area-inset-bottom))!important;
    gap:3px!important;
  }
  .tab-btn {
    min-width:0!important; width:100%!important;
    flex:1 1 0!important;
    padding:9px 3px!important; font-size:10px!important;
    line-height:1.2!important; white-space:normal!important;
  }
}
@media (max-width:390px) {
  .header-main-actions,
  .header-utility-actions { grid-template-columns:repeat(4,minmax(0,1fr))!important; gap:6px!important; }
  .header-main-actions #cycleSelect { width:100%!important; }
  .header-main-actions .btn,
  .header-main-actions a,
  .header-utility-actions>.btn,
  .header-utility-actions>.notification-bell-container,
  .header-utility-actions>.notification-bell-container>button { width:100%!important; min-width:0!important; height:44px!important; }
  .tab-btn { font-size:9px!important; padding-inline:2px!important; }
}

/* Mobile controls v6: one shared 4-column grid with uniform square buttons. */
@media (max-width:768px) {
  .header-right {
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    gap:10px!important;
    align-items:center!important;
  }
  .header-main-actions,
  .header-utility-actions { display:contents!important; }
  .header-main-actions #cycleSelect {
    grid-column:1 / -1!important;
    width:100%!important;
    height:48px!important;
    margin:0!important;
    border-radius:14px!important;
  }
  .header-main-actions .btn,
  .header-main-actions a,
  .header-utility-actions>.btn,
  .header-utility-actions>.notification-bell-container {
    justify-self:center!important;
    width:min(100%,58px)!important;
    min-width:0!important;
    height:auto!important;
    aspect-ratio:1 / 1!important;
    margin:0!important;
    padding:0!important;
    border-radius:15px!important;
  }
  .header-utility-actions>.notification-bell-container>button {
    width:100%!important;
    height:100%!important;
    min-width:0!important;
    border-radius:15px!important;
  }
}
@media (max-width:390px) {
  .header-right { gap:8px!important; }
  .header-main-actions .btn,
  .header-main-actions a,
  .header-utility-actions>.btn,
  .header-utility-actions>.notification-bell-container {
    width:min(100%,54px)!important;
  }
}

/* Freight reconciliation and editable user management */
.freight-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:16px}.freight-filters{display:grid;grid-template-columns:repeat(5,minmax(130px,1fr)) auto;gap:10px;margin:14px 0 20px}.freight-filters .input{margin:0;min-width:0}.freight-image-link{display:inline-flex;align-items:center;white-space:nowrap;margin-left:6px;color:var(--accent-secondary);font-size:11px;font-weight:700;text-decoration:none}.freight-image-link:hover{text-decoration:underline}.overtime-value{color:var(--yellow)}.empty-cell{text-align:center!important;padding:18px!important;color:var(--text-dim)!important}.user-role-select,.user-department-input{min-width:120px;margin:0!important;padding:7px 9px!important}.user-department-name{display:block;min-width:260px;max-width:440px;white-space:normal;overflow-wrap:anywhere;line-height:1.45}.freight-detail-btn{white-space:nowrap;padding:6px 10px!important;border-color:var(--accent-secondary)!important;color:var(--accent-secondary)!important;background:rgba(0,161,154,.08)!important}.user-actions{display:flex;justify-content:center;gap:5px}.user-action{padding:5px 9px!important;font-size:11px!important}#userTableBody td{padding:8px;text-align:left;border-bottom:1px solid var(--border)}
@media(max-width:900px){.freight-filters{grid-template-columns:repeat(2,minmax(0,1fr))}.freight-filters button{grid-column:1/-1}.freight-heading{align-items:flex-start}.user-actions{flex-wrap:wrap}}


/* Mobile app shell v7 — desktop remains unchanged */
.mobile-header-eyebrow { display:none; }
.nav-icon { display:inline-block; margin-right:5px; }
.nav-label { display:inline; }

@media (max-width:768px) {
  .app {
    padding:10px 10px calc(92px + env(safe-area-inset-bottom))!important;
  }

  #mainHeader.header {
    position:relative;
    display:flex!important;
    flex-direction:column!important;
    gap:16px!important;
    padding:18px 16px 16px!important;
    border:1px solid color-mix(in srgb,var(--accent-secondary) 24%,var(--border))!important;
    border-radius:22px!important;
    background:
      radial-gradient(circle at 92% 0,rgba(0,161,154,.12),transparent 36%),
      var(--bg-card)!important;
    box-shadow:0 10px 30px rgba(15,23,42,.08)!important;
  }

  #mainHeader .header-left {
    display:grid!important;
    grid-template-columns:58px minmax(0,1fr)!important;
    gap:13px!important;
    width:100%!important;
    padding:0 0 15px!important;
    border-bottom:1px solid var(--border)!important;
    align-items:center!important;
  }
  #mainHeader .header-left .logo {
    width:58px;height:58px;
    display:grid!important;place-items:center;
    border:1px solid var(--border);
    border-radius:16px;
    background:#fff;
    box-shadow:0 5px 16px rgba(15,23,42,.08);
  }
  #mainHeader .header-left .logo img {
    width:48px!important;max-width:48px!important;height:auto!important;
  }
  #mainHeader .header-copy { min-width:0; }
  #mainHeader .mobile-header-eyebrow {
    display:block;
    margin-bottom:4px;
    color:var(--accent-secondary);
    font-size:9px;
    line-height:1;
    font-weight:800;
    letter-spacing:1.4px;
  }
  #mainHeader h1 {
    margin:0!important;
    color:var(--text)!important;
    font-size:17px!important;
    line-height:1.25!important;
    letter-spacing:-.35px!important;
    text-transform:none!important;
  }
  #mainHeader .subtitle {
    display:block!important;
    margin-top:5px!important;
    color:var(--text-dim)!important;
    font-size:10.5px!important;
    line-height:1.45!important;
  }
  #mainHeader .header-update-time {
    display:inline-flex!important;
    margin-top:4px!important;
    padding:3px 7px;
    border-radius:999px;
    background:rgba(16,185,129,.1);
    color:var(--green)!important;
    font-size:9px!important;
    font-weight:700;
  }

  #mainHeader .header-right {
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:10px!important;
    width:100%!important;
  }
  #mainHeader .header-main-actions,
  #mainHeader .header-utility-actions { display:contents!important; }

  #mainHeader #cycleSelect {
    grid-column:1/-1!important;
    width:100%!important;
    max-width:none!important;
    height:48px!important;
    padding:0 14px!important;
    border:1px solid color-mix(in srgb,var(--accent-secondary) 55%,var(--border))!important;
    border-radius:14px!important;
    background:var(--bg)!important;
    color:var(--text)!important;
    font-size:13px!important;
    font-weight:700!important;
  }

  #mainHeader .header-main-actions .btn,
  #mainHeader .header-main-actions a {
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    height:64px!important;
    aspect-ratio:auto!important;
    display:grid!important;
    grid-template-columns:32px minmax(0,1fr)!important;
    align-items:center!important;
    justify-items:start!important;
    gap:9px!important;
    padding:0 12px!important;
    border-radius:15px!important;
    font-size:12px!important;
    font-weight:750!important;
    text-decoration:none!important;
    box-shadow:none!important;
  }
  #mainHeader .header-main-actions .btn span,
  #mainHeader .header-main-actions a span,
  #mainHeader .btn-presentation span {
    display:inline!important;
    font-size:12px!important;
    line-height:1.25!important;
  }
  #mainHeader .header-action-icon {
    width:32px;height:32px;
    display:grid!important;
    place-items:center;
    border-radius:10px;
    background:rgba(255,255,255,.16);
    font-size:17px!important;
  }
  #mainHeader [data-driver-app-link] { background:linear-gradient(135deg,#f97316,#ea580c)!important;color:#fff!important; }
  #mainHeader .header-action-ai { background:linear-gradient(135deg,#029f98,#087f79)!important; }
  #mainHeader .header-action-audit { background:linear-gradient(135deg,#6558e8,#7c3aed)!important; }
  #mainHeader .btn-presentation {
    background:var(--bg)!important;
    color:var(--text)!important;
    border:1px solid var(--border)!important;
  }
  #mainHeader .btn-presentation .header-action-icon {
    background:rgba(100,116,139,.12);
    color:var(--text);
  }

  #mainHeader .header-utility-actions>.notification-bell-container,
  #mainHeader .header-utility-actions>#themeBtn {
    width:44px!important;min-width:44px!important;height:44px!important;
    aspect-ratio:auto!important;
    justify-self:start!important;
    border-radius:13px!important;
  }
  #mainHeader .header-utility-actions>.notification-bell-container>button {
    width:44px!important;height:44px!important;border-radius:13px!important;
  }
  #mainHeader .header-utility-actions>.btn-refresh,
  #mainHeader .header-utility-actions>.btn-primary {
    width:100%!important;min-width:0!important;height:44px!important;
    aspect-ratio:auto!important;
    padding:0 12px!important;
    border-radius:13px!important;
    font-size:11px!important;
    gap:7px!important;
  }
  #mainHeader .header-utility-actions .action-label {
    display:inline!important;
    font-size:11px!important;
  }
  #mainHeader .header-utility-actions .action-icon { font-size:17px!important; }

  #tabNav.tab-nav {
    position:fixed!important;
    left:0!important;right:0!important;bottom:0!important;top:auto!important;
    z-index:1000!important;
    display:flex!important;
    align-items:stretch!important;
    gap:2px!important;
    width:100%!important;
    margin:0!important;
    padding:7px 6px calc(7px + env(safe-area-inset-bottom))!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    border:0!important;
    border-top:1px solid var(--border)!important;
    border-radius:18px 18px 0 0!important;
    background:color-mix(in srgb,var(--bg-card) 92%,transparent)!important;
    box-shadow:0 -10px 28px rgba(15,23,42,.12)!important;
    backdrop-filter:blur(18px)!important;
    -webkit-backdrop-filter:blur(18px)!important;
    scrollbar-width:none;
  }
  #tabNav.tab-nav::-webkit-scrollbar { display:none; }
  #tabNav .tab-btn {
    flex:1 0 64px!important;
    min-width:64px!important;
    width:auto!important;
    min-height:58px!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    gap:4px!important;
    padding:6px 3px!important;
    border:0!important;
    border-radius:13px!important;
    background:transparent!important;
    color:var(--text-dim)!important;
    font-size:9px!important;
    line-height:1.1!important;
    font-weight:650!important;
    white-space:nowrap!important;
  }
  #tabNav .tab-btn .nav-icon {
    display:grid!important;
    place-items:center;
    width:26px;height:24px;
    margin:0!important;
    border-radius:8px;
    color:currentColor;
    font-size:18px!important;
    line-height:1!important;
  }
  #tabNav .tab-btn .nav-label { display:block!important;font-size:9px!important; }
  #tabNav .tab-btn.active {
    background:rgba(0,161,154,.12)!important;
    color:var(--accent-secondary)!important;
  }
  #tabNav .tab-btn.active .nav-icon {
    background:var(--accent-secondary)!important;
    color:#fff!important;
    box-shadow:0 4px 10px rgba(0,161,154,.25);
  }
}

@media (max-width:390px) {
  #mainHeader.header { padding:16px 13px 14px!important; }
  #mainHeader .header-main-actions .btn,
  #mainHeader .header-main-actions a { height:60px!important;padding:0 10px!important;gap:7px!important; }
  #tabNav .tab-btn { flex-basis:60px!important;min-width:60px!important; }
}

@media (max-width:768px) {
  #mainHeader .header-utility-actions>.notification-bell-container,
  #mainHeader .header-utility-actions>#themeBtn,
  #mainHeader .header-utility-actions>.btn-refresh,
  #mainHeader .header-utility-actions>.btn-primary {
    width:100%!important;
    min-width:0!important;
    height:54px!important;
    aspect-ratio:auto!important;
    margin:0!important;
    padding:5px 3px!important;
    border-radius:13px!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    gap:3px!important;
    font-size:9px!important;
    box-shadow:none!important;
  }
  #mainHeader .header-utility-actions>.notification-bell-container {
    position:relative!important;
    justify-self:stretch!important;
    padding:0!important;
  }
  #mainHeader .header-utility-actions>.notification-bell-container>button {
    width:100%!important;height:54px!important;
    display:flex!important;flex-direction:column!important;
    gap:3px!important;padding:5px 3px!important;
  }
  #mainHeader .utility-icon,
  #mainHeader .header-utility-actions .action-icon {
    display:block!important;
    font-size:16px!important;
    line-height:1!important;
  }
  #mainHeader .utility-label,
  #mainHeader .header-utility-actions .action-label {
    display:block!important;
    font-size:9px!important;
    line-height:1.1!important;
    font-weight:700!important;
    white-space:nowrap!important;
  }
}


/* Role-based tool placement and compact mobile header v8 */
.management-tools {
  margin-bottom:20px;
  padding:18px;
  border:1px solid var(--border);
  border-radius:16px;
  background:linear-gradient(135deg,color-mix(in srgb,var(--accent-secondary) 7%,var(--bg-card)),var(--bg-card));
}
.management-tools-copy>span { color:var(--accent-secondary);font-size:9px;font-weight:800;letter-spacing:1.3px; }
.management-tools-copy h3 { margin:5px 0 3px;font-size:17px; }
.management-tools-copy p { margin:0;color:var(--text-dim);font-size:12px;line-height:1.45; }
.management-tools-actions { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:14px; }
.management-tool-btn {
  display:flex;align-items:center;gap:10px;min-width:0;padding:12px;
  border:1px solid var(--border);border-radius:13px;background:var(--bg-card);
  color:var(--text);text-align:left;text-decoration:none;cursor:pointer;
}
.management-tool-btn>b { display:grid;place-items:center;flex:0 0 34px;width:34px;height:34px;border-radius:10px;background:rgba(0,161,154,.12);color:var(--accent-secondary); }
.management-tool-btn>span { min-width:0;display:flex;flex-direction:column;gap:2px; }
.management-tool-btn strong { font-size:12px; }
.management-tool-btn small { color:var(--text-dim);font-size:9.5px;line-height:1.3; }

#tabNav .nav-icon svg { width:19px;height:19px;display:block;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round; }
#tabNav .tab-btn:first-child .nav-icon svg { fill:currentColor;stroke:none; }

@media (max-width:768px) {
  .app { padding-top:7px!important; }

  #mainHeader.header {
    gap:10px!important;
    padding:12px!important;
    border-radius:18px!important;
  }
  #mainHeader .header-left {
    grid-template-columns:44px minmax(0,1fr)!important;
    gap:10px!important;
    min-height:48px!important;
    padding:0 84px 10px 0!important;
  }
  #mainHeader .header-left .logo {
    width:44px!important;height:44px!important;border-radius:12px!important;
  }
  #mainHeader .header-left .logo img { width:38px!important;max-width:38px!important; }
  #mainHeader .mobile-header-eyebrow { margin-bottom:3px;font-size:7.5px!important;letter-spacing:1.1px!important; }
  #mainHeader h1 { font-size:14px!important;line-height:1.2!important; }
  #mainHeader .subtitle {
    margin-top:3px!important;
    font-size:9px!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }
  #mainHeader .header-update-time {
    margin:3px 0 0!important;padding:2px 5px!important;font-size:8px!important;
  }

  #mainHeader .header-right {
    display:block!important;
    width:100%!important;
  }
  #mainHeader .header-main-actions { display:block!important; }
  #mainHeader #cycleSelect {
    display:block!important;
    height:42px!important;
    padding:0 12px!important;
    border-radius:12px!important;
    font-size:12px!important;
  }
  #mainHeader .header-utility-actions { display:contents!important; }
  #mainHeader .header-utility-actions>.notification-bell-container,
  #mainHeader .header-utility-actions>#themeBtn {
    position:absolute!important;
    top:13px!important;
    width:36px!important;min-width:36px!important;height:36px!important;
    border-radius:11px!important;
  }
  #mainHeader .header-utility-actions>.notification-bell-container { right:54px!important; }
  #mainHeader .header-utility-actions>#themeBtn { right:12px!important; }
  #mainHeader .header-utility-actions>.notification-bell-container>button {
    width:36px!important;height:36px!important;padding:0!important;border-radius:11px!important;
  }
  #mainHeader .header-utility-actions>.btn-refresh,
  #mainHeader .header-utility-actions>.btn-primary { display:none!important; }
  #mainHeader .utility-label { display:none!important; }
  #mainHeader .utility-icon { font-size:15px!important; }

  .management-tools { padding:14px;margin-bottom:16px;border-radius:14px; }
  .management-tools-actions { grid-template-columns:1fr;gap:8px; }
  .management-tool-btn { min-height:58px;padding:10px; }
  .management-tool-btn strong { font-size:12px; }
  .management-tool-btn small { font-size:9.5px; }

  #tabNav .tab-btn .nav-icon { width:28px!important;height:26px!important; }
  #tabNav .nav-icon svg { width:18px;height:18px; }
}

@media (max-width:768px) {
  #mainHeader #headerDriverLink,
  #mainHeader .header-main-actions .header-action-ai,
  #mainHeader .header-main-actions .header-action-audit,
  #mainHeader #headerPresentationBtn { display:none!important; }
}
@media (max-width:420px){#mainHeader .mobile-header-eyebrow{display:none!important}}


/* Mobile-only refinements v9; desktop presentation remains unchanged */
.mobile-dashboard-title,
.mobile-report-switch { display:none; }

@media (min-width:769px) {
  #tabNav .nav-icon svg { display:none!important; }
  #tabNav .tab-btn:nth-child(1) .nav-icon::before { content:'📊'; }
  #tabNav .tab-btn:nth-child(2) .nav-icon::before { content:'📋'; }
  #tabNav .tab-btn:nth-child(3) .nav-icon::before { content:'🧾'; }
  #tabNav .tab-btn:nth-child(4) .nav-icon::before { content:'💰'; }
  #tabNav .tab-btn:nth-child(5) .nav-icon::before { content:'🚚'; }
  #tabNav .tab-btn:nth-child(6) .nav-icon::before { content:'⚙️'; }
  #tabNav .tab-btn:nth-child(7) .nav-icon::before { content:'🕰️'; }
  #tabNav .tab-btn:nth-child(2) .nav-label,
  #tabNav .tab-btn:nth-child(5) .nav-label,
  #tabNav .tab-btn:nth-child(7) .nav-label { font-size:0; }
  #tabNav .tab-btn:nth-child(2) .nav-label::after { content:'Báo cáo tổng quát';font-size:13px; }
  #tabNav .tab-btn:nth-child(5) .nav-label::after { content:'Đối Soát Cước';font-size:13px; }
  #tabNav .tab-btn:nth-child(7) .nav-label::after { content:'Lịch sử báo cáo';font-size:13px; }
}

@media (max-width:768px) {
  .desktop-dashboard-title { display:none!important; }
  .mobile-dashboard-title { display:inline!important; }

  #mainHeader .header-left .logo {
    border:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  #mainHeader .header-left .logo img {
    width:42px!important;
    max-width:42px!important;
  }

  #mainHeader #cycleSelect {
    appearance:none!important;
    -webkit-appearance:none!important;
    padding-right:42px!important;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230f766e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E")!important;
    background-repeat:no-repeat!important;
    background-position:right 14px center!important;
    background-size:16px 16px!important;
  }

  #tabNav .nav-icon::before { content:none!important; }
  #tabNav .nav-icon svg { display:block!important; }
  #tabNav .tab-btn:nth-child(7) { display:none!important; }
  #tabNav .tab-btn {
    flex:1 1 20%!important;
    min-width:0!important;
  }

  .mobile-report-switch {
    position:sticky;
    top:8px;
    z-index:80;
    display:none;
    gap:4px;
    margin:0 0 12px;
    padding:4px;
    border:1px solid var(--border);
    border-radius:13px;
    background:var(--bg-card);
    box-shadow:0 5px 16px rgba(15,23,42,.07);
  }
  .mobile-report-switch button {
    flex:1;
    min-height:38px;
    padding:6px 10px;
    border:0;
    border-radius:10px;
    background:transparent;
    color:var(--text-dim);
    font-size:11px;
    font-weight:700;
  }
  .mobile-report-switch button.active {
    background:var(--accent-secondary);
    color:#fff;
    box-shadow:0 4px 10px rgba(0,161,154,.2);
  }
}


/* Unified compact header, readable reports and resilient charts v10 */
.desktop-dashboard-title { display:none!important; }
.mobile-dashboard-title { display:inline!important; }

#mainHeader #headerDriverLink,
#mainHeader .header-main-actions .header-action-ai,
#mainHeader .header-main-actions .header-action-audit,
#mainHeader #headerPresentationBtn { display:none!important; }

#mainHeader.header {
  display:grid!important;
  grid-template-columns:minmax(280px,1fr) minmax(190px,250px) auto!important;
  align-items:center!important;
  gap:18px!important;
  padding:12px 16px!important;
  border:1px solid color-mix(in srgb,var(--accent-secondary) 24%,var(--border))!important;
  border-radius:18px!important;
  background:radial-gradient(circle at 100% 0,rgba(0,161,154,.1),transparent 34%),var(--bg-card)!important;
  box-shadow:0 8px 24px rgba(15,23,42,.07)!important;
}
#mainHeader .header-left {
  display:grid!important;
  grid-template-columns:46px minmax(0,1fr)!important;
  gap:11px!important;
  align-items:center!important;
  min-width:0!important;
}
#mainHeader .header-left .logo {
  width:46px!important;height:46px!important;
  display:grid!important;place-items:center!important;
  border:0!important;background:transparent!important;box-shadow:none!important;
}
#mainHeader .header-left .logo img { width:44px!important;max-width:44px!important;height:auto!important; }
#mainHeader .mobile-header-eyebrow { display:none!important; }
#mainHeader h1 { margin:0!important;font-size:16px!important;line-height:1.2!important;letter-spacing:-.25px!important;text-transform:none!important; }
#mainHeader .subtitle { margin-top:4px!important;font-size:10px!important;line-height:1.35!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
#mainHeader .header-update-time { margin-left:4px!important;font-size:9px!important; }
#mainHeader .header-right { display:contents!important; }
#mainHeader .header-main-actions { display:block!important; }
#mainHeader #cycleSelect {
  display:block!important;width:100%!important;height:42px!important;margin:0!important;
  padding:0 40px 0 13px!important;border-radius:12px!important;
  appearance:none!important;-webkit-appearance:none!important;
  background-color:var(--bg)!important;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230f766e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E")!important;
  background-repeat:no-repeat!important;background-position:right 13px center!important;background-size:16px!important;
  font-size:12px!important;font-weight:700!important;
}
#mainHeader .header-utility-actions { display:flex!important;align-items:center!important;gap:8px!important;width:auto!important; }
#mainHeader .header-utility-actions>.notification-bell-container,
#mainHeader .header-utility-actions>#themeBtn {
  position:relative!important;top:auto!important;right:auto!important;
  width:38px!important;min-width:38px!important;height:38px!important;
  padding:0!important;border-radius:11px!important;
}
#mainHeader .header-utility-actions>.notification-bell-container>button {
  width:38px!important;height:38px!important;padding:0!important;border-radius:11px!important;
}
#mainHeader .header-utility-actions>.btn-refresh,
#mainHeader .header-utility-actions>.btn-primary { display:none!important; }
#mainHeader .utility-label { display:none!important; }
#mainHeader .utility-icon { display:block!important;font-size:16px!important; }

.freight-heading-actions { display:flex;align-items:center;gap:8px;flex-wrap:wrap; }
.freight-heading-actions .btn { min-height:38px;display:inline-flex;align-items:center;gap:6px; }

#summaryCards {
  grid-template-columns:repeat(5,minmax(0,1fr))!important;
  gap:12px!important;
}
#summaryCards .card {
  position:relative;
  min-height:112px!important;
  padding:17px 14px!important;
  border:1px solid var(--border)!important;
  border-left:0!important;
  overflow:hidden;
  box-shadow:0 5px 16px rgba(15,23,42,.055)!important;
}
#summaryCards .card::before {
  content:'';position:absolute;left:0;right:0;top:0;height:3px;background:var(--accent-secondary);
}
#summaryCards .card-incomplete::before { background:var(--red); }
#summaryCards .card-icon {
  width:32px;height:32px;margin:0 auto 7px!important;
  display:grid!important;place-items:center;
  border-radius:10px;background:rgba(0,161,154,.1);
  font-size:17px!important;font-weight:800;color:var(--accent-secondary);
}
#summaryCards .card-incomplete .card-icon { background:rgba(239,68,68,.1); }
#summaryCards .card-value { font-size:25px!important;line-height:1.05!important;letter-spacing:-.7px; }
#summaryCards .card-label { margin-top:5px;font-size:9px!important;font-weight:750;letter-spacing:.8px; }

.cost-chart-stage {
  width:100%;height:270px;display:flex;align-items:center;justify-content:center;overflow:hidden;
}
#costChart {
  width:100%!important;height:100%!important;max-width:520px!important;max-height:270px!important;
}

.anomaly-table-scroll { max-width:100%;padding:0 16px 16px;overflow-x:auto;-webkit-overflow-scrolling:touch; }
.anomaly-table { width:100%;border-collapse:collapse; }
.anomaly-table th,.anomaly-table td { white-space:nowrap; }

.ai-audit-loading {
  min-height:190px;display:grid;grid-template-columns:72px minmax(0,1fr);
  align-items:center;gap:22px;padding:20px;color:var(--text);
}
.ai-audit-loading strong { display:block;margin-bottom:7px;font-size:15px; }
.ai-audit-loading p { margin:0;color:var(--text-dim);font-size:12px;line-height:1.5; }
.audit-orbit {
  position:relative;width:64px;height:64px;border-radius:50%;
  border:2px solid color-mix(in srgb,var(--accent-secondary) 20%,transparent);
}
.audit-orbit::before,.audit-orbit::after {
  content:'';position:absolute;inset:10px;border-radius:50%;border:2px dashed rgba(101,88,232,.35);
  animation:auditSpin 2.4s linear infinite;
}
.audit-orbit::after { inset:21px;border:0;background:linear-gradient(135deg,#6558e8,#00a19a);animation:auditPulse 1.4s ease-in-out infinite; }
.audit-orbit span { position:absolute;top:-5px;left:26px;width:10px;height:10px;border-radius:50%;background:var(--accent-secondary);box-shadow:0 0 14px rgba(0,161,154,.6); }
.audit-orbit i { position:absolute;right:-3px;bottom:10px;width:7px;height:7px;border-radius:50%;background:#6558e8; }
.audit-loading-steps { display:flex;gap:6px;flex-wrap:wrap;margin-top:12px; }
.audit-loading-steps span { padding:4px 8px;border-radius:999px;background:var(--bg);color:var(--text-dim);font-size:9px;font-weight:700;animation:auditStep 1.5s ease-in-out infinite; }
.audit-loading-steps span:nth-child(2){animation-delay:.2s}.audit-loading-steps span:nth-child(3){animation-delay:.4s}
@keyframes auditSpin{to{transform:rotate(360deg)}} @keyframes auditPulse{50%{transform:scale(.72);opacity:.65}} @keyframes auditStep{50%{color:var(--accent-secondary);background:rgba(0,161,154,.1)}}

@media(max-width:900px) {
  #mainHeader.header { grid-template-columns:minmax(0,1fr) 190px auto!important;gap:10px!important; }
  #summaryCards { grid-template-columns:repeat(2,minmax(0,1fr))!important; }
  #summaryCards .card-cost { grid-column:1/-1; }
}

@media(max-width:768px) {
  #mainHeader.header { display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:9px!important;padding:10px 12px!important; }
  #mainHeader .header-left { width:100%!important;padding:0 82px 8px 0!important;grid-template-columns:42px minmax(0,1fr)!important; }
  #mainHeader .header-left .logo { width:42px!important;height:38px!important; }
  #mainHeader .header-left .logo img { width:41px!important;max-width:41px!important; }
  #mainHeader h1 { font-size:14px!important; }
  #mainHeader .subtitle { font-size:8.5px!important; }
  #mainHeader .header-right { display:block!important; }
  #mainHeader .header-utility-actions>.notification-bell-container,
  #mainHeader .header-utility-actions>#themeBtn { position:absolute!important;top:11px!important; }
  #mainHeader .header-utility-actions>.notification-bell-container { right:52px!important; }
  #mainHeader .header-utility-actions>#themeBtn { right:10px!important; }
  #mainHeader #cycleSelect { height:40px!important; }

  #summaryCards .card { min-height:101px!important;padding:12px 9px!important; }
  #summaryCards .card-icon { width:27px;height:27px;margin-bottom:5px!important;font-size:14px!important; }
  #summaryCards .card-value { font-size:23px!important; }
  #summaryCards .card-label { font-size:8.5px!important; }
  #summaryCards .card-cost {
    min-height:82px!important;
    display:grid!important;grid-template-columns:34px minmax(0,1fr)!important;
    grid-template-rows:auto auto!important;align-items:center!important;text-align:left!important;
    column-gap:10px!important;
  }
  #summaryCards .card-cost .card-icon { grid-row:1/3;margin:0!important; }
  #summaryCards .card-cost .card-value { align-self:end; }
  #summaryCards .card-cost .card-label { align-self:start;margin-top:2px; }

  #tab-report .report-chart-card { height:340px!important; }
  #costChartWrap.report-chart-card { height:390px!important; }
  .cost-chart-stage { height:320px; }
  #costChart { max-width:320px!important;max-height:320px!important; }

  .anomaly-table-scroll { padding:0 10px 12px;overflow:visible; }
  .anomaly-table,.anomaly-table tbody,.anomaly-table tr,.anomaly-table td { display:block;width:100%; }
  .anomaly-table thead { display:none; }
  .anomaly-table tr {
    box-sizing:border-box;margin-bottom:9px;padding:8px 10px;
    border:1px solid var(--border);border-radius:11px;background:var(--bg);
  }
  .anomaly-table td {
    box-sizing:border-box;display:flex!important;align-items:center;justify-content:space-between;
    gap:12px;padding:6px 0!important;border:0!important;white-space:normal!important;text-align:right!important;
    font-size:11px!important;
  }
  .anomaly-table td::before { content:attr(data-label);color:var(--text-dim);font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:.5px; }
  #odoAnomalies details summary { padding:11px 12px!important;font-size:12px!important;flex-wrap:wrap; }

  .ai-audit-loading { min-height:160px;grid-template-columns:52px minmax(0,1fr);gap:14px;padding:12px; }
  .audit-orbit { width:48px;height:48px; }
  .audit-orbit::after { inset:16px; }
}

@media(max-width:480px) {
  .freight-heading { flex-direction:column; }
  .freight-heading-actions { width:100%;display:grid;grid-template-columns:1fr 1fr; }
  .freight-heading-actions .btn { justify-content:center; }
}

.ai-audit-loading-delivery { grid-template-columns:minmax(220px,320px) minmax(0,1fr); }
.audit-animation-slot { height:150px;overflow:hidden;border-radius:14px;background:linear-gradient(180deg,rgba(0,161,154,.06),rgba(0,161,154,.015)); }
.audit-animation-slot .animation-container {
  width:320px!important;height:150px!important;max-width:100%!important;margin:0 auto!important;
  transform:scale(.84);transform-origin:center center;
}
@media(max-width:768px){
  .ai-audit-loading-delivery{grid-template-columns:1fr;}
  .audit-animation-slot{height:130px;}
  .audit-animation-slot .animation-container{height:140px!important;transform:scale(.74);}
}


/* Five KPI redesign and unified report/history navigation v11 */
#summaryCards .card::before { display:none!important; }

#tabNav .tab-btn:nth-child(7) { display:none!important; }
#tabNav .tab-btn { flex:1 1 20%!important; }

.mobile-report-switch {
  width:min(420px,calc(100% - 24px));
  display:none;
  gap:5px;
  margin:14px auto;
  padding:5px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--bg-card);
  box-shadow:0 5px 16px rgba(15,23,42,.07);
}
.mobile-report-switch button {
  flex:1;
  min-height:40px;
  padding:7px 12px;
  border:0;
  border-radius:10px;
  background:transparent;
  color:var(--text-dim);
  font-size:11px;
  font-weight:750;
  cursor:pointer;
}
.mobile-report-switch button.active {
  background:linear-gradient(135deg,#00a19a,#07847e);
  color:#fff;
  box-shadow:0 4px 11px rgba(0,161,154,.2);
}

@media(min-width:769px) {
  #summaryCards .card {
    min-height:92px!important;
    display:grid!important;
    grid-template-columns:42px minmax(0,1fr)!important;
    grid-template-rows:auto auto!important;
    align-items:center!important;
    column-gap:12px!important;
    padding:15px 16px!important;
    text-align:left!important;
    border-radius:16px!important;
  }
  #summaryCards .card-icon {
    grid-row:1/3;
    width:42px!important;height:42px!important;
    margin:0!important;
    border-radius:13px!important;
    font-size:20px!important;
  }
  #summaryCards .card-value {
    align-self:end!important;
    font-size:25px!important;
    line-height:1!important;
    white-space:nowrap;
  }
  #summaryCards .card-label {
    align-self:start!important;
    margin-top:5px!important;
    font-size:8.5px!important;
    white-space:nowrap;
  }

  #summaryCards .card-total {
    background:linear-gradient(135deg,rgba(59,130,246,.07),var(--bg-card) 58%)!important;
  }
  #summaryCards .card-complete {
    background:linear-gradient(135deg,rgba(16,185,129,.08),var(--bg-card) 58%)!important;
  }
  #summaryCards .card-incomplete {
    background:linear-gradient(135deg,rgba(239,68,68,.07),var(--bg-card) 58%)!important;
  }
  #summaryCards .card-rate {
    background:linear-gradient(135deg,rgba(0,161,154,.08),var(--bg-card) 58%)!important;
  }
  #summaryCards .card-cost {
    background:linear-gradient(135deg,rgba(245,158,11,.09),var(--bg-card) 58%)!important;
  }

  #summaryCards .card-total .card-icon { background:rgba(59,130,246,.12)!important; }
  #summaryCards .card-complete .card-icon { background:rgba(16,185,129,.12)!important; }
  #summaryCards .card-incomplete .card-icon { background:rgba(239,68,68,.12)!important; }
  #summaryCards .card-rate .card-icon { background:rgba(0,161,154,.12)!important; }
  #summaryCards .card-cost .card-icon { background:rgba(245,158,11,.14)!important;color:#b66a00!important; }

  .mobile-report-switch {
    position:sticky;
    top:8px;
    z-index:80;
  }
}

@media(max-width:768px) {
  .mobile-report-switch { width:calc(100% - 16px);margin:10px auto 12px; }
}

/* Responsive KPI, report switch and cost distribution refinements v12 */
#summaryCards .card{overflow:hidden!important}
#summaryCards .card-total{background:linear-gradient(135deg,rgba(59,130,246,.09),var(--bg-card) 62%)!important}
#summaryCards .card-complete{background:linear-gradient(135deg,rgba(16,185,129,.10),var(--bg-card) 62%)!important}
#summaryCards .card-incomplete{background:linear-gradient(135deg,rgba(239,68,68,.09),var(--bg-card) 62%)!important}
#summaryCards .card-rate{background:linear-gradient(135deg,rgba(0,161,154,.10),var(--bg-card) 62%)!important}
#summaryCards .card-cost{background:linear-gradient(135deg,rgba(245,158,11,.11),var(--bg-card) 62%)!important}
#summaryCards .card-total .card-icon{background:rgba(59,130,246,.13)!important}
#summaryCards .card-complete .card-icon{background:rgba(16,185,129,.13)!important}
#summaryCards .card-incomplete .card-icon{background:rgba(239,68,68,.13)!important}
#summaryCards .card-rate .card-icon{background:rgba(0,161,154,.13)!important}
#summaryCards .card-cost .card-icon{background:rgba(245,158,11,.16)!important;color:#b66a00!important}
#summaryCards .card-cost .card-value{min-width:0!important;max-width:100%!important;font-size:clamp(17px,1.35vw,23px)!important;letter-spacing:-.8px!important;white-space:nowrap!important}
.mobile-report-switch{position:static!important;top:auto!important;z-index:auto!important;width:100%!important;max-width:none!important;margin:8px 0 16px!important;padding:0 16px!important;gap:2px!important;border:0!important;border-bottom:1px solid var(--border)!important;border-radius:0!important;background:transparent!important;box-shadow:none!important}
.mobile-report-switch button{min-height:42px!important;border-radius:10px 10px 0 0!important;border-bottom:3px solid transparent!important;box-shadow:none!important}
.mobile-report-switch button.active{background:rgba(0,161,154,.09)!important;color:var(--accent-secondary)!important;border-bottom-color:var(--accent-secondary)!important;box-shadow:none!important}
.cost-chart-layout{min-height:270px;display:grid;grid-template-columns:minmax(210px,260px) minmax(220px,1fr);align-items:center;justify-content:center;gap:18px}
.cost-chart-stage{width:240px!important;height:240px!important;min-width:240px;min-height:240px;margin:auto;overflow:visible!important}
#costChart{display:block!important;width:240px!important;height:240px!important;max-width:240px!important;max-height:240px!important;aspect-ratio:1/1!important}
.cost-chart-legend{display:grid;align-content:center;gap:7px;min-width:0}
.cost-legend-item{display:grid;grid-template-columns:11px minmax(0,1fr) 34px;align-items:center;gap:8px;min-width:0;color:var(--text-dim);font-size:10px;line-height:1.25}
.cost-legend-dot{width:10px;height:10px;border-radius:50%;background:var(--legend-color)}
.cost-legend-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cost-legend-item strong{color:var(--text);text-align:right;font-size:10px}
.cost-chart-empty{height:220px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;color:var(--text-dim);font-size:13px}
.audit-animation-slot{display:grid!important;place-items:center!important;height:160px!important;overflow:hidden!important}
.audit-animation-slot .animation-container{position:relative!important;left:auto!important;width:400px!important;height:190px!important;max-width:none!important;margin:0!important;flex:0 0 400px!important;transform:scale(.76)!important;transform-origin:center center!important}
@media(max-width:768px){
#summaryCards .card-cost{grid-template-columns:38px minmax(0,max-content)!important;justify-content:center!important;padding-inline:12px!important}
#summaryCards .card-cost .card-value{font-size:clamp(18px,5.8vw,25px)!important}
.mobile-report-switch{margin:6px 0 12px!important;padding:0 8px!important}
.cost-chart-layout{min-height:0;grid-template-columns:1fr;gap:12px}
.cost-chart-stage{width:230px!important;height:230px!important;min-width:230px;min-height:230px}
#costChart{width:230px!important;height:230px!important;max-width:230px!important;max-height:230px!important}
.cost-chart-legend{width:min(100%,340px);margin:0 auto;padding:0 8px 8px}
#costChartWrap.report-chart-card{height:auto!important;min-height:430px!important}
.audit-animation-slot{height:150px!important}
.audit-animation-slot .animation-container{width:400px!important;height:190px!important;transform:scale(.69)!important}
}

/* Control Tower v13 — KPI-first, overview-to-detail, responsive desktop/mobile */
:root {
  --surface-raised: color-mix(in srgb, var(--bg-card) 92%, var(--accent) 8%);
  --surface-muted: color-mix(in srgb, var(--bg-card) 86%, var(--bg) 14%);
  --line-soft: color-mix(in srgb, var(--border) 78%, var(--accent) 22%);
}

.section-kicker,
.filter-panel-kicker,
.toolbar-kicker,
.chart-kicker {
  display: block;
  color: var(--accent-secondary);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.55px;
  line-height: 1.2;
  text-transform: uppercase;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(16,185,129,.12), 0 0 13px rgba(16,185,129,.5);
  vertical-align: middle;
}

#tab-overview .overview-kpi-wrap { margin-bottom: 20px; }
.overview-kpi-heading,
.overview-section-head,
.overview-canvas-head,
.warehouse-toolbar,
.report-story-head,
.report-data-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.overview-kpi-heading { margin: 0 4px 12px; }
.overview-kpi-heading h2,
.overview-section-head h2,
.report-story-head h2,
.report-data-head h2 { margin: 4px 0 4px; font-size: clamp(20px, 2vw, 25px); letter-spacing: -.4px; }
.overview-kpi-heading p,
.report-story-head p { color: var(--text-dim); font-size: 12px; line-height: 1.45; }
.overview-scope-pill,
.overview-live-state,
.selection-state,
.chart-note,
.report-data-head > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 11px;
}
.overview-scope-pill { padding: 8px 11px; border: 1px solid var(--line-soft); border-radius: 999px; background: var(--bg-card); color: var(--text); font-weight: 700; }
.overview-section { margin-top: 0 !important; padding: clamp(18px, 2.2vw, 28px) !important; border-color: var(--line-soft); overflow: visible !important; }
.overview-section-head { align-items: flex-start; padding-bottom: 17px; border-bottom: 1px solid var(--border-subtle); }
.overview-live-state { padding-top: 3px; }
.overview-layout { display: grid; grid-template-columns: minmax(204px, 232px) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 20px; }
.overview-filter-panel { position: sticky; top: 14px; align-self: start; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: linear-gradient(165deg, var(--surface-raised), var(--bg-card)); box-shadow: var(--shadow-rest); }
.filter-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border-subtle); }
.filter-panel-heading strong { display: block; margin-top: 5px; color: var(--text-bright); font: 700 15px/1.2 'Space Grotesk', sans-serif; }
.filter-toggle { display: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; background: var(--bg-hover); color: var(--text-dim); font-size: 10px; font-weight: 700; cursor: pointer; }
.overview-filter-body { display: grid; gap: 14px; }
.filter-block { display: grid; gap: 6px; }
.filter-block label { color: var(--text-dim); font-size: 10px; font-weight: 700; letter-spacing: .25px; }
.filter-input-wrap { position: relative; }
.filter-input-wrap > span { position: absolute; left: 11px; top: 50%; z-index: 1; transform: translateY(-50%); color: var(--accent-secondary); font-size: 17px; line-height: 1; pointer-events: none; }
.filter-input-wrap .input { width: 100%; margin: 0; padding-left: 30px; }
.overview-filter-panel .input { width: 100%; min-width: 0; margin: 0; padding: 10px 11px; border-radius: 9px; background: var(--bg); font-size: 11px; }
.filter-clear-btn { width: 100%; justify-content: center; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 9px; background: rgba(0,161,154,.08); color: var(--accent-secondary); font-size: 11px; font-weight: 700; }
.filter-clear-btn span { font-size: 15px; }
.filter-panel-hint { display: grid; grid-template-columns: 18px 1fr; gap: 7px; padding-top: 12px; border-top: 1px dashed var(--border); color: var(--text-dim); }
.filter-panel-hint > span { color: var(--accent-secondary); font-size: 17px; }
.filter-panel-hint p { font-size: 10px; line-height: 1.45; }
.overview-main { min-width: 0; }
.overview-canvas-head { align-items: center; margin: 1px 1px 13px; }
.overview-canvas-head strong,
.warehouse-toolbar strong { display: block; margin-top: 5px; color: var(--text-bright); font: 700 15px/1.2 'Space Grotesk', sans-serif; }
.selection-state { padding: 7px 10px; border-radius: 999px; background: var(--bg-hover); color: var(--accent-secondary); }
#tab-overview .region-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 0 18px; }
#tab-overview .region-card { min-height: 124px; padding: 15px; border-radius: 14px; }
#tab-overview .region-card strong { font-size: 17px; }
.warehouse-toolbar { align-items: center; padding: 13px 0 11px; border-top: 1px solid var(--border-subtle); }
.toolbar-legend { display: flex; align-items: center; justify-content: flex-end; gap: 11px; color: var(--text-dim); font-size: 10px; }
.toolbar-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-dot-danger { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.status-dot-success { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.mobile-filter-toggle { display: none; }
#tab-overview .warehouse-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
#tab-overview .wh-card { min-height: 132px; padding: 15px; border-radius: 13px; background: linear-gradient(135deg, var(--bg-card), var(--surface-muted)); }
#tab-overview .wh-name { min-height: 38px; margin-bottom: 8px; font-size: 13px; line-height: 1.35; }
#tab-overview .wh-stats { gap: 8px; flex-wrap: wrap; margin-bottom: 10px; font-size: 10px; }
#tab-overview .wh-progress { height: 5px; }
#tab-overview .wh-cost { font-size: 11px; }
#summaryCards { gap: 11px !important; }
#summaryCards .card { position: relative; min-height: 108px !important; border: 1px solid var(--border); border-radius: 16px !important; box-shadow: var(--shadow-rest); }
#summaryCards .card-foot { grid-column: 2; align-self: start; margin-top: 4px; color: var(--text-dim); font-size: 9px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#summaryCards .card:hover { transform: translateY(-2px); border-color: var(--line-soft); box-shadow: var(--shadow-hover); }

/* Report: overview -> trend -> analysis -> data storyline */
.report-shell { padding: clamp(18px, 2.4vw, 30px) !important; overflow: visible !important; }
.report-story-head { align-items: flex-start; padding-bottom: 18px; border-bottom: 1px solid var(--border-subtle); }
.report-scope-card { display: grid; gap: 4px; min-width: 145px; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--bg-hover); }
.report-scope-card span { color: var(--accent-secondary); font-size: 9px; font-weight: 800; letter-spacing: 1.1px; }
.report-scope-card strong { color: var(--text-bright); font-size: 14px; }
.report-scope-card small { color: var(--text-dim); font-size: 10px; }
.report-sequence { display: flex; align-items: center; gap: 9px; margin: 16px 0 18px; color: var(--text-dim); font-size: 10px; overflow-x: auto; scrollbar-width: none; }
.report-sequence::-webkit-scrollbar { display: none; }
.report-sequence span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
.report-sequence span.is-active { border-color: var(--accent); background: rgba(0,161,154,.1); color: var(--accent-secondary); }
.report-sequence b { color: var(--accent); font-size: 9px; }
.report-sequence i { color: var(--border); font-style: normal; }
#tab-report .report-chart-grid { gap: 14px; margin-bottom: 14px; }
#tab-report .report-primary-grid { grid-template-columns: minmax(0, 1.28fr) minmax(320px, .72fr); }
#tab-report .report-analysis-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#tab-report .report-chart-card { height: 340px; padding: 17px; border-radius: 16px; border-color: var(--border); background: linear-gradient(150deg, var(--surface-raised), var(--bg-card)); box-shadow: var(--shadow-rest); }
#tab-report .report-chart-card:hover { border-color: var(--line-soft); box-shadow: var(--shadow-hover); }
.report-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-height: 34px; margin-bottom: 9px; }
.report-card-head h3,
#costChartWrap > h3 { margin: 4px 0 0 !important; color: var(--text-bright) !important; font-size: 13px !important; line-height: 1.25; }
.chart-note { font-size: 9px; }
.report-chart-card canvas { height: calc(100% - 43px) !important; }
#costChartWrap .cost-chart-layout { min-height: 250px; }
.report-section-divider { display: flex; align-items: center; gap: 10px; margin: 23px 0 16px; color: var(--accent-secondary); font-size: 9px; font-weight: 800; letter-spacing: 1.5px; }
.report-section-divider i { height: 1px; flex: 1; background: linear-gradient(90deg, var(--line-soft), transparent); }
.report-section-divider small { color: var(--text-dim); font-size: 10px; font-weight: 500; letter-spacing: 0; }
.report-data-head { align-items: center; margin: 23px 0 13px; }
.report-data-head h2 { font-size: 19px; }
.report-alert-shell { padding: 22px !important; }
.report-alert-shell .report-data-head { margin: 0 0 12px; }

@media (max-width: 1180px) and (min-width: 769px) {
  .overview-layout { grid-template-columns: 190px minmax(0, 1fr); gap: 14px; }
  #tab-overview .region-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #tab-overview .warehouse-grid { grid-template-columns: 1fr; }
  #tab-report .report-primary-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  #tab-overview .overview-kpi-wrap { margin-bottom: 12px; }
  .overview-kpi-heading,
  .overview-section-head,
  .report-story-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .overview-kpi-heading h2,
  .overview-section-head h2,
  .report-story-head h2 { font-size: 19px; }
  .overview-scope-pill { align-self: flex-start; font-size: 10px; }
  .overview-section { padding: 15px !important; border-radius: 17px !important; }
  .overview-layout { display: block; margin-top: 14px; }
  .overview-filter-panel { position: static; margin-bottom: 14px; padding: 13px; border-radius: 13px; }
  .filter-panel-heading { align-items: center; margin: 0; padding: 0; border: 0; }
  .filter-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .overview-filter-body { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-subtle); }
  .overview-filter-panel.is-collapsed .overview-filter-body { display: none; }
  .overview-filter-panel.is-collapsed { margin-bottom: 10px; }
  .mobile-filter-toggle { display: inline-flex; }
  .overview-live-state { display: none; }
  .overview-canvas-head { align-items: flex-start; flex-direction: column; gap: 8px; margin-inline: 0; }
  .selection-state { font-size: 10px; }
  #tab-overview .region-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #tab-overview .region-card { min-height: 112px; padding: 12px; border-radius: 12px; }
  #tab-overview .region-card strong { font-size: 15px; }
  #tab-overview .region-card-meta,
  #tab-overview .region-card-rate { font-size: 9px; }
  .warehouse-toolbar { align-items: flex-start; }
  .toolbar-legend { flex-wrap: wrap; gap: 7px; font-size: 9px; }
  #tab-overview .warehouse-grid { grid-template-columns: 1fr; }
  #tab-overview .wh-card { min-height: 122px; }
  #summaryCards { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  #summaryCards .card { min-height: 110px !important; padding: 13px 10px !important; }
  #summaryCards .card-foot { font-size: 8px; }
  #summaryCards .card-cost { grid-column: 1 / -1; }
  #tab-report .report-shell { padding: 15px !important; border-radius: 17px !important; }
  .report-scope-card { width: 100%; min-width: 0; }
  .report-sequence { margin: 14px -2px 15px; padding-bottom: 2px; }
  #tab-report .report-chart-grid,
  #tab-report .report-primary-grid,
  #tab-report .report-analysis-grid { grid-template-columns: 1fr; gap: 10px; }
  #tab-report .report-chart-card { height: 300px !important; padding: 13px; border-radius: 14px; }
  #tab-report #costChartWrap.report-chart-card { height: auto !important; min-height: 405px !important; }
  .report-card-head { margin-bottom: 7px; }
  .report-card-head h3,
  #costChartWrap > h3 { font-size: 12px !important; }
  .report-data-head { align-items: flex-start; flex-direction: column; gap: 5px; }
  .report-data-head h2 { font-size: 18px; }
  .report-section-divider { margin: 18px 0 12px; }
  .report-section-divider small { display: none; }
  .report-alert-shell { padding: 16px !important; border-radius: 17px !important; }
}

@media (max-width: 430px) {
  #tab-overview .region-card { min-height: 105px; padding: 11px 10px; }
  #tab-overview .region-card strong { font-size: 14px; }
  #summaryCards .card { min-height: 104px !important; }
  #summaryCards .card-value { font-size: 22px !important; }
  #summaryCards .card-label { font-size: 9px !important; }
  .toolbar-legend > span { display: none; }
}
/* Local UI fixes: Vietnamese glyphs, complete cost legend, manual trip assignment */
:root { --font-vietnamese: 'Be Vietnam Pro', 'Segoe UI', Arial, sans-serif; }
#tab-overview .region-card,
#tab-overview .region-card *,
#tab-overview .wh-card,
#tab-overview .wh-card *,
#manageGrid,
#manageGrid * {
  font-family: var(--font-vietnamese) !important;
  font-variant-ligatures: none;
}
#tab-overview .region-card strong,
#tab-overview .wh-name,
#manageGrid input[type="text"],
#manageGrid th,
#manageGrid td {
  letter-spacing: 0 !important;
}
#costChartWrap.report-chart-card {
  overflow: visible !important;
}
#costChartWrap .cost-chart-legend {
  max-height: 260px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  align-content: start;
}
#costChartWrap .cost-legend-item {
  align-items: start;
}
#costChartWrap .cost-legend-name {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.3;
}
.cost-chart-count {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent-secondary);
  font-size: 10px;
  font-weight: 600;
}
.trip-assignment-controls:has(.trip-assignment-manual-code) {
  grid-template-columns: minmax(0, 1fr) minmax(160px, .8fr) auto;
}
.trip-assignment-manual-code {
  min-width: 0;
}
@media (min-width: 769px) {
  #costChartWrap .cost-chart-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 14px;
  }
}
@media (max-width: 768px) {
  #costChartWrap .cost-chart-legend {
    max-height: 190px;
    grid-template-columns: 1fr;
  }
  .trip-assignment-controls:has(.trip-assignment-manual-code) {
    grid-template-columns: 1fr;
  }
}.config-data-note {
  grid-column: 1 / -1;
  border: 1px solid rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .08);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}.warehouse-config-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.warehouse-config-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.warehouse-config-name > .input:first-child {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  border: none;
  background: transparent;
  padding: 0;
}
.warehouse-zone-label {
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}
.warehouse-zone-select {
  width: 118px;
  min-width: 118px;
  padding: 5px 7px;
  font-size: 11px;
}
@media (max-width: 768px) {
  .warehouse-config-heading,
  .warehouse-config-name {
    align-items: stretch;
  }
  .warehouse-config-name {
    flex-wrap: wrap;
  }
  .warehouse-config-name > .input:first-child {
    flex-basis: 100%;
  }
  .warehouse-zone-select {
    flex: 1;
    min-width: 110px;
  }
}
/* Management tree v1 — scalable region > warehouse > truck/user directories */
.nav-label-mobile { display: none; }
.nav-icon-trip svg { stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.manage-heading, .manage-panel-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:18px; }
.manage-heading h2, .manage-panel-heading h3 { margin:4px 0 5px; }
.manage-heading .subtitle, .manage-panel-heading .subtitle { margin:0; line-height:1.45; }
.manage-config-stats { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:5px; color:var(--text-dim); font-size:10px; text-align:right; }
.manage-config-stats strong { color:var(--accent-secondary); font-size:16px; }
.manage-config-stats i { color:var(--border); font-style:normal; margin:0 3px; }
.user-directory-toolbar, .management-tree-toolbar { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin:14px 0; padding:10px; border:1px solid var(--border); border-radius:12px; background:rgba(0,161,154,.035); }
.user-directory-toolbar .input, .management-tree-actions .input { margin:0; min-width:0; }
.user-directory-toolbar > .input { flex:1 1 260px; }
.user-directory-toolbar > .btn, .management-tree-actions > .btn { white-space:nowrap; margin:0; }
.management-tree-toolbar { margin:0 0 12px; }
.management-tree-toolbar > div:first-child { display:grid; gap:3px; min-width:150px; }
.management-tree-toolbar > div:first-child span { color:var(--text-dim); font-size:10px; }
.management-tree-actions { display:flex; align-items:center; justify-content:flex-end; gap:7px; flex-wrap:wrap; }
.management-tree-actions .input { width:260px; }
.warehouse-management-tree, .user-directory { display:grid; gap:10px; min-width:0; }
.management-region-node, .management-warehouse-node, .user-region-node, .user-warehouse-node { border:1px solid var(--border); border-radius:14px; background:linear-gradient(145deg,var(--bg-card),var(--surface-muted)); overflow:hidden; }
.management-region-node[open], .user-region-node[open] { border-color:color-mix(in srgb,var(--accent-secondary) 48%,var(--border)); }
.management-warehouse-node[open], .user-warehouse-node[open] { background:var(--bg-card); }
.management-tree-summary, .user-region-node > summary, .user-warehouse-node > summary { display:flex; align-items:center; gap:10px; min-height:56px; padding:12px 14px; cursor:pointer; list-style:none; }
.management-tree-summary::-webkit-details-marker, .user-region-node > summary::-webkit-details-marker, .user-warehouse-node > summary::-webkit-details-marker { display:none; }
.tree-chevron { display:inline-grid; place-items:center; width:22px; height:22px; border:1px solid var(--border); border-radius:50%; color:var(--accent-secondary); font-size:15px; line-height:1; transition:transform .16s ease; }
details[open] > summary .tree-chevron { transform:rotate(180deg); }
.management-region-summary { background:rgba(0,161,154,.055); }
.management-region-title, .management-warehouse-title, .user-region-title, .user-warehouse-title { display:grid; gap:3px; min-width:0; flex:1; }
.management-region-title strong, .management-warehouse-title strong, .user-region-title strong, .user-warehouse-title strong { color:var(--text-bright); font-size:14px; line-height:1.35; overflow-wrap:anywhere; }
.management-region-title small, .management-warehouse-title small, .user-region-title small, .user-warehouse-title small { color:var(--text-dim); font-size:10px; line-height:1.4; }
.tree-count { flex:0 0 auto; color:var(--accent-secondary); font-size:11px; font-weight:700; white-space:nowrap; }
.management-region-body, .user-region-body { display:grid; gap:8px; padding:0 10px 10px; }
.management-warehouse-body, .user-warehouse-body { padding:0 14px 14px; border-top:1px solid var(--border); }
.management-warehouse-editor { display:grid; grid-template-columns:minmax(0,1fr) 145px; gap:10px; padding:14px 0 10px; }
.management-warehouse-editor label, .management-warehouse-meta label, .management-truck-field, .user-directory-fields label { display:grid; gap:5px; min-width:0; }
.management-warehouse-editor label > span, .management-warehouse-meta label > span, .management-truck-field > span, .user-directory-fields label > span { color:var(--text-dim); font-size:10px; font-weight:700; }
.management-name-editor input { font-size:15px; font-weight:700; min-height:40px; }
.management-zone-editor select { min-height:40px; }
.management-warehouse-meta { display:grid; grid-template-columns:minmax(0,1fr) 145px auto; gap:10px; align-items:end; padding-bottom:12px; }
.management-warehouse-meta input { margin:0; }
.management-truck-list { display:grid; gap:7px; }
.management-truck-row { display:grid; grid-template-columns:1.1fr 2fr 120px repeat(4,130px) 1.6fr 100px 100px 42px; gap:8px; align-items:end; padding:10px; border:1px solid var(--border); border-radius:10px; background:var(--bg-hover); }
.management-truck-field input, .management-truck-field select { width:100%; min-width:0; margin:0; }
.management-truck-plate input { font-weight:800; }
.management-truck-actions { display:flex; justify-content:flex-end; }
.management-truck-actions .btn { min-height:36px; padding:0 10px; }
.management-add-truck { margin-top:10px; display:inline-flex; }
.manage-config-actions { display:flex; align-items:center; justify-content:space-between; gap:14px; margin-top:16px; padding:13px 15px; border:1px solid color-mix(in srgb,var(--accent-secondary) 45%,var(--border)); border-radius:13px; background:linear-gradient(100deg,rgba(0,161,154,.10),rgba(0,161,154,.025)); }
.manage-config-actions > div { display:grid; gap:3px; min-width:0; }
.manage-config-actions strong { color:var(--text-bright); font-size:12px; }
.manage-config-actions span { color:var(--text-dim); font-size:10px; }
.manage-config-actions .btn { flex:0 0 auto; margin:0; }
.user-directory { gap:8px; }
.user-region-node > summary, .user-warehouse-node > summary { min-height:52px; }
.user-warehouse-body { display:grid; gap:8px; }
.user-directory-card { padding:12px; border:1px solid var(--border); border-radius:11px; background:var(--bg-hover); }
.user-directory-card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.user-identity { display:grid; gap:4px; min-width:0; }
.user-identity strong { color:var(--text-bright); font-size:13px; overflow-wrap:anywhere; }
.user-identity span { color:var(--accent-secondary); font-size:10px; font-weight:700; }
.user-directory-fields { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; margin-top:11px; }
.user-directory-fields .user-directory-field-wide { grid-column:span 2; }
.user-directory-input, .user-directory-fields select { width:100%; min-width:0; margin:0; padding:8px 9px; font-size:11px; }
.user-department-name { min-height:34px; padding:8px 9px; border:1px solid var(--border); border-radius:8px; overflow-wrap:anywhere; color:var(--text); font-size:11px; }
.user-pending-badge { align-self:center; padding:5px 8px; }
@media (max-width: 900px) {
  .manage-heading, .manage-panel-heading { flex-direction:column; gap:8px; }
  .manage-config-stats { justify-content:flex-start; text-align:left; }
  .management-tree-actions { width:100%; justify-content:stretch; }
  .management-tree-actions .input { flex:1 1 100%; width:auto; }
  .management-tree-actions > .btn { flex:1 1 auto; }
  .user-directory-fields { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .user-directory-fields .user-directory-field-wide { grid-column:1/-1; }
}
@media (max-width: 768px) {
  .nav-label-desktop { display:none; }
  .nav-label-mobile { display:inline; }
  #tabNav .tab-btn { min-width:90px; }
  .management-tree-toolbar { align-items:stretch; padding:10px; }
  .management-tree-toolbar > div:first-child { min-width:0; }
  .management-tree-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; }
  .management-tree-actions .input { grid-column:1/-1; width:100%; }
  .management-tree-actions > .btn { width:100%; min-width:0; padding-left:7px; padding-right:7px; }
  .management-tree-summary, .user-region-node > summary, .user-warehouse-node > summary { padding:11px 10px; }
  .management-region-body, .user-region-body { padding-left:7px; padding-right:7px; }
  .management-warehouse-body, .user-warehouse-body { padding-left:10px; padding-right:10px; }
  .management-warehouse-editor, .management-warehouse-meta { grid-template-columns:1fr; }
  .management-warehouse-meta .btn-close { justify-self:end; }
  .management-truck-row { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; padding:9px; }
  .management-truck-ncc, .management-truck-note { grid-column:1/-1; }
  .management-truck-actions { grid-column:1/-1; justify-content:flex-end; }
  .manage-config-actions { align-items:stretch; flex-direction:column; }
  .manage-config-actions .btn { width:100%; }
  .user-directory-toolbar { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .user-directory-toolbar > .input:first-child { grid-column:1/-1; }
  .user-directory-toolbar > .btn { width:100%; min-width:0; }
  .user-directory-card-head { flex-direction:column; }
  .user-actions { width:100%; justify-content:flex-start; }
  .user-directory-fields { grid-template-columns:1fr; }
  .user-directory-fields .user-directory-field-wide { grid-column:auto; }
  .user-directory-card { padding:10px; }
}
/* Mobile trip navigation label — keep the compact label only on phones */
@media (max-width: 768px) {
  #tabNav .tab-btn .nav-label-desktop { display: none !important; }
  #tabNav .tab-btn .nav-label-mobile { display: inline !important; }
}
/* Final mobile label specificity guard */
@media (max-width: 768px) {
  #tabNav .tab-btn > .nav-label.nav-label-desktop { display: none !important; }
  #tabNav .tab-btn > .nav-label.nav-label-mobile { display: inline-block !important; }
}
/* Compact overview filter and scalable user directory polish */
#tab-overview .filter-input-wrap > span { display: none; }
#tab-overview .filter-input-wrap .input { padding-left: 11px; }

#userDirectory {
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  align-items: start;
  gap: 12px;
}
.user-region-node {
  border-color: color-mix(in srgb, var(--accent-secondary) 28%, var(--border));
  border-radius: 16px;
  background: linear-gradient(145deg, var(--surface-raised), var(--bg-card));
  box-shadow: var(--shadow-rest);
}
.user-region-node > summary.user-region-summary {
  min-height: 66px;
  padding: 13px 15px;
  background: linear-gradient(100deg, rgba(0,161,154,.10), rgba(0,161,154,.025));
}
.user-region-node[open] > summary.user-region-summary {
  border-bottom: 1px solid var(--border-subtle);
}
.user-region-body {
  display: grid;
  gap: 10px;
  padding: 10px;
}
.user-warehouse-node {
  border-color: var(--border);
  border-radius: 13px;
  background: var(--bg-card);
}
.user-warehouse-node > summary.user-warehouse-summary {
  min-height: 62px;
  padding: 11px 12px;
}
.user-warehouse-node[open] > summary.user-warehouse-summary {
  background: rgba(0,161,154,.055);
  border-bottom: 1px solid var(--border-subtle);
}
.user-warehouse-body {
  display: grid;
  gap: 9px;
  padding: 10px;
  border-top: 0;
}
.user-directory-card {
  padding: 12px;
  border-color: color-mix(in srgb, var(--accent-secondary) 20%, var(--border));
  border-radius: 11px;
  background: var(--bg-hover);
}
.user-directory-card.is-protected {
  border-color: color-mix(in srgb, var(--yellow) 55%, var(--border));
  background: linear-gradient(145deg, rgba(245,158,11,.10), var(--bg-hover));
}
.user-directory-card-head { align-items: center; }
.user-identity span { color: var(--accent-secondary); }
.user-directory-card.is-protected .user-identity span { color: var(--yellow); }
.user-protected-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--yellow) 45%, var(--border));
  border-radius: 8px;
  color: var(--yellow);
  background: rgba(245,158,11,.08);
  font-size: 10px;
  font-weight: 800;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}
.user-protected-note {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  color: var(--yellow);
  font-size: 10px;
  font-weight: 700;
  white-space: normal;
  text-align: right;
}
.user-directory-card.is-protected input:disabled {
  color: var(--text);
  opacity: .78;
  cursor: not-allowed;
}
@media (max-width: 720px) {
  #userDirectory { grid-template-columns: 1fr; }
  .user-region-node > summary.user-region-summary,
  .user-warehouse-node > summary.user-warehouse-summary { padding-inline: 10px; }
  .user-directory-card-head { align-items: flex-start; flex-direction: column; }
  .user-directory-card-head .user-actions { width: 100%; justify-content: flex-start; }
  .user-protected-badge,
  .user-protected-note { white-space: normal; }
}
.user-directory-fields .user-department-name {
  min-width: 0;
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}
.management-hierarchy-panel {
  display: grid;
  gap: 12px;
  margin: 12px 0 16px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--accent-secondary) 28%, var(--border));
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0,161,154,.08), rgba(0,161,154,.025));
}
.management-hierarchy-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.management-hierarchy-heading > div { display: grid; gap: 3px; }
.management-hierarchy-heading strong { color: var(--text-bright); font-size: 13px; }
.management-hierarchy-note { color: var(--text-dim); font-size: 10px; text-align: right; }
.management-hierarchy-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.management-hierarchy-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0,0,0,.12);
}
.management-hierarchy-item strong {
  color: var(--text-bright);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.management-hierarchy-item span {
  color: var(--accent-secondary);
  font-size: 10px;
  font-weight: 700;
}
.management-zone-roster {
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.5;
}
.management-zone-roster span { color: var(--text); font-weight: 700; }
@media (max-width: 900px) {
  .management-hierarchy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .management-hierarchy-heading { align-items: flex-start; flex-direction: column; }
  .management-hierarchy-note { text-align: left; }
  .management-hierarchy-grid { grid-template-columns: 1fr; }
}
/* Management control tower v2 — compact hierarchy, lazy detail cards, responsive layout */
#manageGrid.warehouse-management-tree {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
#manageGrid > .config-data-note,
#manageGrid > .empty-cell {
  grid-column: 1 / -1;
}
#manageGrid .management-region-node {
  border: 1px solid color-mix(in srgb, var(--accent-secondary) 20%, var(--border));
  border-radius: 16px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--bg-card) 92%, var(--accent-secondary)), var(--bg-card));
  box-shadow: 0 8px 24px rgba(0, 30, 30, .05);
  transition: border-color .18s ease, box-shadow .18s ease;
}
#manageGrid .management-region-node:hover,
#manageGrid .management-region-node[open] {
  border-color: color-mix(in srgb, var(--accent-secondary) 52%, var(--border));
  box-shadow: 0 12px 30px rgba(0, 161, 154, .10);
}
#manageGrid .management-region-node[open] { grid-column: 1 / -1; }
#manageGrid .management-region-summary {
  min-height: 84px;
  padding: 15px 16px;
  background: linear-gradient(135deg, rgba(0, 161, 154, .09), rgba(255, 255, 255, .02));
}
#manageGrid .management-region-summary .tree-chevron {
  width: 28px;
  height: 28px;
  background: color-mix(in srgb, var(--bg-card) 82%, var(--accent-secondary));
  font-size: 16px;
}
#manageGrid .management-region-title strong { font-size: 16px; }
#manageGrid .management-region-title small { font-size: 11px; }
#manageGrid .management-region-summary .tree-count,
#manageGrid .management-warehouse-summary .tree-count {
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--accent-secondary) 24%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-secondary) 10%, transparent);
}
#manageGrid .management-region-body {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  background: rgba(0, 0, 0, .025);
}
#manageGrid .management-warehouse-node {
  border-radius: 13px;
  background: var(--bg-card);
  box-shadow: 0 2px 10px rgba(0, 30, 30, .035);
}
#manageGrid .management-warehouse-node[open] {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--accent-secondary) 43%, var(--border));
}
#manageGrid .management-warehouse-summary {
  min-height: 72px;
  padding: 12px 13px;
  background: var(--bg-card);
}
#manageGrid .management-warehouse-node[open] > .management-warehouse-summary {
  background: rgba(0, 161, 154, .055);
}
#manageGrid .management-warehouse-summary .tree-chevron {
  width: 24px;
  height: 24px;
  font-size: 14px;
}
#manageGrid .management-warehouse-title strong { font-size: 13px; }
#manageGrid .management-warehouse-title small { font-size: 10px; }
#manageGrid .management-warehouse-body {
  padding: 13px;
  background: color-mix(in srgb, var(--bg-card) 92%, var(--surface-muted));
}
#manageGrid .management-warehouse-editor { padding-top: 0; }
#manageGrid .management-lazy-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px dashed color-mix(in srgb, var(--accent-secondary) 34%, var(--border));
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 11px;
  background: color-mix(in srgb, var(--accent-secondary) 4%, transparent);
}
#manageGrid .management-lazy-placeholder::before {
  content: '▦';
  color: var(--accent-secondary);
  font-size: 15px;
}
#manageGrid .management-truck-list { min-width: 0; }
#manageGrid .management-truck-row { box-shadow: 0 2px 8px rgba(0, 30, 30, .03); }
.management-loading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-card) 95%, var(--accent-secondary));
  color: var(--text-dim);
}
.management-loading > div { display: grid; gap: 3px; }
.management-loading strong { color: var(--text-bright); font-size: 13px; }
.management-loading small { font-size: 10px; }
.loading-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-secondary);
  box-shadow: 0 0 0 6px rgba(0, 161, 154, .12);
  animation: managementPulse 1.15s ease-in-out infinite;
}
@keyframes managementPulse { 50% { transform: scale(.72); opacity: .55; } }
#manageTreeHint:empty { display: none; }
@media (max-width: 900px) {
  #manageGrid.warehouse-management-tree { grid-template-columns: 1fr; }
  #manageGrid .management-region-node[open],
  #manageGrid .management-warehouse-node[open] { grid-column: auto; }
  #manageGrid .management-region-body { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  #manageGrid.warehouse-management-tree { gap: 9px; }
  #manageGrid .management-region-summary { min-height: 72px; padding: 12px; }
  #manageGrid .management-region-title strong { font-size: 14px; }
  #manageGrid .management-region-title small { font-size: 10px; }
  #manageGrid .management-region-body { padding: 8px; gap: 8px; }
  #manageGrid .management-warehouse-summary { min-height: 64px; padding: 10px; }
  #manageGrid .management-warehouse-body { padding: 10px; }
  #manageGrid .management-truck-row { min-width: 0; }
}
/* Chevron system v2 — replaces text glyphs with a crisp, stateful control */
.management-tree-summary .tree-chevron,
.user-region-node > summary .tree-chevron,
.user-warehouse-node > summary .tree-chevron {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px !important;
  height: 30px !important;
  margin-right: 1px;
  border: 1px solid color-mix(in srgb, var(--accent-secondary) 22%, var(--border)) !important;
  border-radius: 10px !important;
  background: color-mix(in srgb, var(--bg-card) 90%, var(--accent-secondary));
  color: var(--accent-secondary);
  font-size: 0 !important;
  line-height: 0;
  transform: none !important;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.management-tree-summary .tree-chevron::before,
.user-region-node > summary .tree-chevron::before,
.user-warehouse-node > summary .tree-chevron::before {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .18s ease;
}
.management-tree-summary:hover .tree-chevron,
.user-region-node > summary:hover .tree-chevron,
.user-warehouse-node > summary:hover .tree-chevron {
  border-color: color-mix(in srgb, var(--accent-secondary) 55%, var(--border)) !important;
  box-shadow: 0 4px 12px rgba(0, 161, 154, .12);
}
.management-region-node[open] > .management-region-summary .tree-chevron,
.management-warehouse-node[open] > .management-warehouse-summary .tree-chevron,
.user-region-node[open] > .user-region-summary .tree-chevron,
.user-warehouse-node[open] > .user-warehouse-summary .tree-chevron {
  border-color: color-mix(in srgb, var(--accent-secondary) 48%, var(--border)) !important;
  background: color-mix(in srgb, var(--accent-secondary) 13%, var(--bg-card));
  box-shadow: inset 0 0 0 1px rgba(0, 161, 154, .06);
}
.management-region-node[open] > .management-region-summary .tree-chevron::before,
.management-warehouse-node[open] > .management-warehouse-summary .tree-chevron::before,
.user-region-node[open] > .user-region-summary .tree-chevron::before,
.user-warehouse-node[open] > .user-warehouse-summary .tree-chevron::before {
  transform: translateY(2px) rotate(225deg);
}
@media (max-width: 768px) {
  .management-tree-summary .tree-chevron,
  .user-region-node > summary .tree-chevron,
  .user-warehouse-node > summary .tree-chevron {
    flex-basis: 28px;
    width: 28px !important;
    height: 28px !important;
    border-radius: 9px !important;
  }
}
/* Trip source clarity / automatic sync */
.trip-code-source-title { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.trip-auto-badge { display:inline-flex; align-items:center; padding:6px 10px; border-radius:999px; background:rgba(0,161,154,.12); color:var(--accent,#00a19a); font-size:12px; font-weight:700; }
.trip-code-source-row input[readonly] { cursor:default; opacity:.92; }
.trip-code-source-meta { display:flex; flex-wrap:wrap; gap:8px 16px; margin-top:10px; color:var(--muted,#718080); font-size:12px; }
.trip-code-source-meta strong { color:var(--text,#172022); }
.trip-code-source-meta a, .trip-audit-source a { color:var(--accent,#00a19a); font-weight:700; text-decoration:none; }
.trip-code-source-meta a:hover, .trip-audit-source a:hover { text-decoration:underline; }
@media (max-width: 700px) {
  .trip-code-source-title { align-items:flex-start; }
  .trip-auto-badge { width:100%; justify-content:center; }
  .trip-code-source-meta { display:grid; grid-template-columns:1fr 1fr; gap:8px; line-height:1.45; }
}
/* Management hierarchy v3 — department → zone → warehouse → truck */
.overview-layout.overview-layout-simple { grid-template-columns: minmax(0, 1fr); margin-top: 0; }
.app-footer { text-align: center; padding: 24px 16px 12px; font-size: 12px; color: var(--text-dim); font-family: 'Space Grotesk', sans-serif; letter-spacing: .5px; }
#userDirectory { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#userDirectory > .user-region-node:not(.user-department-node), #userDirectory > .user-department-node[open] { grid-column: 1 / -1; }
#userDirectory .user-department-summary { min-height: 88px; background: linear-gradient(135deg, rgba(0, 161, 154, .13), rgba(0, 161, 154, .035)); }
#userDirectory .user-department-summary .user-region-title strong { font-size: 15px; }
#userDirectory .user-department-summary .user-region-title small { color: var(--accent-secondary); font-weight: 700; }
#userDirectory .user-department-summary .tree-count { padding: 6px 10px; border-radius: 999px; background: rgba(0, 161, 154, .12); }
#userDirectory .user-department-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; background: rgba(0, 0, 0, .025); }
#userDirectory .user-department-body > .user-region-node { min-width: 0; }
#userDirectory .user-department-body > .user-region-node[open] { grid-column: 1 / -1; }
.user-directory-toolbar { justify-content: flex-end; }
#manageGrid .management-department-node[open] { grid-column: 1 / -1; }
#manageGrid .management-department-summary { min-height: 88px; background: linear-gradient(135deg, rgba(0, 161, 154, .13), rgba(0, 161, 154, .035)); }
#manageGrid .management-department-summary .management-region-title strong { font-size: 15px; }
#manageGrid .management-department-summary .management-region-title small { color: var(--accent-secondary); font-weight: 700; }
#manageGrid .management-department-summary .tree-count { padding: 6px 10px; border-radius: 999px; background: rgba(0, 161, 154, .12); }
#manageGrid .management-department-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; background: rgba(0, 0, 0, .025); }
#manageGrid .management-department-body > .management-region-node { min-width: 0; }
#manageGrid .management-zone-node[open] { grid-column: 1 / -1; }
#manageGrid .management-empty-zone-node { opacity: .72; }
#manageGrid .management-empty-zone-node > summary { cursor: default; }
#manageGrid .management-warehouse-meta .btn-close { display: inline-grid !important; place-items: center; justify-content: center; align-self: end; width: 42px; height: 42px; min-height: 42px; padding: 0; line-height: 1; font-size: 21px; }
#manageGrid .management-truck-actions { align-items: end; }
#manageGrid .management-truck-actions .btn { display: inline-grid; place-items: center; justify-content: center; width: 42px; height: 54px; min-height: 54px; padding: 0; line-height: 1; font-size: 20px; }
@media (max-width: 900px) {
  #manageGrid .management-department-body { grid-template-columns: 1fr; }
  #userDirectory, #userDirectory .user-department-body { grid-template-columns: 1fr; }
  .app-footer { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

.region-card-kicker {
  display: block;
  min-height: 1.15em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: .04em;
}

.wh-scope {
  margin-top: 4px;
  color: var(--muted, #718087);
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Vehicle management v4: clear two-level editing row with readable plate and supplier */
#manageGrid .management-truck-list {
  gap: 12px;
  overflow-x: auto;
  padding: 2px;
}
#manageGrid .management-truck-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(280px, 1.8fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) 52px;
  grid-template-areas:
    "plate ncc active start end actions"
    "pause resume note note cost km";
  gap: 12px;
  align-items: end;
  min-width: 0;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--bg-hover) 94%, var(--accent-secondary)), var(--bg-card));
}
#manageGrid .management-truck-plate { grid-area: plate; }
#manageGrid .management-truck-ncc { grid-area: ncc; }
#manageGrid .management-truck-active { grid-area: active; }
#manageGrid .management-truck-start { grid-area: start; }
#manageGrid .management-truck-end { grid-area: end; }
#manageGrid .management-truck-pause { grid-area: pause; }
#manageGrid .management-truck-resume { grid-area: resume; }
#manageGrid .management-truck-note { grid-area: note; }
#manageGrid .management-truck-cost { grid-area: cost; }
#manageGrid .management-truck-km { grid-area: km; }
#manageGrid .management-truck-actions {
  grid-area: actions;
  align-self: end;
  height: 42px;
}
#manageGrid .management-truck-field > span {
  min-height: 2.1em;
  line-height: 1.2;
}
#manageGrid .management-truck-field input,
#manageGrid .management-truck-field select,
#manageGrid .management-truck-field textarea {
  min-height: 42px;
  font-size: 13px;
}
#manageGrid .management-truck-plate input {
  font-size: 15px;
  letter-spacing: .03em;
}
#manageGrid .management-truck-ncc input,
#manageGrid .management-truck-ncc textarea {
  font-size: 13px;
}
#manageGrid .management-truck-ncc-input {
  min-height: 58px;
  line-height: 1.35;
  resize: vertical;
  overflow-wrap: anywhere;
}
#manageGrid .management-truck-actions .btn {
  width: 42px;
  height: 42px;
  min-height: 42px;
}
@media (max-width: 900px) {
  #manageGrid .management-truck-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: none;
    gap: 9px;
    padding: 11px;
  }
  #manageGrid .management-truck-field {
    grid-area: auto;
  }
  #manageGrid .management-truck-ncc,
  #manageGrid .management-truck-note,
  #manageGrid .management-truck-actions {
    grid-area: auto;
    grid-column: 1 / -1;
  }
  #manageGrid .management-truck-actions {
    justify-content: flex-end;
  }
}
@media (max-width: 560px) {
  #manageGrid .management-truck-row {
    grid-template-columns: 1fr;
  }
  #manageGrid .management-truck-ncc,
  #manageGrid .management-truck-note,
  #manageGrid .management-truck-actions {
    grid-column: auto;
  }
  #manageGrid .management-truck-actions {
    justify-content: flex-end;
  }
}
/* Driver module is a first-class Dashboard capability. */
#mainHeader #headerDriverLink {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
@media (max-width: 768px) {
  #mainHeader #headerDriverLink {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    margin-top: 8px !important;
  }
}



/* Final role-aware modal and driver launcher polish */
#modal {
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  max-height: min(92vh, 900px) !important;
  overflow: hidden !important;
}
#modal .modal-header {
  position: relative !important;
  flex: 0 0 auto !important;
  z-index: 30 !important;
  padding-right: 58px !important;
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--border) !important;
}
#modal .modal-header .modal-close-fixed {
  position: absolute !important;
  top: 12px !important;
  right: 12px !important;
  z-index: 40 !important;
  width: 40px !important;
  height: 40px !important;
  margin: 0 !important;
  display: grid !important;
  place-items: center !important;
}
#modal .modal-body {
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
}
#mainHeader .header-main-actions {
  display: grid !important;
  grid-template-columns: minmax(150px, 1fr) minmax(205px, 1.2fr) !important;
  align-items: center !important;
  gap: 10px !important;
  width: 100% !important;
}
#mainHeader .driver-launch-card {
  display: grid !important;
  grid-template-columns: 42px minmax(0, 1fr) auto !important;
  align-items: center !important;
  justify-content: stretch !important;
  gap: 10px !important;
  min-width: 0 !important;
  min-height: 54px !important;
  height: 54px !important;
  padding: 7px 12px !important;
  border: 1px solid rgba(255,255,255,.18) !important;
  border-radius: 16px !important;
  background: linear-gradient(135deg, #ff7a18, #ea580c) !important;
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(234,88,12,.22) !important;
  text-align: left !important;
  line-height: 1 !important;
}
#mainHeader .driver-launch-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 11px 24px rgba(234,88,12,.3) !important;
}
#mainHeader .driver-launch-card .header-action-icon {
  width: 42px !important;
  height: 42px !important;
  display: grid !important;
  place-items: center !important;
  border-radius: 13px !important;
  background: rgba(255,255,255,.18) !important;
  font-size: 22px !important;
  line-height: 1 !important;
}
#mainHeader .driver-launch-copy {
  display: flex !important;
  min-width: 0 !important;
  flex-direction: column !important;
  gap: 4px !important;
}
#mainHeader .driver-launch-copy strong {
  display: block !important;
  overflow: hidden !important;
  font-size: 14px !important;
  line-height: 1.15 !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
#mainHeader .driver-launch-copy small {
  display: block !important;
  color: rgba(255,255,255,.78) !important;
  font-size: 10px !important;
  line-height: 1.15 !important;
  white-space: nowrap !important;
}
#mainHeader .driver-launch-arrow {
  display: grid !important;
  place-items: center !important;
  width: 26px !important;
  height: 26px !important;
  border-radius: 50% !important;
  background: rgba(255,255,255,.16) !important;
  font-size: 17px !important;
  line-height: 1 !important;
}
@media (max-width: 768px) {
  #mainHeader .header-main-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
  }
  #mainHeader .header-main-actions #cycleSelect {
    width: 100% !important;
    height: 48px !important;
  }
  #mainHeader #headerDriverLink.driver-launch-card {
    width: 100% !important;
    min-height: 60px !important;
    height: 60px !important;
    margin: 0 !important;
    padding: 8px 14px !important;
    grid-template-columns: 48px minmax(0, 1fr) auto !important;
    border-radius: 17px !important;
  }
  #mainHeader .driver-launch-card .header-action-icon {
    width: 48px !important;
    height: 48px !important;
    border-radius: 14px !important;
    font-size: 25px !important;
  }
  #mainHeader .driver-launch-copy strong { font-size: 15px !important; }
  #mainHeader .driver-launch-copy small { font-size: 10.5px !important; }
  #mainHeader .driver-launch-arrow { width: 30px !important; height: 30px !important; }
}

/* Privileged read-only account preview */
.view-as-open-btn { align-items:center; gap:6px; background:#fff7df; color:#6b4b00; border:1px solid #e5bd55; }
.view-as-modal { position:fixed; inset:0; z-index:5000; align-items:center; justify-content:center; padding:18px; background:rgba(11,18,30,.58); backdrop-filter:blur(3px); }
.view-as-dialog { width:min(520px,100%); padding:22px; border-radius:18px; background:var(--bg-card); color:var(--text); border:1px solid var(--border); box-shadow:0 24px 70px rgba(0,0,0,.3); }
.view-as-dialog-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.view-as-dialog h3 { margin:4px 0 0; font-size:20px; }
.view-as-dialog p { margin:14px 0; color:var(--text-dim); line-height:1.55; }
.view-as-dialog label { display:block; margin:12px 0 6px; font-size:12px; font-weight:700; }
.view-as-close { border:0; background:transparent; color:var(--text-dim); font-size:26px; cursor:pointer; }
.view-as-help { min-height:18px; margin-top:6px; color:var(--text-dim); font-size:11px; }
.view-as-dialog-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:20px; }
.view-as-banner { position:fixed; left:50%; bottom:16px; transform:translateX(-50%); z-index:4500; width:min(940px,calc(100% - 24px)); align-items:center; justify-content:space-between; gap:14px; padding:12px 14px; border:1px solid #e0ad31; border-radius:14px; background:#fff4cf; color:#553b00; box-shadow:0 12px 36px rgba(58,42,5,.22); }
.view-as-banner > div:first-child { display:flex; flex-direction:column; gap:2px; }
.view-as-banner span { font-size:11px; opacity:.82; }
.view-as-banner-actions { display:flex; align-items:center; gap:7px; flex-wrap:wrap; justify-content:flex-end; }
.view-as-banner .btn { min-height:32px; padding:6px 10px; font-size:11px; text-decoration:none; }
@media (max-width:720px) {
  .view-as-banner { align-items:stretch; flex-direction:column; bottom:8px; }
  .view-as-banner-actions { justify-content:stretch; }
  .view-as-banner-actions .btn { flex:1; justify-content:center; }
  .view-as-dialog { padding:18px; }
}

/* GHN launcher: use the real app mark and give it a balanced square frame. */
#mainHeader .driver-launch-card .header-action-icon {
  width: 52px !important;
  height: 52px !important;
  padding: 3px !important;
  border-radius: 15px !important;
  background: rgba(255, 255, 255, .22) !important;
}
#mainHeader .driver-launch-card .header-action-icon img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 11px !important;
  background: #fff !important;
  object-fit: cover !important;
}
@media (max-width: 768px) {
  #mainHeader #headerDriverLink.driver-launch-card .header-action-icon {
    width: 56px !important;
    height: 56px !important;
    padding: 3px !important;
  }
  #mainHeader .driver-launch-card .header-action-icon img { border-radius: 12px !important; }
}
/* Final v11: non-overlapping dashboard header */
#mainHeader.header {
  display: grid !important;
  grid-template-columns: minmax(360px, 1fr) minmax(520px, auto) !important;
  align-items: center !important;
  gap: 16px !important;
}
#mainHeader .header-left { min-width: 0 !important; }
#mainHeader .header-right {
  display: grid !important;
  grid-template-columns: minmax(150px, 190px) minmax(205px, 240px) auto !important;
  align-items: center !important;
  gap: 10px !important;
  min-width: 0 !important;
  width: auto !important;
}
#mainHeader .header-main-actions {
  display: contents !important;
  width: auto !important;
}
#mainHeader .header-main-actions #cycleSelect {
  grid-column: 1 !important;
  width: 100% !important;
  min-width: 0 !important;
}
#mainHeader #headerDriverLink.driver-launch-card {
  display: grid !important;
  grid-column: 2 !important;
  width: 100% !important;
  min-width: 0 !important;
}
#mainHeader .header-utility-actions {
  grid-column: 3 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
  width: auto !important;
  min-width: 0 !important;
}
#mainHeader .header-utility-actions > .view-as-open-btn,
#mainHeader .header-utility-actions > .notification-bell-container,
#mainHeader .header-utility-actions > #themeBtn { flex: 0 0 auto !important; }
#mainHeader .view-as-open-btn {
  width: 38px !important;
  min-width: 38px !important;
  height: 38px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 11px !important;
}
#mainHeader .view-as-open-btn .utility-label { display: none !important; }

#modal .modal-header .modal-close-fixed,
#aiAuditModal .modal-header .btn-close,
#aiTrainingModal .modal-header .btn-close {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  display: inline-grid !important;
  place-items: center !important;
  border: 1px solid color-mix(in srgb, var(--border) 82%, #ffffff 18%) !important;
  border-radius: 10px !important;
  background: var(--bg) !important;
  color: var(--text-dim) !important;
  font-size: 18px !important;
  line-height: 1 !important;
  box-shadow: none !important;
}
#modal .modal-header .modal-close-fixed:hover,
#aiAuditModal .modal-header .btn-close:hover,
#aiTrainingModal .modal-header .btn-close:hover {
  background: rgba(239,68,68,.10) !important;
  border-color: rgba(239,68,68,.38) !important;
  color: var(--red) !important;
  transform: none !important;
}

.report-image-link {
  appearance: none;
  border: 0;
  padding: 0;
  margin-left: 5px;
  background: transparent;
  color: var(--accent) !important;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}
.report-image-link:hover { color: var(--accent-secondary) !important; }
.report-image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, .62);
}
.report-image-preview-dialog {
  width: min(900px, 96vw);
  max-height: min(90vh, 760px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-card);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .3);
}
.report-image-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.report-image-preview-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.report-image-preview-close:hover { color: var(--red); border-color: rgba(239,68,68,.4); }
.report-image-preview-body {
  min-height: 180px;
  max-height: calc(min(90vh, 760px) - 60px);
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 16px;
}
.report-image-preview-body img {
  display: block;
  max-width: 100%;
  max-height: calc(min(90vh, 760px) - 110px);
  object-fit: contain;
  border-radius: 10px;
}
.report-image-preview-loading,
.report-image-preview-error {
  padding: 24px;
  color: var(--text-dim);
  text-align: center;
  font-weight: 700;
}
.report-image-preview-error { color: var(--red); }

@media (max-width: 1180px) and (min-width: 769px) {
  #mainHeader.header { grid-template-columns: minmax(0, 1fr) !important; }
  #mainHeader .header-right {
    width: 100% !important;
    grid-template-columns: minmax(150px, 190px) minmax(205px, 1fr) auto !important;
  }
}
@media (max-width: 768px) {
  #mainHeader.header {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 9px !important;
    padding: 10px 12px !important;
  }
  #mainHeader .header-right {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 8px !important;
  }
  #mainHeader .header-main-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }
  #mainHeader .header-main-actions #cycleSelect,
  #mainHeader #headerDriverLink.driver-launch-card {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }
  #mainHeader .header-utility-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    width: 100% !important;
    gap: 7px !important;
  }
  #mainHeader .header-utility-actions > .view-as-open-btn,
  #mainHeader .header-utility-actions > .notification-bell-container,
  #mainHeader .header-utility-actions > #themeBtn {
    width: 100% !important;
    min-width: 0 !important;
  }
  #mainHeader .view-as-open-btn .utility-label { display: inline !important; }
}

/* Final v12: compact, predictable mobile header */
#mainHeader.header {
  grid-template-columns: minmax(0, 1fr) minmax(520px, auto) !important;
}
#mainHeader .header-left { min-width: 0 !important; }
#mainHeader .header-right { min-width: 0 !important; }

@media (min-width: 1181px) {
  #mainHeader.header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(520px, auto) !important;
  }
  #mainHeader .header-right {
    display: grid !important;
    grid-template-columns: minmax(150px, 190px) minmax(205px, 240px) auto !important;
    width: auto !important;
  }
}

@media (max-width: 1180px) and (min-width: 769px) {
  #mainHeader.header {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  #mainHeader .header-right {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    width: 100% !important;
  }
  #mainHeader .header-main-actions {
    display: grid !important;
    grid-template-columns: minmax(150px, 190px) minmax(205px, 1fr) !important;
    gap: 10px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  #mainHeader .header-main-actions #cycleSelect,
  #mainHeader #headerDriverLink.driver-launch-card {
    grid-column: auto !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  #mainHeader .header-utility-actions {
    display: flex !important;
    position: static !important;
    flex: 0 0 auto !important;
    width: auto !important;
    gap: 8px !important;
  }
  #mainHeader .header-utility-actions > .view-as-open-btn,
  #mainHeader .header-utility-actions > #themeBtn {
    position: static !important;
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
  }
  #mainHeader .view-as-open-btn .utility-label,
  #mainHeader #themeBtn .utility-label { display: none !important; }
}

@media (max-width: 768px) {
  #mainHeader.header {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 9px !important;
    padding: 12px !important;
    position: relative !important;
    overflow: visible !important;
  }
  #mainHeader .header-left {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 0 0 10px !important;
    min-height: 44px !important;
    box-sizing: border-box !important;
    border-bottom: 1px solid var(--border) !important;
  }
  #mainHeader .header-left .logo {
    display: flex !important;
    width: 44px !important;
    height: 44px !important;
    align-items: center !important;
    justify-content: center !important;
  }
  #mainHeader .header-left .logo img {
    display: block !important;
    width: 38px !important;
    height: 38px !important;
    object-fit: contain !important;
  }
  #mainHeader .header-copy {
    display: block !important;
    min-width: 0 !important;
  }
  #mainHeader .desktop-dashboard-title { display: none !important; }
  #mainHeader .mobile-dashboard-title { display: inline !important; }
  #mainHeader .header-copy h1 {
    display: block !important;
    margin: 0 !important;
    font-size: clamp(18px, 5vw, 24px) !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  #mainHeader .header-copy .subtitle {
    display: block !important;
    margin: 4px 0 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    font-size: 12px !important;
    line-height: 1.25 !important;
  }
  #mainHeader .header-right {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 9px !important;
  }
  #mainHeader .header-main-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
  }
  #mainHeader .header-main-actions #cycleSelect {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    grid-column: auto !important;
  }
  #mainHeader #headerDriverLink.driver-launch-card {
    display: grid !important;
    grid-template-columns: 56px minmax(0, 1fr) 34px !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 66px !important;
    height: 66px !important;
    grid-column: auto !important;
    box-sizing: border-box !important;
  }
  #mainHeader #headerDriverLink .header-action-icon {
    width: 56px !important;
    height: 56px !important;
    padding: 3px !important;
    box-sizing: border-box !important;
  }
  #mainHeader #headerDriverLink .header-action-icon img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 12px !important;
  }
  #mainHeader .header-main-actions .header-action-ai,
  #mainHeader .header-main-actions .header-action-audit,
  #mainHeader #headerPresentationBtn {
    display: none !important;
  }
  #mainHeader .header-utility-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    align-items: stretch !important;
    gap: 8px !important;
    position: static !important;
    width: 100% !important;
  }
  #mainHeader .header-utility-actions > .view-as-open-btn,
  #mainHeader .header-utility-actions > #themeBtn {
    display: flex !important;
    position: static !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    padding: 0 12px !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }
  #mainHeader .header-utility-actions > .notification-bell-container,
  #mainHeader .header-utility-actions > .btn-refresh,
  #mainHeader .header-utility-actions > #loginBtn {
    display: none !important;
  }
  #mainHeader .view-as-open-btn .utility-label,
  #mainHeader #themeBtn .utility-label { display: inline !important; }
}

/* ============================================================
   R3.1-G — UI Polish & Reconciliation Sub-Tabs
   ============================================================ */

/* 1. Driver App Header CTA */
#mainHeader #headerDriverLink.driver-launch-card {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  padding: 6px 14px !important;
  min-height: 44px !important;
  height: auto !important;
  border-radius: 10px !important;
  background: var(--accent-gradient, linear-gradient(135deg, #f97316 0%, #ea580c 100%)) !important;
  color: #ffffff !important;
  text-decoration: none !important;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.25) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}
#mainHeader #headerDriverLink.driver-launch-card:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35) !important;
}
#mainHeader #headerDriverLink .header-action-icon {
  font-size: 20px !important;
  line-height: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
}
#mainHeader #headerDriverLink .driver-launch-copy {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  text-align: left !important;
  line-height: 1.2 !important;
}
#mainHeader #headerDriverLink .driver-launch-copy strong {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
}
#mainHeader #headerDriverLink .driver-launch-copy small {
  font-size: 11px !important;
  color: rgba(255, 255, 255, 0.9) !important;
  font-weight: 500 !important;
}
.driver-launch-arrow {
  display: none !important;
}

/* 2. Modal Close Buttons Top-Right Positioning */
.modal {
  position: relative !important;
}
.modal-header {
  position: relative !important;
  padding-right: 56px !important;
}
.modal-header .btn-close,
.modal-header .modal-close-fixed,
.modal-overlay .modal .btn-close {
  position: absolute !important;
  top: 14px !important;
  right: 14px !important;
  z-index: 50 !important;
  width: 34px !important;
  height: 34px !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  margin: 0 !important;
  cursor: pointer !important;
  background: var(--bg-glass, rgba(255,255,255,0.06)) !important;
  color: var(--text-muted, #94a3b8) !important;
  border: 1px solid var(--border, rgba(255,255,255,0.12)) !important;
  transition: all 0.15s ease !important;
}
.modal-header .btn-close:hover,
.modal-header .modal-close-fixed:hover,
.modal-overlay .modal .btn-close:hover {
  background: var(--red-bg, rgba(239, 68, 68, 0.15)) !important;
  color: var(--red, #ef4444) !important;
  border-color: var(--red, #ef4444) !important;
}

/* 3. Reconciliation Sub-Tabs */
.recon-subtabs-nav {
  display: flex !important;
  gap: 8px !important;
  border-bottom: 1px solid var(--border) !important;
  padding-bottom: 8px !important;
  margin: 16px 0 20px 0 !important;
  flex-wrap: wrap !important;
}
.recon-subtab-btn {
  padding: 8px 16px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  background: var(--bg-card, #1e293b) !important;
  color: var(--text-muted, #94a3b8) !important;
  border: 1px solid var(--border, rgba(255,255,255,0.1)) !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}
.recon-subtab-btn:hover {
  color: var(--text, #f8fafc) !important;
  border-color: var(--accent, #38bdf8) !important;
}
.recon-subtab-btn.active {
  background: var(--accent, #0ea5e9) !important;
  color: #ffffff !important;
  border-color: var(--accent, #0ea5e9) !important;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3) !important;
}
.recon-subtab-panel {
  display: block;
}

/* R3.1-I: Vehicle Check Table - Full Supplier Name & Compact Columns */
#reconSubTabVehicles table th,
#reconSubTabVehicles table td {
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  max-width: 240px;
}
#reconSubTabVehicles table th:first-child,
#reconSubTabVehicles table td:first-child {
  white-space: normal !important;
  text-overflow: clip !important;
  min-width: 260px !important;
  max-width: 420px !important;
  line-height: 1.35 !important;
  word-break: break-word !important;
}
#reconSubTabVehicles table td {
  overflow: hidden !important;
}
@media (max-width: 768px) {
  #reconSubTabVehicles .table-responsive {
    overflow-x: auto !important;
  }
}

/* R3.1-H: Daily Vehicle Timeline / Calendar Slot Alignment */
.day-cell {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  min-height: 86px !important;
  padding: 6px 3px 6px 3px !important;
  box-sizing: border-box !important;
}
.day-cell .day-date {
  font-weight: 700 !important;
  line-height: 1.2 !important;
  font-size: 11px !important;
}
.day-cell .day-weekday {
  font-size: 10px !important;
  opacity: 0.8 !important;
  line-height: 1.2 !important;
  margin-bottom: 2px !important;
}
.day-warning-slot {
  height: 18px !important;
  min-height: 18px !important;
  max-height: 18px !important;
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 2px 0 !important;
  box-sizing: border-box !important;
}
.day-warning-slot .day-anomaly-badge {
  margin-top: 0 !important;
}
.day-trip-slot {
  width: 100% !important;
  min-height: 22px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  margin-top: 2px !important;
  box-sizing: border-box !important;
}
.day-trip-slot .day-trip-id {
  margin-top: 0 !important;
  display: inline-block !important;
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  line-height: 1.2 !important;
  font-size: 8px !important;
}


/* Review improvements: actionable work and a compact mobile navigation. */
.work-queue { margin: 12px 0 18px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); }
.work-queue summary { min-height: 32px; cursor: pointer; font-weight: 700; }
.work-queue p { margin: 8px 0; color: var(--text-dim); font-size: 13px; }
#workQueueItems { display: grid; gap: 8px; }
#workQueueItems button { text-align: left; color: var(--text); background: var(--bg-hover); border: 1px solid var(--border); border-radius: 8px; padding: 10px; min-height: 44px; cursor: pointer; }
#tabNav .mobile-more-btn { display: none; }
.mobile-more-menu[hidden] { display: none !important; }
#mainHeader #viewAsOpenBtn[hidden] { display: none !important; }
.mobile-more-menu { position: fixed; right: 12px; bottom: 76px; z-index: 3900; min-width: 180px; padding: 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.3); }
.mobile-more-menu button { display: block; width: 100%; min-height: 44px; padding: 10px; text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
@media (max-width: 768px) {
  #tabNav > [data-mobile-secondary] { display: none !important; }
  #tabNav .mobile-more-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
  #tabNav { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
  #tabNav .tab-btn { min-height: 48px; min-width: 44px; }
  #tabNav .nav-label, #tabNav .mobile-more-btn { font-size: 12px; }
}
