/* 平台管理 → 用量與異常(public/usage-ui.js):頁首、說明收合沿用 settings-kit.css(.ks-head / .ks-adv),表格沿用方案頁的 .pl-tw / .pl-tbl,
 * 這裡只補摘要數字格、篩選列、數字欄靠右、異常標色、排序鈕、點開的 7 天小圖。標色與 settings-kit.css 的 .ks-pill.warn / .err 同一組顏色。
 * 舊 WebView 守則同 settings-kit.css:不靠 flex gap、不用 grid;觸控區 >= 44px。 */

/* 摘要:一格一個數字 */
.uu-stats { display: flex; flex-wrap: wrap; margin: 0 -5px 10px; }
.uu-stat { flex: 1 1 150px; min-width: 0; margin: 0 5px 10px; padding: 10px 14px; box-sizing: border-box; border: 1px solid var(--line); border-radius: var(--radius, 12px); background: var(--panel, #fff); }
.uu-stat-l { font-size: 13px; font-weight: 700; color: var(--muted); }
.uu-stat-v { margin-top: 2px; font-size: 22px; font-weight: 800; line-height: 1.3; font-variant-numeric: tabular-nums; }
.uu-stat-v small { font-size: 13px; font-weight: 700; color: var(--muted); }
.uu-stat.warn { border-color: #fdba74; background: #fff7ed; }
.uu-stat.warn .uu-stat-v { color: #b45309; }
.uu-stat.ok .uu-stat-v { color: #1e7b34; }

/* 篩選列:公司、排序(手機才出現)、只看異常;最右邊寫資料量是幾點量的 */
.uu-tools { display: flex; flex-wrap: wrap; align-items: center; margin: 0 0 6px; }
#usage-root .uu-tools select { display: inline-block; width: auto; max-width: 100%; min-height: 44px; margin: 0 10px 8px 0; vertical-align: middle; }
#usage-root .uu-tools .uu-sortsel { display: none; }
#usage-root .uu-chk { display: inline-block; width: auto; min-height: 44px; line-height: 44px; margin: 0 10px 8px 0; vertical-align: middle; white-space: nowrap; cursor: pointer; }
#usage-root .uu-chk input { display: inline-block; width: 18px; height: 18px; min-height: 0; margin: 0 6px 0 0; vertical-align: middle; }
.uu-at { margin: 0 0 8px auto; font-size: 12.5px; color: var(--muted); }

/* 表格 */
.uu-tbl thead th { vertical-align: bottom; }
.uu-tbl td { white-space: nowrap; }
.uu-tbl td.uu-st { white-space: normal; min-width: 240px; }
.uu-tbl td.uu-st small, .uu-tbl td small { display: block; }
.uu-tbl th.uu-n, .uu-tbl td.uu-n { text-align: right; font-variant-numeric: tabular-nums; }
.uu-tbl th.uu-n .uu-sort { text-align: right; }
.uu-u { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.uu-tbl tr.uu-row { cursor: pointer; }
.uu-tbl tr.uu-row:hover td { background: rgba(127, 127, 127, .06); }
.uu-tbl td.uu-bad { background: #fff4e0; }
.uu-tbl td.uu-over { background: #fdecea; }
.uu-tag { display: block; margin-top: 2px; font-size: 12px; font-weight: 700; color: #9a5b00; }
.uu-over .uu-tag { color: #b42318; }
.uu-why { display: block; max-width: 320px; margin-top: 4px; padding-left: 8px; border-left: 3px solid #fdba74; white-space: normal; font-size: 12.5px; line-height: 1.45; color: #9a5b00; }
.uu-why.over { border-left-color: #f5b5ae; color: #b42318; font-weight: 700; }
.uu-sort { min-height: 44px; padding: 0 2px; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.uu-act button { min-height: 44px; white-space: nowrap; }
.uu-detrow td { background: rgba(127, 127, 127, .04); white-space: normal; }
.uu-card .ks-adv { margin-top: 6px; }

/* 點開一列:近 7 天小圖 */
.uu-charts { display: flex; flex-wrap: wrap; }
.uu-chart { width: 180px; margin: 0 12px 12px 0; }
.uu-chart-t { font-size: 13px; margin-bottom: 2px; }
.uu-chart-t b { font-variant-numeric: tabular-nums; }
.uu-svg .uu-day { fill: var(--accent); opacity: .45; }
.uu-svg .uu-today { fill: var(--accent); }
.uu-svg .uu-ax { font-size: 9px; fill: currentColor; opacity: .6; }

/* 門檻表:每一列的項目名、勾選、兩個輸入欄垂直置中對齊 */
.uu-th td { vertical-align: middle; }
.uu-th td:first-child { font-weight: 700; }
.uu-th input[type=number] { width: 96px; min-height: 44px; text-align: right; font-variant-numeric: tabular-nums; }
#usage-root .uu-th .uu-chk { min-width: 44px; margin: 0; text-align: center; }
#usage-root .uu-th .uu-chk input { width: 20px; height: 20px; margin: 0; }

@media (max-width: 720px) {
  .uu-why { max-width: none; }
  .uu-chart { width: 46%; margin-right: 4%; }
}
/* 手機(和 table-cards.css 同一個寬度):表頭那排排序小鈕收起,改用篩選列的排序選單;
   一家店一張卡,數字兩兩一排(欄名在上、數字在下),卡片高度少一半 */
@media (max-width: 700px) {
  #usage-root .uu-tools .uu-sortsel { display: inline-block; }
  #usage-root .uu-tools select { flex: 1 1 140px; margin-right: 8px; }
  .uu-at { flex: 1 1 100%; margin: 0 0 6px; }
  .uu-stat { flex-basis: 40%; padding: 8px 12px; }
  .uu-stat-v { font-size: 19px; }
  #usage-root table.rt-cards.uu-tbl > thead { display: none !important; }
  #usage-root table.rt-cards.uu-tbl > tbody > tr.uu-row > td.uu-n {
    display: inline-block !important; width: 33.33% !important; vertical-align: top; padding: 4px 6px 6px 0 !important; text-align: left !important;   /* 一排三格:一家店一張卡的高度再少三分之一 */
  }
  #usage-root table.rt-cards.uu-tbl > tbody > tr.uu-row > td.uu-n::before { position: static; display: block; width: auto; }
  #usage-root table.rt-cards.uu-tbl > tbody > tr.uu-row > td.uu-n.uu-bad, #usage-root table.rt-cards.uu-tbl > tbody > tr.uu-row > td.uu-n.uu-over { padding-left: 6px !important; border-radius: 6px; }
  #usage-root table.rt-cards.uu-tbl > tbody > tr.uu-row > td.uu-act { padding-top: 6px !important; }
  #usage-root table.rt-cards.uu-th > tbody > tr > td:first-child { font-size: 15px; }
}
@media (max-width: 359px) {
  #usage-root table.rt-cards.uu-tbl > tbody > tr.uu-row > td.uu-n { width: 50% !important; }   /* 很窄的螢幕退回兩格一排 */
}
/* 桌面寬度(手機是上面那組一店一張卡):十幾欄的寬表在自己的框裡橫向捲動時,店名欄釘在左邊(釘住的格子要有實色底,捲過去的數字才不會透出來),
   框的左右邊緣用漸層陰影提示「這邊還有欄位」(捲到底就消失),不用猜右邊還有沒有「存檔」那幾欄 */
@media (min-width: 701px) {
  #usage-root .pl-tw { background: linear-gradient(to right, var(--panel, #fff) 30%, rgba(255, 255, 255, 0)) left center / 36px 100% no-repeat local,
    linear-gradient(to left, var(--panel, #fff) 30%, rgba(255, 255, 255, 0)) right center / 36px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .22), rgba(0, 0, 0, 0)) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .22), rgba(0, 0, 0, 0)) right center / 12px 100% no-repeat scroll; }
  .uu-tbl thead th:first-child, .uu-tbl tr.uu-row > td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel, #fff); }
  .uu-tbl tr.uu-row:hover > td:first-child { background: #f4f5f8; }
  .uu-tbl td.uu-st { min-width: 200px; }
  .uu-tbl th, .uu-tbl td { padding-left: 6px; padding-right: 6px; }
}
