/* ==========================================================================
   Design tokens
   Neutrals carry a slight blue cast so the greys read as chosen rather than
   inherited; depth comes from stacked surfaces and hairline borders, not shadows.
   ========================================================================== */

:root {
    --bg: #0c0d11;
    --surface: #14161c;
    --surface-2: #191c23;
    --surface-3: #20242d;
    --border: #262a34;
    --border-strong: #333947;

    --text-bright: #f2f4f8;
    --text: #d8dce6;
    --text-muted: #a6adbd;
    --text-dim: #7e879b;
    --text-faint: #5b6478;

    --accent: #5b8def;
    --accent-soft: #8fb4ff;
    --accent-strong: #4a76cc;
    --accent-glow: rgba(91, 141, 239, 0.14);

    --green: #3ecf8e;
    --red: #f26d6d;
    --red-strong: #d94f4f;
    --red-soft: #ff8f8f;
    --orange: #f0a04b;
    --orange-strong: #d98530;
    --yellow: #f2cb4b;
    --purple: #a97bf0;
    --purple-soft: #c7a6f7;
    --cyan: #46c8d8;

    --radius: 10px;
    --radius-sm: 7px;
    --gap: 16px;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv02', 'cv03', 'cv04';
}


/* ── Login ── */

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

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    width: 100%;
    max-width: 400px;
    margin: 20px;
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.login-card p {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--accent);
    color: var(--text-bright);
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    width: 100%;
    text-align: center;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-danger:hover {
    background: var(--red-strong);
}

.btn-success {
    background: var(--green);
}

.btn-success:hover {
    background: var(--green);
}

.btn-warning {
    background: var(--orange);
}

.btn-warning:hover {
    background: var(--orange-strong);
}

.btn-secondary {
    background: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--border-strong);
}

.btn-small {
    padding: 5px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    width: auto;
}

.login-error {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 12px;
    display: none;
}

/* ── Dashboard layout ── */

.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 244px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-bright);
}

.sidebar-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--accent-glow);
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-section {
    padding: 0 12px;
    margin-bottom: 12px;
}

.sidebar-section-title {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    padding: 8px 8px 4px;
}

.sidebar-link {
    display: block;
    padding: 8px 12px;
    margin-bottom: 3px;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}

.sidebar-link:hover {
    color: var(--text);
    background: var(--surface-3);
}

.sidebar-link.active {
    color: var(--accent-soft);
    background: var(--accent-glow);
    box-shadow: inset 2px 0 0 var(--accent);
}

/* ── Collapsible module group ── */

.sidebar-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-muted);
}

.sidebar-caret {
    display: inline-block;
    width: 12px;
    font-size: 0.7rem;
    color: var(--text-faint);
    transition: color 0.15s;
}

.sidebar-group-header:hover .sidebar-caret {
    color: var(--text);
}

.sidebar-group-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-group-count {
    font-size: 0.7rem;
    color: var(--text-faint);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1px 7px;
}

/* Folded by default; the group carries .open when it is unfolded. */
.sidebar-group-pages {
    display: none;
    margin: 4px 0 10px 12px;
    padding-left: 8px;
    border-left: 1px solid var(--border);
}

.sidebar-group.open > .sidebar-group-pages {
    display: block;
}

.sidebar-group-pages .sidebar-link {
    padding: 7px 10px;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.sidebar-group-pages .sidebar-link:last-child {
    margin-bottom: 0;
}

/* ── Page tiles (module home, addon list) ── */

.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.page-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.page-tile:hover {
    background: var(--surface-2);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.page-tile-name {
    color: var(--text);
    font-weight: 500;
    font-size: 0.95rem;
}

.page-tile-kind {
    color: var(--text-faint);
    font-size: 0.75rem;
    text-transform: lowercase;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.btn-logout {
    display: block;
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.btn-logout:hover {
    color: var(--red);
    border-color: var(--red);
}

/* ── Main content ── */

.main-content {
    flex: 1;
    padding: 36px 40px 64px;
    overflow-y: auto;
    min-width: 0;
}

.page-title {
    font-size: 1.55rem;
    font-weight: 650;
    letter-spacing: -0.015em;
    margin-bottom: 28px;
    color: var(--text-bright);
    text-wrap: balance;
}

/* ── Stat tiles ──
   The label sits above a large tabular figure so a row of them scans as a
   column of numbers; the accent is a dot, not a bar across the top, which kept
   pulling the eye away from the value itself. */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.stat-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.stat-card .stat-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    margin-bottom: 10px;
}

/* The accent dot, drawn on the label so it reads as a category marker. */
.stat-card .stat-label::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex: none;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 680;
    line-height: 1.1;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    word-break: break-word;
}

.stat-card .stat-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 1.1rem;
    opacity: 0.35;
}

.stat-card.green .stat-label::before  { background: var(--green); }
.stat-card.orange .stat-label::before { background: var(--orange); }
.stat-card.red .stat-label::before    { background: var(--red); }
.stat-card.purple .stat-label::before { background: var(--purple); }
.stat-card.cyan .stat-label::before   { background: var(--cyan); }
.stat-card.yellow .stat-label::before { background: var(--yellow); }

.stat-card.green .stat-value  { color: var(--green); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.red .stat-value    { color: var(--red); }
.stat-card.purple .stat-value { color: var(--purple); }
.stat-card.cyan .stat-value   { color: var(--cyan); }
.stat-card.yellow .stat-value { color: var(--yellow); }

/* ── Card ── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 18px;
}

.card h3 {
    font-size: 0.8rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 18px;
    color: var(--text-dim);
}

/* ── Table ── */

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 11px 14px;
    text-align: left;
}

th {
    background: var(--surface-2);
    color: var(--text-dim);
    font-weight: 650;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

td {
    color: var(--text);
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background 0.12s ease;
}

tbody tr:hover td {
    background: var(--surface-2);
}

/* ── JSON display ── */

.json-view {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.85rem;
    color: var(--accent-soft);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Empty / Error ── */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-faint);
}

.empty-state p {
    font-size: 0.95rem;
}

.error-msg {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 8px;
    padding: 16px;
    color: var(--red);
    font-size: 0.9rem;
}

/* ── Loading ── */

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-faint);
}

/* ── Action bar ── */

.action-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.action-bar .btn {
    width: auto;
    flex-shrink: 0;
}

/* ── Action form ── */

.action-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.action-form .form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 140px;
}

.action-form .form-field label {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.action-form .form-field input,
.action-form .form-field select {
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.action-form .form-field input:focus,
.action-form .form-field select:focus {
    border-color: var(--accent);
}

.action-form .btn {
    width: auto;
    flex-shrink: 0;
    align-self: flex-end;
    height: 38px;
    padding: 0 20px;
}

/* ── Toast notifications ── */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-bright);
    pointer-events: auto;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.toast-success {
    background: var(--green);
    border: 1px solid var(--green);
}

.toast-error {
    background: var(--red);
    border: 1px solid var(--red-soft);
}

.toast-info {
    background: var(--accent);
    border: 1px solid var(--accent-soft);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ── Modal overlay ── */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.modal-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-actions .btn {
    width: auto;
    min-width: 100px;
}

/* ── Pagination ── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination .page-btn {
    padding: 6px 12px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.pagination .page-btn:hover {
    color: var(--text);
    background: var(--border-strong);
    border-color: var(--border-strong);
}

.pagination .page-btn.active {
    color: var(--text-bright);
    background: var(--accent);
    border-color: var(--accent);
}

.pagination .page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination .page-info {
    color: var(--text-faint);
    font-size: 0.85rem;
    padding: 0 8px;
}

/* ── Tab bar ── */

.tab-bar {
    display: flex;
    gap: 2px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Bar chart (CSS only) ── */

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 180px;
    padding: 0 8px;
    margin-top: 12px;
    border-bottom: 1px solid var(--border);
}

.bar-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.bar-chart-bar {
    width: 100%;
    max-width: 40px;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.3s ease;
    position: relative;
}

.bar-chart-bar:hover {
    background: var(--accent-soft);
}

.bar-chart-bar .bar-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--border-strong);
    color: var(--text-bright);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 50;
}

.bar-chart-bar:hover .bar-tooltip {
    display: block;
}

.bar-chart-label {
    font-size: 0.65rem;
    color: var(--text-faint);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding-top: 6px;
}

/* ── Inline edit ── */

.inline-edit {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.inline-edit:hover {
    background: var(--accent-glow);
}

.inline-edit-input {
    width: 80px;
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}

/* ── Toggle switch ── */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-strong);
    border-radius: 11px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--text-bright);
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--green);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* ── Search bar ── */

.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-bar input,
.search-bar select {
    padding: 9px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    min-width: 200px;
}

.search-bar input:focus,
.search-bar select:focus {
    border-color: var(--accent);
}

.search-bar .btn {
    width: auto;
    height: 38px;
    padding: 0 20px;
    flex-shrink: 0;
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .dashboard {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        padding: 8px;
        gap: 4px;
    }

    .sidebar-section {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: 0;
        margin: 0;
    }

    .sidebar-section-title {
        width: 100%;
    }

    .sidebar-link {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .main-content {
        padding: 20px;
    }

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

    .profile-banner {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 18px;
    }

    .profile-avatar {
        margin-bottom: 0;
    }

    .profile-badges {
        margin-left: 0;
    }

    .profile-side {
        margin-left: 0;
        align-items: flex-start;
        width: 100%;
    }

    .profile-meta,
    .profile-badges {
        justify-content: flex-start;
    }

    .action-form {
        flex-direction: column;
        align-items: stretch;
    }

    .action-form .btn {
        align-self: stretch;
    }

    .tab-bar {
        gap: 0;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .bar-chart {
        height: 120px;
    }
}

/* ── Player profile banner ────────────────────────────────────────────────── */
.profile-banner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(120deg, rgba(33, 150, 243, 0.16), var(--surface-2) 62%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-bottom: 58px;
}

/* The medallion hangs past the banner, which is what makes it read as a profile card. */
.profile-avatar {
    flex: none;
    width: 104px;
    height: 104px;
    margin-bottom: -46px;
    border-radius: var(--radius);
    border: 3px solid var(--surface);
    background: var(--bg);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.profile-avatar img {
    image-rendering: pixelated;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.profile-headline {
    min-width: 0;
    flex: 1;
}

.profile-identity {
    min-width: 0;
    flex: 1;
}

.profile-name {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-bright);
    line-height: 1.1;
    margin-bottom: 8px;
}

/* Right-hand column of the banner: status on top, dates under it. */
.profile-side {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    min-width: 0;
}

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

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

/* Chips rather than stacked lines: two UUIDs used to take as much height as the name. */
.profile-id {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 0.78rem;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 999px;
    padding: 4px 12px;
    max-width: 100%;
}

.profile-id-label {
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.64rem;
    font-weight: 650;
    white-space: nowrap;
}

.profile-id-value {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: var(--text-muted);
    cursor: pointer;
    word-break: break-all;
}

.profile-id-value:hover {
    color: var(--accent-soft);
}

/* Facts grid, used for the dates and any scalar the modules return. */
.profile-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.profile-fact {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.profile-fact-label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    font-weight: 650;
    margin-bottom: 5px;
}

.profile-fact-value {
    color: var(--text-bright);
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
}

/* ── UUID cell ── */

.uuid-cell {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.82em;
    color: var(--text-dim);
}

/* ── Key/value list, used by the details cards and the profile's module sections ── */

.kv-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
}

.kv-row:nth-child(odd) {
    background: var(--surface-2);
}

.kv-key {
    color: var(--text-dim);
    font-size: 0.82rem;
    text-transform: capitalize;
}

.kv-value {
    color: var(--text-bright);
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    word-break: break-word;
}

/* ── Clickable player name ── */

.player-link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s;
}

.player-link:hover {
    color: var(--accent-soft);
    text-decoration: underline;
}

/* ── Player avatar inline ── */

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

.player-cell img {
    border-radius: 4px;
    vertical-align: middle;
}

/* ── Section title ── */

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    margin-top: 8px;
}

/* ── Module data section on profile ── */

.module-section {
    margin-bottom: 20px;
}

.module-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* ── Number formatting ── */

.num-cell {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* The action column hugs its buttons instead of stretching to fill the row. */
.col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

td.col-actions {
    display: table-cell;
}

td.col-actions .btn-small + .btn-small {
    margin-left: 6px;
}

/* ── Badges ── */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.badge-green { background: rgba(76, 175, 80, 0.2); color: var(--green); }
.badge-red { background: rgba(244, 67, 54, 0.2); color: var(--red); }
.badge-orange { background: rgba(255, 152, 0, 0.2); color: var(--orange); }
.badge-yellow { background: rgba(255, 235, 59, 0.2); color: var(--yellow); }
.badge-blue { background: rgba(33, 150, 243, 0.2); color: var(--accent); }
.badge-purple { background: rgba(156, 39, 176, 0.2); color: var(--purple-soft); }
.badge-cyan { background: rgba(0, 188, 212, 0.2); color: var(--cyan); }

/* ── Truncated text ── */

.truncated {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

/* ── Filter bar ── */

.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-bar label {
    color: var(--text-muted);
    font-size: 0.9em;
    white-space: nowrap;
}
.filter-bar input,
.filter-bar select {
    max-width: 300px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: var(--text-bright);
    font-size: 0.95em;
    height: 40px;
}
.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: rgba(255,255,255,0.3);
}
.filter-bar .btn {
    height: 40px;
    padding: 0 20px;
    white-space: nowrap;
    flex-shrink: 0;
    width: auto;
}

/* Minecraft-style item tooltip */
.item-cell {
    position: relative;
    white-space: nowrap;
}

/* Pixel art scaled up must not be smoothed, or a 16px texture turns to mush. */
.item-sprite {
    width: 22px;
    height: 22px;
    image-rendering: pixelated;
    vertical-align: middle;
    margin-right: 8px;
}
.item-name {
    cursor: pointer;
    font-weight: 500;
}
.mc-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    z-index: 100;
    background: #1a1a2e;
    border: 2px solid #25005a;
    border-radius: 4px;
    padding: 6px 10px;
    min-width: 200px;
    max-width: 350px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    white-space: nowrap;
}
.item-cell:hover .mc-tooltip {
    display: block;
}
.mc-tooltip-name {
    font-weight: 700;
    margin-bottom: 2px;
}
.mc-tooltip-enchant {
    color: var(--text-dim);
    font-style: italic;
}
.mc-tooltip-lore {
    color: var(--purple);
    font-style: italic;
}
.mc-tooltip-durability {
    color: var(--green);
    margin-top: 4px;
    font-size: 0.75rem;
}
.mc-tooltip-amount {
    color: var(--text-dim);
    margin-top: 2px;
    font-size: 0.75rem;
}

/* ── Table row actions ── */

td .btn-small {
    margin: 0 2px;
}

/* ── Collapsible message card ── */

.message-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.message-card .message-content {
    flex: 1;
    min-width: 0;
}

.message-card .message-type {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.message-card .message-text {
    color: var(--text);
    font-size: 0.9rem;
    word-break: break-word;
}

.message-card .message-actions {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Raw config (YAML) editor ── */
.config-hint {
    display: block;
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 12px;
    line-height: 1.5;
}
.config-editor {
    width: 100%;
    min-height: 60vh;
    resize: vertical;
    box-sizing: border-box;
    padding: 14px 16px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    tab-size: 2;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}
.config-editor:focus {
    outline: none;
    border-color: var(--accent);
}
.config-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
}
.config-actions .btn {
    width: auto;
}
.config-status {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-dim);
    white-space: pre-wrap;
}
.config-status.config-error {
    color: var(--red-soft);
}


/* ── Profile: states, tallies and facts ───────────────────────────────────── */
/* A module's block on a player profile leads with what is true about them. */
.profile-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.stats-grid-compact {
    margin-bottom: 14px;
}

/* Booleans inside a list or a table cell, so a state is not read as a word. */
.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.pill-on {
    background: rgba(244, 67, 54, 0.18);
    color: var(--red);
}

.pill-off {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted, #8b8b8b);
}


/* ── Profile header: dates alongside the name ─────────────────────────────── */
/* What used to be a card of two lines under the header, now part of it. */
.profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.profile-meta-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    min-width: 0;
}

.profile-meta-label {
    display: block;
    font-size: 0.64rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    font-weight: 650;
    margin-bottom: 2px;
}

.profile-meta-value {
    display: block;
    font-size: 0.9rem;
    color: var(--text-bright);
    font-weight: 600;
}
