:root {
    --bg-main: #030b17;
    --bg-card: linear-gradient(160deg, rgba(6, 20, 35, 0.94), rgba(8, 27, 49, 0.84));
    --bg-card-hover: rgba(1, 153, 244, 0.14);
    --text-main: #e7f6ff;
    --text-sub: #9fc2da;
    --line: rgba(1, 153, 244, 0.26);
    --line-strong: rgba(1, 153, 244, 0.54);
    --primary: #0199f4;
    --ok: #29ae6b;
    --warn: #fdb022;
    --danger: #f04438;
}

* {
    box-sizing: border-box;
    font-family: Gilroy, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text-main);
    background:
            radial-gradient(circle at 90% -10%, rgba(1, 153, 244, 0.24), transparent 42%),
            radial-gradient(circle at -5% 110%, rgba(1, 153, 244, 0.18), transparent 44%),
            var(--bg-main);
}

a {
    text-decoration: none;
    color: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(3, 11, 23, 0.88);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.title-block h1 {
    margin: 0;
    font-size: 18pt;
    line-height: 1;
}

.title-block span {
    font-size: 10pt;
    color: var(--text-sub);
}

.logo-chip {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    border: 1px solid var(--line-strong);
    background: rgba(1, 153, 244, 0.22);
}

.page {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 1280px;
    margin: 0 auto;
}

.page-login {
    min-height: 100vh;
    justify-content: center;
    align-items: center;
}

.login-card {
    width: min(480px, 94vw);
}

.card {
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--bg-card);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.34);
    padding: 14px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.section-title h2 {
    margin: 0;
    font-size: 16pt;
}

.section-title .icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(1, 153, 244, 0.18);
    border: 1px solid var(--line);
}

.muted {
    color: var(--text-sub);
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

input,
select,
textarea {
    border: 1px solid rgba(143, 184, 211, 0.34);
    background: rgba(1, 153, 244, 0.14);
    color: var(--text-main);
    border-radius: 10px;
    padding: 9px 10px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--line-strong);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    border: 1px solid var(--line);
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.btn:hover {
    border-color: var(--line-strong);
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), #2fb4ff);
    color: #fff;
    border-color: transparent;
}

.btn.danger {
    background: rgba(240, 68, 56, 0.18);
    border-color: rgba(240, 68, 56, 0.44);
}

.btn.ghost {
    background: rgba(255, 255, 255, 0.03);
}

.topbar-right .btn.active {
    background: rgba(1, 153, 244, 0.2);
    border-color: var(--line-strong);
}

.chip {
    width: max-content;
    padding: 4px 8px;
    border-radius: 9999px;
    border: 1px solid var(--line);
    background: rgba(1, 153, 244, 0.16);
    font-size: 10pt;
}

.chip.ok {
    background: rgba(41, 174, 107, 0.2);
    border-color: rgba(41, 174, 107, 0.54);
}

.chip.warn {
    background: rgba(253, 176, 34, 0.2);
    border-color: rgba(253, 176, 34, 0.54);
}

.chip.source {
    font-weight: 700;
}

.chip.source-launcher {
    background: rgba(1, 153, 244, 0.2);
    border-color: rgba(1, 153, 244, 0.54);
}

.chip.source-telegram {
    background: rgba(41, 174, 107, 0.2);
    border-color: rgba(41, 174, 107, 0.54);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    border-width: 1px;
}

.status-chip::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.status-open {
    background: rgba(253, 176, 34, 0.18);
    border-color: rgba(253, 176, 34, 0.5);
    color: #ffe1a8;
}

.status-open::before {
    background: #fdb022;
    box-shadow: 0 0 0 4px rgba(253, 176, 34, 0.2);
}

.status-waiting {
    background: rgba(1, 153, 244, 0.2);
    border-color: rgba(1, 153, 244, 0.56);
    color: #b2e6ff;
}

.status-waiting::before {
    background: #2fb4ff;
    box-shadow: 0 0 0 4px rgba(1, 153, 244, 0.22);
}

.status-resolved {
    background: rgba(41, 174, 107, 0.18);
    border-color: rgba(41, 174, 107, 0.52);
    color: #b7f0d2;
}

.status-resolved::before {
    background: #29ae6b;
    box-shadow: 0 0 0 4px rgba(41, 174, 107, 0.2);
}

.filters {
    display: grid;
    grid-template-columns: 1fr max-content max-content;
    gap: 8px;
    margin-bottom: 10px;
}

.tickets-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ticket-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    background: rgba(1, 153, 244, 0.07);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ticket-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--line-strong);
}

.ticket-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.ticket-row-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ticket-id {
    font-weight: 700;
    font-size: 10pt;
}

.ticket-subject {
    font-size: 13pt;
}

.ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--text-sub);
    font-size: 10pt;
}

.ticket-meta span {
    max-width: 100%;
    word-break: break-word;
}

.page-ticket .meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    font-size: 10pt;
    color: var(--text-sub);
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.msg.from-launcher {
    background: rgba(1, 153, 244, 0.12);
}

.msg.from-support {
    background: rgba(41, 174, 107, 0.12);
}

.msg.from-system {
    background: rgba(253, 176, 34, 0.1);
}

.msg-meta {
    color: var(--text-sub);
    font-size: 9pt;
}

.msg-body {
    white-space: pre-wrap;
}

.msg-meta-json pre {
    margin: 0;
    white-space: pre-wrap;
    color: #d8eaf7;
}

.reply-form,
.status-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reply-form,
.status-form,
.status-current {
    background: rgba(3, 11, 23, 0.72);
    border: 1px solid rgba(1, 153, 244, 0.2);
    border-radius: 12px;
    padding: 10px;
}

.status-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-current {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.status-quick-actions {
    display: grid;
    grid-template-columns: minmax(220px, 360px);
    gap: 8px;
}

.status-quick-form {
    margin: 0;
}

.status-quick-form .btn {
    width: 100%;
}

.users-table-wrap {
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
}

.users-table th,
.users-table td {
    border-bottom: 1px solid var(--line);
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

.users-create-form {
    margin-bottom: 10px;
}

.streamers-create-form {
    margin-bottom: 10px;
}

.streamers-create-form .streamer-flag {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.streamers-create-form .streamer-flag input {
    width: 18px;
    height: 18px;
}

.maintenance-form .maintenance-toggle {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.maintenance-form .maintenance-toggle input {
    width: 18px;
    height: 18px;
}

.streamer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.streamer-actions form {
    margin: 0;
}

.streamers-tools {
    margin-top: 8px;
}

.page-kpi .filters input[readonly] {
    color: var(--text-sub);
    cursor: default;
}

.ticket-inline-link {
    color: #8fd8ff;
    text-decoration: underline;
}

.empty-state {
    color: var(--text-sub);
    border: 1px dashed var(--line);
    border-radius: 10px;
    padding: 14px;
}

.alert {
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
}

.alert.error {
    background: rgba(240, 68, 56, 0.16);
    border: 1px solid rgba(240, 68, 56, 0.42);
}

.alert.success {
    background: rgba(41, 174, 107, 0.16);
    border: 1px solid rgba(41, 174, 107, 0.42);
}

@media (max-width: 960px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-right {
        flex-wrap: wrap;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .status-current {
        flex-direction: column;
        align-items: flex-start;
    }

    .status-quick-actions {
        grid-template-columns: 1fr;
    }
}
