table.ai-usage-summary {
   width: 100%;
}

table.ai-usage {
   width: 100%;

   col.token3 {
      width: 4%;
   }

   col.duration {
      width: 5%;
   }

   col.huntgroup {
      width: 6%;
   }

   td.huntgroup {
      overflow-wrap: break-word;
      white-space: normal;
   }
}

table.chat-usage,
table.voice-usage {
   table-layout: fixed;
   width: 100%;
   min-width: max-content;

   col.huntgroup {
      width: 220px;
   }

   col.caller-did {
      width: 120px;
   }

   col.timestamp {
      width: 150px;
   }

   col.duration {
      width: 80px;
   }

   col.token3 {
      width: 72px;
   }

   col.summary {
      width: 280px;
   }

   td.huntgroup {
      min-width: 220px;
      white-space: normal;
      overflow-wrap: break-word;
      word-break: break-word;
   }

   td.caller-did {
      min-width: 120px;
      white-space: normal;
      overflow-wrap: break-word;
      word-break: break-word;
   }

   td.timestamp,
   th.timestamp {
      white-space: nowrap;
      font-size: 0.95em;
   }

   td.summary {
      min-width: 220px;
      max-width: 320px;
      overflow-wrap: break-word;
      white-space: normal;
      font-size: 0.95em;
   }
}

table.chat-iva-usage {
   table-layout: fixed;
   width: 100%;
   min-width: max(100%, 1840px);

   col.huntgroup {
      width: 220px;
   }

   col.timestamp {
      width: 150px;
   }

   col.duration {
      width: 80px;
   }

   col.token3 {
      width: 72px;
   }

   col.summary {
      width: 280px;
   }

   td.huntgroup {
      min-width: 220px;
      white-space: normal;
      overflow-wrap: break-word;
      word-break: break-word;
   }

   td.timestamp,
   th.timestamp {
      white-space: nowrap;
      font-size: 0.95em;
   }

   td.summary {
      min-width: 220px;
      max-width: 320px;
      overflow-wrap: break-word;
      white-space: normal;
      font-size: 0.95em;
   }
}

/* Detail wrap height is set in usage.js from viewport geometry (see sizeUsageDetailWraps). */
#content.ai-usage-content,
.panel-body.ai-usage-content {
   overflow: hidden;
}

.panel-body.ai-usage-content {
   padding: 0 7px;
}

.panel-body.ai-usage-content .ai-usage-summary-section {
   margin-bottom: 0.5em;
}

.ai-usage-detail-wrap {
   position: relative;
   margin-top: 1.5em;
   overflow: auto;
}

.ai-usage-detail-wrap table.ai-usage tfoot {
   position: sticky;
   bottom: 0;
   z-index: 2;
}

/* Keep Call Accounting .total gold styling; sticky footer should not force white. */
.ai-usage-detail-wrap table.cdrs.ai-usage tfoot tr.total {
   box-shadow: 0 -1px 0 #999999;
}

.ai-usage-load-more {
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   gap: 0.4em;
   margin-top: 0.75em;
   padding: 0.5em 0;
}

.ai-usage-load-more-status {
   color: #424242;
   font-size: 0.95em;
}

.ai-usage-load-more-btn {
   cursor: pointer;
   font: inherit;
   font-size: 1.05em;
   font-weight: 600;
   padding: 0.55em 2.25em;
   min-width: 24em;
   border: solid 1px #999999;
   background: rgb(250, 199, 72);
   color: #424242;
}

.ai-usage-load-more-btn:hover {
   background: rgb(245, 188, 50);
}

.ai-usage-load-more.is-complete .ai-usage-load-more-btn {
   display: none;
}

.ai-usage-summary-section {
   overflow-x: auto;
}

.ai-usage-sorting-overlay {
   display: flex;
   position: fixed;
   inset: 0;
   z-index: 2000;
   align-items: center;
   justify-content: center;
   background: rgba(255, 255, 255, 0.6);
   pointer-events: all;
}

.ai-usage-detail-wrap.ai-usage-sorting table.ai-usage {
   pointer-events: none;
}

.ai-usage-sorting-status {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 0.75em;
   padding: 1.25em 1.75em;
   border: 1px solid rgba(0, 0, 0, 0.1);
   border-radius: 0.5em;
   background: #fff;
   box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.ai-usage-sorting-label {
   font-size: 1.1em;
   font-weight: 500;
   color: #333;
}

.ai-usage-sorting-spinner {
   box-sizing: border-box;
   width: 48px;
   height: 48px;
   border: 5px solid rgba(0, 0, 0, 0.12);
   border-top-color: #fac748;
   border-radius: 50%;
   animation: ai-usage-sorting-spin 0.75s linear infinite;
}

@keyframes ai-usage-sorting-spin {
   to {
      transform: rotate(360deg);
   }
}

/* Usage tables in report host: billing-aligned chrome (billing host uses billing.css). */
table.cdrs.ai-usage,
table.cdrs.ai-usage-summary {
   border-collapse: collapse;
   border: solid 1px #999999;
   min-width: 100%;
   background-color: #ffffff;
}

table.cdrs.ai-usage tbody tr:nth-child(even),
table.cdrs.ai-usage-summary tbody tr:nth-child(even) {
   background-color: #f6f6f6;
}

table.cdrs.ai-usage th,
table.cdrs.ai-usage-summary th {
   background-color: #f6f6f6;
   padding: 0.5rem 0.5rem 0.25rem 0.5rem;
   border-bottom: solid 1px #999999;
   border-right: 1px solid #999999;
}

table.cdrs.ai-usage td,
table.cdrs.ai-usage-summary td {
   padding: 0.5rem 0.5rem;
   border-right: 1px solid #999999;
}

table.cdrs.ai-usage th.table-caption,
table.cdrs.ai-usage-summary th.table-caption {
   font-size: 1.125em;
   padding-top: 1.5em;
   padding-left: 1em;
   text-align: left;
   background-color: #ffffff;
}

table.cdrs.ai-usage tfoot tr.total {
   border-top: solid 0px #333333;
   border-bottom: solid 1px #999999;
   border-right: 1px solid #999999;
   font-size: 1.25em;
   font-weight: 500;
   background: rgb(250, 199, 72);
}

table.cdrs.ai-usage tfoot tr.total td {
   white-space: nowrap;
   border-right: 1px solid transparent;
}

table.cdrs.ai-usage tfoot tr.total td:last-of-type {
   border-right: 1px solid #999999;
}

/* Report host only: sortable column headers (billing usage stays plain .cdrs th). */
.panel-body.ai-usage-content table.cdrs.ai-usage th[data-sort-col] {
   color: #3b7bce;
   cursor: pointer;
   transition: background-color 0.2s ease;
}

.panel-body.ai-usage-content table.cdrs.ai-usage th[data-sort-col] .fa {
   font-size: 1em;
   line-height: 1;
   vertical-align: baseline;
}

.panel-body.ai-usage-content table.cdrs.ai-usage th[data-sort-col]:hover {
   background-color: #eff5fc;
   border-radius: 4px;
}

.panel-body.ai-usage-content .ai-usage-load-more-btn {
   font-size: inherit;
   font-weight: 600;
   min-width: unset;
   padding: 0.375rem 0.75rem;
   border-radius: 0.25rem;
   border: 1px solid #fac748;
   background-color: #fac748;
   color: #25291c;
   text-transform: uppercase;
}

.panel-body.ai-usage-content .ai-usage-load-more-btn:hover {
   filter: brightness(0.9);
   background-color: #fac748;
}

@media (prefers-color-scheme: dark) {
   table.cdrs.ai-usage,
   table.cdrs.ai-usage-summary {
      border: solid 3px #333333;
      background-color: #111111;
   }

   table.cdrs.ai-usage tbody tr:nth-child(even),
   table.cdrs.ai-usage-summary tbody tr:nth-child(even) {
      background-color: #202020;
   }

   table.cdrs.ai-usage th,
   table.cdrs.ai-usage-summary th {
      background-color: #222222;
      border-bottom: solid 1px #444444;
      border-right: 1px solid #444444;
   }

   table.cdrs.ai-usage td,
   table.cdrs.ai-usage-summary td {
      border-right: 1px solid #444444;
   }

   table.cdrs.ai-usage th.table-caption,
   table.cdrs.ai-usage-summary th.table-caption {
      background-color: #111111;
   }

   table.cdrs.ai-usage tfoot tr.total {
      border-bottom: solid 1px #444444;
      border-right: 1px solid #444444;
      background: rgba(255, 255, 255, 0.125);
   }

   table.cdrs.ai-usage tfoot tr.total td:last-of-type {
      border-right: 1px solid #666666;
   }

   .ai-usage-detail-wrap table.cdrs.ai-usage tfoot tr.total {
      box-shadow: 0 -1px 0 #444444;
   }
}
