/* ============================================================================
   Shared components. ui.js emits the markup these rules style; pages compose
   them instead of inventing their own. Built on the tokens in styles.css and
   on the button, badge, card and table classes already defined there, so a
   page migrates by switching to ui.*, not by restyling.
   ========================================================================== */

/* --- Buttons: size and state modifiers ------------------------------------ */

/* .table-action is the small ghost button; .small makes any variant that size. */
.primary.small,
.ghost.small,
.subtle.small,
.danger-button.small,
.danger-solid.small {
  padding: 5px 10px;
  font-size: 12px;
}

/* One destructive look for outlined buttons, wherever they sit. */
.danger-button,
.ghost.danger,
.table-action.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

.danger-button:hover,
.ghost.danger:hover,
.table-action.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-dim);
}

button[aria-busy="true"] {
  cursor: progress;
  opacity: 0.7;
}

button[aria-busy="true"]::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: ui-spin 0.7s linear infinite;
}

@keyframes ui-spin {
  to { transform: rotate(360deg); }
}

/* --- Fields --------------------------------------------------------------- */

.field {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}

.field > .field-label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--n-10);
}

.field.required > .field-label::after {
  content: " *";
  color: var(--danger);
}

.field > .field-hint,
.field > .field-error {
  margin: 0;
}

.field-error {
  font-size: 12px;
  color: var(--danger);
}

.field-error:empty {
  display: none;
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--danger);
}

/* An input with something beside it: a unit, or a Generate button. */
.field-control {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.field-control > input,
.field-control > select {
  flex: 1;
  min-width: 0;
}

.field-unit {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.field input[readonly] {
  background: var(--bg-sink);
  color: var(--text-muted);
}

/* --- Action rows ---------------------------------------------------------- */

/* The one row of buttons under a form, in a dialog or on a page. The error
   sits on the left, where it is read before the button that caused it. */
.form-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-3);
  margin-top: var(--s-5);
}

.form-foot > .error {
  flex: 1;
  min-height: 0;
}

.form-foot > .error:empty {
  visibility: hidden;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.actions.end {
  justify-content: flex-end;
}

/* --- Dialogs -------------------------------------------------------------- */

dialog.ui-dialog.sm { width: min(440px, calc(100vw - 32px)); }
dialog.ui-dialog.lg { width: min(780px, calc(100vw - 32px)); }
dialog.ui-dialog.wide { width: min(940px, calc(100vw - 32px)); }

.ui-dialog .dialog-head {
  margin-bottom: var(--s-4);
}

.ui-dialog .dialog-message {
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0 0 var(--s-4);
}

.ui-dialog .dialog-body {
  display: grid;
  gap: var(--s-4);
}

.ui-dialog .secret-value {
  margin: 0;
}

/* Detail dialog: a titled section with its action on the right. */
.detail-section {
  display: grid;
  gap: var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border-soft);
}

.detail-section:first-child {
  padding-top: 0;
  border-top: 0;
}

/* Actions on the record itself sit at the start of the footer, away from
   the button that closes the dialog. */
.form-foot > .foot-start {
  order: -1;
  display: flex;
  gap: var(--s-2);
}

.detail-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
}

.detail-section-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
}

.detail-section-head p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.detail-section-head > .btn,
.detail-section-head > button {
  flex: none;
}

.detail-section .table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
}

td > .sub {
  display: block;
  margin-top: 2px;
}

tbody tr.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Credentials dialog: each value sits in its own row beside its Copy button. */
.cred-list {
  display: grid;
  gap: var(--s-4);
  margin: var(--s-4) 0;
}

.cred-field {
  display: grid;
  gap: var(--s-1);
}

.cred-row {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
}

.cred-row .secret-value {
  flex: 1;
  min-width: 0;
  padding: var(--s-3);
  font-size: 13px;
}

.cred-row .cred-snippet {
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

.copy-done {
  color: var(--success);
  font-size: 12.5px;
}

/* --- Notices -------------------------------------------------------------- */

.notice.info {
  border-color: color-mix(in srgb, var(--info) 45%, var(--border));
  background: var(--info-dim);
}

.notice.danger {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: var(--danger-dim);
}

.notice.success {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
  background: var(--success-dim);
}

.notice.with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.notice code {
  font-family: var(--mono);
  font-size: 12px;
}

/* --- Empty, loading and error states -------------------------------------- */

.empty .actions {
  justify-content: center;
  margin-top: var(--s-4);
}

.empty.loading strong::before,
.spinner {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: var(--s-2);
  vertical-align: -1px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  border-right-color: transparent;
  animation: ui-spin 0.7s linear infinite;
}

/* --- Toasts --------------------------------------------------------------- */

.toast.warning { border-color: var(--warn); }
.toast.info { border-color: var(--info); }

.toast.persist { pointer-events: auto; }

.toast .toast-close {
  margin-left: var(--s-3);
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.toast .toast-close:hover { opacity: 1; }

/* --- UI kit page ---------------------------------------------------------- */

.ui-kit {
  display: grid;
  gap: var(--s-5);
}

.ui-kit .card > .actions + .actions {
  margin-top: var(--s-3);
}

/* A status line beside the form's buttons (e.g. "Connection OK"). */
.form-foot > .form-status:empty {
  display: none;
}

/* The info mark next to a field label; its text is the tooltip. */
.field-label .info-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: var(--s-1);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 10px;
  font-style: italic;
  font-weight: 600;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
}

.field-label .info-mark:hover,
.field-label .info-mark:focus-visible {
  color: var(--text);
  border-color: var(--text-muted);
}

/* --- Schema widgets: radio group, slider, collapsible fieldset ------------ */

.ui-radio { display: flex; flex-wrap: wrap; gap: var(--s-2, 8px); }
.ui-radio label {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px;
  white-space: nowrap; flex: 0 0 auto;
}
.ui-radio label:has(input:checked) { border-color: var(--accent, currentColor); background: color-mix(in srgb, var(--accent, currentColor) 10%, transparent); }
.ui-radio input { margin: 0; }
.ui-radio-hint { margin: 6px 0 0; }
.ui-radio-hint.hidden { display: none; }
.ui-probe-status { margin: 4px 0 0; color: var(--success); }
.field input[type="range"] { flex: 1; padding: 0; }
.ui-range-value { min-width: 3.5em; text-align: right; }
/* A token the plugin issues: its state, the new value shown once, the actions. */
.ui-token { display: grid; gap: var(--s-2); }
.ui-token-row { display: flex; gap: var(--s-2); align-items: center; }
.ui-token-field { position: relative; flex: 1; min-width: 0; }
.ui-token-field .secret-value { margin: 0; height: 40px; box-sizing: border-box; padding: 0 44px 0 var(--s-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; }
.ui-token-field .icon-button { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); }
.ui-token-field .icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ui-token-row > button { height: 40px; }
.ui-token-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-2) var(--s-4); font-size: 12.5px; }
.ui-token-links { display: flex; flex-wrap: wrap; gap: var(--s-3); }
details.ui-fieldset { border: 1px solid var(--border); border-radius: 8px; padding: var(--s-3, 12px); }
details.ui-fieldset > summary { cursor: pointer; font-weight: 600; }
details.ui-fieldset[open] > summary { margin-bottom: var(--s-3, 12px); }
.ui-when.hidden { display: none; }

/* Menu: a button opening a short list of links (ui.menu). */
.ui-suggest { position: relative; flex: 1; min-width: 0; }
.ui-suggest > input { width: 100%; }
.ui-sugg { position: fixed; z-index: 1000; display: grid; max-height: 240px; overflow: auto; overscroll-behavior: contain; scroll-padding-top: 22px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-raised); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2); }
.ui-sugg-opt { padding: var(--s-2) var(--s-3); border: 0; background: transparent; color: var(--text); font: 12px var(--mono); text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.ui-sugg-opt[aria-selected="true"] { background: var(--accent-dim); color: var(--accent-strong); }
.ui-sugg-group { position: sticky; top: 0; z-index: 1; padding: 3px var(--s-3); background: var(--surface-raised); font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.ui-menu { position: relative; display: inline-block; }
.ui-menu > summary { list-style: none; cursor: pointer; }
.ui-menu > summary::-webkit-details-marker { display: none; }
.ui-menu-caret { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: 0.6; }
.ui-menu-list { position: absolute; top: calc(100% + 6px); z-index: 40; min-width: 300px; padding: 6px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); display: grid; gap: 2px; }
.ui-menu.end .ui-menu-list { right: 0; }
.ui-menu.start .ui-menu-list { left: 0; }
.ui-menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: inherit; text-decoration: none; }
.ui-menu-item:hover, .ui-menu-item:focus-visible { background: var(--surface-hover); }
.ui-menu-item .icon { width: 18px; height: 18px; flex: none; }
.ui-menu-item span { display: grid; }
.ui-menu-item strong { font-size: 13px; font-weight: 550; }
.ui-menu-item small { font-size: 12px; color: var(--text-muted); }

/* Filters: a row of filter controls; under 760px a button opening them (ui.filters). */
.ui-filters { position: relative; display: flex; align-items: center; }
.ui-filters-toggle { display: none; height: 32px; padding: 0 var(--s-3); font-size: 12.5px; }
.ui-filters-toggle .icon { width: 15px; height: 15px; }
.ui-filters-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent-dim); color: var(--accent-strong); font-size: 11px; line-height: 18px; text-align: center; }
.ui-filters-body { display: flex; align-items: center; gap: var(--s-3); }
@media (max-width: 760px) {
  .ui-filters-toggle { display: inline-flex; }
  .ui-filters-body { display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; width: min(300px, calc(100vw - 2 * var(--s-4))); padding: var(--s-3); flex-direction: column; align-items: stretch; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); }
  .ui-filters.open .ui-filters-body { display: flex; }
  .ui-filters-body > select, .ui-filters-body > input { width: 100%; min-width: 0; }
}

/* table children: a caret opens the rows under a row. */
.ui-tree-row { cursor: pointer; }
.ui-tree-toggle, .ui-tree-pad { display: inline-flex; width: 20px; height: 20px; margin: -2px 6px -2px -4px; vertical-align: middle; }
.ui-tree-toggle { align-items: center; justify-content: center; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-muted); cursor: pointer; }
.ui-tree-toggle:hover { background: var(--border-soft); color: var(--text); }
.ui-tree-toggle span { width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.ui-tree-toggle[aria-expanded="true"] span { transform: rotate(45deg); }
.ui-subrow td { color: var(--text-muted); font-size: .92em; }
.ui-subrow td:first-child { padding-left: 46px; }
.ui-panel.flush table .ui-subrow td:first-child { padding-left: 50px; }

/* Rows whose order matters: dragged into place by the grip. */
.ui-row-sortable { cursor: grab; }
.ui-row-sortable.dragging { opacity: .5; }
.ui-row-sortable.drop-target td { box-shadow: inset 0 2px 0 var(--accent); }
.ui-row-grip { color: var(--text-muted); font-size: 16px; line-height: 1; user-select: none; }

/* Drawer: a right-hand panel with a stack of views (ui.drawer). */
.ui-drawer {
  width: min(760px, 94vw); max-width: none; height: 100dvh; max-height: 100dvh;
  margin: 0 0 0 auto; padding: 0; border: 0; border-left: 1px solid var(--border); border-radius: 0;
  background: var(--surface); color: var(--text); box-shadow: -24px 0 60px rgba(3, 5, 8, .22);
}
.ui-drawer.lg { width: min(1040px, 94vw); }
.ui-drawer[open] { display: flex; flex-direction: column; animation: ui-drawer-in 220ms cubic-bezier(.22, 1, .36, 1); }
@keyframes ui-drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .ui-drawer[open] { animation: none; } }
.ui-drawer-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border-soft, var(--border)); }
.ui-drawer-title { flex: 1; min-width: 0; }
.ui-drawer-title h2 { margin: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-drawer-title .eyebrow { margin: 0 0 2px; }
.ui-drawer-views { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ui-drawer-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ui-drawer-view[hidden] { display: none; }
.ui-drawer-body { flex: 1; min-height: 0; overflow: auto; padding: var(--s-5); }
.ui-drawer-foot { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border-soft, var(--border)); }
.ui-drawer-foot .error { margin: 0 auto 0 0; color: var(--danger, #c0392b); font-size: 13px; }

/* --- Data dashboards --------------------------------------------------------
   ui.kpi, ui.panel, ui.dgrid, ui.segmented, ui.rank, ui.appMark, ui.skeleton.
   The colour says what a number means: accent use, success good, danger risk,
   warn medium, info neutral facts, violet personal data. */

.t-accent { --tone: var(--accent); --tone-dim: var(--accent-dim); }
.t-success { --tone: var(--success); --tone-dim: var(--success-dim); }
.t-danger { --tone: var(--danger); --tone-dim: var(--danger-dim); }
.t-warn { --tone: var(--warn); --tone-dim: var(--warn-dim); }
.t-info { --tone: var(--info); --tone-dim: var(--info-dim); }
.t-violet { --tone: #a855f7; --tone-dim: color-mix(in srgb, #a855f7 16%, transparent); }
.t-neutral { --tone: var(--text-muted); --tone-dim: var(--surface-raised); }

.ui-dgrid { display: grid; gap: 14px; min-width: 0; }
.ui-dgrid.c6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.ui-dgrid.c5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ui-dgrid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ui-dgrid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ui-dgrid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .ui-dgrid.c6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) { .ui-dgrid.c5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .ui-dgrid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .ui-dgrid.c3, .ui-dgrid.c2 { grid-template-columns: minmax(0, 1fr); } .ui-dgrid.c6, .ui-dgrid.c5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .ui-dgrid.c6, .ui-dgrid.c5, .ui-dgrid.c4 { grid-template-columns: minmax(0, 1fr); } }

.ui-dash-ico { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; flex: none; background: var(--tone-dim); color: var(--tone); }
.ui-dash-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* KPI */
.ui-kpi { position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 16px 16px 14px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden; }
.ui-kpi-head { display: flex; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 550; color: var(--text-muted); min-width: 0; }
.ui-kpi-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-kpi-value { font-size: 30px; line-height: 1; font-weight: 680; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--text); }
.ui-kpi-value.t-danger, .ui-kpi-value.t-warn, .ui-kpi-value.t-violet { color: var(--tone); }
.ui-kpi-foot { display: flex; align-items: center; gap: 8px; min-height: 20px; flex-wrap: wrap; position: relative; z-index: 1; }
.ui-kpi-note { font-size: 12px; color: var(--text-muted); }
.ui-kpi-spark { position: absolute; right: 12px; bottom: 12px; opacity: 0.9; }
.ui-kpi-info { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: auto; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: none; color: var(--text-dim); font: italic 600 10px/1 inherit; cursor: help; }
.ui-kpi-info:hover, .ui-kpi-info:focus-visible { color: var(--text); border-color: var(--text-muted); }
.ui-kpi-tip { position: absolute; z-index: 3; top: 42px; left: 10px; right: 10px; padding: 9px 11px; border-radius: 10px; background: var(--text); color: var(--surface); font-size: 12px; font-weight: 450; line-height: 1.45; white-space: normal; box-shadow: var(--shadow-sm); opacity: 0; visibility: hidden; transform: translateY(-2px); transition: opacity 0.12s, transform 0.12s, visibility 0.12s; pointer-events: none; }
.ui-kpi-info:hover + .ui-kpi-tip, .ui-kpi-info:focus-visible + .ui-kpi-tip { opacity: 1; visibility: visible; transform: none; }
.ui-spark .line { fill: none; stroke: var(--tone); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ui-spark .area { fill: var(--tone-dim); stroke: none; }
.ui-delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ui-delta.good { color: var(--success); background: var(--success-dim); }
.ui-delta.bad { color: var(--danger); background: var(--danger-dim); }
.ui-delta.flat { color: var(--text-muted); background: var(--surface-raised); }
.ui-delta.new { color: var(--accent-strong); background: var(--accent-dim); text-transform: lowercase; }

/* Panel */
.ui-panel { display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; box-shadow: var(--shadow-sm); padding: 18px 20px; }
.ui-panel.flush { padding: 0; overflow: hidden; }
.ui-panel.flush .ui-panel-head { padding: 18px 20px 12px; margin: 0; }
.ui-panel.flush .ui-panel-foot { padding: 10px 20px 14px; }
.ui-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ui-panel-head h3 { margin: 0; font-size: 15px; font-weight: 640; letter-spacing: -0.015em; color: var(--text); }
.ui-panel-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.ui-panel-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.ui-panel-body { flex: 1; min-width: 0; }
.ui-panel-foot { margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.ui-panel.flush table th:first-child, .ui-panel.flush table td:first-child { padding-left: 20px; }
.ui-panel.flush table th:last-child, .ui-panel.flush table td:last-child { padding-right: 20px; }

/* Segmented control */
.ui-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-raised); border: 1px solid var(--border-soft); }
.ui-seg button { border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: 7px; cursor: pointer; font-variant-numeric: tabular-nums; }
.ui-seg button:hover { color: var(--text); }
.ui-seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ui-seg.small button { padding: 4px 10px; font-size: 12px; }

/* Ranked list */
.ui-rank { display: grid; gap: 12px; }
.ui-rank-row { display: grid; gap: 6px; }
.ui-rank-row[hidden] { display: none; }
.ui-rank-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text); }
.ui-rank-top span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-rank-top b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ui-rank-top b small { font-weight: 450; color: var(--text-muted); margin-left: 4px; }
.ui-rank-bar { height: 4px; border-radius: 4px; background: var(--surface-raised); overflow: hidden; }
.ui-rank-bar i { display: block; width: 0; height: 100%; border-radius: 4px; background: var(--tone); transition: width 400ms var(--ease, ease); }
.ui-rank-more { justify-self: start; margin-top: 2px; }
.ui-rank-empty { margin: 8px 0; font-size: 13px; color: var(--text-muted); }

/* App marks */
.ui-app { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.ui-app-name { display: grid; min-width: 0; }
.ui-app-name strong { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-app-name small { font-size: 11.5px; color: var(--text-muted); }
.ui-app-logo { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 6px; }
.ui-app-logo svg { width: 18px; height: 18px; color: var(--text); }
.ui-app-logo.letter { font-size: 10.5px; font-weight: 700; color: #fff; }
.ui-app-logo.h0 { background: #5b8cff; } .ui-app-logo.h1 { background: #22a06b; } .ui-app-logo.h2 { background: #e8a317; } .ui-app-logo.h3 { background: #8b5cf6; }
.ui-app-logo.h4 { background: #ec4899; } .ui-app-logo.h5 { background: #14b8a6; } .ui-app-logo.h6 { background: #f97316; } .ui-app-logo.h7 { background: #64748b; }

/* Skeleton */
.ui-skeleton { display: grid; gap: 14px; }
.ui-kpi.sk, .ui-panel.sk { min-height: 112px; gap: 12px; }
.ui-panel.sk.tall { min-height: 300px; }
.sk i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-raised), var(--surface-hover), var(--surface-raised)); background-size: 200% 100%; animation: ui-sk 1.2s linear infinite; }
.sk i:first-child { width: 45%; }
.sk i:nth-child(2) { width: 30%; height: 26px; }
@keyframes ui-sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk i, .ui-rank-bar i { animation: none; transition: none; } }
