.tk-panel { container-type: inline-size; }
.tk-filters { display: flex; align-items: center; gap: 8px; margin: 13px 0 17px; }
.tk-filters select {
  width: auto; max-width: 100%; padding-inline: 10px;
}
.tk-panel .badge { align-self: flex-end; font-size: var(--type-caption); padding: 3px 9px; }
.tk-panel .op-empty > svg { width: 25px; height: 25px; color: #796da4; margin-bottom: 6px; }

.tk-list { display: grid; gap: 12px; }
.tk-card {
  display: grid;
  grid-template-columns: minmax(175px,.78fr) minmax(270px,1.6fr) minmax(248px,.68fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--panel-shadow);
  background: #fff;
}
.tk-identity {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 12px; padding: 22px 24px;
  background: linear-gradient(120deg, #eeebfa, #f7f5fd);
  border-right: 1px solid #e7e4f2;
}
.tk-mark {
  display: grid; place-items: center; width: 39px; height: 39px; flex: none;
  border-radius: var(--radius-panel); color: #fff; background: #6655a7;
}
.tk-mark svg { width: 22px; height: 22px; }
.tk-grants { display: flex; flex-wrap: wrap; gap: 4px; }
.tk-grant { display: inline-flex; gap: 4px; align-items: center; padding: 2px 7px; border: 1px solid #d5d0e9; border-radius: var(--radius-panel); background: #fbfaff; color: #54477a; font-size: var(--small-label); font-weight: 630; }
.tk-grant svg { width: 12px; height: 12px; }
.tk-grant-read { color: #365c58; border-color: #c7dbd6; background: #f6fcfa; }
.tk-grant-write { color: #805221; border-color: #e6d6ba; background: #fffaf1; }
.tk-identity h2 { font-size: clamp(17px,1.3vw,21px); line-height: 1.4; color: #302a4a; overflow-wrap: anywhere; }
.tk-identity small { color: #685d83; font-size: var(--type-caption); }
.tk-identity .mono { font-size: var(--type-caption); }
.tk-disabled .tk-identity { background: #f4f5f8; border-color: #e7e8ef; }
.tk-disabled .tk-mark { background: #72788b; }
.tk-scope { min-width: 0; align-self: center; padding: 20px clamp(16px,2vw,32px); }
.tk-scope dl { display: grid; gap: 13px; margin: 0; }
.tk-scope dl > div { display: grid; grid-template-columns: 80px minmax(0,1fr); align-items: baseline; gap: 9px; }
.tk-scope dt { color: #59677c; font-size: var(--type-caption); }
.tk-scope dd { display: flex; align-items: center; flex-wrap: wrap; margin: 0; gap: 4px 7px; color: #49546b; font-size: var(--type-ui); }
.tk-platform { padding: 2px 7px; border-radius: var(--radius-small); border: 1px solid #e2e6ed; background: #f9fafc; color: #495267; font-size: var(--type-caption); }
.tk-kind { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; }
.tk-kind svg { width: 15px; height: 15px; color: #76699f; }
.tk-members { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.tk-members a { color: var(--blue-strong); font-size: var(--type-ui); font-weight: 600; }
.tk-members a + a::before { content: "·"; color: #8490a3; margin-right: 8px; }
.tk-members a:hover { text-decoration: underline; }
.tk-read-scope { min-width: 0; }
.tk-read-scope summary { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; list-style: none; color: var(--blue-strong); }
.tk-read-scope summary svg { flex: none; height: 13px; width: 13px; }
.tk-read-scope[open] summary svg { transform: rotate(90deg); }
.tk-read-scope > div { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 4px; }
.tk-actions { display: flex; align-items: flex-end; justify-content: space-between; flex-direction: column; gap: 18px; padding: 20px 20px 20px 0; }
.tk-row-buttons { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.tk-row-buttons .tk-edit { border-radius: var(--control-radius); color: var(--blue-strong); min-height: 32px; }
.tk-actions .btn.tk-stop { border-color: #e7d9dc; border-radius: var(--control-radius); background: white; color: #99424b; min-height: 32px; padding: 4px 11px; }
.tk-actions .btn.tk-stop:hover { background: #fff4f3; border-color: #d3a8ab; color: #84363f; }
@container (max-width: 850px) {
  .tk-card { grid-template-columns: minmax(175px,.72fr) minmax(215px,1.4fr); }
  .tk-identity { padding-inline: 18px; }
  .tk-scope { padding-inline: 17px; }
  .tk-scope dl > div { grid-template-columns: 80px minmax(0,1fr); }
  .tk-actions { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 10px; padding: 9px 16px; min-height: 44px; border-top: 1px solid #e8eaf1; }
  .tk-panel .badge { align-self: center; }
}
@container (max-width: 640px) {
  .tk-card { grid-template-columns: minmax(0,1fr); }
  .tk-identity { gap: 8px 14px; padding: 14px 16px; border: 0; border-bottom: 1px solid #e7e4f2; }
  .tk-identity { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; }
  .tk-identity .tk-grants { grid-column: 2; }
  .tk-identity .tk-mark { width: 32px; height: 32px; border-radius: var(--control-radius); }
  .tk-identity .tk-mark svg { width: 17px; height: 17px; }
  .tk-scope { padding: 17px 16px; }
  .tk-scope dl { gap: 12px; }
  .tk-panel .tk-filters { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 6px; }
  .tk-filters .op-search { grid-column: 1 / -1; width: 100%; }
  .tk-panel .tk-filters .op-search input, .tk-panel .tk-filters select { width: 100%; }
}

@container (max-width: 380px) {
  .tk-actions { display: grid; justify-content: stretch; }
  .tk-panel .tk-actions > .badge { justify-self: start; }
  .tk-row-buttons { display: grid; grid-template-columns: auto auto auto; justify-content: stretch; gap: 5px; }
  .tk-row-buttons .btn { padding-inline: 6px; white-space: nowrap; }
}

dialog.cloud-modal:has(.tk-editor) { width: 566px; }
.cloud-modal .dialog-body:has(.tk-editor, .tk-confirm-body) { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.cloud-modal form[data-form="token"] { display: flex; flex-direction: column; min-height: 0; }
.cloud-modal .tk-editor, .cloud-modal .tk-confirm-body { overflow-y: auto; min-height: 0; padding: 16px clamp(14px, 4vw, 22px); }
.cloud-modal form[data-form="token"] .form-end, .cloud-modal .tk-confirm-body + .cm-actions { flex: none; margin: 0; padding: 10px clamp(14px, 4vw, 22px); background: white; }
.tk-field-error { margin: 0 0 8px; color: #9d293b; font-size: var(--type-caption); }
.tk-card h2:focus-visible { outline: 2px solid var(--blue-strong); outline-offset: 3px; }
.cloud-modal .tk-editor [hidden] { display: none; }
.cloud-modal .tk-permission-list { display: grid; gap: 8px; margin: 0 0 14px; }
.cloud-modal .tk-permission-list > legend { margin-bottom: 2px; }
.tk-permission { min-width: 0; border: 1px solid #dddfe9; border-radius: var(--radius-panel); overflow: hidden; }
.tk-permission:has(> .tk-permission-head input:checked) { border-color: #bdb3e4; }
.tk-permission-head { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; cursor: pointer; }
.tk-permission-head:hover { background: #f9f8fb; }
.tk-permission-head:has(input:checked) { background: #f6f4fc; }
.cloud-modal .tk-permission-head input { width: 16px; height: 16px; flex: none; margin-top: 3px; }
.tk-permission-head strong, .tk-permission-head small { display: block; }
.tk-permission-head strong { color: #342f4b; font-size: var(--type-body); line-height: 21px; }
.tk-permission-head small { color: #626b7b; font-size: var(--type-caption); line-height: 1.6; margin-top: 2px; }
.cloud-modal .tk-permission-body { border: 0; border-top: 1px solid #e5e1ef; margin: 0; padding: 10px 13px 12px; }
.cloud-modal .tk-options { margin: 0; padding: 0; border: 0; }
.cloud-modal .tk-options + .tk-options { margin-top: 10px; }
.tk-options > div { display: flex; flex-wrap: wrap; gap: 5px; }
.tk-options label { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 8px; border: 1px solid #dce0e8; border-radius: var(--control-radius); color: #505a6c; font-size: var(--type-caption); cursor: pointer; }
.tk-options label:has(input:checked) { background: #f6f4fc; border-color: #d4cbed; color: #50427c; }
.tk-options label:hover { border-color: #ad9dd8; }
.tk-options input { width: 13px; height: 13px; }
.tk-editor .field:last-child { margin-bottom: 0; }
