* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f6f8;
    color: #1f2329;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #1f2329;
    color: white;
}

.topbar .brand {
    font-weight: 600;
    font-size: 1.2rem;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar a {
    color: #cfd4dd;
    text-decoration: none;
}

.topbar a:hover {
    color: white;
}

.topbar .user {
    color: #8a94a6;
    font-size: .9rem;
}

.inline {
    display: inline;
}

.link-button {
    background: none;
    border: none;
    color: #cfd4dd;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.link-button:hover {
    color: white;
}

.container {
    max-width: 900px;
    margin: 24px auto;
    padding: 0 24px;
}

h1 {
    margin-top: 0;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.card h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

button, .button {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #1f2329;
    background: #1f2329;
    color: white;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

button:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .85rem;
}

.badge.stopped {
    background: #fce1e1;
    color: #b3261e;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
}

.login-card {
    background: #fff;
    padding: 36px 32px 28px;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .10);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 1.85rem;
    letter-spacing: -.01em;
}

.login-card h2 {
    margin: 0 0 26px;
    font-size: 1.05rem;
    color: #6b7280;
    font-weight: 400;
}

.login-card label {
    display: block;
    margin-bottom: 16px;
}

.login-card label span {
    display: block;
    font-size: .9rem;
    margin-bottom: 6px;
    color: #374151;
    font-weight: 500;
}

.login-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font: inherit;
    font-size: 1rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.login-card input:focus {
    outline: none;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

.generated-line {
    display: inline-block;
    width: 100%;
    background: #fff3cd;
    border-left: 3px solid #f59e0b;
    padding-left: 6px;
    margin-left: -9px;
}

.config-editor-content {
    width: 100%;
    min-height: 500px;
    max-height: 700px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: "SF Mono", Consolas, monospace;
    font-size: .85rem;
    line-height: 1.5;
    background: #f8f9fb;
    color: #1f2329;
    white-space: pre;
    overflow: auto;
    tab-size: 2;
    outline: none;
    box-sizing: border-box;
}

.config-editor-content:focus {
    outline: 2px solid #1d4ed8;
    outline-offset: -1px;
}

.config-editor-content .config-line {
    display: inline;
}

.config-editor-content .generated-line {
    display: inline-block;
    min-width: 100%;
    background: #fff3cd;
    border-left: 3px solid #f59e0b;
    padding-left: 6px;
    margin-left: -9px;
    box-sizing: border-box;
    cursor: not-allowed;
}

.config-editor-content .generated-line::after {
    content: ' ⚙';
    color: #f59e0b;
    font-size: .75rem;
    user-select: none;
}

.login-card button {
    width: 100%;
    margin-top: 10px;
    padding: 14px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    min-height: 48px;
}

.alert {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: .9rem;
    margin-bottom: 12px;
}

.alert.error {
    background: #fce1e1;
    color: #b3261e;
}

.alert.info {
    background: #e0eaff;
    color: #1d4ed8;
}

.lang-switch {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    color: #8a94a6;
    font-size: .85rem;
}

.lang-switch a {
    color: #cfd4dd;
}

.lang-switch a:hover {
    color: white;
}

.lang-switch-login {
    margin-top: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: .85rem;
}

.lang-switch-login a {
    color: #6b7280;
    text-decoration: none;
}

.lang-switch-login a:hover {
    color: #1f2329;
}

.container.narrow {
    max-width: 520px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #eef0f3;
}

.table th {
    background: #f8f9fb;
    font-weight: 600;
    color: #4b5563;
    font-size: .85rem;
}

.table tr:last-child td {
    border-bottom: none;
}

.table .actions {
    text-align: right;
    white-space: nowrap;
}

.link {
    color: #1d4ed8;
    text-decoration: none;
    margin-left: 12px;
}

.link:hover {
    text-decoration: underline;
}

.link-button.danger {
    color: #b3261e;
    margin-left: 12px;
}

.link-button.danger:hover {
    color: #7a1a14;
}

.badge.admin {
    background: #e0eaff;
    color: #1d4ed8;
}

.badge.user {
    background: #eef0f3;
    color: #4b5563;
}

.badge.enabled {
    background: #d8f3dc;
    color: #1b7a3a;
}

.badge.disabled {
    background: #fce1e1;
    color: #b3261e;
}

.muted {
    color: #6b7280;
}

.form .field {
    margin-bottom: 16px;
}

.form label {
    display: block;
    font-size: .9rem;
    margin-bottom: 6px;
    color: #374151;
}

.form input[type=text],
.form input[type=password],
.form select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font: inherit;
}

.form .checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.form .checkbox input {
    width: auto;
}

.form .hint {
    color: #6b7280;
    font-size: .8rem;
    margin: 4px 0 0;
}

.form .field-error {
    color: #b3261e;
    font-size: .8rem;
    margin: 4px 0 0;
}

.form .has-error input,
.form .has-error select {
    border-color: #b3261e;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.form-actions .link {
    margin: 0;
}

.alert.success {
    background: #d8f3dc;
    color: #1b7a3a;
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 8px;
}

.inline-form label {
    margin: 0;
}

.inline-form input {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font: inherit;
    width: 140px;
}

.logs {
    background: #1f2329;
    color: #d4d4d4;
    padding: 12px;
    border-radius: 6px;
    font-family: "SF Mono", Consolas, monospace;
    font-size: .8rem;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre;
    word-break: normal;
    margin: 0;
}

.logs.log-soft-wrap {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: hidden;
}

.chart-empty {
    margin: 4px 0 0;
    font-size: .78rem;
    color: #9ca3af;
    text-align: center;
}

.copy-box {
    display: flex;
    gap: 8px;
    align-items: center;
}

.copy-box input[type=text] {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font: inherit;
    font-family: "SF Mono", Consolas, monospace;
    font-size: .85rem;
    background: #f8f9fb;
    color: #1f2329;
}

.copy-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: white;
    color: #1f2329;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    min-width: 90px;
}

.copy-btn:hover {
    background: #f5f6f8;
}

.config-editor {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: "SF Mono", Consolas, monospace;
    font-size: .85rem;
    line-height: 1.5;
    background: #f8f9fb;
    color: #1f2329;
    resize: vertical;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    tab-size: 2;
}

.config-editor:focus {
    outline: 2px solid #1d4ed8;
    outline-offset: -1px;
}

.link-button.on-light {
    color: #1d4ed8;
}

.link-button.on-light:hover {
    color: #1e3a8a;
}

.link-button.on-light.danger {
    color: #b3261e;
}

.link-button.on-light.danger:hover {
    color: #7a1a14;
}

.import-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.log-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
}

.log-filter select {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font: inherit;
    background: white;
}

/* ===== Breadcrumbs ===== */
.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: .85rem;
    color: #9ca3af;
    padding: 12px 24px;
    background: #f8f9fb;
    border-bottom: 1px solid #eef0f3;
    margin: 0 0 20px;
    line-height: 1.4;
}

.breadcrumbs a {
    color: #9ca3af;
    text-decoration: none;
    padding: 4px 2px;
    transition: color .15s ease;
}

.breadcrumbs a:hover {
    color: #1f2329;
    text-decoration: none;
}

.breadcrumbs .crumb-sep {
    color: #d1d5db;
    font-size: .8rem;
    user-select: none;
}

.breadcrumbs .crumb-current {
    color: #4b5563;
    font-weight: 500;
    padding: 4px 2px;
}

/* ===== Import panels (home) ===== */
.import-panels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.import-panel {
    display: flex;
    flex-direction: column;
    padding: 18px 18px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    min-height: 108px;

    font: inherit;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.import-panel:hover,
.import-panel:focus-visible {
    transform: translateY(-2px);
    border-color: #1d4ed8;
    box-shadow: 0 8px 20px rgba(29, 78, 216, .08);
    outline: none;
}

.import-panel-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1f2329;
    margin-bottom: 6px;
}

.import-panel-desc {
    color: #6b7280;
    font-size: .92rem;
    line-height: 1.35;
    flex: 1;
}

.import-panel-arrow {
    align-self: flex-end;
    color: #1d4ed8;
    font-size: 1.35rem;
    line-height: 1;
    transition: transform .15s ease;
}

.import-panel:hover .import-panel-arrow {
    transform: translateX(4px);
}

/* ===== Admin grid ===== */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.admin-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 150px;
    padding: 20px 20px 48px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.admin-card:hover,
.admin-card:focus-visible {
    transform: translateY(-2px);
    border-color: #1d4ed8;
    box-shadow: 0 8px 20px rgba(29, 78, 216, .08);
    outline: none;
}

.admin-card h3 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1f2329;
}

.admin-card-desc {
    margin: 0;
    color: #6b7280;
    font-size: .88rem;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .15s ease, transform .15s ease;
}

.admin-card:hover .admin-card-desc,
.admin-card:focus-visible .admin-card-desc {
    opacity: 1;
    transform: translateY(0);
}

.admin-card-arrow {
    position: absolute;
    right: 16px;
    bottom: 14px;
    font-size: 1.25rem;
    line-height: 1;
    color: #1d4ed8;
    transition: transform .15s ease;
}

.admin-card:hover .admin-card-arrow {
    transform: translate(3px, -3px);
}

/* ===== Base mobile-friendly tweaks ===== */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    -webkit-tap-highlight-color: transparent;
}

input, select, textarea, button {
    font-family: inherit;
}

/* ===== Advanced block (collapsible) ===== */
.advanced-block {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
}

.advanced-block > summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 18px;
    font-size: .92rem;
    color: #6b7280;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    transition: color .15s ease;
}

.advanced-block > summary::-webkit-details-marker {
    display: none;
}

.advanced-block > summary::before {
    content: "›";
    display: inline-block;
    font-size: 1.1rem;
    line-height: 1;
    transition: transform .2s ease;
    color: #9ca3af;
}

.advanced-block[open] > summary::before {
    transform: rotate(90deg);
}

.advanced-block > summary:hover {
    color: #1f2329;
}

.advanced-block-body {
    padding: 0 18px 18px;
    border-top: 1px solid #eef0f3;
}

.advanced-block-body .hint {
    margin: 14px 0 10px;
}

/* ===== Monitoring ===== */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.metric-tile {
    background: #f8f9fb;
    border: 1px solid #eef0f3;
    border-radius: 10px;
    padding: 14px 16px;
}

.metric-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1f2329;
    line-height: 1.2;
}

.metric-sub {
    font-size: .78rem;
    color: #9ca3af;
    margin-top: 4px;
}

.chart-block {
    margin-bottom: 20px;
}

.chart-block:last-child {
    margin-bottom: 0;
}

.chart-title {
    font-size: .82rem;
    color: #4b5563;
    font-weight: 500;
    margin-bottom: 8px;
}

.chart {
    width: 100%;
    height: 120px;
    display: block;
    background: #f8f9fb;
    border-radius: 8px;
}

.chart-axis {
    stroke: #e5e7eb;
    stroke-width: 1;
}

.chart-line {
    fill: none;
    stroke-width: 1.8;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart-line-cpu {
    stroke: #1d4ed8;
}

.chart-line-mem {
    stroke: #16a34a;
}

.chart-line-xray {
    stroke: #d97706;
}

@media (max-width: 720px) {
    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .metric-tile {
        padding: 10px 12px;
    }

    .metric-value {
        font-size: 1.15rem;
    }

    .chart {
        height: 90px;
    }
}

@media (max-width: 720px) {
    .advanced-block > summary {
        padding: 12px 16px;
    }

    .advanced-block-body {
        padding: 0 16px 16px;
    }
}

/* ===== Responsive ===== */
@media (max-width: 720px) {

    /* Topbar — sticky, две строки */
    .topbar {
        position: sticky;
        top: 0;
        z-index: 50;
        padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px));
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
        flex-wrap: wrap;
        gap: 0;
        background: rgba(31, 35, 41, .96);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .topbar .brand {
        font-size: 1.15rem;
        font-weight: 700;
        flex: 1 1 auto;
        line-height: 1;
        padding-bottom: 10px;
    }

    .topbar nav {
        flex: 1 1 100%;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 10px 14px;
        row-gap: 8px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, .10);
        font-size: .92rem;
    }

    .topbar nav a,
    .topbar nav .link-button {
        padding: 6px 0;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        line-height: 1;
    }

    .topbar .lang-switch {
        font-size: .82rem;
        gap: 4px;
    }

    .topbar .user {
        margin-left: auto;
        font-size: .82rem;
        color: #8a94a6;
        max-width: 30%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Контейнер */
    .container {
        margin: 20px auto 24px;
        padding: 0 16px;
    }

    .container.narrow {
        max-width: 100%;
    }

    h1 {
        font-size: 1.35rem;
        margin-bottom: 14px;
    }

    h2 {
        font-size: 1.05rem;
    }

    .card {
        padding: 14px 16px;
        border-radius: 10px;
        margin-bottom: 12px;
    }

    /* Кнопки / инпуты — крупные тап-зоны */
    button, .button {
        padding: 12px 18px;
        font-size: 1rem;
        min-height: 44px;
        border-radius: 8px;
        width: auto;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .form-actions button,
    .form-actions .button {
        width: 100%;
    }

    .form-actions .link {
        margin: 0;
        text-align: center;
        padding: 10px 0;
    }

    .form input[type=text],
    .form input[type=password],
    .form input[type=number],
    .form select,
    .login-card input {
        font-size: 16px; /* iOS: не зумит при фокусе */
        padding: 12px 12px;
        min-height: 46px;
        border-radius: 8px;
        width: 100%;
    }

    /* Login — почти full-screen на мобиле */
    .login-page {
        align-items: center;
        justify-content: center;
        padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
        padding-top: calc(20px + env(safe-area-inset-top, 0px));
        min-height: 100dvh;
    }

    .login-card {
        width: 100%;
        max-width: 100%;
        padding: 28px 22px 24px;
        border-radius: 14px;
    }

    .login-card h1 {
        font-size: 2rem;
        margin-bottom: 4px;
    }

    .login-card h2 {
        font-size: 1rem;
        margin-bottom: 22px;
    }

    .login-card label {
        margin-bottom: 14px;
    }

    .login-card label span {
        font-size: .85rem;
    }

    .login-card input {
        font-size: 16px;
        padding: 14px 14px;
        min-height: 52px;
        border-radius: 10px;
    }

    .login-card button {
        width: 100%;
        margin-top: 12px;
        padding: 16px;
        font-size: 1.05rem;
        min-height: 54px;
        border-radius: 10px;
    }

    .lang-switch-login {
        margin-top: 20px;
        font-size: .9rem;
    }

    /* Toolbar — вертикально */
    .toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        flex-wrap: wrap;
    }

    .toolbar .button {
        width: auto;
        text-align: left;
        padding: 10px 16px;
        min-height: 40px;
        font-size: .95rem;
    }

    .toolbar .link {
        padding: 6px 0;
    }

    /* Copy-box — stacked */
    .copy-box {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .copy-box input[type=text] {
        width: 100%;
        font-size: 16px;
        padding: 12px 12px;
        min-height: 46px;
    }

    .copy-btn {
        width: 100%;
        min-height: 44px;
        font-size: 1rem;
    }

    /* ===== Tables → cards ===== */
    .table {
        display: block;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
        white-space: normal;
    }

    .table thead {
        display: none;
    }

    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 12px 14px;
        margin-bottom: 10px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
    }

    .table tr:last-child {
        margin-bottom: 0;
    }

    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 6px 0;
        border: none;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: right;
        font-size: .92rem;
    }

    .table td::before {
        content: attr(data-label);
        font-size: .72rem;
        font-weight: 600;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: .04em;
        flex: 0 0 auto;
        text-align: left;
    }

    .table td:not([data-label])::before {
        display: none;
    }

    /* Первая ячейка — как заголовок карточки */
    .table td:first-child {
        padding-top: 0;
        padding-bottom: 10px;
        margin-bottom: 8px;
        border-bottom: 1px solid #eef0f3;
        font-weight: 700;
        font-size: 1.08rem;
        color: #1f2329;
        justify-content: flex-start;
        text-align: left;
    }

    .table td:first-child::before {
        display: none;
    }

    .table td:first-child + td {
        padding-top: 8px;
    }

    .table td::before {
        color: #4b5563;
    }

    /* Действия — в подвале карточки */
    .table td.actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 8px 18px;
        padding-top: 12px;
        padding-bottom: 0;
        margin-top: 8px;
        border-top: 1px solid #eef0f3;
        text-align: right;
    }

    .table td.actions::before {
        display: none;
    }

    .table td.actions .link,
    .table td.actions .link-button {
        padding: 6px 0;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        margin: 0;
        font-size: .92rem;
    }

    /* Import panels */
    .import-panels {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .import-panel {
        min-height: 96px;
        padding: 16px 16px 12px;
    }

    .import-panel-title {
        font-size: 1.15rem;
    }

    /* Admin grid */
    .admin-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .admin-card {
        min-height: auto;
        padding: 16px 18px 42px;
    }

    .admin-card-desc {
        opacity: 1;
        transform: none;
    }

    .admin-card-arrow {
        transform: none !important;
    }

    /* Breadcrumbs */
    .breadcrumbs {
        padding: 10px 16px;
        margin: 0 0 14px;
        font-size: .8rem;
        gap: 4px;
    }

    .breadcrumbs a,
    .breadcrumbs .crumb-current {
        padding: 3px 1px;
    }

    /* Логи */
    .logs {
        font-size: .72rem;
        line-height: 1.45;
        padding: 10px;
        max-height: 55vh;
    }

    /* Log filter */
    .log-filter {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .log-filter select {
        width: 100%;
        font-size: 16px;
        padding: 10px 12px;
        min-height: 44px;
    }

    /* Config editor */
    .config-editor {
        font-size: 14px;
        padding: 10px;
    }
}

@media (max-width: 380px) {
    .topbar nav {
        gap: 8px 12px;
        font-size: .85rem;
    }

    h1 {
        font-size: 1.22rem;
    }

    .card {
        padding: 12px 14px;
    }
}

.log-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.log-collapse-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.log-keyword-filter {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font: inherit;
    font-size: .9rem;
    min-width: 180px;
}

@media (max-width: 720px) {
    .log-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .log-keyword-filter {
        width: 100%;
        font-size: 16px;
        padding: 10px 12px;
        min-height: 44px;
    }
}

/* ===== Log viewer additions ===== */

.log-fullscreen {
    font-size: 1rem;
    padding: 2px 8px;
}

.log-viewer.log-fullscreen-active {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #fff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.log-viewer.log-fullscreen-active .logs {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
    margin: 0;
}

.log-viewer.log-fullscreen-active .log-toolbar {
    flex: 0 0 auto;
}

/* ===== Chart axes / grid / legend ===== */
.chart-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.chart-stats {
    display: flex;
    gap: 14px;
    font-size: .78rem;
    color: #9ca3af;
}

.chart-stats b {
    color: #1f2329;
    font-weight: 600;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 6px;
    font-size: .78rem;
    color: #4b5563;
}

.chart-legend-swatch {
    display: inline-block;
    width: 18px;
    height: 0;
    border-top-width: 2px;
    border-top-style: solid;
    border-top-color: #9ca3af;
}

.chart-legend-swatch.chart-line-pod {
    border-top-color: #1d4ed8;
    border-top-width: 3px;
}

.chart-legend-swatch.chart-line-xray {
    border-top-color: #d97706;
    border-top-style: dashed;
}

.chart-legend-swatch.chart-line-cache {
    border-top-color: #6b7280;
    border-top-style: dashed;
}

.chart-legend-swatch.chart-line-telemt {
    border-top-color: #7c3aed;
    border-top-style: dashed;
}

.chart-legend-swatch.chart-line-jvm {
    border-top-color: #1d4ed8;
    border-top-width: 3px;
}

.chart-wrap {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.chart-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 120px;
    min-width: 56px;
    font-size: .7rem;
    color: #9ca3af;
    font-family: "SF Mono", Consolas, monospace;
    text-align: right;
    line-height: 1;
}

.chart-y-axis span {
    transform: translateY(-50%);
}

.chart-y-axis span:first-child {
    transform: translateY(0);
}

.chart-y-axis span:last-child {
    transform: translateY(-100%);
}

.chart-x-axis {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: #9ca3af;
    padding: 2px 4px 0 64px;
    font-family: "SF Mono", Consolas, monospace;
}

.chart-grid {
    stroke: #e5e7eb;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.chart-line,
.chart-line-pod,
.chart-line-cache,
.chart-line-xray,
.chart-line-telemt,
.chart-line-jvm {
    fill: none;
    stroke-width: 1.8;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.chart-line-bold {
    stroke-width: 2.4;
}

.chart-line-dashed {
    stroke-dasharray: 5 4;
    stroke-width: 1.5;
}

.chart-line-pod {
    stroke: #1d4ed8;
}

/* Вся cgroup-память вместе с page cache: серая, вспомогательная. */
.chart-line-cache {
    stroke: #6b7280;
}

.chart-line-xray {
    stroke: #d97706;
}

.chart-line-telemt {
    stroke: #7c3aed;
}

.chart-line-jvm {
    stroke: #1d4ed8;
}

/* ===== Highlight: клик по подписи в легенде выделяет линию ===== */
.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 6px 2px 12px;
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: background-color .12s ease, opacity .12s ease;
}

/* Цветной штрих серии — те же цвета, что у линий на графике. */
.chart-legend-item.chart-line-pod {
    border-top: 0;
    background-image: linear-gradient(#1d4ed8, #1d4ed8);
    background-repeat: no-repeat;
    background-position: 4px 50%;
    background-size: 14px 3px;
}

.chart-legend-item.chart-line-xray {
    border-top: 0;
    background-image: linear-gradient(90deg, #d97706 60%, transparent 60%);
    background-repeat: no-repeat;
    background-position: 4px 50%;
    background-size: 14px 3px;
}

.chart-legend-item.chart-line-cache {
    border-top: 0;
    background-image: linear-gradient(90deg, #6b7280 60%, transparent 60%);
    background-repeat: no-repeat;
    background-position: 4px 50%;
    background-size: 14px 3px;
}

.chart-legend-item.chart-line-telemt {
    border-top: 0;
    background-image: linear-gradient(90deg, #7c3aed 60%, transparent 60%);
    background-repeat: no-repeat;
    background-position: 4px 50%;
    background-size: 14px 3px;
}

.chart-legend-item.chart-line-jvm {
    border-top: 0;
    background-image: linear-gradient(#1d4ed8, #1d4ed8);
    background-repeat: no-repeat;
    background-position: 4px 50%;
    background-size: 14px 3px;
}

.chart-legend-item:hover {
    background-color: #f3f4f6;
}

.chart-legend-item:focus-visible {
    outline: 2px solid #1d4ed8;
    outline-offset: 1px;
}

/* Приглушённые серии: и линия на графике, и подпись в легенде.
   У линий класс вида chart-line-pod / chart-line-xray, а не chart-line. */
.chart-legend-item.chart-legend-dimmed,
path[class*="chart-line-"].chart-line-dimmed {
    opacity: .22;
}

.chart-legend-item.chart-legend-dimmed:hover {
    opacity: .6;
}


@media (max-width: 720px) {
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .chart-stats {
        font-size: .72rem;
    }
}

/* ===== Telegram add buttons ===== */
.tg-add-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.tg-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    background: #229ED9;
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    line-height: 1;
    min-height: 44px;
    box-sizing: border-box;
    transition: background .15s ease, transform .1s ease;
}

.tg-add-btn::before {
    content: "";
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M9.78 18.65l.28-4.23 7.68-6.92c.34-.31-.07-.46-.52-.19L7.74 13.3 3.64 12c-.88-.25-.89-.86.2-1.3l15.97-6.16c.73-.33 1.43.18 1.15 1.3l-2.72 12.81c-.19.91-.74 1.13-1.5.71L12.6 16.3l-1.99 1.93c-.23.23-.42.42-.83.42z'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
}

.tg-add-btn:hover {
    background: #1c8ec4;
    color: #fff;
}

.tg-add-btn:active {
    transform: scale(.98);
}

@media (max-width: 720px) {
    .tg-add-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .tg-add-btn {
        justify-content: center;
        width: 100%;
    }
}

/* ===== Modal overlay ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 22, 30, .55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    animation: modal-fade .15s ease;
}

@keyframes modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-card {
    background: #fff;
    border-radius: 14px;
    padding: 24px 22px 20px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
    animation: modal-pop .18s ease;
}

@keyframes modal-pop {
    from { transform: translateY(8px) scale(.98); opacity: 0; }
    to   { transform: translateY(0)  scale(1);   opacity: 1; }
}

.modal-card h3 {
    margin: 0 0 10px;
    font-size: 1.15rem;
    color: #1f2329;
}

.modal-card p {
    margin: 0 0 14px;
    color: #4b5563;
    line-height: 1.45;
    font-size: .95rem;
}

.modal-card ol {
    margin: 0 0 16px 18px;
    padding: 0;
    color: #374151;
    line-height: 1.6;
    font-size: .95rem;
}

.modal-card ol li + li { margin-top: 6px; }

.modal-card code {
    background: #f3f4f6;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: .88em;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 18px;
}

.modal-actions .button,
.modal-actions button {
    width: 100%;
    text-align: center;
    min-height: 44px;
    padding: 10px 16px;
    font-size: 1rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Secondary button */
button.secondary,
.button.secondary {
    background: #fff;
    color: #1f2329;
    border: 1px solid #d1d5db;
}
button.secondary:hover,
.button.secondary:hover {
    background: #f5f6f8;
    color: #1f2329;
    border-color: #9ca3af;
}

/* Cancel link-button inside modal — centered */
.modal-actions .link-button {
    text-align: center;
    padding: 8px 0;
    color: #6b7280;
}
.modal-actions .link-button:hover { color: #1f2329; }

/* ===== Import panels: eye + update badge ===== */
.import-panel-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
}

.preview-eye {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 6px;
    text-decoration: none;
    transition: color .15s ease, background .15s ease;
    z-index: 1;
}
.preview-eye:hover,
.preview-eye:focus-visible {
    color: #1d4ed8;
    background: #e0eaff;
    outline: none;
}

.update-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .72rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    margin-top: 8px;
    align-self: flex-start;
}
.update-badge.minor {
    background: #eef0f3;
    color: #4b5563;
}
.update-badge.major {
    background: #fce1e1;
    color: #b3261e;
    font-weight: 600;
}

/* ===== Script preview ===== */
.script-code {
    display: flex;
    background: #1f2329;
    color: #d4d4d4;
    border-radius: 8px;
    font-family: "SF Mono", Consolas, monospace;
    font-size: .82rem;
    line-height: 1.55;
    overflow: auto;
    max-height: 70vh;
    margin: 0;
}

.script-code-gutter {
    flex: 0 0 auto;
    min-width: 52px;
    padding: 14px 10px 14px 12px;
    background: #16191d;
    color: #5b6472;
    text-align: right;
    user-select: none;
    border-right: 1px solid #2a2f36;
    font-variant-numeric: tabular-nums;
}

.script-code-body {
    flex: 1 1 auto;
    margin: 0;
    padding: 14px 16px;
    white-space: pre;
    overflow: visible;
    color: inherit;
    background: transparent;
}

/* На мобильных — gutter чуть уже */
@media (max-width: 720px) {
    .script-code { font-size: .74rem; }
    .script-code-gutter { min-width: 40px; padding: 10px 8px; }
    .script-code-body { padding: 10px 12px; }
}

/* ===== Script catalog (admin) ===== */
.script-entry-badge {
    display: inline-block;
    background: #e0eaff;
    color: #1d4ed8;
    font-size: .72rem;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
}
.script-version {
    font-family: "SF Mono", Consolas, monospace;
    font-size: .85rem;
    color: #4b5563;
}

.script-deps .dep-link {
    display: inline-block;
    background: #e0eaff;
    color: #1d4ed8;
    border-radius: 4px;
    padding: 2px 8px;
    margin: 0 6px 4px 0;
    font-family: "SF Mono", Consolas, monospace;
    font-size: .82rem;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.script-deps .dep-link:hover,
.script-deps .dep-link:focus-visible {
    background: #1d4ed8;
    color: #fff;
    text-decoration: none;
    outline: none;
}

/* ===== Edge visibility (admin) ===== */
.edge-map-meta {
    margin: .2rem 0 .8rem;
    color: #4b5563;
    font-size: .9rem;
}
.edge-addresses {
    font-size: .78rem;
    margin-top: 2px;
    word-break: break-all;
}
.edge-yes {
    color: #15803d;
    font-weight: 600;
}
.edge-no {
    color: #b91c1c;
    font-weight: 600;
}
.edge-type {
    background: #e5e7eb;
    color: #374151;
}
.edge-type-reality { background: #e0eaff; color: #1d4ed8; }
.edge-type-telemt { background: #ede9fe; color: #6d28d9; }
.edge-type-caddy { background: #dcfce7; color: #166534; }
.edge-type-fallback { background: #fef3c7; color: #92400e; }
.fallback-row td {
    background: #fffbeb;
}
.edge-warnings {
    border: 1px solid #fde68a;
    background: #fffbeb;
    border-radius: 8px;
    padding: .7rem 1rem;
    margin: 0 0 1rem;
}
.edge-warnings h3 {
    margin: 0 0 .4rem;
    font-size: .95rem;
}
.edge-warnings ul,
.edge-warning-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: .86rem;
}
.edge-warning-list {
    padding-left: 1rem;
}
.warn-warn { color: #92400e; }
.warn-info { color: #1d4ed8; }
.edge-config-block {
    border-top: 1px solid #e5e7eb;
    padding-top: .9rem;
    margin-top: .9rem;
}
.edge-config-block:first-of-type {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
}
.edge-config-meta {
    font-size: .82rem;
    word-break: break-all;
}
.config-view,
.diff-view {
    max-height: 420px;
    overflow: auto;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    padding: .8rem 1rem;
    font-family: "SF Mono", Consolas, monospace;
    font-size: .8rem;
    line-height: 1.45;
    white-space: pre;
}
.diff-view {
    background: #111827;
}
.edge-config-toolbar {
    margin: .5rem 0;
}