/* ============================================================
   WORKSPACE STANDALONE — полностью автономные стили
   IDE-like resizable panels for LIMS configuration screens.
   Не зависит от precision-modernism.css, base_precision и т.п.
   ============================================================ */

/* --- Design tokens ------------------------------------------ */
:root {
    --ws-bg:            #f0f4f7;
    --ws-surface:       #ffffff;
    --ws-surface-alt:   #f6f9fb;
    --ws-border:        rgba(12, 31, 46, 0.10);
    --ws-border-strong: rgba(12, 31, 46, 0.16);
    --ws-text:          #12324d;
    --ws-muted:         #587283;
    --ws-primary:       #027fb7;
    --ws-primary-soft:  #dff2fb;
    --ws-primary-tint:  rgba(2, 127, 183, 0.10);
    --ws-success:       #1f8f63;
    --ws-success-tint:  rgba(31, 143, 99, 0.12);
    --ws-warning:       #c38a1c;
    --ws-warning-tint:  rgba(195, 138, 28, 0.14);
    --ws-danger:        #c94747;
    --ws-danger-tint:   rgba(201, 71, 71, 0.12);
    --ws-radius:        6px;
    --ws-radius-sm:     4px;
    --ws-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* --- Soft theme --------------------------------------------- */
html[data-theme="soft"] {
    --ws-bg:            #f5f3ef;
    --ws-surface:       #faf8f5;
    --ws-surface-alt:   #f0ede8;
    --ws-border:        rgba(60, 50, 30, 0.10);
    --ws-border-strong: rgba(60, 50, 30, 0.16);
    --ws-text:          #2c2417;
    --ws-muted:         #7a6e5d;
    --ws-primary:       #8b6914;
    --ws-primary-soft:  rgba(139, 105, 20, 0.12);
    --ws-primary-tint:  rgba(139, 105, 20, 0.07);
    --ws-success:       #3a7d4f;
    --ws-success-tint:  rgba(58, 125, 79, 0.10);
    --ws-warning:       #b07d18;
    --ws-warning-tint:  rgba(176, 125, 24, 0.12);
    --ws-danger:        #b94040;
    --ws-danger-tint:   rgba(185, 64, 64, 0.10);
}

/* --- Dark theme --------------------------------------------- */
html[data-theme="dark"] {
    --ws-bg:            #1a1e24;
    --ws-surface:       #22272e;
    --ws-surface-alt:   #2a2f38;
    --ws-border:        rgba(255, 255, 255, 0.08);
    --ws-border-strong: rgba(255, 255, 255, 0.14);
    --ws-text:          #d0d7de;
    --ws-muted:         #8b949e;
    --ws-primary:       #58a6ff;
    --ws-primary-soft:  rgba(88, 166, 255, 0.15);
    --ws-primary-tint:  rgba(88, 166, 255, 0.08);
    --ws-success:       #3fb950;
    --ws-success-tint:  rgba(63, 185, 80, 0.12);
    --ws-warning:       #d29922;
    --ws-warning-tint:  rgba(210, 153, 34, 0.12);
    --ws-danger:        #f85149;
    --ws-danger-tint:   rgba(248, 81, 73, 0.12);
}

/* --- Reset / base ------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

/* --- Thin scrollbars (PyCharm-style) ------------------------ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--ws-border-strong);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--ws-muted);
}
::-webkit-scrollbar-corner {
    background: transparent;
}
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--ws-border-strong) transparent;
}

body.ws-body {
    margin: 0;
    padding: 0;
    font-family: var(--ws-font);
    font-size: 14px;
    line-height: 1.45;
    color: var(--ws-text);
    background: var(--ws-bg);
    overflow: hidden;
    height: 100vh;
}

/* --- Shell (full-viewport grid) ----------------------------- */
.ws-shell {
    display: grid;
    grid-template-rows: auto auto 1fr;
    height: 100vh;
    overflow: hidden;
}

/* --- Header ------------------------------------------------- */
.ws-header {
    padding: 12px 16px 8px;
    background: var(--ws-surface);
    border-bottom: 1px solid var(--ws-border);
}
.ws-header__row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}
.ws-header__context { flex: 1 1 auto; min-width: 0; }
.ws-header__title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ws-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ws-header__meta {
    font-size: 0.78rem;
    color: var(--ws-muted);
    margin-top: 2px;
}
.ws-header__actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

/* --- Buttons (self-contained, no precision deps) ------------ */
.ws-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: var(--ws-font);
    color: var(--ws-text);
    background: var(--ws-surface);
    border: 1px solid var(--ws-border-strong);
    border-radius: var(--ws-radius);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.ws-btn:hover {
    background: var(--ws-surface-alt);
    border-color: var(--ws-primary);
    color: var(--ws-primary);
}
.ws-btn:disabled, .ws-btn[disabled] {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}
.ws-btn--primary {
    background: var(--ws-primary);
    color: #fff;
    border-color: var(--ws-primary);
}
.ws-btn--primary:hover {
    opacity: 0.88;
    color: #fff;
    background: var(--ws-primary);
}
.ws-btn--lg {
    height: 34px;
    padding: 0 18px;
    font-size: 0.85rem;
}

/* --- Overview-блок (обзор раздела в editor) ----------- */
.ws-overview {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 32px;
    align-items: start;
    padding: 24px 8px 8px;
}
.ws-overview__metric {
    text-align: center;
    padding: 24px 16px;
    background: var(--ws-surface-alt);
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-radius);
}
.ws-overview__metric-value {
    font-size: 3rem;
    font-weight: 300;
    line-height: 1;
    color: var(--ws-primary);
}
.ws-overview__metric-label {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--ws-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ws-overview__body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.ws-overview__lead {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--ws-text);
}
.ws-overview__lead--muted {
    color: var(--ws-muted);
}
.ws-overview__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- Ghost button (для breadcrumb и лёгких действий) -------- */
.ws-btn--ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--ws-primary);
    padding: 2px 8px;
    font-size: 0.74rem;
    font-weight: 600;
    height: auto;
    border-radius: 4px;
}
.ws-btn--ghost:hover {
    background: var(--ws-primary-tint);
    border-color: transparent;
    color: var(--ws-primary);
    opacity: 1;
}

.ws-action-form {
    display: inline-flex;
    margin: 0;
}

/* --- Status strip ------------------------------------------- */
.ws-strip {
    display: flex;
    gap: 14px;
    padding: 5px 16px;
    font-size: 0.76rem;
    color: var(--ws-muted);
    background: var(--ws-surface-alt);
    border-bottom: 1px solid var(--ws-border);
    align-items: center;
    justify-content: space-between;
}
.ws-strip__items {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    flex: 1 1 auto;
    min-width: 0;
}
.ws-strip__item { white-space: nowrap; }
.ws-strip__item b { color: var(--ws-text); font-weight: 600; }
.ws-strip__item.is-danger  b { color: var(--ws-danger); }
.ws-strip__item.is-warning b { color: var(--ws-warning); }
.ws-strip__item.is-success b { color: var(--ws-success); }

/* --- Panel toolbar (PyCharm-style) -------------------------- */
.ws-toolbar {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    align-items: center;
}
.ws-toolbar__btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-family: var(--ws-font);
    color: var(--ws-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--ws-radius-sm);
    cursor: pointer;
    user-select: none;
    transition: background 0.12s, color 0.12s;
}
.ws-toolbar__btn:hover {
    background: var(--ws-primary-tint);
    color: var(--ws-text);
}
.ws-toolbar__btn.is-active {
    background: var(--ws-primary-soft);
    color: var(--ws-primary);
    font-weight: 600;
}
.ws-toolbar__icon {
    font-size: 0.85rem;
    line-height: 1;
}

/* --- Panel close button ------------------------------------- */
/* Кнопка визуально сидит внутри стики-шапки панели. Шапка имеет padding 8px 12px
   и height по content (~13px + padding = ~29px). Кнопка центрируется по высоте шапки. */
.ws-panel__close {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--ws-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--ws-radius-sm);
    cursor: pointer;
    z-index: 3;
    line-height: 1;
    padding: 0;
}
.ws-panel__close:hover {
    background: var(--ws-danger-tint);
    color: var(--ws-danger);
    border-color: var(--ws-danger-tint);
}
.ws-panel { position: relative; }

/* Резервируем справа место под кнопку-закрытие, чтобы контролы/текст шапки не наезжали на неё. */
.ws-panel:has(> .ws-panel__close) > .ws-panel__head {
    padding-right: 34px;
}

/* --- Body (three columns + bottom) -------------------------- */
.ws-body-grid {
    display: grid;
    grid-template-columns: var(--ws-left, 260px) 5px 1fr 5px var(--ws-right, 280px);
    grid-template-rows: 1fr 5px var(--ws-bottom, 180px);
    overflow: hidden;
    min-height: 0;
}
/* Прячем панель и её gutter, сжимая трек до нуля */
.ws-body-grid.is-hidden-structure {
    grid-template-columns: 0 0 1fr 5px var(--ws-right, 280px);
}
.ws-body-grid.is-hidden-inspector {
    grid-template-columns: var(--ws-left, 260px) 5px 1fr 0 0;
}
.ws-body-grid.is-hidden-structure.is-hidden-inspector {
    grid-template-columns: 0 0 1fr 0 0;
}
.ws-body-grid.is-hidden-diagnostics {
    grid-template-rows: 1fr 0 0;
}
/* Скрываем открытые элементы */
.ws-body-grid.is-hidden-structure  > [data-ws-panel="structure"],
.ws-body-grid.is-hidden-structure  > [data-ws-gutter="left"],
.ws-body-grid.is-hidden-inspector  > [data-ws-panel="inspector"],
.ws-body-grid.is-hidden-inspector  > [data-ws-gutter="right"],
.ws-body-grid.is-hidden-diagnostics > [data-ws-panel="diagnostics"],
.ws-body-grid.is-hidden-diagnostics > [data-ws-gutter="row"] {
    display: none;
}

/* --- Panels common ------------------------------------------ */
.ws-panel {
    background: var(--ws-surface);
    overflow: auto;
    min-width: 0;
    min-height: 0;
}
.ws-panel__head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 12px;
    background: var(--ws-surface);
    border-bottom: 1px solid var(--ws-border);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ws-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --- Tree expand/collapse controls -------------------------- */
.ws-tree-controls {
    display: flex;
    gap: 2px;
}
.ws-tree-controls__btn {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-family: var(--ws-font);
    color: var(--ws-muted);
    background: none;
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-radius-sm);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.ws-tree-controls__btn:hover {
    color: var(--ws-primary);
    border-color: var(--ws-primary);
    background: var(--ws-primary-tint);
}

/* --- Tree search -------------------------------------------- */
.ws-tree-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 4px;
    border-bottom: 1px solid var(--ws-border);
    background: var(--ws-bg-muted, transparent);
}
.ws-tree-search__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 24px;
    padding: 0 8px;
    font-size: 0.78rem;
    font-family: var(--ws-font);
    color: inherit;
    background: var(--ws-bg, #fff);
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-radius-sm);
    outline: none;
}
.ws-tree-search__input:focus {
    border-color: var(--ws-primary);
    box-shadow: 0 0 0 2px var(--ws-primary-tint);
}
.ws-tree-search__clear {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ws-muted);
    background: none;
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-radius-sm);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 0.7rem;
}
.ws-tree-search__clear:hover {
    color: var(--ws-primary);
    border-color: var(--ws-primary);
}
.ws-tree-search__clear.is-hidden {
    display: none;
}
.ws-tree-search__count {
    font-size: 0.72rem;
    color: var(--ws-muted);
    min-width: 60px;
    text-align: right;
    white-space: nowrap;
}

/* Совпадение прямое — подсвечиваем сам узел. */
.ws-tree li[data-ws-tree-node].is-search-hit > .ws-tree__node {
    background: var(--ws-primary-tint, rgba(33,150,243,0.1));
    border-radius: var(--ws-radius-sm);
}
.ws-tree [data-ws-label] mark {
    background: var(--ws-primary-tint, #fff59d);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.ws-panel__body {
    padding: 10px 12px;
}

/* --- Grid placement ----------------------------------------- */
.ws-structure   { grid-column: 1; grid-row: 1; border-right: 1px solid var(--ws-border); }
.ws-editor      { grid-column: 3; grid-row: 1; }
.ws-inspector   { grid-column: 5; grid-row: 1; border-left: 1px solid var(--ws-border); }
.ws-diagnostics { grid-column: 1 / -1; grid-row: 3; border-top: 1px solid var(--ws-border); }

/* --- Resize gutters ----------------------------------------- */
.ws-gutter {
    background: transparent;
    position: relative;
    z-index: 6;
    transition: background 0.12s;
}
.ws-gutter--col {
    grid-row: 1;
    cursor: col-resize;
    width: 5px;
}
.ws-gutter--col:hover,
.ws-gutter--col.is-dragging {
    background: var(--ws-primary);
    opacity: 0.30;
}
.ws-gutter--left  { grid-column: 2; }
.ws-gutter--right { grid-column: 4; }

.ws-gutter--row {
    grid-column: 1 / -1;
    grid-row: 2;
    cursor: row-resize;
    height: 5px;
}
.ws-gutter--row:hover,
.ws-gutter--row.is-dragging {
    background: var(--ws-primary);
    opacity: 0.30;
}

/* --- Tree --------------------------------------------------- */
.ws-tree { list-style: none; padding: 0; margin: 0; }
.ws-tree .ws-tree { padding-left: 16px; }
.ws-tree.is-collapsed { display: none; }

.ws-tree__node {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 0.8rem;
    color: var(--ws-text);
    border-radius: var(--ws-radius-sm);
    cursor: pointer;
    user-select: none;
}
.ws-tree__node:hover { background: var(--ws-primary-tint); }
.ws-tree__node.is-selected {
    background: var(--ws-primary-soft);
    font-weight: 600;
}
.ws-tree__toggle {
    width: 14px;
    text-align: center;
    font-size: 0.65rem;
    color: var(--ws-muted);
    flex-shrink: 0;
}
/* PyCharm-like типовые бейджи: моноширинная буква-маркер с цветом по типу узла. */
.ws-tree__icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--ws-font-mono, ui-monospace, Consolas, "SF Mono", Menlo, monospace);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 3px;
    color: #fff;
    background: var(--ws-muted);
    text-transform: uppercase;
    letter-spacing: 0;
    user-select: none;
}
.ws-tree__icon--nd    { background: var(--ws-kind-nd,    #5b6b7e); }
.ws-tree__icon--os    { background: var(--ws-kind-os,    #1f8a70); }
.ws-tree__icon--point { background: var(--ws-kind-point, #d98c1a); }
.ws-tree__icon--spec  { background: var(--ws-kind-spec,  #4c63c6); }

/* --- Kind badge (общая пиктограмма типа сущности для eyebrow'ов) ------ */
/* PyCharm-like буквенные бейджи, используются во всех заголовках editor/inspector. */
.ws-kind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    vertical-align: -4px;
    margin-right: 6px;
    font-family: var(--ws-font-mono, ui-monospace, Consolas, "SF Mono", Menlo, monospace);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 3px;
    color: #fff;
    text-transform: uppercase;
    user-select: none;
    flex-shrink: 0;
}
.ws-kind--nd    { background: var(--ws-kind-nd,    #5b6b7e); }
.ws-kind--os    { background: var(--ws-kind-os,    #1f8a70); }
.ws-kind--point { background: var(--ws-kind-point, #d98c1a); }
.ws-kind--spec  { background: var(--ws-kind-spec,  #4c63c6); }
.ws-kind--stage { background: var(--ws-kind-stage, #8a4fbf); }
.ws-tree__badge {
    margin-left: auto;
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--ws-surface-alt);
    color: var(--ws-muted);
}
.ws-tree__badge.is-danger  { background: var(--ws-danger-tint);  color: var(--ws-danger); }
.ws-tree__badge.is-success { background: var(--ws-success-tint); color: var(--ws-success); }

/* --- Search input ------------------------------------------- */
.ws-search {
    width: 100%;
    padding: 5px 8px;
    font-size: 0.8rem;
    font-family: var(--ws-font);
    color: var(--ws-text);
    background: var(--ws-surface-alt);
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-radius);
    outline: none;
    margin-bottom: 6px;
}
.ws-search:focus {
    border-color: var(--ws-primary);
    box-shadow: 0 0 0 2px var(--ws-primary-tint);
}

/* --- Tabs (editor & diagnostics) ---------------------------- */
.ws-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--ws-border);
    background: var(--ws-surface-alt);
    padding: 0 12px;
}
.ws-tabs__tab {
    padding: 7px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: var(--ws-font);
    color: var(--ws-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    user-select: none;
    transition: color 0.12s;
}
.ws-tabs__tab:hover { color: var(--ws-text); }
.ws-tabs__tab.is-active {
    color: var(--ws-primary);
    border-bottom-color: var(--ws-primary);
    font-weight: 600;
}

.ws-tab-pane { display: none; }
.ws-tab-pane.is-active { display: block; }

/* --- Diagnostic count badge --------------------------------- */
.ws-tabs__count {
    display: inline-block;
    min-width: 16px;
    text-align: center;
    padding: 0 5px;
    margin-left: 4px;
    font-size: 0.68rem;
    border-radius: 8px;
    font-weight: 600;
    background: var(--ws-danger-tint);
    color: var(--ws-danger);
}
.ws-tabs__count.is-warning {
    background: var(--ws-warning-tint);
    color: var(--ws-warning);
}

/* --- Inspector property list -------------------------------- */
.ws-props { list-style: none; padding: 0; margin: 0; }
.ws-props__row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--ws-border);
    font-size: 0.78rem;
}
.ws-props__label { color: var(--ws-muted); white-space: nowrap; }
.ws-props__value { color: var(--ws-text); font-weight: 500; text-align: right; word-break: break-word; }

/* --- Diagnostic list ---------------------------------------- */
.ws-diag-list { list-style: none; padding: 6px 12px; margin: 0; }
.ws-diag-list__item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 3px 4px;
    font-size: 0.78rem;
    color: var(--ws-text);
    cursor: pointer;
    border-radius: var(--ws-radius-sm);
}
.ws-diag-list__item:hover { background: var(--ws-primary-tint); }
.ws-diag-icon {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    font-weight: 700;
    font-size: 0.72rem;
}
.ws-diag-icon.is-error   { color: var(--ws-danger); }
.ws-diag-icon.is-warning { color: var(--ws-warning); }
.ws-diag-icon.is-ok      { color: var(--ws-success); }

/* --- Data table --------------------------------------------- */
.ws-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.ws-table th {
    text-align: left;
    padding: 6px 10px;
    background: var(--ws-surface-alt);
    color: var(--ws-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--ws-border);
    position: sticky;
    top: 0;
    z-index: 1;
}
.ws-table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--ws-border);
    color: var(--ws-text);
}
.ws-table tr:hover td { background: var(--ws-primary-tint); }
.ws-table--clickable tbody tr { cursor: pointer; }
.ws-table--clickable tbody tr:hover td { background: var(--ws-primary-soft); }

/* --- Key-value list (overview) ----------------------------- */
.ws-kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 16px;
    margin: 0;
    font-size: 0.8rem;
}
.ws-kv dt {
    color: var(--ws-muted);
    font-weight: 500;
}
.ws-kv dd {
    margin: 0;
    color: var(--ws-text);
}

/* --- Pills / badges ----------------------------------------- */
.ws-pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 0.70rem;
    font-weight: 600;
    white-space: nowrap;
}
.ws-pill--ok      { background: var(--ws-success-tint); color: var(--ws-success); }
.ws-pill--warn    { background: var(--ws-warning-tint); color: var(--ws-warning); }
.ws-pill--error   { background: var(--ws-danger-tint);  color: var(--ws-danger); }
.ws-pill--info    { background: var(--ws-primary-tint); color: var(--ws-primary); }
.ws-pill--neutral { background: var(--ws-surface-alt);  color: var(--ws-muted); }

/* --- Empty state -------------------------------------------- */
.ws-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--ws-muted);
    font-size: 0.82rem;
}

/* --- Quick-action links inside inspector -------------------- */
.ws-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 10px;
}
.ws-quick-actions__btn {
    display: block;
    padding: 4px 8px;
    font-size: 0.76rem;
    font-family: var(--ws-font);
    color: var(--ws-primary);
    background: none;
    border: none;
    border-radius: var(--ws-radius-sm);
    cursor: pointer;
    text-align: left;
}
.ws-quick-actions__btn:hover {
    background: var(--ws-primary-tint);
}
.ws-quick-actions__btn:disabled {
    color: var(--ws-muted);
    opacity: 0.5;
    cursor: default;
}

/* --- Inspector eyebrow -------------------------------------- */
.ws-inspector__eyebrow {
    font-size: 0.74rem;
    color: var(--ws-muted);
    margin: 0 0 8px;
}

/* --- Editor content blocks ---------------------------------- */
.ws-editor-wrap {
    height: 100%;
    overflow: auto;
}
.ws-editor-block {
    padding: 0;
}
.ws-editor-block[hidden] { display: none !important; }

.ws-editor__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--ws-border);
    background: var(--ws-surface-alt);
    flex-wrap: wrap;
}
.ws-editor__eyebrow {
    font-size: 0.72rem;
    color: var(--ws-muted);
    margin-bottom: 2px;
}
.ws-editor__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--ws-text);
}
.ws-editor__subtitle {
    font-size: 0.78rem;
    color: var(--ws-muted);
    margin-top: 2px;
}
.ws-editor__actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
    align-items: center;
}

.ws-editor__section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ws-border);
}
.ws-editor__section:last-child { border-bottom: none; }
.ws-editor__section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.ws-editor__section-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ws-muted);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --- Cards (specs, stages) ---------------------------------- */
.ws-card {
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-radius);
    margin-bottom: 6px;
    background: var(--ws-surface);
    transition: border-color 0.12s;
}
.ws-card:hover { border-color: var(--ws-border-strong); }
.ws-card--clickable { cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.ws-card--clickable:hover {
    border-color: var(--ws-primary);
    background: var(--ws-primary-tint);
}
.ws-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
}
.ws-card__title {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ws-text);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.ws-card__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--ws-primary-tint);
    color: var(--ws-primary);
    flex-shrink: 0;
}
.ws-card__actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.ws-card__body {
    padding: 0 12px 8px;
    font-size: 0.78rem;
    color: var(--ws-muted);
}
.ws-card__sub {
    padding: 4px 12px 8px;
    border-top: 1px dashed var(--ws-border);
}
.ws-card__sub-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ws-muted);
    margin-bottom: 4px;
}
.ws-card__sub-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 0.76rem;
    color: var(--ws-text);
}
.ws-card__sub-item .ws-btn {
    margin-left: auto;
    padding: 2px 8px;
    font-size: 0.7rem;
}

/* ============================================================
   Modal override for workspace (scoped to .ws-body)
   Replaces --cm-* with --ws-* so modal looks native to IDE UI.
   Does NOT affect precision pages.
   ============================================================ */

/* Backdrop */
.ws-body .app-modal__backdrop {
    background: rgba(10, 20, 30, 0.50);
    backdrop-filter: blur(8px);
}
html[data-theme="dark"] .ws-body .app-modal__backdrop {
    background: rgba(0, 0, 0, 0.62);
}

/* Dialog */
.ws-body .app-modal__dialog {
    border-radius: 10px;
    border: 1px solid var(--ws-border-strong);
    background: var(--ws-surface);
    color: var(--ws-text);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.10);
    backdrop-filter: none;
    font-family: var(--ws-font);
}
html[data-theme="dark"] .ws-body .app-modal__dialog {
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.45),
        0 2px 8px rgba(0, 0, 0, 0.30);
}

/* Header */
.ws-body .app-modal__header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ws-border);
    background: var(--ws-surface-alt);
    border-radius: 10px 10px 0 0;
}
.ws-body .app-modal__title {
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ws-text);
}
.ws-body .app-modal__subtitle {
    font-size: 0.76rem;
    color: var(--ws-muted);
}

/* Close button */
.ws-body .app-modal__close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--ws-border);
    background: var(--ws-surface);
    color: var(--ws-muted);
    font-size: 16px;
    transition: background 0.12s, color 0.12s;
}
.ws-body .app-modal__close:hover {
    background: var(--ws-danger-tint);
    color: var(--ws-danger);
    border-color: var(--ws-danger);
    transform: none;
}

/* Body */
.ws-body .app-modal__body {
    padding: 16px;
    background: var(--ws-surface);
}

/* Footer */
.ws-body .app-modal__footer {
    padding: 10px 16px 14px;
    border-top: 1px solid var(--ws-border);
    background: var(--ws-surface-alt);
}

/* Buttons */
.ws-body .app-modal__btn {
    min-height: 32px;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--ws-border-strong);
    background: var(--ws-surface);
    color: var(--ws-text);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--ws-font);
    transition: background 0.12s, border-color 0.12s;
}
.ws-body .app-modal__btn:hover {
    background: var(--ws-surface-alt);
    border-color: var(--ws-primary);
    color: var(--ws-primary);
    transform: none;
}
.ws-body .app-modal__btn--primary {
    background: var(--ws-primary);
    border-color: var(--ws-primary);
    color: #fff;
}
.ws-body .app-modal__btn--primary:hover {
    opacity: 0.9;
    background: var(--ws-primary);
    color: #fff;
}
.ws-body .app-modal__btn--danger {
    background: var(--ws-danger-tint);
    border-color: var(--ws-danger);
    color: var(--ws-danger);
}

/* Loading overlay */
.ws-body .app-modal.is-loading .app-modal__body::after {
    background: rgba(255, 255, 255, 0.75);
    color: var(--ws-text);
    font-size: 0.82rem;
    font-weight: 600;
}
html[data-theme="dark"] .ws-body .app-modal.is-loading .app-modal__body::after {
    background: rgba(26, 30, 36, 0.80);
}

/* Form fields inside modal */
.ws-body .app-modal__body label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    /*color: var(--ws-muted);*/
    margin-bottom: 4px;
}
.ws-body .app-modal__body input[type="text"],
.ws-body .app-modal__body input[type="number"],
.ws-body .app-modal__body input[type="date"],
.ws-body .app-modal__body input[type="email"],
.ws-body .app-modal__body textarea,
.ws-body .app-modal__body select {
    display: block;
    width: 100%;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-family: var(--ws-font);
    color: var(--ws-text);
    background: var(--ws-surface);
    border: 1px solid var(--ws-border-strong);
    border-radius: 5px;
    outline: none;
    transition: border-color 0.15s;
}
.ws-body .app-modal__body input:focus,
.ws-body .app-modal__body textarea:focus,
.ws-body .app-modal__body select:focus {
    border-color: var(--ws-primary);
    box-shadow: 0 0 0 2px var(--ws-primary-tint);
}
.ws-body .app-modal__body input[type="checkbox"] {
    width: auto;
    accent-color: var(--ws-primary);
}

/* Sections inside modal content */
.ws-body .app-modal-content__section {
    border-radius: 8px;
    border: 1px solid var(--ws-border);
    background: var(--ws-surface-alt);
    padding: 12px;
}
.ws-body .app-modal-content__title {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ws-text);
}
.ws-body .app-modal-content__label {
    color: var(--ws-muted);
    font-size: 0.7rem;
}

/* Error list */
.ws-body .app-modal__body .errorlist {
    list-style: none;
    padding: 0;
    margin: 4px 0 8px;
}
.ws-body .app-modal__body .errorlist li {
    font-size: 0.78rem;
    color: var(--ws-danger);
    padding: 2px 0;
}

/* Dragging state */
.ws-body .app-modal__dialog.is-dragging {
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.22),
        0 4px 12px rgba(0, 0, 0, 0.14);
}

/* ============================================================
   Bridge: map --cm-* to --ws-* inside .ws-body
   This lets precision-form, my-form, my-select2 styles work
   without pulling precision-modernism.css.
   ============================================================ */
.ws-body {
    --cm-text:          var(--ws-text);
    --cm-muted:         var(--ws-muted);
    --cm-surface:       var(--ws-surface);
    --cm-surface-alt:   var(--ws-surface-alt);
    --cm-line:          var(--ws-border);
    --cm-line-strong:   var(--ws-border-strong);
    --cm-primary:       var(--ws-primary);
    --cm-primary-soft:  var(--ws-primary-soft);
    --cm-primary-tint:  var(--ws-primary-tint);
    --cm-danger:        var(--ws-danger);
    --cm-danger-tint:   var(--ws-danger-tint);
    --cm-warning:       var(--ws-warning);
    --cm-warning-tint:  var(--ws-warning-tint);
    --cm-success:       var(--ws-success);
    --cm-success-tint:  var(--ws-success-tint);
    --cm-card-soft:     var(--ws-surface-alt);
    --cm-card-bg-start: var(--ws-surface);
    --cm-card-bg-end:   var(--ws-surface);
    --cm-shell-panel-soft: var(--ws-surface-alt);
    --cm-shadow-lg:     0 8px 32px rgba(0,0,0,0.14);
    --cm-radius:        6px;
    --cm-radius-sm:     4px;
    --bs-border-width:  1px;
    --bs-border-radius: 6px;
}

/* ============================================================
   Precision-form override for workspace modal (IDE look)
   ============================================================ */
.ws-body .precision-form__section {
    border-radius: 8px;
    border: 1px solid var(--cm-line);
    background: var(--cm-card-soft);
    overflow: hidden;
}
.ws-body .precision-form__section-header {
    padding: 10px 14px 0;
}
.ws-body .precision-form__section-title {
    font-size: 0.84rem;
}
.ws-body .precision-form__section-body {
    padding: 10px 14px 14px;
    gap: 10px;
}
.ws-body .precision-form__row {
    grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
    gap: 10px;
    display: grid;
}
.ws-body .precision-form__label {
    padding-top: 7px;
    font-size: 0.74rem;
}
.ws-body .precision-form__control .form-control,
.ws-body .precision-form__control .text-box,
.ws-body .precision-form__control input[type="text"],
.ws-body .precision-form__control input[type="number"],
.ws-body .precision-form__control input[type="date"],
.ws-body .precision-form__control input[type="datetime-local"],
.ws-body .precision-form__control input[type="email"],
.ws-body .precision-form__control input[type="url"],
.ws-body .precision-form__control input[type="password"],
.ws-body .precision-form__control select,
.ws-body .precision-form__control textarea {
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 0.82rem;
    font-family: var(--ws-font);
}
.ws-body .precision-form__control textarea {
    min-height: 80px;
}
.ws-body .precision-form__errors {
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 0.78rem;
}

.ws-body .precision-form__help {
    font-size: 0.74rem;
    color: var(--cm-muted);
    line-height: 1.45;
    padding-left: 8px;
}

/* ============================================================
   Select2 override for workspace (IDE look, no transparency)
   ============================================================ */
.ws-body .select2-container--default .select2-selection {
    min-height: 34px !important;
    border-radius: 5px !important;
    background-color: var(--ws-surface) !important;
    border-color: var(--ws-border-strong) !important;
    font-size: 0.82rem !important;
    font-family: var(--ws-font) !important;
}
.ws-body .select2-container--default .select2-selection--single {
    display: flex !important;
    align-items: center !important;
}
.ws-body .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--ws-text) !important;
    background-color: var(--ws-surface) !important;
    font-size: 0.82rem !important;
    line-height: 22px !important;
    padding: 4px 20px !important;
    border: 1px solid var(--ws-border-strong);
}
.ws-body .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--ws-muted) !important;
}
.ws-body .select2-container--default .select2-selection__arrow {
    min-height: 32px !important;
}
.ws-body .precision-form__control .select2-selection {
    min-height: 34px !important;
    border-radius: 5px !important;
    /*padding: 4px 8px !important;*/
}

/* Dropdown */
.ws-body .select2-container--default .select2-dropdown {
    background-color: var(--ws-surface) !important;
    border-color: var(--ws-border-strong) !important;
    border-radius: 5px !important;
    font-size: 0.82rem !important;
    font-family: var(--ws-font) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.14) !important;
}
.ws-body .select2-container--default .select2-results__option {
    padding: 6px 10px !important;
    font-size: 0.82rem !important;
    color: var(--ws-text) !important;
}
.ws-body .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--ws-primary) !important;
    color: #fff !important;
}
.ws-body .select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: var(--ws-primary-tint) !important;
}
.ws-body .select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: var(--ws-surface) !important;
    border-color: var(--ws-border-strong) !important;
    color: var(--ws-text) !important;
    min-height: 30px !important;
    padding: 5px 8px !important;
    font-size: 0.82rem !important;
    font-family: var(--ws-font) !important;
    border-radius: 4px !important;
}
.ws-body .select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--ws-primary) !important;
    box-shadow: 0 0 0 2px var(--ws-primary-tint) !important;
    outline: none !important;
}

/* Multiple select */
.ws-body .select2-container--default .select2-selection--multiple {
    padding: 4px 6px !important;
    min-height: 34px !important;
}
.ws-body .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--ws-surface-alt) !important;
    border-color: var(--ws-border-strong) !important;
    border-radius: 4px !important;
    font-size: 0.78rem !important;
    padding: 2px 6px !important;
}

/* ============================================================
   ACTIVITY RAIL (PyCharm Tool Window Bar)
   Узкая вертикальная полоса слева с главными кнопками модулей.
   ============================================================ */
.ws-frame {
    display: grid;
    grid-template-columns: var(--ws-rail-width, 52px) 1fr;
    height: 100vh;
    overflow: visible;
}
/* Когда rail скрыт: убираем первый grid-track целиком,
   иначе shell (единственный дочерний элемент) попадёт в track
   шириной 0 и визуально исчезнет. */
.ws-frame.is-hidden-rail {
    grid-template-columns: 1fr;
}
.ws-frame.is-hidden-rail > .ws-rail {
    display: none;
}

.ws-rail {
    position: relative;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 6px 4px;
    background: var(--ws-surface-alt);
    border-right: 1px solid var(--ws-border);
    overflow: visible;
    min-height: 0;
}
.ws-rail__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}
.ws-rail__group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ws-rail__group--bottom {
    flex-shrink: 0;
    padding-top: 4px;
}
.ws-rail__sep {
    height: 1px;
    background: var(--ws-border);
    margin: 4px 2px;
}
.ws-rail__section-label {
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ws-muted);
    text-align: center;
    padding: 4px 0 2px;
    opacity: 0.75;
}

.ws-rail__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    margin-bottom: 6px;
    border-radius: var(--ws-radius);
    color: #fff;
    background: var(--ws-primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}
.ws-rail__brand:hover { opacity: 0.9; color: #fff; }
.ws-rail__brand-mark { line-height: 1; }

.ws-rail__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    width: 100%;
    min-height: 44px;
    color: var(--ws-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--ws-radius-sm);
    cursor: pointer;
    text-decoration: none;
    font-family: var(--ws-font);
    user-select: none;
    transition: background 0.12s, color 0.12s;
}
.ws-rail__btn:hover {
    background: var(--ws-primary-tint);
    color: var(--ws-text);
}
.ws-rail__btn.is-active {
    background: var(--ws-primary-soft);
    color: var(--ws-primary);
}
.ws-rail__btn--accent {
    color: var(--ws-primary);
}
.ws-rail__icon {
    font-size: 1rem;
    line-height: 1;
}
.ws-rail__label {
    font-size: 0.62rem;
    line-height: 1;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.ws-rail__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--ws-primary-soft);
    color: var(--ws-primary);
    font-size: 0.72rem;
    font-weight: 600;
}

.ws-rail__user { position: relative; }
.ws-rail__user-btn { padding: 6px 2px; }
.ws-rail__user-menu {
    position: absolute;
    left: calc(100% + 6px);
    bottom: 0;
    min-width: 200px;
    padding: 10px 12px;
    background: var(--ws-surface);
    border: 1px solid var(--ws-border-strong);
    border-radius: var(--ws-radius);
    box-shadow: 0 6px 20px rgba(12, 31, 46, 0.14);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ws-rail__user-menu[hidden] { display: none; }
.ws-rail__user-name {
    font-weight: 600;
    color: var(--ws-text);
    font-size: 0.82rem;
}
.ws-rail__user-meta {
    font-size: 0.72rem;
    color: var(--ws-muted);
    margin-bottom: 6px;
}
.ws-rail__user-link {
    display: block;
    padding: 4px 6px;
    font-size: 0.78rem;
    color: var(--ws-text);
    background: transparent;
    border: none;
    border-radius: var(--ws-radius-sm);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.ws-rail__user-link:hover {
    background: var(--ws-primary-tint);
    color: var(--ws-primary);
}
.ws-rail__user-link--danger { color: var(--ws-danger); }
.ws-rail__user-link--danger:hover {
    background: var(--ws-danger-tint);
    color: var(--ws-danger);
}

/* Бургер-тогл в header для скрытия rail */
.ws-header__rail-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-right: 8px;
    padding: 0;
    font-size: 0.95rem;
    color: var(--ws-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--ws-radius-sm);
    cursor: pointer;
    vertical-align: middle;
}
.ws-header__rail-toggle:hover {
    background: var(--ws-primary-tint);
    color: var(--ws-primary);
}
.ws-header__context {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
}
.ws-header__context .ws-header__title,
.ws-header__context .ws-header__meta {
    flex: 0 1 auto;
}

