/* ============================================================
   АСЖ shell — каркас и библиотека компонентов нового стиля
   Источник значений: эталон «Актуарный модуль АСЖ - экраны.html» (AM-252).
   Токены (--brand, --hl, --ink…) объявлены в site.css :root.
   ============================================================ */

/* Страховка box-sizing: страницы вне Blazor-каркаса (Identity/Views) могут не иметь
   глобального border-box из bootstrap — без него .input/.btn c width:100% переполняют контейнер */
.topbar, .topbar *,
.sb, .sb *,
.card, .card *,
.btn, .input,
.field, .field *,
.filebox, .filebox *,
.tbl, .tbl th, .tbl td,
.tabs, .tabs * {
    box-sizing: border-box;
}

/* ===== Каркас: шапка ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1100;
    height: 58px;
    background: #FAFBFD;
    display: flex;
    align-items: stretch;
    padding: 0 22px;
    border-bottom: 1px solid var(--border-2);
}

.topbar .brand {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    align-self: center;
    width: 226px;
    box-sizing: border-box;
    text-decoration: none;
}

.topbar .brand::before {
    content: "";
    width: 14px;
    height: 14px;
    background: var(--brand);
    border-radius: 3px;
    flex: none;
}

.topbar .navtabs {
    display: flex;
    align-items: stretch;
    margin-left: 0;
}

.topbar .tab {
    display: flex;
    align-items: center;
    padding: 0 19px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-3);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    letter-spacing: .005em;
    white-space: nowrap;
    text-decoration: none;
}

.topbar .tab:hover { color: var(--ink); }

.topbar .tab.on {
    color: var(--brand-text);
    font-weight: 700;
    border-bottom-color: var(--brand);
}

.topbar .grow { flex: 1; }

.topbar .acct {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    align-self: center;
}

.topbar .gear {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-3);
    cursor: pointer;
    text-decoration: none;
}

.topbar .gear svg { width: 18px; height: 18px; stroke-width: 1.6; }
.topbar .gear:hover { background: #ECEEF4; color: var(--ink); }
.topbar .gear.on { background: var(--brand-soft); color: var(--brand-text); }

.topbar .who {
    color: var(--ink-3);
    font-size: 12.5px;
    font-family: var(--mono);
}

.topbar .outform {
    display: inline-flex;
    align-items: center;
    border-left: 1px solid var(--border-2);
    padding-left: 14px;
    margin: 0;
}

.topbar .out {
    font-size: 12.5px;
    color: var(--ink-3);
    cursor: pointer;
    background: none;
    border: 0;
    padding: 0;
    font-family: var(--sans);
    text-decoration: none;
}

.topbar .out:hover { color: var(--ink); }

/* ===== Каркас: тело — сайдбар + контент ===== */
.app-body {
    display: grid;
    grid-template-columns: 248px 1fr;
    min-height: calc(100vh - 58px);
}

/* ===== Сайдбар ===== */
.sb {
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 10px 0 16px;
    position: sticky;
    top: 58px;
    height: calc(100vh - 58px);
    overflow-y: auto;
}

.sb::-webkit-scrollbar { width: 9px; }
.sb::-webkit-scrollbar-thumb { background: #D5D9E2; border-radius: 9px; border: 2px solid #fff; }

.sb-head {
    padding: 14px 20px 7px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--ink-4);
}

.sb a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 18px 8px 19px;
    color: #2D3344;
    font-size: 13px;
    text-decoration: none;
    border-left: 3px solid transparent;
    line-height: 1.25;
}

.sb a:hover { background: #F6F7FA; color: #000; }
.sb a svg { width: 16px; height: 16px; flex: none; color: var(--ink-4); stroke-width: 1.6; }
.sb a .nm { flex: 1; }

.sb a.on {
    font-weight: 600;
    color: var(--brand-text);
    background: var(--brand-soft);
    border-left-color: var(--brand);
}

.sb a.on svg { color: var(--brand-text); }

/* ===== Контент ===== */
.content {
    background: var(--bg);
    padding: 26px 30px 40px;
    min-width: 0;
}

.pagehead {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.pagehead h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -.01em;
    margin: 0;
    line-height: 1.3;
}

.pagehead .crumb { color: var(--ink-3); font-weight: 400; }
.pagehead .crumb b { color: var(--ink); font-weight: 600; }

/* Крошка-ссылка «назад к списку»: цвет как у крошки, а не bootstrap-синий */
.pagehead .crumb a { color: inherit; text-decoration: none; }
.pagehead .crumb a:hover { color: var(--brand-text); text-decoration: underline; }

/* Тулбар — ряд кнопок над таблицей/карточкой */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    align-items: center;
}

/* ===== Кнопки ===== */
.btn {
    height: 36px;
    padding: 0 16px;
    border-radius: 5px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .02em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    font-family: var(--sans);
    line-height: 1;
    text-decoration: none;
}

.btn svg { width: 15px; height: 15px; stroke-width: 1.7; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--hl-soft); }

.btn-pri { background: var(--btn); color: #fff; }
.btn-pri:hover { background: var(--btn-dark); color: #fff; }

.btn-out { background: #fff; border-color: var(--btn); color: var(--btn); }
.btn-out:hover { background: var(--brand-soft); color: var(--btn); }

.btn-ghost { background: #fff; border-color: var(--border-2); color: var(--ink-2); }
.btn-ghost:hover { background: #F2F4F8; color: var(--ink); }

.btn-amber { background: #fff; border-color: #E3C77A; color: var(--amber); }
.btn-amber:hover { background: var(--amber-soft); color: var(--amber); }

.btn-disabled,
.btn:disabled,
.btn[disabled] {
    background: #EBEDF1;
    color: var(--ink-4);
    border-color: var(--border-2);
    cursor: not-allowed;
}

.btn-text {
    height: auto;
    padding: 0;
    border: 0;
    background: none;
    color: var(--btn);
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: .03em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    gap: 7px;
    align-items: center;
    font-family: var(--sans);
}

.btn-text:hover { color: var(--btn-dark); background: none; }
.btn-text.danger { color: var(--err); }
.btn-upper { text-transform: uppercase; }

/* ===== Карточка ===== */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 7px;
    overflow: hidden;
}

.card.pad { padding: 22px 24px; }
.card + .card { margin-top: 16px; }

.card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
}

.sect-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin: 24px 0 14px;
}

.lede {
    font-size: 13.5px;
    color: var(--ink-2);
    margin-bottom: 18px;
    max-width: 1000px;
}

.lede code {
    font-family: var(--mono);
    font-size: 12px;
    background: #EEF0F4;
    padding: 1px 5px;
    border-radius: 3px;
    color: var(--ink);
}

/* ===== Поля форм ===== */
.fgrid { display: grid; gap: 18px 22px; }

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field label {
    font-size: 12px;
    color: var(--ink-3);
    font-weight: 500;
    margin: 0;
}

.field .req::after { content: " *"; color: var(--err); }

.input {
    height: 38px;
    border: 1px solid var(--border-2);
    border-radius: 5px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    font-size: 13px;
    color: var(--ink);
    background: #fff;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    font-family: var(--sans);
}

.input .ph { color: var(--ink-4); }
.input.placeholder { color: var(--ink-4); }
.input::placeholder { color: var(--ink-4); }
.input .ic-r { margin-left: auto; color: var(--ink-4); flex: none; }

.input.sel {
    cursor: pointer;
    position: relative;
    padding-right: 32px;
    -webkit-appearance: none;
    appearance: none;
}

.input.sel::after {
    content: "";
    position: absolute;
    right: 13px;
    top: 50%;
    margin-top: -6px;
    width: 8px;
    height: 8px;
    border-right: 1.6px solid var(--ink-4);
    border-bottom: 1.6px solid var(--ink-4);
    transform: rotate(45deg);
}

/* select как нативный элемент: шеврон фоном (у <select> нет ::after) */
select.input.sel {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5l3.5 3.5 3.5-3.5' fill='none' stroke='%23A5ABBA' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
}

.input:focus,
.input.focus,
.input:focus-within {
    border-color: var(--hl);
    box-shadow: 0 0 0 3px var(--hl-soft);
    outline: none;
}

.input.locked,
.input:disabled,
.input[disabled] {
    background: #EEF0F4;
    border-color: transparent;
    color: var(--ink-3);
}

.field .hint {
    font-size: 11.5px;
    color: var(--ink-4);
    line-height: 1.4;
}

.filebox { display: flex; align-items: center; gap: 0; font-size: 13px; }

.filebox .fb-btn {
    height: 34px;
    padding: 0 14px;
    background: #EEF0F4;
    border: 1px solid var(--border-2);
    border-radius: 5px 0 0 5px;
    color: var(--ink-3);
    display: inline-flex;
    align-items: center;
}

.filebox .fb-name {
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border-2);
    border-left: 0;
    border-radius: 0 5px 5px 0;
    color: var(--ink-4);
    display: inline-flex;
    align-items: center;
    flex: 1;
    min-width: 160px;
}

/* ===== Вкладки внутри страницы (cyan underline) ===== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-2);
    margin-bottom: 20px;
}

.tabs .t {
    padding: 11px 18px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-3);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    background: none;
    border-top: 0;
    border-left: 0;
    border-right: 0;
    font-family: var(--sans);
}

.tabs .t:hover { color: var(--ink-2); }
.tabs .t.on { color: var(--hl-dark); border-bottom-color: var(--hl); }

/* ===== Таблица ===== */
.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
    margin: 0;
}

.tbl thead th {
    text-align: left;
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-2);
    background: #ECEEF4;
    border-bottom: 1px solid var(--border-2);
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: bottom;
}

.tbl thead th.c { text-align: center; }

.tbl tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--ink-2);
    vertical-align: middle;
}

.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #FAFBFD; }

.tbl td.id { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tbl td.num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }
.tbl td.c { text-align: center; }
.tbl td.actions { text-align: right; white-space: nowrap; }

.tbl .when { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .when b { color: var(--ink); font-weight: 600; }
.tbl .twoline { line-height: 1.5; }
.tbl .sub { color: var(--ink-4); font-size: 12px; }

.tbl .empty {
    text-align: center;
    color: var(--ink-3);
    padding: 26px;
    font-size: 13.5px;
}

.tbl.dense thead th, .tbl.dense tbody td { padding-left: 9px; padding-right: 9px; }
.tbl.dense td.actions .iac { width: 27px; }

/* ===== Иконки-действия в строках ===== */
.iac {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 5px;
    color: var(--ink-3);
    cursor: pointer;
    vertical-align: middle;
    background: none;
    border: 0;
    padding: 0;
}

.iac svg { width: 16px; height: 16px; stroke-width: 1.6; }
.iac:hover { background: #EEF0F6; color: var(--ink); }
.iac.danger:hover { background: var(--err-soft); color: var(--err); }
.iac.brand:hover { background: var(--brand-soft); color: var(--brand-text); }
.iac.disabled, .iac:disabled { color: var(--ink-4); opacity: .5; cursor: default; }
.iac.disabled:hover, .iac:disabled:hover { background: none; color: var(--ink-4); }

/* ===== Статусы-пилюли ===== */
.st {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 99px;
    white-space: nowrap;
}

.st.ok { color: var(--green); background: var(--green-soft); }
.st.run { color: #1F4FA0; background: #E4ECF8; }
.st.err { color: var(--err); background: var(--err-soft); }
.st.draft { color: var(--ink-3); background: #EDEEF2; }
.st.warn { color: var(--amber); background: var(--amber-soft); }

.typepill {
    display: inline-flex;
    align-items: center;
    padding: 4px 13px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: var(--btn);
}

.role { font-size: 13px; color: var(--ink-2); }
.role.owner { color: var(--brand-text); font-weight: 600; }

/* ===== Ячейка версии ===== */
.vcell { line-height: 1.5; }
.vcell .vmain { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.vcell .vsub {
    font-size: 11.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.vcell .vsub.upd { color: var(--green); }
.vcell .vsub.save { color: var(--green); }
.vcell .vsub.muted { color: var(--ink-4); }
.vcell .vsub svg { width: 12px; height: 12px; stroke-width: 2; }

/* ===== Прогресс ===== */
.prog {
    height: 5px;
    border-radius: 99px;
    background: #E4ECF8;
    overflow: hidden;
    margin-top: 6px;
    max-width: 170px;
}

.prog > i { display: block; height: 100%; background: var(--hl); width: 0%; }

/* ===== Бокс кода потоков ===== */
.codebox {
    border: 1px solid var(--border-2);
    border-radius: 6px;
    background: #FBFBFD;
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--ink-2);
    white-space: pre;
    overflow: auto;
}

.codebox .kw { color: #7C3AED; }
.codebox .ty { color: var(--brand-text); }

/* Заголовок-плашка потока над codebox */
.stream-name {
    background: #EEF0F4;
    border-radius: 6px 6px 0 0;
    padding: 14px 18px 13px;
    position: relative;
    border: 1px solid var(--border);
    border-bottom: 0;
}

.stream-name .lbl { font-size: 11px; color: var(--ink-4); font-weight: 500; margin-bottom: 3px; }
.stream-name .v { font-size: 15px; color: var(--ink-2); font-weight: 600; }

.stream-name .cov {
    position: absolute;
    right: 16px;
    bottom: 12px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink-4);
}

/* ===== Чипы в ячейках (подгруппа действий) ===== */
.cellchips { display: inline-flex; align-items: center; gap: 2px; }

.pchip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 99px;
    background: var(--brand-soft);
    color: var(--brand-text);
    font-size: 11px;
    font-weight: 700;
    margin-right: 2px;
}

/* ===== Примечание ===== */
.note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--ink-3);
}

.note b { color: var(--ink-2); font-weight: 600; }

/* ===== Легаси-иконки feather в контенте страниц ===== */
.feather { width: 16px; height: 16px; }

/* CodeMirror под стиль codebox (вместо чёрной рамки 2px) */
.CodeMirror {
    border: 1px solid var(--border-2) !important;
    border-radius: 0 0 6px 6px;
    background: #FBFBFD;
    font-family: var(--mono) !important;
    font-size: 12.5px !important;
    line-height: 1.7 !important;
}
