/* Business Costs and Charges / Additional Fees. Presentation only. Loaded after zap-directory.css.
   Both lists keep the exact markup app.js builds: .list-card > h3 (category and full amount),
   p.muted, .pill-row, .card-actions with inline handlers. The Charges list also starts with a
   .metric-card holding the pending total. Nothing is removed or hidden except the decorative column
   headers and empty pills, amounts wrap and are never cut, and colors come from the zap-theme.css
   tokens, so Light and Dark follow body.light.
   Desktop (>=1024px): a bordered panel, one row per record, columns title | details | actions.
   Phones and tablets: compact cards, two-column buttons of touch size. */

/* ---------- Screen headers and forms (all widths) ---------- */
#expenses>.section-title,#charges>.section-title{margin:4px 0 14px}
#addExpense,#addCharge{border-color:var(--zap-action)!important;color:var(--zap-link)!important;font-weight:600;min-height:36px;padding:6px 14px}
#addExpense:hover,#addCharge:hover{background:var(--zap-nav-active-bg)!important}
#expenses>.card,#charges>.card{padding:16px}
#expenses .form-grid,#charges .form-grid{gap:12px 14px}
#expenses .form-grid label,#charges .form-grid label{min-width:0;font-size:12px;font-weight:600;color:var(--zap-text-2)}
#expenses .form-grid input,#expenses .form-grid select,#charges .form-grid input,#charges .form-grid select{max-width:100%;min-width:0}
#charges>.card>.muted{margin:0;font-size:13px;line-height:19px}

/* ---------- Carrier profitability summary ---------- */
#carrierCostSummary .section-title{margin:0 0 12px}
#carrierCostSummary .section-title h2{margin:0}
#carrierCostSummary .cost-preview{grid-template-columns:repeat(auto-fit,minmax(min(100%,170px),1fr));gap:10px;margin-top:0}
#carrierCostSummary .cost-preview>div{min-width:0;padding:12px;border:1px solid var(--zap-border);border-radius:6px;background:var(--zap-panel-2);gap:4px}
#carrierCostSummary .cost-preview span{font-size:12px;line-height:16px;font-weight:500;color:var(--zap-text-2)}
#carrierCostSummary .cost-preview strong{font-size:18px;line-height:24px;font-weight:600;color:var(--zap-text);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
/* styles.css pins pale green and pink, which cannot be read on the Light theme */
#carrierCostSummary .profit-positive{color:var(--zap-pos)!important}
#carrierCostSummary .profit-negative{color:var(--zap-neg)!important}

/* ---------- The lists: shared ---------- */
#expensesList,#chargesList{display:grid;grid-template-columns:minmax(0,1fr)!important;gap:0;max-width:none!important;width:100%;margin:0}
#expensesList .list-card,#chargesList .list-card{
  min-width:0;max-width:none!important;margin:0!important;overflow-wrap:anywhere;
  background:var(--zap-panel)!important;border:0;border-bottom:1px solid var(--zap-border);border-radius:0!important}
#expensesList .list-card:last-child,#chargesList .list-card:last-child{border-bottom:0}
#expensesList .list-card h3,#chargesList .list-card h3{
  margin:0;font-size:15px;line-height:20px;font-weight:600;color:var(--zap-text);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
#expensesList .list-card>p,#chargesList .list-card>p{margin:2px 0 0;font-size:12.5px;line-height:17px;color:var(--zap-muted);overflow-wrap:anywhere}
#expensesList .pill-row,#chargesList .pill-row{display:flex;flex-wrap:wrap;gap:6px;margin:0;min-width:0}
#expensesList .pill,#chargesList .pill{max-width:100%;white-space:normal;overflow-wrap:anywhere}
#expensesList .pill-row .pill:empty,#chargesList .pill-row .pill:empty{display:none}
#expensesList .card-actions,#chargesList .card-actions{display:flex!important;flex-wrap:wrap!important;gap:6px;margin:0;min-width:0}
#expensesList .card-actions .small-btn,#chargesList .card-actions .small-btn{
  min-width:0!important;flex:0 1 auto!important;min-height:32px;padding:4px 10px;font-size:12.5px;line-height:16px;white-space:normal;overflow-wrap:anywhere}
/* Delete reads as the careful action without changing what it does */
#expensesList .card-actions .small-btn[onclick^="removeItem"],#chargesList .card-actions .small-btn[onclick^="removeItem"]{color:var(--zap-neg)!important}

/* The pending total that leads the Charges list */
#chargesList>.metric-card{padding:14px 16px!important;background:var(--zap-panel-2)!important;border-radius:6px!important;min-width:0}
#chargesList>.metric-card>p:first-child{margin:0;font-size:11.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--zap-text-2)}
#chargesList>.metric-card h3{margin:2px 0 0;font-size:22px;line-height:30px;font-weight:600;color:var(--zap-text);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
#chargesList>.metric-card>p.muted{margin:4px 0 0!important;font-size:12.5px!important;line-height:17px;color:var(--zap-muted);max-width:72ch}

/* ---------- Empty state ---------- */
#expensesList>.card:only-child,#chargesList>.card{
  padding:26px 16px!important;text-align:center;background:var(--zap-panel-2)!important;border:1px dashed var(--zap-border-strong);border-radius:6px!important}
#expensesList>.card:only-child .muted,#chargesList>.card .muted{margin:0;font-size:14px;font-weight:600;color:var(--zap-text-2)}
#expensesList>.card:only-child::after{content:"Use the form above to add one.";display:block;margin-top:4px;font-size:12.5px;color:var(--zap-muted)}

/* ---------- Desktop (>=1024px): one panel, one row per record ---------- */
.zcl-head{display:none}
@media (min-width:1024px){
  #expensesList:has(>.list-card){border:1px solid var(--zap-border);border-top:0;border-radius:0 0 6px 6px;background:var(--zap-panel);overflow:hidden}
  .zcl-head{display:grid;grid-template-columns:minmax(220px,1.1fr) minmax(0,2fr) 272px;gap:16px;padding:8px 16px;
    background:var(--zap-panel-2);border:1px solid var(--zap-border);border-radius:6px 6px 0 0;
    color:var(--zap-text-2);font-size:11.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase}
  .zcl-head span:last-child{text-align:right}
  .zcl-head:has(+ #expensesList>.card:only-child){display:none}
  #expensesList .list-card,#chargesList .list-card{
    display:grid;grid-template-columns:minmax(220px,1.1fr) minmax(0,2fr) 272px;column-gap:16px;row-gap:4px;align-items:center;padding:10px 16px!important}
  #expensesList .list-card>h3,#chargesList .list-card>h3{grid-column:1;grid-row:1/span 2}
  #expensesList .list-card>p:nth-of-type(1),#chargesList .list-card>p:nth-of-type(1){grid-column:2;grid-row:1;margin:0}
  #expensesList .list-card>.pill-row,#chargesList .list-card>.pill-row{grid-column:2;grid-row:2}
  #expensesList .list-card>.card-actions,#chargesList .list-card>.card-actions{grid-column:3;grid-row:1/span 2;justify-content:flex-end}
  #expensesList .list-card>p:nth-of-type(n+2),#chargesList .list-card>p:nth-of-type(n+2){grid-column:1/-1;grid-row:auto}
  #expensesList .list-card:hover,#chargesList .list-card:hover{background:var(--zap-panel-2)!important}

  /* The Charges list starts with the pending total, so the header has to sit between that card and
     the rows. The list steps aside (display:contents) and the screen orders what is inside it. */
  #charges.active{display:flex;flex-direction:column}
  #chargesList{display:contents}
  #chargesList>.metric-card{order:1}
  .zcl-head--charges{order:2}
  #chargesList>.list-card,#chargesList>.card{order:3}
  #chargesList>.list-card{border:1px solid var(--zap-border);border-top:0;border-bottom:0;margin:0!important}
  #chargesList>.list-card+.list-card{border-top:1px solid var(--zap-border)}
  #chargesList>.list-card:last-child{border-bottom:1px solid var(--zap-border);border-radius:0 0 6px 6px!important}
  #charges:has(#chargesList>.card) .zcl-head--charges{display:none}
}

/* ---------- Phones and tablets: compact cards (same markup) ---------- */
@media (max-width:1023.98px){
  #expensesList,#chargesList{gap:10px}
  #expensesList .list-card,#chargesList .list-card{padding:12px!important;border:1px solid var(--zap-border);border-radius:6px!important}
  #expensesList .list-card h3,#chargesList .list-card h3{font-size:15px}
  #expensesList .list-card>p,#chargesList .list-card>p{margin:3px 0 0}
  #expensesList .pill-row,#chargesList .pill-row{margin:8px 0 10px}
  #expensesList .card-actions,#chargesList .card-actions{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  #expensesList .card-actions .small-btn,#chargesList .card-actions .small-btn{min-height:44px;padding:6px 8px;width:100%}
  /* a lone last button (1 or 3 actions) fills the row */
  #expensesList .card-actions .small-btn:last-child:nth-child(odd),#chargesList .card-actions .small-btn:last-child:nth-child(odd){grid-column:1/-1}
  #chargesList>.metric-card{margin-bottom:0!important}
}

/* Touch screens at desktop width (iPad landscape): larger targets */
@media (pointer:coarse){
  #expensesList .card-actions .small-btn,#chargesList .card-actions .small-btn{min-height:44px}
  #addExpense,#addCharge{min-height:44px}
}

/* ---------- YTD Earnings by Carrier: monthly gross and RPM ---------- */
.ytd-monthly{margin-top:10px;border-top:1px solid var(--zap-border);padding-top:8px}
.ytd-monthly summary{cursor:pointer;font-size:13px;font-weight:600;color:var(--zap-link)}
.ytd-monthly-scroll{overflow-x:auto;margin-top:8px}
.ytd-monthly-table{width:100%;border-collapse:collapse;font-size:12.5px;font-variant-numeric:tabular-nums;color:var(--zap-text)}
.ytd-monthly-table th,.ytd-monthly-table td{padding:5px 6px;text-align:left;white-space:nowrap;border-bottom:1px solid var(--zap-border)}
.ytd-monthly-table thead th{font-size:11px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--zap-text-2)}
.ytd-monthly-table tbody th,.ytd-monthly-table tfoot th{font-weight:500}
.ytd-monthly-table tfoot th,.ytd-monthly-table tfoot td{font-weight:700;border-bottom:0}
.ytd-monthly-table .num{text-align:right}
.ytd-monthly-note{margin:8px 0 0;font-size:12px}

/* ---------- Saved Invoices: one folder per carrier ---------- */
.si-bar{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;justify-content:space-between;margin:2px 0 10px;font-size:13px}
.si-folder{border:1px solid var(--zap-border);border-radius:8px;background:var(--zap-panel);margin:0 0 12px}
.si-folder>summary{display:flex;flex-wrap:wrap;gap:8px 10px;align-items:center;padding:12px 16px;cursor:pointer;list-style:none;font-weight:600;color:var(--zap-text)}
.si-folder>summary::-webkit-details-marker{display:none}
.si-folder>summary::before{content:"\25B8";color:var(--zap-muted);font-size:13px;transition:transform .15s}
.si-folder[open]>summary::before{transform:rotate(90deg)}
.si-folder>summary:focus-visible{outline:2px solid var(--zap-action);outline-offset:-2px;border-radius:8px}
.si-folder .si-name{flex:1 1 200px;min-width:0;overflow-wrap:anywhere}
.si-folder .si-body{padding:0 12px 12px;border-top:1px solid var(--zap-border)}
.si-month{margin:14px 4px 8px;font-size:11.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--zap-text-2)}
.si-folder .list-card{margin-bottom:10px}
@media (prefers-reduced-motion:reduce){.si-folder>summary::before{transition:none}}
