/* Staffboard > IA e fala (public/staff-ai-hub.js). Staffboard tokens only;
   dark mode follows :root[data-theme="dark"] through those tokens. */
#staff-ai-hub {
  /* Chart series — validated categorical slots (dataviz palette 1–4):
     light passes CVD/normal-vision checks; legend + tooltips + tables give the
     required relief for the two lighter slots. Dark uses its own steps. */
  --aih-s1: #2a78d6; --aih-s2: #eb6834; --aih-s3: #1baf7a; --aih-s4: #eda100;
  max-width: var(--page-max, 1180px);
}
:root[data-theme="dark"] #staff-ai-hub { --aih-s1: #3987e5; --aih-s2: #d95926; --aih-s3: #199e70; --aih-s4: #c98500; }

.aih { display: flex; flex-direction: column; gap: var(--space-5, 24px); }
.aih h3 { font-family: var(--font-head); font-size: 17px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.2px; }
.aih h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 0 8px; }
.aih p { margin: 0 0 8px; line-height: 1.5; }
.aih code { font-size: 12px; background: var(--panel-2); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
.aih-muted { color: var(--muted); font-size: 12.5px; }
.aih-warn-text { color: var(--danger-strong); font-size: 12.5px; }
.aih-empty { color: var(--muted); font-size: 13px; padding: 18px 0; }
.aih-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.aih-loading { color: var(--muted); padding: 24px 0; }

.aih-card {
  min-width: 0; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-card, 24px); padding: 20px 22px; box-shadow: var(--shadow-md);
}
.aih-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.aih-card-head > div { min-width: 0; }

/* Summary: three KPIs + chart */
.aih-summary { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 2.2fr); gap: 14px; align-items: stretch; }
.aih-kpis { display: grid; gap: 14px; }
.aih-kpi { display: flex; flex-direction: column; gap: 3px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg, 20px); padding: 14px 18px; box-shadow: var(--shadow-sm); }
.aih-kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
/* Lighter numerals (owner preference): 500 weight, tabular figures. */
.aih-kpi-value { font-family: var(--font-head); font-size: 26px; font-weight: 500; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; color: var(--text); }
.aih-chart-card { display: flex; flex-direction: column; }
.aih-chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.aih-chart .aih-gridline { stroke: var(--border); stroke-width: 1; }
.aih-chart .aih-axis { fill: var(--muted); font-size: 10px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.aih-chart .aih-hit:hover { fill: var(--accent-soft); }
.aih-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; margin: 10px 0 0; font-size: 12px; color: var(--text-2); }
.aih-legend li { display: inline-flex; align-items: center; gap: 6px; }
.aih-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Task cards */
.aih-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 860px) { .aih-grid { grid-template-columns: 1fr; } }
.aih-task { display: flex; flex-direction: column; }
.aih-facts { display: grid; gap: 10px; margin: 4px 0 14px; }
.aih-facts > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.aih-facts dt { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0; }
.aih-facts dd { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.aih-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.aih-task .aih-actions { margin-top: auto; }
.aih-status { min-height: 1em; font-size: 13px; color: var(--text-2); margin-top: 8px; }
.aih-status:empty { display: none; }

.aih-pill { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.aih-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.aih-pill-ok { background: var(--success-soft); color: var(--success); }
.aih-pill-bad { background: var(--danger-soft); color: var(--danger-strong); }
.aih-pill-neutral { background: var(--panel-2); color: var(--text-2); }
.aih-tag { font-size: 10.5px; font-weight: 600; color: var(--info); background: var(--info-soft); border-radius: 4px; padding: 0 4px; }

.aih-meter { display: inline-block; vertical-align: middle; width: 72px; height: 6px; border-radius: 3px; background: var(--panel-3); overflow: hidden; margin-right: 8px; }
.aih-meter span { display: block; height: 100%; background: var(--success); border-radius: 3px; }
.aih-meter span.is-high { background: var(--warn-strong); }

/* Model picker drawer */
.aih-drawer { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; }
.aih-picker fieldset { border: 0; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.aih-model {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 4px 14px; align-items: center;
  margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius, 12px);
  text-transform: none; letter-spacing: normal; font-size: 13px; font-weight: 400; color: var(--text); cursor: pointer;
}
.aih-model:hover { background: var(--panel-2); }
.aih-model:has(input:checked) { border-color: var(--app-strong); box-shadow: 0 0 0 2px var(--app-soft); }
.aih-model input[type=radio] { width: auto; margin: 0; accent-color: var(--app-strong); }
.aih-model-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.aih-model-note { display: block; }
.aih-model-num { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; gap: 2px; }
.aih-model-num .aih-muted { font-size: 11px; }
.aih-custom-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.aih-custom-row select { width: auto; flex: none; }
.aih-custom-row input { flex: 1 1 160px; min-width: 0; }

/* Keys */
.aih-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 14px; }
.aih-key { border: 1px solid var(--border); border-radius: var(--radius-lg, 20px); padding: 16px 18px; background: var(--panel-2); min-width: 0; }
.aih-key-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.aih-key-head strong { font-family: var(--font-head); font-size: 15px; font-weight: 600; }
.aih-key-meta { font-size: 13.5px; }
.aih-key-meta .aih-muted { display: block; margin-top: 2px; }
.aih-voice label { display: flex; flex-direction: column; gap: 6px; }
.aih-voice select { max-width: 100%; }
.aih-key-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.aih-key-form label.aih-check { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: normal; font-weight: 400; font-size: 13px; color: var(--text-2); }

/* Tables */
.aih-table-wrap { overflow-x: auto; margin: 4px 0 10px; }
.aih-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.aih-table th, .aih-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.aih-table thead th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.aih-table tbody th { font-weight: 500; }
.aih-table input[type=number] { width: 96px; padding: 6px 8px; font-variant-numeric: tabular-nums; }
.aih-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.aih-add-price input { max-width: 240px; }

/* Speech details (public/staff-speech-settings.js renders inside the card) */
.sps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 8px 28px; }
.sps-col { min-width: 0; }
.sps h4:first-child, .sps-col > h4:first-of-type { margin-top: 12px; }
.sps p { font-size: 13.5px; }
.sps-note { color: var(--text-2); font-size: 13px; }
.sps-form { display: grid; gap: 8px; margin: 8px 0 12px; }
.sps-form label { margin: 0; }
.sps-form button { justify-self: start; }
.sps-table-wrap { overflow-x: auto; }
.sps-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sps-table th, .sps-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }

@media (max-width: 900px) {
  .aih-summary { grid-template-columns: 1fr; }
  .aih-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .aih-kpis { grid-template-columns: 1fr; }
  .aih-card { padding: 16px; }
  .aih-model { grid-template-columns: auto minmax(0, 1fr); }
  .aih-model-num { grid-column: 2; align-items: flex-start; text-align: left; }
  .aih-facts > div { grid-template-columns: 1fr; gap: 2px; }
}
