/* ── GM Admin Panel ─────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #171923;
    --bg-card: #1e2030;
    --bg-hover: #262a3d;
    --bg-input: #2a2e42;
    --border: #2d3250;
    --border-hover: #3d4470;
    --text-primary: #e8eaf0;
    --text-secondary: #9ca3b8;
    --text-muted: #6b7290;
    --accent: #6c5ce7;
    --accent-hover: #7c6ff7;
    --accent-glow: rgba(108, 92, 231, 0.25);
    --green: #00cec9;
    --green-bg: rgba(0, 206, 201, 0.12);
    --red: #ff6b6b;
    --red-bg: rgba(255, 107, 107, 0.12);
    --yellow: #feca57;
    --yellow-bg: rgba(254, 202, 87, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── Humanization evaluation ──────────────────────────────── */
.humanization-help { color: var(--text-muted); font-size: .82rem; margin-top: .25rem; }
.humanization-layout { display: grid; grid-template-columns: minmax(250px, 32%) 1fr; gap: 1.25rem; }
.humanization-ranking, .humanization-detail { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; min-width: 0; }
.humanization-ranking h3, .humanization-detail h3, .humanization-detail h4 { margin-bottom: .75rem; }
.humanization-detail h4 { margin-top: 1.25rem; color: var(--text-secondary); }
.ranking-list { display: grid; gap: .5rem; max-height: 70vh; overflow: auto; }
.ranking-card { display: flex; align-items: center; gap: .65rem; text-align: left; width: 100%; padding: .75rem; color: var(--text-primary); background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.ranking-card:hover { border-color: var(--accent); }
.ranking-card.low-sample { opacity: .72; border-style: dashed; }
.ranking-card .card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.ranking-card .card-row { display: flex; align-items: baseline; gap: .5rem; }
.ranking-card .card-row .ranking-name { flex: 1; font-weight: 600; }
.ranking-card .card-score { font-size: 1.25rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.ranking-card small { color: var(--text-muted); font-size: .78rem; }
.ranking-card .rank-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; flex-shrink: 0; }
.ranking-card .rank-badge.low { background: var(--bg-secondary); color: var(--text-muted); border: 1px solid var(--border); font-size: .68rem; }
.ranking-card .trophy-col { display: flex; flex-direction: column; align-items: center; gap: 0; flex-shrink: 0; min-width: 56px; }
.ranking-card .trophy-icon { font-size: 2.4rem; line-height: 1; }
.ranking-card .trophy-label { font-size: .6rem; font-weight: 800; color: #f0b90b; letter-spacing: .06em; margin-top: -2px; }
/* Run report cards use simpler layout without card-body */
.run-report-card { flex-direction: column; align-items: flex-start; }
.run-report-card .ranking-name { font-weight: 600; }
.detail-heading { display: flex; justify-content: space-between; align-items: start; }
.total-score { color: var(--green); font-size: 2.4rem; font-weight: 700; line-height: 1; }
.total-score small { color: var(--text-muted); font-size: .8rem; }
.dimension-bars { display: grid; gap: .55rem; }
.dimension-row { display: grid; grid-template-columns: 5rem 1fr 2rem; align-items: center; gap: .6rem; font-size: .8rem; }
.score-track { height: .55rem; overflow: hidden; border-radius: 999px; background: var(--bg-input); }
.score-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); }
.trend-chart { width: 100%; height: 120px; background: var(--bg-secondary); border-radius: var(--radius-sm); padding: 8px; }
.trend-chart polyline { fill: none; stroke: var(--green); stroke-width: 2; vector-effect: non-scaling-stroke; }
.trend-labels { display: flex; justify-content: space-between; color: var(--text-muted); font-size: .72rem; }
.finding-list { display: grid; gap: .75rem; }
.finding-list article, .review-box { padding: .8rem; border: 1px solid var(--border); background: var(--bg-secondary); border-radius: var(--radius-sm); }
.finding-list header { display: flex; justify-content: space-between; }
.finding-list p { margin-top: .5rem; font-size: .85rem; }
.finding-list code { margin-right: .35rem; color: var(--yellow); }
.badge-warn { color: var(--yellow); background: var(--yellow-bg); }
@media (max-width: 800px) { .humanization-layout { grid-template-columns: 1fr; } }

#app {
    min-height: 100vh;
}

/* ── Loading Screen ─────────────────────────────────────────── */
#loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Access Denied ──────────────────────────────────────────── */
#access-denied {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.denied-card {
    text-align: center;
    background: var(--bg-card);
    padding: 3rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.denied-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.denied-card h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.denied-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ── Hidden ─────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Header ─────────────────────────────────────────────────── */
#gm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.gm-badge {
    background: linear-gradient(135deg, var(--accent), #a855f7);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.gm-email {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 16px var(--accent-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(255, 107, 107, 0.2);
}

.btn-danger:hover {
    background: rgba(255, 107, 107, 0.2);
    border-color: var(--red);
}

.btn-success {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(0, 206, 201, 0.2);
}

.btn-success:hover {
    background: rgba(0, 206, 201, 0.2);
    border-color: var(--green);
}

.btn-warn {
    background: var(--yellow-bg);
    color: var(--yellow);
    border: 1px solid rgba(254, 202, 87, 0.2);
}

.btn-warn:hover {
    background: rgba(254, 202, 87, 0.2);
    border-color: var(--yellow);
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 0;
    padding: 0 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 0.85rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Tab Panels ─────────────────────────────────────────────── */
.panel-content {
    padding: 1.5rem 2rem;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.panel-toolbar h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ── Table ──────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead {
    background: var(--bg-secondary);
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(45, 50, 80, 0.5);
    color: var(--text-primary);
    vertical-align: middle;
}

tbody tr:hover {
    background: var(--bg-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

.empty-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

/* ── Status & Role Badges ───────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.badge-gm {
    background: linear-gradient(135deg, var(--accent), #a855f7);
    color: #fff;
}

.badge-user {
    background: var(--bg-input);
    color: var(--text-secondary);
}

.badge-active {
    background: var(--green-bg);
    color: var(--green);
}

.badge-disabled {
    background: var(--red-bg);
    color: var(--red);
}

.badge-openclaw {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.badge-success {
    background: var(--green-bg);
    color: var(--green);
}

.badge-warn {
    background: var(--yellow-bg);
    color: var(--yellow);
}

/* ── Action Buttons (inline in table) ───────────────────────── */
.action-group {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    #gm-header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .header-right {
        width: 100%;
        justify-content: flex-end;
    }

    .tab-bar {
        padding: 0 1rem;
    }

    .panel-content {
        padding: 1rem;
    }

    .tab-btn {
        padding: 0.7rem 1rem;
        font-size: 0.8rem;
    }
}

/* ── Registry Specifics ─────────────────────────────────────── */
.badge.status-online { background: #1a7f37; color: white; }
.badge.status-pending { background: #9a6700; color: white; }
.badge.status-offline { background: #6e7781; color: white; }
.badge.status-disabled { background: #cf222e; color: white; }
.badge.status-degraded { background: #d29922; color: black; }

.monospace { 
    font-family: 'JetBrains Mono', 'Courier New', monospace; 
    font-size: 0.85rem;
    color: var(--text-primary);
}
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 4px; }

.status-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 10px;
    cursor: help;
    margin-left: 6px;
    vertical-align: middle;
}

.status-tip:hover {
    background: var(--accent);
    color: white;
}
/* ── World Log Specifics ───────────────────────────────────── */
.log-content-box {
    background: #f1f3f5;
    color: #1a1b1e !important;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    max-height: 150px;
    overflow-y: auto;
    margin: 0;
    line-height: 1.4;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    border: 1px solid #e9ecef;
    white-space: pre-wrap;
    word-break: break-all;
}

#system-logs-table td {
    vertical-align: top;
}


/* Agent submission audit */
.submission-help { color: #929bb1; line-height: 1.7; font-size: 13px; }
.submission-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 18px 0; }
.submission-filters label { display: grid; gap: 6px; font-size: 12px; }
.submission-filters input, .submission-filters select { background: #171b28; color: #e3e8f4; border: 1px solid #3d455c; border-radius: 7px; padding: 9px; max-width: 250px; }
#submissions-tbody td { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 110px; vertical-align: top; }
#submissions-tbody pre { max-width: 640px; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
#submissions-tbody summary { cursor: pointer; color: #aebcff; }
.submission-status-accepted { color: #50c897; }
.submission-status-rejected, .submission-status-failed { color: #ff8888; }
.submission-status-received, .submission-status-unknown { color: #e9bf64; }
.submission-pager { display: flex; gap: 18px; align-items: center; justify-content: flex-end; margin: 16px 0; }
