:root {
    color-scheme: dark;
    --bg: #0b1118;
    --panel: #141b24;
    --surface: #1b2530;
    --field: #0f1620;
    --text: #e7edf4;
    --muted: #9aa8b8;
    --line: #2a3644;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --danger: #f87171;
    --ok: #34d399;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--accent);
}

.app-shell {
    width: min(1220px, calc(100% - 28px));
    margin: 24px auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    padding: 16px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.topbar div {
    display: grid;
    gap: 4px;
}

.topbar span {
    color: var(--muted);
    font-size: 14px;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.auth-panel,
.panel,
.ticket-side,
.chat-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.auth-panel {
    width: min(460px, 100%);
    margin: 80px auto;
    padding: 28px;
}

.panel {
    padding: 22px;
}

h1,
h2,
h3 {
    margin: 0 0 16px;
}

form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field);
    color: var(--text);
}

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

input::placeholder,
textarea::placeholder {
    color: var(--muted);
}

button {
    justify-self: start;
    padding: 11px 16px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--accent);
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
}

button:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}

button.danger,
.danger {
    background: var(--danger);
}

.dashboard-grid,
.admin-grid,
.ticket-layout {
    display: grid;
    gap: 18px;
}

.dashboard-grid,
.admin-grid {
    grid-template-columns: minmax(280px, 430px) 1fr;
}

.ticket-layout {
    grid-template-columns: 300px 1fr;
    min-height: calc(100vh - 120px);
}

.ticket-list {
    display: grid;
    gap: 10px;
}

.ticket-row,
.admin-ticket summary,
.profile-block summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    text-decoration: none;
    color: var(--text);
}

.admin-ticket,
.profile-block {
    margin-bottom: 12px;
}

.admin-ticket form,
.profile-block form {
    margin-top: 12px;
}

.inline-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.login-edit {
    margin-top: 12px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check input {
    width: auto;
}

.alert,
.toast {
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--field);
}

.alert-ok,
.toast-ok {
    border-color: rgba(52, 211, 153, 0.45);
    background: rgba(52, 211, 153, 0.12);
}

.alert-error,
.toast-error {
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(248, 113, 113, 0.12);
}

.ticket-side {
    padding: 20px;
}

.ticket-side dl {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 8px 12px;
    margin: 0 0 18px;
}

.ticket-side dt {
    color: var(--muted);
}

.ticket-side dd {
    margin: 0;
    word-break: break-word;
}

.status-pill,
.presence-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.14);
    color: var(--accent);
    font-size: 13px;
}

.presence-box {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

#presenceList {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

#typingLine {
    min-height: 20px;
    color: var(--muted);
    font-size: 14px;
}

.chat-panel {
    display: grid;
    grid-template-rows: 1fr auto;
    min-height: 70vh;
    overflow: hidden;
}

.chat-messages {
    overflow-y: auto;
    padding: 22px;
    background: linear-gradient(180deg, #111923, #0d141d);
}

.bubble {
    width: fit-content;
    max-width: min(680px, 92%);
    margin: 0 0 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--field);
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.bubble.user {
    margin-left: auto;
    background: rgba(52, 211, 153, 0.14);
}

.bubble.supporter {
    background: var(--panel);
}

.bubble-meta {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

.bubble-text {
    line-height: 1.45;
    word-break: break-word;
}

.file-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.file-card {
    display: grid;
    gap: 2px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(15, 22, 32, 0.78);
    color: var(--text);
    text-decoration: none;
}

.file-card small {
    color: var(--muted);
}

.chat-form {
    grid-template-columns: minmax(120px, 180px) 1fr auto auto;
    align-items: end;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.chat-form textarea {
    min-height: 52px;
    max-height: 160px;
}

.upload-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 14px;
    border-radius: 8px;
    color: #fff;
    background: #334155;
    cursor: pointer;
}

.upload-button input {
    display: none;
}

.selected-files {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.selected-files button {
    padding: 7px 10px;
    color: var(--text);
    background: var(--surface);
}

.progress {
    grid-column: 1 / -1;
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface);
}

.progress span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 120ms ease;
}

.locked-chat {
    padding: 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
}

.dragging .chat-panel {
    outline: 3px solid rgba(56, 189, 248, 0.4);
    outline-offset: -8px;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(2, 6, 12, 0.78);
    animation: fadeIn 140ms ease;
}

.lightbox[hidden] {
    display: none;
}

.lightbox-card {
    position: relative;
    width: min(900px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow: auto;
    padding: 22px;
    border-radius: 10px;
    background: var(--field);
    box-shadow: var(--shadow);
    animation: scaleIn 140ms ease;
}

.lightbox-card img,
.lightbox-card video,
.lightbox-card iframe {
    width: 100%;
    max-height: 620px;
    border: 0;
}

.lightbox-card iframe {
    min-height: 560px;
}

.lightbox-card textarea {
    min-height: 260px;
}

.lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: #475569;
}

.lightbox-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.98); }
    to { transform: scale(1); }
}

@media (max-width: 900px) {
    .dashboard-grid,
    .admin-grid,
    .ticket-layout {
        grid-template-columns: 1fr;
    }

    .chat-form {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 620px) {
    .app-shell {
        width: calc(100% - 16px);
        margin: 8px auto;
    }

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

    .auth-panel,
    .panel,
    .ticket-side {
        padding: 16px;
    }

    .chat-messages {
        padding: 14px;
    }

    .bubble {
        max-width: 100%;
    }
}

.admin-dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.9fr);
    gap: 18px;
    align-items: start;
}

.profile-panel {
    display: grid;
    gap: 18px;
}

.profile-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.profile-toolbar h1,
.profile-card h2,
.login-list h3 {
    margin: 0;
}

.profile-grid {
    display: grid;
    gap: 14px;
}

.profile-card {
    display: grid;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.profile-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: start;
}

.profile-address,
.profile-meta,
.empty-state {
    margin: 6px 0 0;
    color: var(--muted);
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.login-list {
    display: grid;
    gap: 10px;
}

.login-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.login-main {
    display: grid;
    gap: 3px;
}

.login-main span {
    color: var(--muted);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.login-inline-form {
    display: block;
}

.login-row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.login-row-actions button {
    padding: 8px 10px;
}

.modal-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.modal-form .check,
.modal-form button {
    align-self: end;
}

.ticket-panel {
    max-height: calc(100vh - 140px);
    overflow: auto;
}

@media (max-width: 980px) {
    .admin-dashboard,
    .profile-head,
    .modal-form {
        grid-template-columns: 1fr;
    }

    .profile-actions,
    .login-row-actions {
        justify-content: flex-start;
    }

    .login-row {
        flex-direction: column;
    }

    .ticket-panel {
        max-height: none;
    }
}
.topbar nav a,
.tab-control a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
}

.topbar nav a.active,
.tab-control a.active {
    border-color: var(--accent);
    color: #ffffff;
    background: var(--accent);
}

.supporter-section {
    display: grid;
    gap: 18px;
}

.tab-control {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.ticket-create-form {
    width: 100%;
}

.profile-search {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.profile-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.profile-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
}

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

.profile-table th {
    background: var(--surface);
    color: var(--muted);
    font-size: 14px;
}

.profile-table tr:last-child td {
    border-bottom: 0;
}

.profile-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-row-actions button {
    padding: 8px 10px;
}

@media (max-width: 720px) {
    .profile-search {
        grid-template-columns: 1fr;
    }
}
.profile-detail {
    display: grid;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.profile-click-row {
    cursor: pointer;
}

.profile-click-row:hover,
.profile-click-row.active {
    background: rgba(56, 189, 248, 0.12);
}