/* MC Tech Admin */
:root {
    --bg: #10140f;
    --bg-2: #161c15;
    --panel: #1b231a;
    --panel-2: #222c20;
    --line: #334232;
    --text: #e6efe4;
    --muted: #8fa08b;
    --moss: #7dbe62;
    --moss-dim: #4e7a3c;
    --gold: #d2b056;
    --danger: #d4654f;
    --console: #0a0e09;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --radius: 14px;
    --mono: "IBM Plex Mono", "Consolas", "Cascadia Mono", monospace;
    --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--sans);
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(125, 190, 98, 0.08), transparent 55%),
        linear-gradient(180deg, var(--bg) 0%, #0c100b 100%);
    color: var(--text);
    min-height: 100%;
}

a { color: var(--moss); text-decoration: none; }
button, input, textarea, select { font-family: inherit; }

:focus-visible {
    outline: 2px solid var(--moss);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Классы с display перебивают hidden, а он нужен для чипов и панелей прогресса */
[hidden] { display: none !important; }

.auth-wrap {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 32px 16px;
}
.auth-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 32px 28px 28px;
    box-shadow: var(--shadow);
}
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 9px;
    background: linear-gradient(160deg, #8fd36a, #3d6b32);
    display: grid;
    place-items: center;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #10210c;
    margin-bottom: 16px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 26px; }
.auth-card p { margin: 0 0 22px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.field input {
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 11px 12px;
    outline: none;
}
.field input:focus { border-color: var(--moss-dim); }
.alert {
    background: rgba(212, 101, 79, 0.12);
    color: #f0b4a8;
    border: 1px solid rgba(212, 101, 79, 0.28);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 14px;
}
.alert.ok {
    background: rgba(125, 190, 98, 0.12);
    color: #c6e7b7;
    border-color: rgba(125, 190, 98, 0.28);
}

.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100%;
}
.layout-fill {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}
.layout-fill .main {
    min-height: 0;
    overflow: hidden;
}
.content-fill {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.content-fill .hint { flex: none; }
.side {
    background: var(--bg-2);
    border-right: 1px solid var(--line);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    /* Меню не должно уезжать вверх на длинных страницах */
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 8px;
}
.logo strong { display: block; font-size: 15px; }
.logo span { color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
    color: var(--text);
    padding: 10px 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav a.active, .nav a:hover { background: var(--panel-2); }
.side-foot { margin-top: auto; color: var(--muted); font-size: 12px; padding: 8px; word-break: break-all; }

.main { display: flex; flex-direction: column; min-width: 0; }
.top {
    min-height: 64px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 22px;
    background: rgba(16, 20, 15, 0.86);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 8;
}
.layout-fill .top { position: static; }
.top-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; margin-right: auto; }
.page-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 36px;
    padding: 0 9px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}
.burger span { display: block; height: 2px; background: var(--text); border-radius: 2px; }
.nav-scrim {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 4, 0.6);
    z-index: 20;
}
.role {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--gold);
    font-size: 12px;
    font-weight: 500;
}
.user { color: var(--muted); font-size: 14px; display: flex; gap: 14px; align-items: center; }
.content { padding: 22px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.settings {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.settings h2 { margin: 0 0 14px; font-size: 18px; }
.settings textarea {
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
    min-height: 90px;
    resize: vertical;
    font-family: var(--mono);
    font-size: 13px;
}
.settings .field input,
.settings .field select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 11px 12px;
    outline: none;
}
.settings .muted { display: block; margin-top: 6px; }
.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    color: var(--text);
    font-size: 14px;
}

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    background: var(--moss);
    color: #13210e;
    font-weight: 600;
}
.btn:hover { filter: brightness(1.05); }
.btn.ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}
.btn.danger { background: var(--danger); color: #fff; }
.btn.gold { background: var(--gold); color: #231b08; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}
.top-head .status { min-width: 0; }
.top-head .status span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.top-head .status .dot { flex: none; }
.dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--danger);
}
.dot.on { background: var(--moss); box-shadow: 0 0 0 4px rgba(125, 190, 98, 0.15); }

.console-shell {
    flex: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--console);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.console-bar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: #10160f;
}
.console-bar .btn {
    padding: 7px 12px;
    font-size: 13px;
}
.console-bar .btn.active {
    background: var(--moss);
    color: #13210e;
    border-color: var(--moss);
}
.console-offline.wait {
    background: rgba(210, 176, 86, 0.14);
    border-bottom-color: rgba(210, 176, 86, 0.35);
    color: #e8d59a;
}
.console-out {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    color: #c7e8b8;
}
.console-in {
    flex: none;
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: #10160f;
}
.console-complete {
    flex: 1;
    position: relative;
    min-width: 0;
}
.console-complete input {
    width: 100%;
    background: #0c120b;
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 12px 12px;
    font-family: var(--mono);
    outline: none;
}
#console-suggest {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    margin: 0;
    padding: 6px;
    list-style: none;
    max-height: 220px;
    overflow: auto;
    background: #151c14;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 6;
}
#console-suggest li {
    padding: 7px 10px;
    font-family: var(--mono);
    font-size: 13px;
    color: #c7e8b8;
    border-radius: 7px;
    cursor: pointer;
}
#console-suggest li.active,
#console-suggest li:hover {
    background: #2a3a27;
    color: #fff;
}
.hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
}
.toolbar label {
    color: var(--muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toolbar select {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 12px;
}
.access-yes { color: var(--moss); font-weight: 550; }
.access-no { color: var(--muted); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 14px; }
.crumbs a { color: var(--moss); }
.crumbs span { color: var(--text); }

.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: auto;
    box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 500; background: var(--panel-2); }
tr:hover td { background: rgba(125, 190, 98, 0.04); }
.row-name { color: var(--text); font-weight: 550; cursor: pointer; }
.row-name.dir { color: var(--gold); }
.file-ext {
    display: inline-flex;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable.sorted::after { content: " ▾"; font-size: 11px; }
th.sortable.sorted[data-dir="asc"]::after { content: " ▴"; }
.search-input {
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 12px;
    min-width: 160px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }

.drop {
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 16px;
    color: var(--muted);
    text-align: center;
    margin-bottom: 14px;
}
.backup-progress {
    margin: 0 0 14px;
    padding: 12px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
}
.backup-bar {
    height: 8px;
    border-radius: 99px;
    background: #1c271b;
    overflow: hidden;
}
.backup-bar i {
    display: block;
    height: 100%;
    width: 12%;
    background: var(--moss);
    border-radius: 99px;
    transition: width 0.4s ease;
}
.backup-bar i.ok { width: 100%; background: var(--moss); }
.backup-bar i.err { width: 100%; background: var(--danger); }
.backup-progress p { margin: 8px 0 0; }

.content-fill .toolbar { flex: none; }
.lang-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #10160f;
    color: var(--gold);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.editor-wrap {
    flex: 1;
    display: flex;
    min-height: 0;
    background: var(--console);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.editor-gutter {
    flex: none;
    margin: 0;
    width: 52px;
    padding: 16px 10px 16px 0;
    overflow: hidden;
    text-align: right;
    color: #4d5c4b;
    background: #0c120b;
    border-right: 1px solid #1c271b;
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.55;
    user-select: none;
    white-space: pre;
}
.editor-pane {
    position: relative;
    flex: 1;
    min-width: 0;
}
.editor-hl,
.editor-pane textarea {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 16px 18px;
    border: 0;
    overflow: auto;
    white-space: pre;
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.55;
    tab-size: 2;
}
.editor-hl {
    color: #d7ecd0;
    pointer-events: none;
    background: transparent;
}
.editor-pane textarea {
    z-index: 1;
    background: transparent;
    color: transparent;
    caret-color: #e8f3e4;
    resize: none;
    outline: none;
}
/* Большие файлы показываем без подсветки, иначе перекраска на каждый ввод подвешивает вкладку */
.editor-pane.plain .editor-hl { display: none; }
.editor-pane.plain textarea { color: #d7ecd0; }
.hl-cmt { color: #6a7868; font-style: italic; }
.hl-key { color: #b9d6b0; }
.hl-str { color: #e2c56d; }
.hl-num { color: #7dbe62; }
.hl-bool { color: #7eb8d4; }
.hl-null { color: #8fa08b; }
.hl-val { color: #f3d7a4; }
.hl-pun { color: #6d806a; }

.modal-bg {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    display: none;
    place-items: center;
    padding: 16px;
}
.modal-bg.show { display: grid; }
.modal {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
}
.modal h3 { margin: 0 0 12px; }
.modal .field { margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.section-title { margin: 22px 0 12px; font-size: 18px; }
.project-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}
.project-switch select {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 8px;
    font-family: var(--sans);
    font-size: 13px;
}
.mode-badge {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gold);
    border: 1px solid #4c4020;
    border-radius: 999px;
    padding: 3px 9px;
}
.tech-users { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 10px; }
.tech-users .check { margin: 0; }

.node-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}
.node-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.node-head strong { font-size: 16px; }
.node-head .muted { font-size: 12px; }
.node-state {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
}
.node-state.on { color: var(--moss); border-color: var(--moss-dim); }
.node-state.off { color: var(--danger); border-color: #5a3129; }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px 10px;
    min-width: 92px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.kpi span { color: var(--muted); font-size: 11px; }
.kpi b { font-family: var(--mono); font-size: 13px; }
.charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}
.chart-box {
    background: var(--console);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px 4px;
}
.chart-title { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.chart { display: block; width: 100%; }
.bars { margin-top: 14px; display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; font-size: 12px; }
.bar-label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bar-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--moss-dim), var(--moss)); }
.bar-value { font-family: var(--mono); }
.node-actions { margin-top: 12px; display: flex; gap: 8px; align-items: center; font-size: 12px; }
.spark-link {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 14px;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 13px;
}
.spark-link a { color: var(--gold); font-family: var(--mono); word-break: break-all; }
.content .console-shell { min-height: 240px; }

.toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(380px, calc(100vw - 32px));
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: var(--shadow);
    background: rgba(212, 101, 79, 0.16);
    border: 1px solid rgba(212, 101, 79, 0.4);
    color: #f5c6ba;
}
.toast.ok {
    background: rgba(125, 190, 98, 0.16);
    border-color: rgba(125, 190, 98, 0.4);
    color: #cdebbd;
}
.toast-x {
    margin-left: auto;
    background: none;
    border: 0;
    color: inherit;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
}
.toast-x:hover { opacity: 1; }

.drop.over {
    border-color: var(--moss);
    border-style: solid;
    background: rgba(125, 190, 98, 0.08);
    color: var(--text);
}
.row-name.plain { cursor: default; font-weight: 400; }
.empty-row td { color: var(--muted); text-align: center; padding: 26px 14px; }
.read-only-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid #4c4020;
    color: var(--gold);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.dirty-dot { color: var(--gold); font-weight: 700; }

@media (max-width: 980px) {
    .user-name { display: none; }
    .project-switch span { display: none; }
}

@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
    .burger { display: flex; }
    .side {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 264px;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }
    .side.open { transform: none; box-shadow: var(--shadow); }
    body.nav-open { overflow: hidden; }
    /* Консоль и редактор не запираем на один экран: страница должна скроллиться */
    .layout-fill { height: auto; max-height: none; overflow: visible; }
    .layout-fill .main, .content-fill { overflow: visible; }
    .console-shell, .editor-wrap { min-height: 62vh; }
    .top { padding: 10px 14px; }
    .content { padding: 16px 14px; }
    .role { display: none; }
    .bar-row { grid-template-columns: 1fr; }
}

@media (min-width: 861px) {
    .nav-scrim { display: none; }
}

.error-card {
    width: min(460px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 32px 28px 28px;
    box-shadow: var(--shadow);
}
.error-code {
    margin: 0 0 8px;
    font-family: var(--mono);
    font-size: 72px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--moss);
}
.error-card.warn .error-code { color: var(--gold); }
.error-card.danger .error-code { color: var(--danger); }
.error-card h1 { margin: 0 0 8px; font-size: 24px; }
.error-card > p { margin: 0 0 10px; color: var(--muted); }
.error-path {
    font-family: var(--mono);
    font-size: 12px;
    word-break: break-all;
    color: var(--muted);
    opacity: 0.85;
}
.error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #13210e;
    text-decoration: none;
}
a.btn.ghost { color: var(--text); }

.seal-banner {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 18px;
    margin: 0 0 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.seal-banner .dot { margin-top: 6px; }
.seal-banner strong { display: block; margin-bottom: 4px; }
.seal-banner.ok { border-color: rgba(125, 190, 98, 0.45); }
.seal-banner.bad { border-color: rgba(220, 80, 70, 0.55); }
.seal-banner.off { opacity: 0.95; }
.seal-h { margin: 22px 0 10px; font-size: 16px; }
.seal-ok { color: var(--moss); font-weight: 550; }
.seal-missing, .seal-tampered, .seal-renamed { color: var(--danger); font-weight: 550; }
.seal-hash { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.file-ext.seal-lock {
    color: var(--gold);
    border-color: rgba(212, 168, 75, 0.45);
}
