:root {
    --sidebar: #14213d;
    --sidebar-soft: #1f3157;
    --sidebar-width: 232px;
    --sidebar-collapsed-width: 72px;
    --header: #ffffff;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #687389;
    --line: #dfe5ef;
    --accent: #0f9f9a;
    --accent-dark: #0b7874;
    --blue: #2563eb;
    --green: #15a36d;
    --green-soft: #e9f8f1;
    --red: #df3b45;
    --red-soft: #fff0f1;
    --warning: #b7791f;
    --shadow: 0 14px 36px rgba(21, 32, 55, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button {
    cursor: pointer;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--sidebar);
    color: #edf5ff;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    z-index: 30;
    transition: width 0.18s ease, padding 0.18s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 20px;
    min-width: 0;
}

.brand-copy {
    min-width: 0;
    overflow: hidden;
}

.brand-mark {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #ffffff;
    font-weight: 800;
}

.brand-title {
    font-weight: 800;
    font-size: 17px;
}

.brand-subtitle {
    color: #9fb3d6;
    font-size: 12px;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    margin-left: auto;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd8ef;
    transition: background 0.16s ease, color 0.16s ease;
}

.sidebar-toggle:hover {
    background: var(--sidebar-soft);
    color: #ffffff;
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 8px;
    color: #cbd8ef;
    text-decoration: none;
    transition: background 0.16s ease, color 0.16s ease;
}

.nav-item svg {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
}

.nav-item:hover,
.nav-item.active {
    background: var(--sidebar-soft);
    color: #ffffff;
}

.sidebar-session {
    margin-top: auto;
    display: grid;
    gap: 8px;
    padding-top: 16px;
}

.sidebar-session form {
    margin: 0;
}

.session-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 0 12px;
    color: #9fb3d6;
    overflow: hidden;
}

.session-user svg {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
}

.session-user span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-item.logout {
    width: 100%;
    border: 0;
    background: rgba(255, 255, 255, 0.06);
    font-weight: 700;
}

.nav-item.logout:hover {
    background: #243a66;
}

.topbar {
    position: fixed;
    inset: 0 0 auto var(--sidebar-width);
    min-height: 72px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 20;
    backdrop-filter: blur(10px);
    transition: left 0.18s ease;
}

.topbar > div:first-child {
    flex: 0 0 220px;
    min-width: 180px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 800;
}

.topbar-subtitle {
    color: var(--muted);
    font-size: 12px;
}

.topbar-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    scrollbar-gutter: stable;
}

.topbar-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.topbar-form input,
.topbar-form select {
    min-height: 38px;
    width: auto;
}

.topbar-form input[type="search"] {
    width: 240px;
}

.topbar-form input[type="date"] {
    width: 142px;
}

.topbar-meta svg {
    width: 16px;
    height: 16px;
}

.main {
    margin-left: var(--sidebar-width);
    padding: 96px 28px 36px;
    transition: margin-left 0.18s ease;
}

.sidebar-collapsed {
    --sidebar-width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar {
    padding: 14px 10px;
}

.sidebar-collapsed .brand {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 4px 0 16px;
}

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .session-user span {
    display: none;
}

.sidebar-collapsed .sidebar-toggle {
    width: 42px;
    min-height: 42px;
    margin-left: 0;
}

.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0;
}

.sidebar-collapsed .session-user {
    justify-content: center;
    padding: 0;
}

.flash-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.flash {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
}

.flash.success {
    color: var(--green);
    border-color: #bcebd8;
    background: var(--green-soft);
}

.flash.error {
    color: var(--red);
    border-color: #ffc7cc;
    background: var(--red-soft);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(9, minmax(110px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    min-height: 86px;
}

.stat-card span {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    font-size: 26px;
    margin-top: 8px;
}

.stat-card.ok strong {
    color: var(--green);
}

.stat-card.danger strong {
    color: var(--red);
}

.content-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 1px 2px rgba(21, 32, 55, 0.04);
    margin-bottom: 18px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.panel-head h1 {
    margin: 0;
    font-size: 20px;
}

.panel-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.toolbar,
.filters,
.modal-actions,
.row-actions,
.sticky-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filters {
    margin-bottom: 16px;
}

.modal-actions {
    margin-top: 20px;
}

.form-grid .modal-actions {
    margin-top: 8px;
}

.detail-body + .modal-actions,
.mini-table-wrap + .modal-actions {
    margin-top: 24px;
}

.filters.single {
    max-width: 560px;
}

.filters input,
.filters select {
    min-height: 38px;
}

.filters input[type="search"] {
    min-width: 240px;
    flex: 1;
}

.btn,
.icon-btn,
.text-btn {
    border: 0;
    background: transparent;
    color: inherit;
}

.btn {
    min-height: 38px;
    border-radius: 8px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
}

.btn svg {
    width: 16px;
    height: 16px;
    min-width: 16px;
    flex: 0 0 16px;
    display: block;
}

.btn.primary {
    color: #ffffff;
    background: var(--accent);
}

.btn.primary:hover {
    background: var(--accent-dark);
}

.btn.ghost {
    color: var(--text);
    border: 1px solid var(--line);
    background: #ffffff;
}

.btn.ghost:hover,
.btn.subtle:hover {
    background: #f0f4fb;
}

.btn.subtle {
    color: var(--muted);
    background: #eef2f7;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    color: var(--muted);
}

.icon-btn:hover {
    background: #edf2f8;
    color: var(--text);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.text-btn {
    color: var(--blue);
    font-weight: 700;
    padding: 0;
}

.text-btn.danger {
    color: var(--red);
}

.text-btn {
    cursor: pointer;
}

.cell-link {
    display: inline;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    padding: 0;
    margin: 0;
    text-align: left;
    cursor: pointer;
    appearance: none;
}

.cell-link:hover {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cell-link:focus {
    outline: none;
}

.cell-link:focus-visible {
    border-radius: 4px;
    box-shadow: 0 0 0 3px rgba(15, 159, 154, 0.16);
}

.copy-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
}

.copy-btn {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 28px;
    color: #6d5ce7;
    background: #eef0ff;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.copy-btn:hover,
.copy-btn.copied {
    color: #ffffff;
    background: #6d5ce7;
}

.copy-btn:active {
    transform: scale(0.94);
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.url-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid #b7deda;
    border-radius: 8px;
    color: #0f766e;
    background: #ecfdf9;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.url-action:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #dff8f5;
}

.url-action svg {
    width: 14px;
    height: 14px;
}

.select-col {
    width: 44px;
    text-align: center !important;
}

.select-col input {
    width: 16px;
    height: 16px;
    padding: 0;
}

.action-col {
    width: 72px;
    white-space: nowrap;
}

.bulk-toolbar,
.mini-toolbar {
    justify-content: flex-end;
}

.btn.danger {
    color: #ffffff;
    background: var(--red);
}

.btn.disabled,
.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.confirm-copy {
    color: var(--muted);
    margin: 0 0 16px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 9px 10px;
    outline: 0;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 159, 154, 0.14);
}

input[readonly] {
    color: var(--muted);
    background: #f8fafc;
}

.form-hint {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

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

.data-table,
.mini-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.data-table th,
.data-table td,
.mini-table th,
.mini-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.data-table th,
.mini-table th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 800;
}

.data-table th.table-sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.table-sortable::after {
    content: "↕";
    display: inline-block;
    margin-left: 6px;
    color: #94a3b8;
    font-size: 11px;
}

.data-table th.table-sortable.sort-asc::after {
    content: "↑";
    color: var(--accent);
}

.data-table th.table-sortable.sort-desc::after {
    content: "↓";
    color: var(--accent);
}

.data-table tr:last-child td,
.mini-table tr:last-child td {
    border-bottom: 0;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover td {
    background: #f8fbff;
}

.strong-cell {
    font-weight: 800;
}

.muted-cell {
    color: var(--muted);
    white-space: nowrap;
}

.empty-cell {
    color: var(--muted);
    text-align: center;
    padding: 28px !important;
}

.status-pair {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 112px;
}

.status-chip,
.status-badge,
.platform-pill,
.result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    border-radius: 8px;
    padding: 0 9px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.status-chip {
    color: var(--muted);
    background: #f1f5f9;
    border: 1px solid #dce3ee;
    opacity: 1;
    font: inherit;
    cursor: pointer;
}

.status-chip.active {
    opacity: 1;
}

.status-chip.normal.active,
.status-badge.normal,
.result-badge.ok {
    color: var(--green);
    background: var(--green-soft);
    border-color: #bcebd8;
}

.status-chip.banned.active,
.status-badge.banned,
.result-badge.danger {
    color: var(--red);
    background: var(--red-soft);
    border-color: #ffc7cc;
}

.status-note-field {
    margin-top: 12px;
}

.check-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    color: #3c465b;
    font-weight: 700;
}

.check-line input {
    width: 16px;
    height: 16px;
    padding: 0;
}

.platform-pill {
    color: #2f5fce;
    background: #eef4ff;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 18, 32, 0.42);
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.15s ease;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.modal.show {
    display: flex;
}

.modal-panel {
    width: min(720px, 100%);
    max-height: calc(100vh - 44px);
    overflow: auto;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
    padding: 18px;
}

.modal-panel.small {
    width: min(480px, 100%);
}

.modal-panel.wide {
    width: min(900px, 100%);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-head .icon-btn {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    background: #f8fafc;
    color: #64748b;
}

.modal-head .icon-btn:hover {
    background: #eef2f7;
    color: var(--text);
}

.modal-head h2 {
    margin: 0;
    font-size: 18px;
}

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

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field span {
    color: #3c465b;
    font-weight: 700;
}

.form-field.full,
.modal-actions.full {
    grid-column: 1 / -1;
}

.login-body {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(15, 159, 154, 0.16), rgba(37, 99, 235, 0.08)),
        var(--bg);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(420px, 100%);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.login-brand h1 {
    margin: 0;
    font-size: 22px;
}

.login-brand p {
    margin: 2px 0 0;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 14px;
}

.login-submit {
    width: 100%;
    margin-top: 4px;
}

.checkbox-field {
    flex-direction: row;
    align-items: center;
    align-self: end;
    min-height: 40px;
}

.checkbox-field input {
    width: 18px;
    height: 18px;
}

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

.mini-table {
    min-width: 560px;
}

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

.drag-col {
    width: 44px;
}

.drag-handle {
    width: 44px;
    color: var(--muted);
    cursor: grab;
}

.source-cell {
    color: var(--muted);
    white-space: nowrap;
}

.column-alias-input {
    min-width: 150px;
}

.drag-handle svg {
    width: 18px;
    height: 18px;
}

.sortable-row.dragging {
    opacity: 0.45;
}

[data-sortable-list].saving {
    opacity: 0.72;
}

.relation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.relation-column {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    padding: 12px;
    min-width: 0;
}

.relation-column-head {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 34px;
    align-items: end;
    gap: 8px;
    margin-bottom: 10px;
}

.relation-column-head label {
    display: grid;
    gap: 5px;
}

.relation-column-head span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.relation-column textarea {
    min-height: 240px;
}

.sticky-actions {
    position: sticky;
    bottom: 16px;
    justify-content: flex-end;
    margin-top: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.error-list {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.error-list div {
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--red);
    background: var(--red-soft);
    border: 1px solid #ffc7cc;
}

.status-context {
    display: grid;
    gap: 8px;
    margin: 12px 0 18px;
}

.status-context div {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
}

.status-context span {
    color: var(--muted);
}

.status-context strong {
    overflow-wrap: anywhere;
}

.detail-body {
    display: grid;
    gap: 16px;
}

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

.detail-item {
    display: grid;
    gap: 5px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    min-width: 0;
}

.detail-item span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.detail-item strong {
    font-size: 14px;
    overflow-wrap: anywhere;
}

.detail-section h3 {
    margin: 0 0 10px;
    font-size: 15px;
}

.detail-table-wrap {
    max-height: 300px;
    overflow: auto;
}

@media (max-width: 1120px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }
}

@media (max-width: 780px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
        padding: 14px 10px;
    }

    .brand {
        flex-direction: column;
        justify-content: center;
        gap: 8px;
        padding: 4px 0 16px;
    }

    .brand-copy,
    .brand-title,
    .brand-subtitle,
    .nav-item span,
    .session-user span {
        display: none;
    }

    .sidebar-toggle {
        width: 42px;
        min-height: 42px;
        margin-left: 0;
    }

    .nav-item {
        justify-content: center;
        padding: 0;
    }

    .session-user {
        justify-content: center;
        padding: 0;
    }

    .topbar {
        left: var(--sidebar-collapsed-width);
        padding: 0 16px;
    }

    .topbar > div:first-child {
        flex-basis: 150px;
        min-width: 120px;
    }

    .topbar-actions {
        max-width: none;
    }

    .topbar-form input[type="search"] {
        width: 180px;
    }

    .main {
        margin-left: var(--sidebar-collapsed-width);
        padding: 96px 14px 28px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .panel-head {
        flex-direction: column;
    }

    .filters,
    .toolbar {
        width: 100%;
    }

    .filters input[type="search"] {
        min-width: 0;
    }

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

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

    .batch-pair {
        grid-template-columns: 1fr;
    }

    .relation-column-head {
        grid-template-columns: 1fr;
    }

    .relation-column-head .icon-btn {
        justify-self: end;
    }
}
