:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --line: #d7ddea;
    --text: #172033;
    --muted: #667085;
    --accent: #0f766e;
    --accent-soft: #ccfbf1;
    --danger: #b42318;
    --warn: #b54708;
    --info: #1d4ed8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: linear-gradient(180deg, #f7f8fc 0%, #edf2f9 100%);
    color: var(--text);
    font-family: "Segoe UI", sans-serif;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 18px;
}

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

.nav {
    display: flex;
    gap: 10px;
}

.nav a {
    text-decoration: none;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 8px 12px;
    border-radius: 999px;
}

.nav a.active {
    color: var(--accent);
    background: var(--accent-soft);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.user-info button,
.login-submit-btn {
    border: 1px solid #c7d0e0;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
}

main {
    padding: 28px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.05);
    overflow: visible;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

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

.panel-subtitle {
    color: var(--muted);
    font-size: 14px;
}

.table-wrap {
    overflow-x: auto;
    overflow-y: visible;
}

.table-footer {
    display: flex;
    justify-content: flex-end;
    padding: 14px 18px 18px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.table.table-tight {
    min-width: 0;
}

.table th,
.table td {
    border-bottom: 1px solid #eef2f7;
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

.table th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.balance-table th.balance-amount-col,
.balance-table td.balance-amount-cell,
.balance-table th.balance-delta-col,
.balance-table td.balance-delta-cell {
    min-width: 96px;
    text-align: right;
    white-space: nowrap;
    width: 96px;
}

.table th.bet-profit-col,
.table td.bet-profit-cell {
    min-width: 96px;
    text-align: right;
    white-space: nowrap;
    width: 96px;
}

.table tr:hover {
    background: #fafcff;
}

.table tr.is-expandable {
    cursor: pointer;
}

.table tr.is-expanded,
.table tr.is-expandable:hover {
    background: #f3f7ff;
}

.raw-row td {
    padding: 10px 14px;
    background: #f8fbff;
}

.detail-menu {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.detail-menu-btn,
.raw-edit-btn,
.editor-actions button {
    border: 1px solid #c7d0e0;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.detail-menu-btn.active {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: #9ae6d8;
}

.detail-view.hidden {
    display: none;
}

.raw-preview {
    font-size: 14px;
    line-height: 1.5;
    color: #344054;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.raw-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.pager {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.pager-btn {
    border: 1px solid #c7d0e0;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.pager-btn:disabled {
    cursor: default;
    opacity: 0.45;
}

.pager-status {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    min-width: 120px;
    text-align: center;
}

.kpi {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid transparent;
}

.badge.info {
    color: var(--info);
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.22);
}

.badge.good {
    color: #027a48;
    background: rgba(18, 183, 106, 0.12);
    border-color: rgba(18, 183, 106, 0.22);
}

.badge.warn {
    color: var(--warn);
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.24);
}

.badge.bad {
    color: var(--danger);
    background: rgba(211, 47, 47, 0.12);
    border-color: rgba(211, 47, 47, 0.24);
}

.notice {
    margin: 18px 0 0;
    padding: 14px 16px;
    border-radius: 14px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.hidden {
    display: none !important;
}

.center-empty {
    padding: 42px 24px;
    text-align: center;
    color: var(--muted);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 40, 0.42);
    z-index: 100;
    overflow-y: auto;
    padding: 24px 0;
}

.modal-content {
    width: min(420px, calc(100vw - 32px));
    margin: 0 auto;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18);
}

.modal-header,
.modal-body {
    padding: 20px;
}

.modal-header {
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close {
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
}

.form-group input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d0d7e2;
    border-radius: 10px;
    font: inherit;
}

.form-group textarea,
.form-group select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d0d7e2;
    border-radius: 10px;
    font: inherit;
    resize: vertical;
}

.editor-modal-content {
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.editor-modal-content .modal-body {
    overflow-y: auto;
}

.row-menu {
    position: relative;
}

.row-menu summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    border: 1px solid #c7d0e0;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
}

.row-menu summary::-webkit-details-marker {
    display: none;
}

.row-menu[open] summary {
    color: var(--accent);
    background: var(--accent-soft);
}

.row-menu-items {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    z-index: 5;
}

.row-menu-items a,
.row-menu-items button,
.inline-link {
    display: block;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.row-menu-items button {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
}

.row-menu-separator {
    height: 1px;
    background: var(--line);
    margin: 2px 0;
}

.row-menu-items a:hover,
.row-menu-items button:hover,
.inline-link:hover {
    text-decoration: underline;
}

.error-message {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--danger);
    background: #fef3f2;
    border: 1px solid #fecdca;
}

@media (max-width: 800px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .brand {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    main {
        padding: 16px;
    }
}
