/* Конструктор своих дашбордов (COSPYRO Workspace Builder) + левая панель-док перетягивания виджетов. */

.cb-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none;
  padding: 5px 14px 3px; border-bottom: 1px solid rgba(255, 255, 255, .055);
  background: rgba(255, 255, 255, .015); min-height: 34px;
}
.cb-tabs { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.cb-tabs::-webkit-scrollbar { display: none; }
.cb-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; flex: none;
  font-size: 11px; font-weight: 500; color: var(--muted); background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(255, 255, 255, .07); white-space: nowrap;
  transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.cb-tab:hover { color: var(--ink); background: var(--glass); }
.cb-tab.on {
  color: #0b0b0d; background: var(--metal-hi); border-color: transparent; font-weight: 600;
  box-shadow: inset 0 1px 0 #fff, 0 2px 10px -4px rgba(255, 255, 255, .32);
}
.cb-tab-add { border-style: dashed; border-color: rgba(255, 255, 255, .2); color: var(--soft); }
.cb-tab-add:hover { border-style: solid; border-color: rgba(255, 255, 255, .36); color: var(--ink); }
.cb-acts { display: flex; align-items: center; gap: 5px; flex: none; }
.cb-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 11px; font-weight: 500; color: var(--muted); background: rgba(255, 255, 255, .04);
  border: 1px solid var(--rule); white-space: nowrap; transition: background .12s var(--ease), color .12s var(--ease);
}
.cb-btn:hover { color: var(--ink); background: var(--glass-2); }
.cb-btn.on { color: #0b0b0d; background: var(--metal-hi); border-color: transparent; font-weight: 600; }
.cb-btn.ok { color: var(--up); border-color: rgba(76, 195, 138, .42); background: rgba(76, 195, 138, .1); }
.cb-btn.ok:hover { background: rgba(76, 195, 138, .18); }
.cb-btn.dn:hover { color: var(--down); border-color: rgba(229, 99, 107, .42); }

/* ---------- сцена конструктора: левый док + 12-колоночная сетка ---------- */
.cb-stage {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}
.cb-dock {
  width: 246px; flex: none; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  border-right: 1px solid var(--rule); background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .015));
  padding: 9px 10px 10px; animation: pageIn .13s var(--ease);
}
.cb-dock-h { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; flex: none; }
.cb-dock-h b { font: 500 10.5px/1 var(--disp); letter-spacing: .7px; text-transform: uppercase; color: var(--soft); }
.cb-dock-h span { font-size: 10px; color: var(--faint); }
.cb-dock-q {
  width: 100%; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--rule);
  background: rgba(255, 255, 255, .05); color: var(--ink); font: 11.5px var(--body); outline: none; margin-bottom: 8px; flex: none;
}
.cb-dock-q:focus { border-color: var(--rule-2); background: rgba(255, 255, 255, .08); }
.cb-dock-q::placeholder { color: var(--faint); }
.cb-dock-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 2px; }
.cb-dock-cat {
  font-size: 9.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .8px;
  padding: 7px 4px 2px; font-weight: 600;
}
.cb-dock-cat:first-child { padding-top: 0; }
.cb-dock-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: 9px; background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(255, 255, 255, .07); cursor: grab; user-select: none;
  transition: background .11s var(--ease), border-color .11s var(--ease), transform .11s var(--ease);
}
.cb-dock-item:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); }
.cb-dock-item:active { cursor: grabbing; transform: scale(.985); }
.cb-dock-grip { color: var(--faint); font-size: 11px; letter-spacing: -1px; }
.cb-dock-meta { min-width: 0; }
.cb-dock-meta b { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-dock-meta small { display: block; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.cb-dock-add {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--rule); color: var(--soft); font-size: 13px; line-height: 1;
}
.cb-dock-add:hover { background: var(--metal-hi); color: #0b0b0d; border-color: transparent; }

/* плавающий превью-чип при перетягивании виджета из левого дока */
.cb-drag-pill {
  position: fixed; z-index: 200; pointer-events: none; padding: 7px 11px; border-radius: 10px;
  background: #16181d;
  border: 1px solid rgba(56, 189, 248, .75); box-shadow: 0 14px 36px -8px rgba(0, 0, 0, .9);
  font-size: 11.5px; font-weight: 600; color: var(--ink); white-space: nowrap;
  transform: translate(-50%, -50%);
}
.cb-drag-pill small { color: #38bdf8; font-weight: 500; margin-left: 6px; font-size: 10px; }

/* ---------- сетка пользовательского дашборда (12 / 16 / 24 колонки + масштаб) ---------- */
.content.cb-grid {
  position: relative; flex: 1; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 8px 14px 14px;
  display: grid; grid-template-columns: repeat(var(--cb-cols, 12), minmax(0, 1fr));
  grid-auto-rows: var(--cb-row, 114px);
  gap: var(--cb-gap, 9px); align-content: start;
}
.content.cb-grid.cb-edit {
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: calc((100% - 28px) / var(--cb-cols, 12)) calc(var(--cb-row, 114px) + var(--cb-gap, 9px));
  background-position: 14px 8px;
}
.content.cb-grid.dens-dense { --cb-gap: 6px; padding: 6px 10px 10px; font-size: 11.5px; }
.content.cb-grid.dens-dense .cb-w { padding: 6px 8px; border-radius: 10px; }
.content.cb-grid.dens-dense .cb-hd { margin-bottom: 3px; min-height: 17px; }
.content.cb-grid.dens-dense .dt-t { font-size: 9.5px; }
.content.cb-grid.dens-dense .d-row, .content.cb-grid.dens-dense .live-row, .content.cb-grid.dens-dense .lv-row { padding: 3px 6px; font-size: 10px; }
.content.cb-grid.dens-ultra { --cb-gap: 5px; padding: 5px 8px 8px; font-size: 10.5px; }
.content.cb-grid.dens-ultra .cb-w { padding: 4px 6px; border-radius: 8px; }
.content.cb-grid.dens-ultra .cb-hd { margin-bottom: 2px; min-height: 15px; }
.content.cb-grid.dens-ultra .dt-t { font-size: 9px; letter-spacing: .3px; }
.content.cb-grid.dens-ultra .d-row, .content.cb-grid.dens-ultra .live-row, .content.cb-grid.dens-ultra .lv-row, .content.cb-grid.dens-ultra .cb-tbl { font-size: 9.5px; padding: 2px 5px; }
.content.cb-grid.dens-ultra .px-val { font-size: 14px; }
.content.cb-grid.dens-ultra .cb-ci-box b { font-size: 10.5px; }

/* акцентные подсветки и индивидуальный масштаб виджета */
.cb-w.acc-up { box-shadow: inset 0 1px 0 rgba(76, 195, 138, .55), 0 0 0 1px rgba(76, 195, 138, .28), var(--pane-shadow); }
.cb-w.acc-down { box-shadow: inset 0 1px 0 rgba(229, 99, 107, .55), 0 0 0 1px rgba(229, 99, 107, .28), var(--pane-shadow); }
.cb-w.acc-warn { box-shadow: inset 0 1px 0 rgba(212, 176, 114, .55), 0 0 0 1px rgba(212, 176, 114, .28), var(--pane-shadow); }
.cb-w.acc-blue { box-shadow: inset 0 1px 0 rgba(56, 189, 248, .55), 0 0 0 1px rgba(56, 189, 248, .28), var(--pane-shadow); }
.cb-w.fs-sm .cb-body { font-size: 86%; }
.cb-w.fs-lg .cb-body { font-size: 112%; }

/* 5 зон растягивания: левый край, правый край, нижний край, левый-низ и правый-низ */
.cb-rsz { display: none; position: absolute; z-index: 16; }
.cb-grid.cb-edit .cb-rsz { display: block; }
.cb-rsz-l { left: 0; top: 22px; bottom: 14px; width: 7px; cursor: ew-resize; }
.cb-rsz-r { right: 0; top: 22px; bottom: 14px; width: 7px; cursor: ew-resize; }
.cb-rsz-b { left: 14px; right: 14px; bottom: 0; height: 7px; cursor: ns-resize; }
.cb-rsz-l:hover, .cb-rsz-r:hover { background: rgba(56, 189, 248, .28); }
.cb-rsz-b:hover { background: rgba(56, 189, 248, .28); }
.cb-rsz-br { right: 1px; bottom: 1px; width: 16px; height: 16px; cursor: nwse-resize; border-radius: 0 0 10px 0; }
.cb-rsz-br::after {
  content: ""; position: absolute; right: 3px; bottom: 3px; width: 7px; height: 7px;
  border-right: 2px solid rgba(255, 255, 255, .45); border-bottom: 2px solid rgba(255, 255, 255, .45); border-radius: 0 0 2px 0;
}
.cb-rsz-bl { left: 1px; bottom: 1px; width: 16px; height: 16px; cursor: nesw-resize; border-radius: 0 0 0 10px; }
.cb-rsz-bl::after {
  content: ""; position: absolute; left: 3px; bottom: 3px; width: 7px; height: 7px;
  border-left: 2px solid rgba(255, 255, 255, .45); border-bottom: 2px solid rgba(255, 255, 255, .45); border-radius: 0 0 0 2px;
}
.cb-rsz-br:hover::after, .cb-rsz-bl:hover::after { border-color: #38bdf8; }
.cb-dens-seg { display: inline-flex; gap: 1px; padding: 2px; border-radius: 999px; background: rgba(255,255,255,.04); border: 1px solid var(--rule); }
.cb-dens-seg button { height: 20px; padding: 0 7px; border-radius: 999px; font-size: 10px; color: var(--muted); }
.cb-dens-seg button:hover { color: var(--ink); }
.cb-dens-seg button.on { background: var(--metal-hi); color: #0b0b0d; font-weight: 600; }

.cb-w {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  padding: 8px 10px; border-radius: 13px; overflow: hidden;
  transition: box-shadow .12s var(--ease), border-color .12s var(--ease);
}
.cb-grid.cb-edit .cb-w { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), var(--pane-shadow); }
.cb-grid.cb-edit .cb-w.dragging { opacity: .52; z-index: 25; }
.cb-grid.cb-edit .cb-w.resizing { z-index: 25; box-shadow: inset 0 0 0 1px rgba(56, 189, 248, .75), var(--pane-shadow); }

.cb-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  flex: none; margin-bottom: 5px; min-height: 20px;
}
.cb-grid.cb-edit .cb-hd { cursor: grab; user-select: none; }
.cb-grid.cb-edit .cb-hd:active { cursor: grabbing; }
.cb-hd-l { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cb-grip { display: none; color: var(--faint); font-size: 12px; letter-spacing: -1px; line-height: 1; }
.cb-grid.cb-edit .cb-grip { display: inline-block; }
.cb-hd-r { display: flex; align-items: center; gap: 4px; flex: none; }
.cb-ic {
  display: none; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 6px;
  font-size: 11px; color: var(--muted); background: rgba(255, 255, 255, .06); border: 1px solid var(--rule);
}
.cb-grid.cb-edit .cb-ic { display: inline-flex; }
.cb-ic:hover { color: var(--ink); background: var(--glass-2); }
.cb-ic.del:hover { color: var(--down); border-color: rgba(229, 99, 107, .5); }

.cb-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; position: relative; container-type: inline-size; }
/* мини-скринер в узком виджете: второстепенные столбцы (4ч, RSI, затем Fund) прячем, а не обрезаем таблицу справа */
@container (max-width: 360px) {
  .cb-tbl th:nth-child(3), .cb-tbl td:nth-child(3), .cb-tbl th:nth-child(5), .cb-tbl td:nth-child(5) { display: none; }
}
@container (max-width: 250px) {
  .cb-tbl th:nth-child(6), .cb-tbl td:nth-child(6) { display: none; }
}

.cb-ghost {
  pointer-events: none; z-index: 20; border-radius: 13px;
  background: rgba(56, 189, 248, .13); border: 1.5px dashed rgba(56, 189, 248, .72);
}

/* поповер настроек виджета */
.cb-cfg {
  position: absolute; right: 8px; top: 32px; z-index: 30; width: 224px; padding: 10px 11px; border-radius: 11px;
  background: #15161b; border: 1px solid var(--rule-2); transform-origin: 100% 0; animation: popIn .14s var(--ease);
  box-shadow: 0 18px 46px -14px rgba(0, 0, 0, .92); display: flex; flex-direction: column; gap: 7px; font-size: 11.5px;
}
@media (prefers-reduced-motion: reduce) { .cb-cfg { animation: none; } }
.cb-cfg label { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .5px; }
.cb-cfg select, .cb-cfg input {
  height: 27px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--rule);
  background: rgba(255, 255, 255, .06); color: var(--ink); font: 12px var(--body); outline: none;
}
.cb-cfg select option { background: #141418; color: var(--ink); }
.cb-sz-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.cb-sz-row button {
  height: 24px; border-radius: 6px; font-size: 10.5px; color: var(--muted);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--rule);
}
.cb-sz-row button:hover { color: var(--ink); background: var(--glass-2); }

.cb-empty {
  grid-column: 1 / -1; grid-row: 1 / span 4; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; border: 1.5px dashed var(--rule); border-radius: 15px;
  color: var(--muted); padding: 32px; text-align: center;
}
.cb-empty b { font-size: 15px; color: var(--ink); }

/* модалка шаблонов */
.cb-modal {
  position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 18px;
  background: rgba(4, 4, 6, .72); animation: fadeIn .16s var(--ease);
}
.cb-modal .cb-box { animation: modalIn .2s var(--ease); }
@media (prefers-reduced-motion: reduce) { .cb-modal, .cb-modal .cb-box { animation: none; } }
.cb-box { width: min(760px, 100%); max-height: 84vh; display: flex; flex-direction: column; overflow: hidden; }
.cb-box .p-body { overflow-y: auto; padding-top: 4px; }
.cb-name-in {
  width: 100%; height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--rule-2);
  background: var(--glass); color: var(--ink); font: 13px var(--body); outline: none; margin-bottom: 10px;
}
.cb-tpls, .cb-cat { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px; }
.cb-card {
  text-align: left; padding: 11px 12px; border-radius: 11px; background: rgba(255, 255, 255, .04);
  border: 1px solid var(--rule); display: flex; flex-direction: column; gap: 4px;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.cb-card:hover { background: rgba(255, 255, 255, .085); border-color: var(--rule-2); }
.cb-card b { font-size: 12.5px; color: var(--ink); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cb-card small { font-size: 11px; color: var(--muted); line-height: 1.35; }
.cb-card em { font-style: normal; font-size: 9.5px; color: var(--faint); padding: 1px 6px; border-radius: 999px; border: 1px solid var(--rule); }

/* ---------- стили виджетов внутри конструктора ---------- */
.cb-w .d-chart-top { margin-bottom: 3px; }
.cb-w .d-chart-box { flex: 1; min-height: 80px; width: 100%; }
.cb-w .tv-wrap { position: relative; flex: 1; min-height: 110px; border-radius: 8px; overflow: hidden; }
.cb-w .reg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); gap: 5px; overflow-y: auto; }
.cb-w .reg-mini { padding: 5px 7px; border-radius: 7px; background: rgba(255, 255, 255, .035); border: 1px solid rgba(255, 255, 255, .06); font-size: 10.5px; }
.cb-w .reg-mini b { display: block; font-size: 12px; margin-top: 1px; }
.cb-w .pa-mini-form { display: grid; grid-template-columns: 64px 46px 1fr auto; gap: 4px; margin-bottom: 5px; flex: none; }
.cb-w .pa-mini-form select, .cb-w .pa-mini-form input {
  height: 24px; padding: 0 5px; border-radius: 6px; border: 1px solid var(--rule);
  background: var(--glass); color: var(--ink); font-size: 11px; outline: none; min-width: 0;
}
.cb-w .pa-mini-form select option { background: #141418; color: var(--ink); }

/* мини-таблица скринера / инфо по монете / стакан / мини-калькулятор */
.cb-tbl { width: 100%; border-collapse: collapse; font-size: 11px; }
.cb-tbl th { text-align: right; color: var(--faint); font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px; padding: 4px 5px; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: #121216; }
.cb-tbl td { text-align: right; padding: 5px 5px; border-bottom: 1px solid rgba(255, 255, 255, .05); white-space: nowrap; }
.cb-tbl th:first-child, .cb-tbl td:first-child { text-align: left; }
.cb-tbl tr:hover td { background: rgba(255, 255, 255, .04); }
.cb-ci-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-top: 6px; overflow-y: auto; }
.cb-ci-box { padding: 5px 7px; border-radius: 8px; background: rgba(255, 255, 255, .035); border: 1px solid rgba(255, 255, 255, .06); font-size: 10.5px; }
.cb-ci-box small { display: block; color: var(--faint); font-size: 9.5px; }
.cb-ci-box b { font-size: 12px; font-weight: 600; }
.cb-ob-bars { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; flex: none; }
.cb-ob-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 6px; align-items: center; font-size: 10.5px; }
.cb-ob-track { height: 6px; border-radius: 999px; background: var(--glass-2); overflow: hidden; display: flex; }
.cb-ob-track i { display: block; height: 100%; }
.cb-calc-f { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-bottom: 6px; flex: none; }
.cb-calc-f label { display: flex; flex-direction: column; gap: 2px; font-size: 9.5px; color: var(--faint); text-transform: uppercase; }
.cb-calc-f input, .cb-calc-f select {
  height: 25px; padding: 0 7px; border-radius: 6px; border: 1px solid var(--rule);
  background: var(--glass); color: var(--ink); font-size: 11.5px; outline: none; min-width: 0;
}
.cb-calc-f select option { background: #141418; }
.cb-calc-res { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-top: auto; }
.cb-calc-res div { padding: 5px 7px; border-radius: 8px; background: rgba(255, 255, 255, .04); border: 1px solid var(--rule); }
.cb-calc-res small { display: block; font-size: 9px; color: var(--faint); text-transform: uppercase; }
.cb-calc-res b { font-size: 12px; }
.cb-wg-svg { flex: 1; min-height: 110px; border-radius: 8px; background: rgba(0, 0, 0, .2); border: 1px solid var(--rule); overflow: hidden; }
.cb-wg-svg svg { width: 100%; height: 100%; display: block; }

@media (max-width: 959px) {
  .cb-bar { padding: 5px 8px; }
  .cb-hint { display: none; }
  .cb-stage { flex-direction: column; overflow: visible; }
  .cb-dock { width: 100%; max-height: 260px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .content.cb-grid { display: flex; flex-direction: column; overflow: visible; padding: 8px; gap: 8px; }
  .cb-w { grid-column: auto !important; grid-row: auto !important; min-height: 190px; }
  .cb-rsz { display: none !important; }
}
