/* ZAP visual redesign (Lovable reference: asphalt sidebar, amber accent, warm light surface).
   Loaded last among the app stylesheets. Scope: the authenticated app only.
   - Desktop sidebar (>=1024px) and the Dashboard header/cards are restyled here.
   - Visual only: no IDs, data-attributes, markup or behaviour is changed.
   - Tokens live under --zr-* so they can be removed as a block to restore the previous look. */

:root{
  --zr-asphalt:#2E3338;
  --zr-asphalt-2:#3A4047;
  --zr-asphalt-text:#E3E6EA;
  --zr-asphalt-muted:#A4ACB6;
  --zr-amber:#E9A21B;
  --zr-amber-soft:rgba(233,162,27,.16);
}
body.light{
  --zap-bg:#F6F3EC;
  --zap-panel:#FFFFFF;
  --zap-panel-2:#FBF9F4;
  --zap-border:#E4DED2;
  --zap-border-strong:#D3CBBB;
}

/* ---------- Desktop sidebar: asphalt surface, amber active marker ---------- */
@media (min-width:1024px){
  .bottom-nav{
    background:var(--zr-asphalt)!important;
    border-right:1px solid #22262B!important;
  }
  .bottom-nav::before{color:var(--zr-asphalt-muted)}
  .bottom-nav .nav-btn{color:var(--zr-asphalt-text)}
  .bottom-nav .nav-btn:hover{background:var(--zr-asphalt-2);color:#FFFFFF}
  .bottom-nav .nav-btn.active{
    background:var(--zr-asphalt-2);
    color:#FFFFFF;
    box-shadow:inset 3px 0 0 var(--zr-amber);
  }
  .bottom-nav .nav-btn.active .nav-icon{color:var(--zr-amber)}
  .bottom-nav .nav-btn:focus-visible{outline-color:var(--zr-amber)}
  .zap-nav-toggle{background:transparent;border-color:#4A515A;color:var(--zr-asphalt-text)}
  .zap-nav-toggle:hover{background:var(--zr-asphalt-2);color:#FFFFFF}
}

/* ---------- Dashboard: clearer hierarchy, same figures and periods ---------- */
#dashboard .hero-card{
  border-left:3px solid var(--zr-amber);
  padding:18px 20px;
}
#dashboard .hero-card h2{font-size:28px;line-height:34px;font-weight:700;margin:4px 0 2px;font-variant-numeric:tabular-nums}
#dashboard .hero-card .eyebrow{color:var(--zap-text-2)}
#dashboard .metric-card{padding:14px 16px}
#dashboard .metric-card p{text-transform:none;letter-spacing:0}
#dashboard .metric-card h3{font-size:24px;line-height:30px;font-weight:700;margin-top:4px}
#dashboard .ring{
  border-color:var(--zr-amber);
}
#dashboard .ring span{color:var(--zap-text)}

/* ---------- Shared headings inside the app: calmer section titles ---------- */
.app-shell .screen > h2:first-child{font-size:18px;font-weight:600}

/* ---------- Load Board: section title and mobile/desktop rhythm ---------- */
#loads > .section-title h2{font-size:18px;font-weight:600}
#loads .card{padding:14px}

/* ---------- Invoices: clearer invoice groups and totals ---------- */
#invoices > .section-title h2{font-size:18px;font-weight:600}
#invoices > .card p.muted{margin:0;line-height:20px}
#savedInvoicesList details > summary{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:12px 14px;cursor:pointer}
#savedInvoicesList .si-name{font-weight:600;font-size:15px;margin-right:auto;min-width:0;overflow-wrap:anywhere}
#savedInvoicesList .pill-row{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
#savedInvoicesList .pill,#savedInvoicesList .pill-row .pill,#invoices .pill{font-variant-numeric:tabular-nums}
#savedInvoicesList .card-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
#carrierYtdEarningsList .card{padding:14px 16px}
#carrierYtdEarningsList .card h3{font-variant-numeric:tabular-nums}

/* ---------- Header: one compact row (desktop) that wraps on phones. Same elements, same IDs. ---------- */
.app-shell>.topbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px 12px;margin-bottom:8px}
.app-shell>.topbar>div:first-child{display:flex;flex-wrap:wrap;align-items:center;gap:2px 10px;min-width:0}
.app-shell>.topbar h1{font-size:18px;line-height:24px;margin:0}
.app-shell>.topbar .eyebrow{margin:0}
.app-shell>.topbar #appSubtitle,.app-shell>.topbar #userEmail{margin:0;font-size:12px;line-height:18px}
.app-shell>.topbar .top-actions{display:flex;flex-wrap:wrap;align-items:center;gap:6px}

/* ---------- Dashboard: indicators first (markup order), then the board, HOS and the fleet map ---------- */
#dashboard>.grid.two:first-child{margin-bottom:12px}
#dashboard .hero-card{margin-bottom:12px}
/* Not applied while the map is expanded (.is-expanded keeps its full-screen size) */
#dashboard .fleet-map-shell:not(.is-expanded){min-height:320px}
#dashboard .fleet-map-shell:not(.is-expanded) .fleet-map{height:320px}
@media (max-width:640px){
  #dashboard .fleet-map-shell:not(.is-expanded){min-height:260px}
  #dashboard .fleet-map-shell:not(.is-expanded) .fleet-map{height:260px}
}

/* ---------- Dashboard indicators: 2 columns on phones, 4 on desktop; discreet line icons (CSS only) ---------- */
#dashboard>.grid.two:first-child{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
@media (min-width:760px){#dashboard>.grid.two:first-child{grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}}
#dashboard>.grid.two:first-child .metric-card{position:relative;padding:12px 12px 12px 46px;min-width:0;border-left:3px solid var(--zr-amber)}
#dashboard>.grid.two:first-child .metric-card::before{content:"";position:absolute;left:12px;top:50%;transform:translateY(-50%);width:22px;height:22px;background:no-repeat center/contain}
#dashboard>.grid.two:first-child .metric-card:nth-child(1)::before{background-image:url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2222%22 height=%2222%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23E9A21B%22 stroke-width=%221.75%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2%22/%3E%3Ccircle cx=%229%22 cy=%227%22 r=%224%22/%3E%3Cpath d=%22M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75%22/%3E%3C/svg%3E")}
#dashboard>.grid.two:first-child .metric-card:nth-child(2)::before{background-image:url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2222%22 height=%2222%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23E9A21B%22 stroke-width=%221.75%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M3 6h11v10H3z%22/%3E%3Cpath d=%22M14 10h4l3 3v3h-7%22/%3E%3Ccircle cx=%227%22 cy=%2217%22 r=%222%22/%3E%3Ccircle cx=%2217%22 cy=%2217%22 r=%222%22/%3E%3C/svg%3E")}
#dashboard>.grid.two:first-child .metric-card:nth-child(3)::before{background-image:url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2222%22 height=%2222%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23E9A21B%22 stroke-width=%221.75%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M21 8 12 3 3 8v8l9 5 9-5z%22/%3E%3Cpath d=%22M3 8l9 5 9-5M12 13v8%22/%3E%3C/svg%3E")}
#dashboard>.grid.two:first-child .metric-card:nth-child(4)::before{background-image:url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2222%22 height=%2222%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23E9A21B%22 stroke-width=%221.75%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M12 2v20%22/%3E%3Cpath d=%22M17 6H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6%22/%3E%3C/svg%3E")}
body.light #dashboard>.grid.two:first-child .metric-card:nth-child(1)::before{background-image:url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2222%22 height=%2222%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%238A5A00%22 stroke-width=%221.75%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2%22/%3E%3Ccircle cx=%229%22 cy=%227%22 r=%224%22/%3E%3Cpath d=%22M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75%22/%3E%3C/svg%3E")}
body.light #dashboard>.grid.two:first-child .metric-card:nth-child(2)::before{background-image:url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2222%22 height=%2222%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%238A5A00%22 stroke-width=%221.75%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M3 6h11v10H3z%22/%3E%3Cpath d=%22M14 10h4l3 3v3h-7%22/%3E%3Ccircle cx=%227%22 cy=%2217%22 r=%222%22/%3E%3Ccircle cx=%2217%22 cy=%2217%22 r=%222%22/%3E%3C/svg%3E")}
body.light #dashboard>.grid.two:first-child .metric-card:nth-child(3)::before{background-image:url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2222%22 height=%2222%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%238A5A00%22 stroke-width=%221.75%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M21 8 12 3 3 8v8l9 5 9-5z%22/%3E%3Cpath d=%22M3 8l9 5 9-5M12 13v8%22/%3E%3C/svg%3E")}
body.light #dashboard>.grid.two:first-child .metric-card:nth-child(4)::before{background-image:url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2222%22 height=%2222%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%238A5A00%22 stroke-width=%221.75%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M12 2v20%22/%3E%3Cpath d=%22M17 6H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6%22/%3E%3C/svg%3E")}
#dashboard>.grid.two:first-child .metric-card p{overflow-wrap:anywhere;line-height:16px}
#dashboard>.grid.two:first-child .metric-card h3{font-size:20px;line-height:26px;overflow-wrap:anywhere}
@media (min-width:760px){#dashboard>.grid.two:first-child .metric-card{padding:14px 14px 14px 52px}#dashboard>.grid.two:first-child .metric-card h3{font-size:24px;line-height:30px}}
/* Empty "Today command center" containers take no space; alerts render normally when they have content */
#todayAlerts:empty,#todayMoney:empty,#todayLoads:empty,#eldStatus:empty{display:none}
#dashboard>div[style]:has(>h2):not(:has(#todayAlerts:not(:empty),#todayMoney:not(:empty),#todayLoads:not(:empty),#eldStatus:not(:empty))){margin-bottom:0!important}

/* Motion: respect reduced-motion preferences in the app shell */
@media (prefers-reduced-motion:reduce){
  .app-shell .screen,.app-shell .screen *{animation:none!important;transition:none!important}
}

/* ---------- Load Board: filters, table and cards (presentation only; IDs, data and handlers unchanged) ---------- */
/* Search / Filter: stacked full-width fields on phones so the selects show their full text */
@media (max-width:1023.98px){
  #loadSearchBox>div[style]{grid-template-columns:minmax(0,1fr)!important;gap:10px!important}
  #loadSearchBox select,#loadSearchBox input{width:100%;min-width:0}
  #loadSearchBox .section-title{flex-wrap:wrap}
}
@media (min-width:1024px){
  #loadSearchBox>div[style]{grid-template-columns:minmax(0,2fr) minmax(0,1fr) minmax(0,1fr)!important}
}
@media (min-width:1024px){#loadSearchBox .section-title p{margin:0;text-align:right}}
@media (max-width:1023.98px){#loadSearchBox .section-title p{margin:4px 0 0}}

/* Desktop table: readable places and figures, aligned tabular numbers, clear header */
.zlt td.zlt-text{min-width:140px;max-width:230px}
.zlt .zlt-num{font-variant-numeric:tabular-nums;font-weight:600}
.zlt .zlt-num .zlt-sub{font-weight:400}
.zlt thead th{white-space:nowrap}
.zlt tbody tr:hover>*{background:var(--zap-panel-2)}
.zlt .zlt-load{min-width:120px}
#bulkActionRow>label{white-space:nowrap;font-size:13px}
#bulkActionRow>b{white-space:nowrap}
/* Table fit: long load numbers wrap, action buttons keep their text on one line, tighter cell padding */
.zlt th.zlt-load,.zlt td.zlt-load{white-space:normal;max-width:200px;overflow-wrap:anywhere}
.zlt th.zlt-load .zlt-open{white-space:normal;overflow-wrap:anywhere}
.zlt-actions-in .small-btn{white-space:nowrap;padding:4px 8px}
.zlt th,.zlt td{padding-left:7px;padding-right:7px}
.zlt td.zlt-text{min-width:116px;max-width:210px}
.zlt td.zlt-party{min-width:118px}
.zlt td.zlt-party+td.zlt-text{min-width:116px}
/* Mobile cards: the load number reads as a title line, the route stays the main line */
#loadsList .list-card .load-no{color:var(--zap-text);font-weight:700;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}

/* ---------- Loads pass 2: mobile cards keep Edit, Next status and More; secondary actions live in More ---------- */
@media (max-width:1023.98px){
  #loadsList .list-card .card-actions-main{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:0}
  #loadsList .list-card .card-actions-main>.small-btn{min-height:44px;min-width:0;padding:6px 6px;font-size:13px;line-height:17px;white-space:normal}
  #loadsList .list-card .card-more{min-width:0}
  #loadsList .list-card .card-more[open]{grid-column:1/-1}
  #loadsList .list-card .card-more-toggle{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;min-height:44px;padding:6px;cursor:pointer;list-style:none;font-size:13px;font-weight:600;box-sizing:border-box}
  #loadsList .list-card .card-more-toggle::-webkit-details-marker{display:none}
  #loadsList .list-card .card-more-toggle::after{content:"";width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:6px solid currentColor}
  #loadsList .list-card .card-more[open]>.card-more-toggle::after{border-top:0;border-bottom:6px solid currentColor}
  #loadsList .list-card .card-more-body{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-top:6px;padding:8px;border:1px solid var(--zap-border-strong);border-radius:8px;background:var(--zap-panel-2);scroll-margin-bottom:96px}
  #loadsList .list-card .card-more-body>.small-btn{min-height:44px;min-width:0;padding:6px 6px;font-size:13px;line-height:17px;white-space:normal}
  #loadsList .list-card .card-more-status{grid-column:1/-1;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  #loadsList .list-card .card-more-delete{grid-column:1/-1;color:var(--zap-neg);border-color:var(--zap-chip-red-bg)!important}
  #loadsList .list-card .card-more-toggle:focus-visible,#loadsList .list-card .card-more-body .small-btn:focus-visible{outline:2px solid var(--zap-link);outline-offset:2px}
}

/* ---------- Loads pass 2: desktop compaction (controls unchanged, spacing only) ---------- */
@media (min-width:1024px){
  #loads>.section-title{margin:4px 0 8px}
  #loads .card{padding:10px 12px}
  #loads .card>.section-title{margin:0 0 6px}
  #loadSearchBox{margin-bottom:8px!important}
  #loadSearchBox>div[style]{gap:8px!important;margin-bottom:0}
  #loadSearchBox>div:last-of-type{margin-top:6px!important}
  #bulkActionBar{padding:8px 12px!important;margin-bottom:8px!important}
  #bulkActionBar p{margin-top:4px!important}
  #loadsList{margin-top:0}
}
@media (min-width:1024px){
  .app-shell>.topbar>div:first-child{flex-wrap:nowrap;white-space:nowrap}
}

/* ---------- Invoices (screen only; invoice print and PDFs are not touched) ---------- */
#invoices>.section-title{margin:4px 0 8px}
#invoices>.section-title h2{font-size:18px;font-weight:600}
#invoices>.card{padding:10px 12px;margin-bottom:10px}
#invoices>.card p.muted{margin:0;font-size:13px;line-height:19px}
#invoices .section-title h2{font-size:16px;font-weight:600}
#invoices .section-title p.muted{margin:2px 0 0;font-size:12.5px}
#carrierYtdEarningsList{gap:8px}
#carrierYtdEarningsList .card{padding:12px 14px;margin:0}
#carrierYtdEarningsList .card h3{font-size:18px;font-weight:700;font-variant-numeric:tabular-nums;margin:2px 0 0;overflow-wrap:anywhere}
#carrierYtdEarningsList .card p{font-size:12.5px}
/* Saved invoices: folder header, invoice number, status and total, actions in a row */
#savedInvoicesList details.si-folder>summary{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;padding:10px 14px;min-height:44px;cursor:pointer}
#savedInvoicesList .si-name{font-weight:600;font-size:15px;margin-right:auto;min-width:0;overflow-wrap:anywhere}
#savedInvoicesList .si-month{font-size:11.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--zap-muted);margin:12px 0 6px}
#savedInvoicesList .list-card{padding:12px 14px;margin:0 0 8px}
#savedInvoicesList .list-card h3{font-size:16px;font-weight:700;margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
#savedInvoicesList .list-card p.muted{margin:2px 0 0;font-size:12.5px;overflow-wrap:anywhere}
#savedInvoicesList .list-card .pill-row{margin:8px 0 0;display:flex;flex-wrap:wrap;gap:6px}
#savedInvoicesList .list-card .pill{font-variant-numeric:tabular-nums}
#savedInvoicesList .card-actions{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0 0}
#savedInvoicesList .card-actions .small-btn{min-height:40px;padding:6px 12px;white-space:normal}
@media (max-width:640px){
  #savedInvoicesList .list-card .card-actions .small-btn{flex:1 1 100%}
  #savedInvoicesList .si-name{font-size:14px}
}
#savedInvoicesList .card-actions .small-btn{width:auto}
#savedInvoicesList .card-actions .small-btn{flex:0 0 auto;width:auto;min-width:0}
#savedInvoicesList .list-card .card-actions{display:flex;justify-content:flex-start}
/* mobile-fix.css stretches every .card-actions button with !important; Invoices keeps its buttons at content width. */
#savedInvoicesList .card-actions .small-btn{flex:0 0 auto!important;min-width:0!important}
@media (max-width:640px){#savedInvoicesList .list-card .card-actions .small-btn{flex:1 1 100%!important}}
