/* Компоненты F1a (0002 `13` §3): кнопка, поле, чип, карточка, таблица, окно, вкладки, ползунок, уведомление.
   Владелец — F1a. Подключено в web/{studio,admin}/index.html (шов оркестратора). Вид — по CSS эталона
   `visualization.html`; классы окна — compact < 600, medium 600–1023, large ≥ 1024 (§1). Только классы и
   CSS-переменные: CSP `style-src 'self'` (`37` §3.1) не пускает встроенные стили. */

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .92em; font-variant-numeric: tabular-nums; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- кнопка: рамка, потом тень (Geist) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--ctl); padding: 0 12px;
  border: 1px solid var(--rule-2); background: var(--surface); color: var(--ink); border-radius: var(--r-ctl); cursor: pointer;
  white-space: nowrap; font-weight: 500; box-shadow: var(--shadow-1);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--g5); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; box-shadow: 0 1px 2px rgba(14,124,134,.3); }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }
.btn.soft { background: var(--accent-tint); border-color: transparent; color: var(--accent); box-shadow: none; }
.btn.soft:hover:not(:disabled) { filter: brightness(.97); }
.btn.ai { background: linear-gradient(135deg, var(--accent-tint), var(--surface)); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.btn.ai:hover:not(:disabled) { background: var(--accent-tint); }
.btn.danger { color: var(--err); }
.btn.danger:hover:not(:disabled) { background: var(--err-tint); border-color: var(--err); }
.btn.sm { height: var(--ctl-sm); padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.icon { width: var(--ctl); padding: 0; }
.btn.sm.icon { width: var(--ctl-sm); }
.btn .ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.sm .ico { width: 15px; height: 15px; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--rule-2); border-bottom-width: 2px;
  border-radius: 5px; color: var(--ink-2); background: var(--surface-2); line-height: 1.3; }
.btn.primary kbd { background: transparent; border-color: rgba(255,255,255,.4); color: inherit; }

/* ---------- поле ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
/* `display: flex` перекрывал атрибут `hidden` — скрытое поле было видно (пароль в «Скачать всё моё», FINFIX) */
.field[hidden] { display: none; }
.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 0; letter-spacing: .01em; }
.field input:not([type=range]), .field textarea, .field select {
  background: var(--surface); border: 1px solid var(--rule-2); border-radius: var(--r-ctl); height: var(--ctl); padding: 0 10px;
  min-width: 0; width: 100%; transition: border-color var(--dur), box-shadow var(--dur); }
.field textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-tint); }
.field input:disabled, .field textarea:disabled { background: var(--surface-2); color: var(--ink-2); cursor: not-allowed; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); opacity: 1; }
.field .help { margin: 0; font-size: 12px; color: var(--ink-2); }
.field .err { margin: 0; font-size: 12px; font-weight: 500; color: var(--err); background: var(--err-tint); border-radius: 8px; padding: 6px 9px; }
.field .err[hidden] { display: none; }
.field.invalid input, .field.invalid textarea, .field [aria-invalid="true"] { border-color: var(--err); }

/* ---------- ползунок ---------- */
.field.range .range-row { display: flex; align-items: center; gap: 12px; }
.field input[type=range] { flex: 1 1 auto; min-width: 0; min-height: 24px; margin: 0; accent-color: var(--accent); }
.field.range output { min-width: 3.5em; text-align: right; color: var(--ink); }

/* ---------- чип ---------- */
.chip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px; border: 1px solid var(--rule);
  border-radius: var(--r-chip); background: var(--surface); color: var(--ink); white-space: nowrap; font-weight: 500; font-size: 13px;
  transition: border-color var(--dur), background var(--dur); }
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--g5); background: var(--surface-2); }
.chip.accent { background: var(--accent-tint); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip.warn { background: var(--warn-tint); border-color: transparent; color: var(--warn); font-weight: 600; }
.chip.danger { background: var(--err-tint); border-color: transparent; color: var(--err); font-weight: 600; }
.chip.agent { background: var(--g10); color: var(--g0); border-color: transparent; font-weight: 600; }
button.chip.agent:hover { background: var(--g9); }
.chip .n { background: var(--accent); color: var(--on-accent); font: 600 11px var(--mono); padding: 1px 6px; border-radius: 999px; }
.chip.agent .n { background: var(--g0); color: var(--g10); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--g6); flex: none; }
.chip .dot.ok { background: var(--ok); }
.chip .dot.busy { background: var(--warn); }
.chip .dot.err { background: var(--err); }
.chip.agent .dot.ok { background: #5DCB8C; }
/* контурный значок в чипе (палитра команд `#cmdkBtn`) — как `.btn .ico`, без заливки (FINFIX: был чёрный круг) */
.chip .ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- карточка ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-card); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--rule-soft); min-height: 48px; flex-wrap: wrap; }
.card-h h2, .card-h h3 { font-size: 14px; margin: 0; font-weight: 600; }
.card-h .sub { color: var(--ink-2); font-size: 12.5px; }
.card-b { padding: 14px; }

/* ---------- таблица ---------- */
.tbl-scroll { overflow: auto; max-height: 320px; -webkit-overflow-scrolling: touch; border-radius: 0 0 var(--r-card) var(--r-card); }
.tbl-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.card-b > .tbl-scroll { margin: -14px; }
table.t { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--surface); }
table.t th { text-align: left; font-size: 11.5px; letter-spacing: .02em; color: var(--ink-3); font-weight: 600; padding: 9px 12px;
  border-bottom: 1px solid var(--rule); position: -webkit-sticky; position: sticky; top: 0; background: var(--surface); z-index: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.t td { padding: 0 12px; height: 40px; border-bottom: 1px solid var(--rule-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.t tr.sel td { background: var(--accent-soft); }
table.t td.num, table.t th.num { text-align: right; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.t th.acts, table.t td.acts { width: 112px; text-align: right; }
@media (max-width: 1179.98px) { table.t .p2 { display: none; } }
@media (max-width: 1359.98px) { table.t .p3 { display: none; } }

/* ---------- окно: нативный <dialog> + showModal() ---------- */
dialog.modal { padding: 0; margin: auto; color: var(--ink); background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-sheet); box-shadow: var(--shadow-3); width: min(600px, calc(100vw - 32px)); max-width: none;
  max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; animation: f1a-pop var(--dur) var(--ease); }
dialog.modal.wide { width: min(1000px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(6,10,16,.5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--rule-soft); }
.modal-h h2 { font-size: 16px; margin: 0; font-weight: 600; }
.modal-b { padding: 16px; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 14px; }
.modal-b p { margin: 0; }
.modal-f { padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--rule-soft); display: flex; gap: 8px;
  justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.grab { display: none; width: 40px; height: 5px; border-radius: 3px; background: var(--g4); margin: 8px auto 0; flex: none; }
@keyframes f1a-pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes f1a-sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- вкладки (APG) ---------- */
.tabbar { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface-2); margin: 0 0 12px; }
.tabbar [role=tab] { flex: 1; min-height: calc(var(--ctl) - 8px); border: 0; background: transparent; cursor: pointer; padding: 2px 10px;
  border-radius: 7px; white-space: nowrap; color: var(--ink-2); font-weight: 500; transition: background var(--dur), color var(--dur); }
.tabbar [role=tab]:hover { color: var(--ink); }
.tabbar [role=tab][aria-selected="true"] { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-1); }
.tabpanel { border-radius: 8px; }
.tabpanel p { margin: 0; }

/* ---------- уведомления ---------- */
.toasts { position: fixed; right: 16px; bottom: calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; z-index: 30;
  max-width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--g10); color: var(--g0); padding: 11px 14px; border-radius: 12px; box-shadow: var(--shadow-2); display: flex;
  gap: 12px; align-items: center; font-size: 13.5px; animation: f1a-pop var(--dur) var(--ease); }
.toast .toast-t { flex: 1 1 auto; min-width: 0; }
.toast.err .toast-t::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #F4857C; margin-right: 8px; }
.toast .btn { height: 28px; background: transparent; color: inherit; border-color: currentColor; box-shadow: none; }
.toast .btn.x { width: 28px; border-color: transparent; }
.toast .btn:hover:not(:disabled) { background: rgba(127,127,127,.25); border-color: currentColor; }

/* ---------- витрина /dev/ui ---------- */
.gallery { margin: 16px 0 0; }
.gallery > h2 { font-size: 16px; margin: 0 0 4px; }
.g-status { margin: 0 0 12px; color: var(--ink-2); }
.g-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); align-items: start; }
.g-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.g-row:last-child { margin-bottom: 0; }
.swatches { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; }
.swatches li { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.sw { width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--rule-2); flex: none; }
.sw[data-t="--g0"] { background: var(--g0); } .sw[data-t="--g1"] { background: var(--g1); } .sw[data-t="--g2"] { background: var(--g2); }
.sw[data-t="--g3"] { background: var(--g3); } .sw[data-t="--g4"] { background: var(--g4); } .sw[data-t="--g5"] { background: var(--g5); }
.sw[data-t="--g6"] { background: var(--g6); } .sw[data-t="--g7"] { background: var(--g7); } .sw[data-t="--g8"] { background: var(--g8); }
.sw[data-t="--g9"] { background: var(--g9); } .sw[data-t="--g10"] { background: var(--g10); }
.sw[data-t="--ink-3"] { background: var(--ink-3); } .sw[data-t="--rule-soft"] { background: var(--rule-soft); }
.sw[data-t="--accent"] { background: var(--accent); } .sw[data-t="--accent-strong"] { background: var(--accent-strong); }
.sw[data-t="--accent-tint"] { background: var(--accent-tint); } .sw[data-t="--accent-soft"] { background: var(--accent-soft); }
.sw[data-t="--on-accent"] { background: var(--on-accent); }
.sw[data-t="--spend"] { background: var(--spend); } .sw[data-t="--spend-tint"] { background: var(--spend-tint); }
.sw[data-t="--ok"] { background: var(--ok); } .sw[data-t="--ok-tint"] { background: var(--ok-tint); }
.sw[data-t="--warn"] { background: var(--warn); } .sw[data-t="--warn-tint"] { background: var(--warn-tint); }
.sw[data-t="--err"] { background: var(--err); } .sw[data-t="--err-tint"] { background: var(--err-tint); }
.sw[data-t="--claude"] { background: var(--claude); } .sw[data-t="--codex"] { background: var(--codex); }

/* ---------- medium 600–1023 ---------- */
@media (max-width: 1023.98px) {
  .tbl-scroll { overflow-x: auto; }
}

/* ---------- compact < 600: таблицы → карточки, окна → нижние листы, цели ≥ 40 ---------- */
@media (max-width: 599.98px) {
  .btn.sm { font-size: 14px; }
  .tabbar [role=tab] { min-height: 40px; }
  table.t, table.t tbody, table.t tr, table.t td { display: block; }
  table.t thead { display: none; }
  table.t tr { border-bottom: 1px solid var(--rule); padding: 10px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  table.t td { height: auto; padding: 2px 0; border: 0; white-space: normal; font-size: 13.5px; }
  table.t td::before { content: attr(data-l); display: block; font-size: 11px; color: var(--ink-3); font-weight: 600; }
  table.t td.num { text-align: left; }
  table.t td.acts { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; width: auto; text-align: left; }
  table.t td.acts::before { display: none; }
  table.t .p2, table.t .p3 { display: block; }
  dialog.modal, dialog.modal.wide { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 94%; max-height: 94dvh;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0; border-left: 0; border-right: 0; border-bottom: 0; }
  dialog.modal[open] { animation: f1a-sheet var(--dur) var(--ease); }
  .grab { display: block; }
  .modal-b { padding: 14px; }
  .modal-f .btn { flex: 1 1 auto; }
  .toasts { right: 12px; left: 12px; max-width: none; bottom: calc(84px + var(--safe-b)); }
  .toast { font-size: 14px; }
  .toast .btn { height: var(--ctl-sm); }
  .toast .btn.x { width: var(--ctl-sm); }
}
