body {
    font-family: Segoe UI, system-ui, sans-serif;
    background: #0f1318;
    color: #e8edf2;
    margin: 0;
    padding: 24px;
}

main {
    max-width: 1100px;
    margin: 0 auto;
}

h1, h2 {
    margin-top: 0;
}

.card {
    background: #171d26;
    border: 1px solid #2a3340;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 20px;
}

.admin-tab-btn {
    background: #2a3340;
}

.admin-tab-btn.active {
    background: #2f7dd1;
}

.admin-tab-panel {
    display: none;
}

.admin-tab-panel.active {
    display: block;
}

.admin-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.admin-subtab-btn {
    background: #222a35;
    font-size: 13px;
    padding: 6px 12px;
}

.admin-subtab-btn.active {
    background: #2f7dd1;
}

.keys-subpanel {
    display: none;
}

.keys-subpanel.active {
    display: block;
}

.releases-table td {
    vertical-align: top;
}

.release-target-line {
    font-size: 13px;
}

.target-link {
    background: none;
    border: none;
    color: #3a8de6;
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
}

.target-link.muted {
    color: #8a96a3;
}

.target-link:hover {
    color: #6eb3ff;
}

.release-actions-col {
    min-width: 220px;
}

.release-group-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.release-group-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    padding: 2px 6px;
    background: #222a35;
    border-radius: 4px;
    border: 1px solid #2a3340;
}

.release-groups-hint {
    font-size: 12px;
    margin-bottom: 6px;
}

.badge-remove-form {
    margin: 0;
    display: inline-flex;
}

.badge-remove {
    background: transparent;
    border: none;
    color: #ff8a8a;
    cursor: pointer;
    padding: 0 2px;
    font-size: 14px;
    line-height: 1;
}

.group-assign-form {
    margin: 0 0 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.group-assign-form select {
    max-width: 150px;
    font-size: 12px;
    padding: 4px 6px;
    min-width: 100px;
}

.group-assign-form button {
    font-size: 12px;
    padding: 4px 8px;
}

.group-row-actions {
    flex-wrap: wrap;
}

.group-notes {
    font-size: 12px;
    margin-top: 4px;
}

.group-edit-modal label {
    display: block;
    margin-top: 10px;
}

.group-edit-modal input[type="text"] {
    width: 100%;
    box-sizing: border-box;
}

.release-row-actions {
    flex-wrap: wrap;
}

.admin-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
}

.admin-modal-backdrop[hidden] {
    display: none;
}

.admin-modal {
    background: #171d26;
    border: 1px solid #2a3340;
    border-radius: 8px;
    max-width: 520px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    padding: 16px;
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.admin-modal-header h4 {
    margin: 0;
    font-size: 1rem;
}

.admin-modal-close {
    min-width: 32px;
    padding: 4px 10px;
    line-height: 1;
}

.admin-modal-body {
    font-size: 14px;
}

.target-modal-list {
    margin: 0;
    padding-left: 18px;
    line-height: 1.7;
}

.target-modal-list code {
    color: #3a8de6;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    margin-bottom: 0;
}

.stat-label {
    display: block;
    color: #8a96a3;
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    line-height: 1;
}

/* CHANGE: collapsible admin blocks (tester groups create form, etc.). */
.collapsible {
    margin-bottom: 8px;
}

.collapsible-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0 0 8px;
    padding: 6px 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid #2a3340;
    border-radius: 0;
    color: #e8edf2;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.collapsible-toggle:hover {
    color: #fff;
}

.collapsible-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(180deg, #1e2632 0%, #171d26 100%);
    border: 1px solid #354152;
    border-radius: 8px;
    color: #9aa8b8;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.collapsible-toggle:hover .collapsible-chevron {
    background: linear-gradient(180deg, #263040 0%, #1e2632 100%);
    border-color: #4a7ec4;
    color: #6eb3ff;
    box-shadow: 0 2px 6px rgba(47, 125, 209, 0.2);
}

.collapsible-chevron .chevron-icon {
    width: 18px;
    height: 18px;
}

/* Развернуто: стрелка вверх (свернуть). Свернуто: стрелка вниз (развернуть). */
.collapsible .chevron-expand {
    display: none;
}

.collapsible .chevron-collapse {
    display: block;
}

.collapsible.is-collapsed .chevron-expand {
    display: block;
}

.collapsible.is-collapsed .chevron-collapse {
    display: none;
}

.collapsible.is-collapsed .collapsible-body {
    display: none;
}

.collapsible-body {
    padding-top: 8px;
}

.collapsible-body h3 {
    margin-top: 20px;
}

.license {
    border-top: 1px solid #2a3340;
    padding-top: 16px;
    margin-top: 16px;
}

.key {
    font-size: 1.1rem;
    color: #3a8de6;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 8px;
}

.badge.active { background: #1e3a2f; color: #55c83c; }
.badge.revoked { background: #3a1e1e; color: #ff8a8a; }
.badge.severity-medium { background: #2a3340; color: #b8c4d4; margin-left: 0; }
.badge.severity-required { background: #3a2a1e; color: #ffb347; margin-left: 0; }

.meta { color: #8a96a3; font-size: 14px; }

form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

form.inline { display: inline-flex; }

label { font-size: 13px; color: #8a96a3; }

input {
    background: #11161d;
    border: 1px solid #2a3340;
    color: #e8edf2;
    padding: 8px 10px;
    border-radius: 4px;
}

/* CHANGE: password show/hide toggle on admin login. */
.password-field {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 260px;
    max-width: 100%;
}

.password-field input {
    width: 100%;
    padding-right: 42px;
    box-sizing: border-box;
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #8a96a3;
    cursor: pointer;
}

.password-toggle:hover {
    color: #e8edf2;
    background: transparent;
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.login-form {
    flex-direction: column;
    align-items: flex-start;
}

select,
textarea {
    background: #11161d;
    border: 1px solid #2a3340;
    color: #e8edf2;
    padding: 8px 10px;
    border-radius: 4px;
}

textarea {
    width: 100%;
    resize: vertical;
    min-height: 120px;
    font: inherit;
    line-height: 1.5;
}

button {
    background: #2f7dd1;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
}

button.secondary { background: #2a3340; }
button.danger { background: #b83a32; }

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 13px;
}

th, td {
    border: 1px solid #2a3340;
    padding: 8px;
    text-align: left;
}

th { background: #1e2631; }

/* CHANGE: activations table — device hash gets more space; other columns stay compact. */
.activations-table .col-device { width: 42%; }
.activations-table .col-version { width: 10%; }
.activations-table .col-activated { width: 16%; }
.activations-table .col-lastseen { width: 16%; }
.activations-table .col-action { width: 16%; }

.activations-table .device-hash code {
    display: inline-block;
    max-width: 100%;
    word-break: break-all;
    white-space: normal;
    font-size: 12px;
}

.activations-table .col-version,
.activations-table td:nth-child(2),
.activations-table th:nth-child(2) {
    white-space: nowrap;
}

.activations-table td:nth-child(3),
.activations-table td:nth-child(4),
.activations-table th:nth-child(3),
.activations-table th:nth-child(4) {
    white-space: nowrap;
    font-size: 12px;
}

.error { color: #ff8a8a; }

.success { color: #55c83c; }

.hint {
    color: #8a96a3;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.backup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    align-items: end;
}

.filters-grid > div {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stack-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.dynamic-key-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.dynamic-key-row input {
    width: 100%;
    box-sizing: border-box;
}

.button-link {
    display: inline-block;
    background: #2f7dd1;
    color: #fff;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 4px;
}

.import-form input[type="file"] {
    max-width: 280px;
}

.toolbar { margin-bottom: 16px; }

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #e8edf2;
}

.check-row input {
    width: auto;
}

/* CHANGE: upload progress for Admin → Updates create-release multipart. */
.upload-progress {
    width: 100%;
    margin: 12px 0 4px;
    padding: 12px;
    border: 1px solid #2a3340;
    border-radius: 6px;
    background: #11161d;
    box-sizing: border-box;
}

.upload-progress-title {
    font-size: 14px;
    margin-bottom: 8px;
    color: #e8edf2;
}

.upload-progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #2a3340;
    overflow: hidden;
}

.upload-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #2f7dd1, #55c83c);
    transition: width 0.15s ease-out;
}

.upload-progress-meta {
    margin-top: 8px;
    font-size: 13px;
    color: #8a96a3;
}

button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}
