/* Signal OSX design system: charts, figures and the form and settings parts added for version 0.4.
   Approved by the operator on 15 November 2026 as version 0.4 (DEC-SYS-20261115-04).
   Link it third, after signal-osx.css and signal-osx-components.css. It reads their variables and adds
   the chart colours. Source of truth for the colours: tokens.json. Rules: ../specs/charts.md */

/* Chart colours. Six series in a fixed order, never cycled; a seventh folds into "Other" (grey).
   Each is at least 3:1 on the page and on a card; the order is checked for colour-blind safety.
   The ramp is one hue for "how much": step 1 is least, step 5 is most. */
:root {
  --sx-chart-1: #5A81FA; --sx-chart-2: #1A9E8C; --sx-chart-3: #8A5C08; --sx-chart-4: #D25CA4; --sx-chart-5: #5A2CAE; --sx-chart-6: #4C8A22;
  --sx-chart-ramp-1: #94ADFC; --sx-chart-ramp-2: #5A81FA; --sx-chart-ramp-3: #3F60CC; --sx-chart-ramp-4: #2B4399; --sx-chart-ramp-5: #1B2B66;
  --sx-chart-other: #7E8099;
}
[data-theme="dark"] {
  --sx-chart-1: #5A81FA; --sx-chart-2: #23A892; --sx-chart-3: #A8741A; --sx-chart-4: #C2418D; --sx-chart-5: #9A78E8; --sx-chart-6: #6FA63C;
  --sx-chart-ramp-1: #3D58BC; --sx-chart-ramp-2: #5A81FA; --sx-chart-ramp-3: #819FFB; --sx-chart-ramp-4: #A9BDFD; --sx-chart-ramp-5: #D0DBFE;
  --sx-chart-other: #8A8DB5;
}

/* Charts and figures (version 0.4). Rules: specs/charts.md. The chart library draws the marks;
   these classes give it the frame, the colours and the words around it. */
.sx-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sx-space-4); }
.sx-stat { display: flex; flex-direction: column; gap: var(--sx-space-1); padding: var(--sx-space-5); border-radius: var(--sx-radius-card);
  background: var(--sx-raised); box-shadow: var(--sx-shadow-card); }
.sx-stat__label { display: flex; align-items: center; gap: var(--sx-space-2); font-size: var(--sx-size-label); color: var(--sx-muted); }
.sx-stat__value { font-size: var(--sx-size-page); line-height: var(--sx-leading-tight); font-weight: var(--sx-weight-regular); color: var(--sx-text);
  font-variant-numeric: tabular-nums; }
.sx-stat__change { display: flex; align-items: center; gap: var(--sx-space-1); font-size: var(--sx-size-label); color: var(--sx-text-2); }
.sx-chart { display: flex; flex-direction: column; gap: var(--sx-space-4); padding: var(--sx-space-5); border-radius: var(--sx-radius-card);
  background: var(--sx-raised); box-shadow: var(--sx-shadow-card); min-width: 0; }
.sx-chart__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sx-space-4); }
.sx-chart__sub { margin: 2px 0 0; font-size: var(--sx-size-label); color: var(--sx-muted); }
/* The plot is drawn at its true size (width and height equal to its viewBox) and never scaled, so its words stay 13px.
   When the card is narrower than the plot, the frame scrolls sideways. */
.sx-chart__frame { overflow-x: auto; }
.sx-chart__plot { display: block; flex: none; max-width: none; overflow: visible; }
.sx-chart__plot text { font-family: inherit; font-size: var(--sx-size-label); fill: var(--sx-muted); font-variant-numeric: tabular-nums; }
.sx-chart__plot .sx-chart__name { fill: var(--sx-text-2); }
.sx-chart__grid { stroke: var(--sx-line); stroke-width: 1; }
.sx-chart__base { stroke: var(--sx-line-control); stroke-width: 1; }
.sx-chart__line { fill: none; stroke: var(--sx-series); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sx-chart__bar, .sx-chart__dot { fill: var(--sx-series); }
.sx-chart__dot { stroke: var(--sx-raised); stroke-width: 2; }
.sx-chart__target { stroke: var(--sx-chart-other); stroke-width: 1.5; stroke-dasharray: 4 4; fill: none; }
.sx-series-1 { --sx-series: var(--sx-chart-1); } .sx-series-2 { --sx-series: var(--sx-chart-2); } .sx-series-3 { --sx-series: var(--sx-chart-3); }
.sx-series-4 { --sx-series: var(--sx-chart-4); } .sx-series-5 { --sx-series: var(--sx-chart-5); } .sx-series-6 { --sx-series: var(--sx-chart-6); }
.sx-series-other { --sx-series: var(--sx-chart-other); }
.sx-legend { display: flex; flex-wrap: wrap; gap: var(--sx-space-2) var(--sx-space-5); margin: 0; padding: 0; list-style: none; font-size: var(--sx-size-label); color: var(--sx-text-2); }
.sx-legend__item { display: inline-flex; align-items: center; gap: var(--sx-space-2); }
.sx-legend__key { flex: none; width: 10px; height: 10px; border-radius: 2px; background: var(--sx-series); }
.sx-legend__key--line { height: 2px; width: 14px; border-radius: 1px; }
.sx-chart-tip { display: grid; gap: var(--sx-space-1); min-width: 160px; padding: var(--sx-space-3); border-radius: var(--sx-radius-box); background: var(--sx-raised);
  box-shadow: var(--sx-shadow-menu); font-size: var(--sx-size-label); color: var(--sx-text-2); }
.sx-chart-tip__row { display: flex; align-items: center; gap: var(--sx-space-2); }
.sx-chart-tip__row b { margin-left: auto; font-weight: var(--sx-weight-medium); color: var(--sx-text); font-variant-numeric: tabular-nums; }
.sx-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sx-space-2); min-height: 200px; padding: var(--sx-space-6);
  text-align: center; color: var(--sx-muted); }
.sx-empty .sx-title { color: var(--sx-text); }
.sx-empty p { margin: 0; max-width: 44ch; font-size: var(--sx-size-ui); }
.sx-empty .sx-button { margin-top: var(--sx-space-2); }

/* Form and settings parts (version 0.4). Rules: specs/forms.md.
   A chosen control is solid in the primary colour, the same as a chosen filter. */
.sx-textarea { display: block; width: 100%; min-height: 96px; padding: var(--sx-space-2) var(--sx-space-3); border: 1px solid var(--sx-line-field);
  border-radius: var(--sx-radius-control); background: var(--sx-surface); color: var(--sx-text); font: inherit; line-height: var(--sx-leading); resize: vertical; }
[data-theme="dark"] .sx-textarea { background: transparent; }
.sx-textarea::placeholder { color: var(--sx-muted); opacity: 1; }
.sx-field--error .sx-textarea, .sx-field--error .sx-select { border-color: var(--sx-danger); }
.sx-field__count { margin-left: auto; font-size: var(--sx-size-label); color: var(--sx-muted); font-variant-numeric: tabular-nums; }
.sx-field__foot { display: flex; gap: var(--sx-space-3); }
.sx-select { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; min-height: var(--sx-control-height); padding: 3px var(--sx-space-3);
  border: 1px solid var(--sx-line-field); border-radius: var(--sx-radius-control); background: var(--sx-surface); color: var(--sx-text); text-align: left; }
[data-theme="dark"] .sx-select { background: transparent; }
.sx-select > svg:last-child { margin-left: auto; color: var(--sx-muted); }
.sx-select__placeholder { color: var(--sx-muted); }
.sx-token { display: inline-flex; align-items: center; gap: var(--sx-space-1); min-height: 26px; padding: 0 2px 0 var(--sx-space-2); border-radius: 6px;
  background: var(--sx-selected); color: var(--sx-text); font-size: var(--sx-size-label); font-weight: var(--sx-weight-medium); white-space: nowrap; }
.sx-token button { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--sx-text-2); }
.sx-token button:hover { background: var(--sx-line-box); }
.sx-menu__item[aria-selected="true"], .sx-menu__item[aria-checked="true"] { font-weight: var(--sx-weight-medium); }
.sx-check { display: flex; align-items: flex-start; gap: 10px; min-height: 24px; }
.sx-check input { appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 2px 0 0; border: 1px solid var(--sx-line-field);
  border-radius: 5px; background: var(--sx-surface); }
[data-theme="dark"] .sx-check input { background-color: transparent; }
.sx-check input[type="radio"] { border-radius: 50%; }
/* 0.24.4: only a tick box can be part-chosen; a radio in a group with nothing chosen also matches :indeterminate,
   so the rule names the tick box (studio issue 641). */
.sx-check input:checked, .sx-check input[type="checkbox"]:indeterminate { border-color: var(--sx-primary-bg); background-color: var(--sx-primary-bg); }
.sx-check input[type="checkbox"] { position: relative; }
.sx-check input[type="checkbox"]:checked::after { content: ""; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 10px;
  border: solid var(--sx-primary-text); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.sx-check input[type="checkbox"]:indeterminate::after { content: ""; position: absolute; left: 3px; right: 3px; top: 7px; height: 2px; background: var(--sx-primary-text); }
.sx-check input[type="radio"]:checked { box-shadow: inset 0 0 0 4px var(--sx-primary-bg); background-color: var(--sx-primary-text); }
.sx-check input:disabled, .sx-check input:disabled ~ * { opacity: 0.5; }
.sx-check__text { display: flex; flex-direction: column; gap: 2px; }
.sx-check__help { font-size: var(--sx-size-label); color: var(--sx-muted); }
.sx-toggle { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 40px; height: 24px; margin: 0; border: 1px solid var(--sx-line-field);
  border-radius: var(--sx-radius-pill); background: var(--sx-line-box); transition: background var(--sx-motion-fast) var(--sx-ease); }
.sx-toggle::after { content: ""; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--sx-surface);
  box-shadow: 0 0 0 1px var(--sx-line-field); transition: transform var(--sx-motion-fast) var(--sx-ease); }
.sx-toggle:checked { border-color: var(--sx-primary-bg); background: var(--sx-primary-bg); }
.sx-toggle:checked::after { transform: translateX(16px); background: var(--sx-primary-text); box-shadow: none; }
.sx-toggle:disabled { opacity: 0.5; }
.sx-tabs { display: flex; gap: var(--sx-space-6); border-bottom: 1px solid var(--sx-line-box); overflow-x: auto; }
.sx-tab { flex: none; display: inline-flex; align-items: center; gap: var(--sx-space-2); min-height: 40px; padding: 0; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px; background: transparent; color: var(--sx-text-2); text-decoration: none; white-space: nowrap; }
.sx-tab:hover { color: var(--sx-text); }
.sx-tab[aria-selected="true"], .sx-tab[aria-current="page"] { border-bottom-color: var(--sx-text); color: var(--sx-text); font-weight: var(--sx-weight-medium); }
.sx-settings { border-radius: var(--sx-radius-card); background: var(--sx-raised); box-shadow: var(--sx-shadow-card); }
.sx-settings__head { padding: var(--sx-space-5); border-bottom: 1px solid var(--sx-line); }
.sx-settings__head p { margin: 2px 0 0; font-size: var(--sx-size-label); color: var(--sx-muted); }
.sx-setting { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sx-space-6); padding: var(--sx-space-4) var(--sx-space-5); border-bottom: 1px solid var(--sx-line-row); }
.sx-setting:last-child { border-bottom: 0; }
.sx-setting__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 60ch; }
.sx-setting__name { font-weight: var(--sx-weight-medium); }
.sx-setting__help { font-size: var(--sx-size-label); color: var(--sx-muted); }
.sx-setting__control { flex: none; display: flex; align-items: center; gap: var(--sx-space-2); }
.sx-progress { display: flex; flex-direction: column; gap: 6px; }
.sx-progress__words { display: flex; justify-content: space-between; gap: var(--sx-space-3); font-size: var(--sx-size-label); color: var(--sx-text-2); }
.sx-progress__bar { height: 6px; border-radius: 3px; background: var(--sx-line-box); overflow: hidden; }
.sx-progress__bar span { display: block; height: 100%; border-radius: 3px; background: var(--sx-accent); }
.sx-pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sx-space-4); padding: var(--sx-space-3) var(--sx-space-5); border-top: 1px solid var(--sx-line);
  font-size: var(--sx-size-label); color: var(--sx-muted); }
.sx-pager__buttons { display: flex; align-items: center; gap: var(--sx-space-1); }
.sx-pager__page { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 var(--sx-space-2); border: 0; border-radius: var(--sx-radius-control); background: transparent; color: var(--sx-text-2);
  font-size: var(--sx-size-ui); font-variant-numeric: tabular-nums; }
.sx-pager__page:hover { background: var(--sx-selected); }
.sx-pager__page[aria-current="page"] { background: var(--sx-selected); color: var(--sx-text); font-weight: var(--sx-weight-medium); }
.sx-pager__page[disabled] { opacity: 0.5; }
.sx-tooltip { display: inline-block; max-width: 280px; padding: 6px 10px; border-radius: var(--sx-radius-control); background: var(--sx-primary-bg); color: var(--sx-primary-text);
  font-size: var(--sx-size-label); line-height: var(--sx-leading-tight); }
.sx-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sx-space-2); min-height: 160px; padding: var(--sx-space-6);
  border: 1px dashed var(--sx-line-field); border-radius: var(--sx-radius-card); background: transparent; color: var(--sx-muted); text-align: center; }
.sx-drop--over { border-style: solid; border-color: var(--sx-accent); background: var(--sx-selected); }
.sx-drop p { margin: 0; }
.sx-drop strong { color: var(--sx-text); font-weight: var(--sx-weight-medium); }
.sx-file { display: flex; align-items: center; gap: var(--sx-space-3); padding: var(--sx-space-3) var(--sx-space-4); border: 1px solid var(--sx-line-box); border-radius: var(--sx-radius-box); }
.sx-file__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sx-file__text span { font-size: var(--sx-size-label); color: var(--sx-muted); }
@media (max-width: 767px) {
  .sx-setting { flex-direction: column; gap: var(--sx-space-3); }
  .sx-pager__page:not([aria-label]) { display: none; }
}
