/* Dashboard, Projects and API pages: KPI tiles, charts, tables, range switch, tooltip. Loaded after settings.css. Smallest text 14px. */
.st-head .ws-head-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ws-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 0; }
.ws-range { display: inline-flex; flex-wrap: wrap; max-width: 100%; }
.ws-filter { margin: 12px 0 0; font-size: var(--fs-small); color: var(--text-muted); }

.ws-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 0; }
.ws-kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.ws-kpi:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ws-kpi-label { font-size: var(--fs-small); color: var(--text-muted); }
.ws-kpi-value { font-size: calc(26px + var(--ui-plus, 0px)); font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ws-kpi-change { font-size: var(--fs-small); color: var(--text-muted); }
.ws-kpi .st-bar { margin-top: 6px; }

.ws-chart-box { margin: 20px 0 0; }
.ws-chart-title { margin: 0 0 8px; font-size: var(--fs-body); font-weight: 600; }
.ws-chart { position: relative; }
.ch-svg { display: block; width: 100%; height: auto; overflow: visible; }
/* Chart text: only these three sizes; --ch-k (js/chart-text.js) undoes the SVG stretch so they match the page text. */
.ch-svg text { font-family: var(--font); font-size: calc(var(--fs-micro) * var(--ch-k, 1)); fill: var(--text-muted); }
.ch-svg .ch-value { fill: var(--text); font-weight: 600; }
.ch-hit:hover > rect:first-child, .ch-hit > rect[data-tip]:hover { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; stroke-opacity: .55; rx: 4; }
.ch-svg [data-pick], .ch-rank [data-pick] { cursor: pointer; }
.ch-empty { margin: 0; padding: 28px 0; text-align: center; font-size: var(--fs-small); color: var(--text-muted); }
.ch-rank { flex: 1 1 200px; margin: 0; padding: 0; list-style: none; }
.ch-rank li:hover { background: var(--surface-2); }
.ch-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.ch-rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-rank-val { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.ch-rank li { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr 48px; align-items: center; gap: 10px; padding: 6px 4px; border-radius: var(--radius-sm); font-size: var(--fs-small); }
.ch-rank-track { height: 10px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.ch-rank-track span { display: block; height: 100%; border-radius: inherit; }
.ch-rank-val { text-align: right; }
.ch-data { margin: 12px 0 0; font-size: var(--fs-small); }
.ch-data summary { cursor: pointer; color: var(--accent); }

.ws-scroll { overflow-x: auto; }
.ws-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: var(--fs-small); }
.ws-table th { padding: 8px 10px; border-bottom: 1px solid var(--border-strong); text-align: left; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.ws-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; }
.ws-table tr.is-revoked td { color: var(--text-muted); }
.ws-table tr.is-revoked strong { font-weight: 400; text-decoration: line-through; }
.ws-mono { font-family: var(--mono); font-size: var(--fs-small); white-space: nowrap; }
.ws-who { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.ws-table .st-chip { white-space: nowrap; }
.st-avatar.ws-face { width: 24px; height: 24px; font-size: var(--fs-small); }
.ws-row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.st-card .ws-row-actions button { min-height: 34px; padding: 4px 12px; }
.ws-create { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.ws-create-fields { display: grid; grid-template-columns: 1.4fr 1.4fr 1fr; gap: 0 12px; }
.ws-create-fields > :nth-child(n+4) { grid-column: 1 / -1; }
.ws-scope { margin-top: 18px; }
.ws-scope-title { margin: 0; font-size: var(--fs-body); font-weight: 600; }
.ws-scope-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.ws-scope-row .st-field { margin-top: 10px; }

#stats-tip { position: fixed; z-index: 30; min-width: 190px; max-width: 340px; padding: 12px 16px; border-radius: var(--radius-md); background: var(--text); color: var(--bg); font-size: var(--fs-small); line-height: 1.55; white-space: pre-line; box-shadow: var(--shadow-float); pointer-events: none; }
#stats-tip::after { content: ''; position: absolute; left: var(--arrow, 50%); width: 12px; height: 12px; margin-left: -6px; background: inherit; transform: rotate(45deg); }
#stats-tip.is-above::after { bottom: -6px; }
#stats-tip.is-below::after { top: -6px; }
#stats-tip[hidden] { display: none; }
#stats-tip strong { display: block; margin-bottom: 4px; font-size: var(--fs-body); }

/* Narrow cards (phones, tablets with the sidebar): tables marked .ws-cards become one card per row, labelled cells. */
.st-card { container-type: inline-size; }
@container (max-width: 860px) {
  .ws-create-fields, .ws-scope-row { grid-template-columns: 1fr; }
  .ws-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ws-cards, .ws-cards tbody, .ws-cards tr, .ws-cards td { display: block; width: 100%; }
  .ws-cards tr { margin-top: 10px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); }
  .ws-cards td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 0; text-align: right; }
  .ws-cards td::before { content: attr(data-label); flex: none; color: var(--text-muted); text-align: left; }
  .ws-cards td[data-label="Actions"]::before { content: none; }
  .ws-row-actions { width: 100%; }
}

.ws-menu-wrap { position: relative; }
.st-card button.ws-menu-btn, button.ws-menu-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--text-muted); cursor: pointer; }
button.ws-menu-btn:hover, button.ws-menu-btn[aria-expanded="true"] { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.ws-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 20; display: flex; flex-direction: column; min-width: 190px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-float); }
.ws-menu[hidden] { display: none; }
.ws-menu button, .st-card .ws-menu button { justify-content: flex-start; min-height: 36px; padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font-size: var(--fs-small); text-align: left; white-space: nowrap; cursor: pointer; }
.ws-menu button:hover:not(:disabled), .st-card .ws-menu button:hover:not(:disabled) { background: var(--surface-2); }
.ws-menu button.ws-menu-danger { color: var(--danger); }
.ws-toast { position: fixed; bottom: 24px; left: 50%; z-index: 40; display: flex; align-items: center; gap: 14px; max-width: min(560px, calc(100vw - 32px)); padding: 10px 14px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--toast-bg); color: var(--text); font-size: var(--fs-small); box-shadow: var(--shadow-float); transform: translateX(-50%); }
.ws-toast[hidden] { display: none; }
.ws-toast-undo { height: 28px; padding: 0 12px; font: inherit; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.ws-toast-undo:hover { background: var(--surface-2); }
@media (max-width: 640px) { .ws-toast { bottom: 84px; } }
.ws-range button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--text-muted); font-size: var(--fs-small); cursor: pointer; }
.ws-range button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ws-range button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.ws-kpi.is-action { width: 100%; font: inherit; color: inherit; text-align: left; cursor: pointer; transition: border-color .15s, background-color .15s; }
.ws-kpi.is-action:hover, .ws-kpi.is-open { border-color: var(--accent); background: var(--accent-soft); }
.ws-kpi-hint { margin-top: 2px; font-size: var(--fs-small); color: var(--accent); }
.ws-kpi-hint::after { content: '›'; display: inline-block; margin-left: 6px; font-size: 1.2em; line-height: 1; transition: transform .15s; }
.ws-kpi.is-open .ws-kpi-hint::after { transform: rotate(90deg); }
.ws-key-chip { display: inline-flex; align-items: center; gap: 6px; margin: 12px 0 0; }
.ws-key-chip button { padding: 0 2px; border: 0; background: none; color: inherit; font: inherit; line-height: 1; cursor: pointer; }
.ws-key-chip button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ws-count-errors { color: var(--text-muted); }
.ws-details { margin: 16px 0 0; }
.ws-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; margin: 12px 0 0; font-size: var(--fs-small); color: var(--text-muted); }

.ws-usage.is-loading { opacity: .55; pointer-events: none; transition: opacity .15s; }
.ws-when { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ws-when input[type=date] { width: auto; min-width: 160px; }
.ws-when-time { display: inline-flex; align-items: center; gap: 6px; }
.ws-when-time .ws-dd { min-width: 80px; }
.ws-pager .ws-dd { min-width: 140px; margin-right: auto; }
.ws-info { display: flex; gap: 10px; margin: 8px 0 0; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: var(--fs-small); }
.ws-info[hidden] { display: none; }
.ws-info::before { content: 'i'; flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 700; line-height: 20px; text-align: center; }
.ws-dr { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0 0; }
.ws-dr-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-small); color: var(--text-muted); }
.ws-dr-field input { width: auto; min-width: 160px; }
.ws-dr-note { color: var(--text-muted); padding-bottom: 10px; }
@media (pointer: coarse) { .ws-dr-field input { min-height: 44px; } }
