:root {
    --primary-color: #2962ff;
    --primary-hover: #1565c0;
    --primary-bg: #e3f2fd;
    --nav-bg: #0f1626;
    --sidebar-bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --line: #eaecf0;
    --body-bg: #eef2f6;
    --border-color: #eaecf0;
    --text-main: #1d2129;
    --text-secondary: #4e5969;
    --text-muted: #86909c;
    --success: #00b42a;
    --danger: #d32f2f;
    --warning: #ff7d00;
    --shadow: 0 10px 30px rgba(10, 34, 66, 0.08);
    --radius: 14px;
    --font-family: "Manrope", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: linear-gradient(160deg, rgba(41, 98, 255, 0.06), rgba(0, 150, 136, 0.03) 38%, transparent 62%), var(--body-bg);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

.sidebar-wide {
    width: 220px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.logo-container {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}

.logo-container span {
    color: var(--primary-color);
    margin-right: 4px;
}

.nav-list {
    padding: 16px 8px;
    flex: 1;
    overflow-y: auto;
}

.nav-section-title {
    padding: 4px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.nav-item {
    padding: 10px 16px;
    margin-bottom: 4px;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: #f2f3f5;
    color: var(--text-main);
}

.nav-item.active {
    color: var(--primary-color);
    background: var(--primary-bg);
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 8px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 24px 0 24px;
    gap: 16px;
}

.topbar h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

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

.chip {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-weight: 500;
}

.page-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.view-content {
    display: none;
}

.view-content.active {
    display: block;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    margin-bottom: 8px;
}

.page-header p,
.muted {
    color: var(--text-muted);
}

.content-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

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

.box-header h3 {
    font-weight: 600;
}

.card-grid {
    display: grid;
    gap: 16px;
}

.metrics-grid {
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 24px;
}

.audit-grid {
    grid-template-columns: repeat(3, 1fr);
}

.metric-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.metric-blue {
    border-top: 4px solid var(--primary-color);
}

.metric-green {
    border-top: 4px solid var(--success);
}

.metric-orange {
    border-top: 4px solid var(--warning);
}

.metric-purple {
    border-top: 4px solid #8e44ad;
}

.metric-label {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
}

.center-box {
    text-align: center;
}

.warning-box {
    background: #fff3e6;
    padding: 16px;
    border: 1px solid #ff9800;
    border-radius: 8px;
    margin-bottom: 24px;
}

.warning-box strong {
    display: block;
    color: #e65100;
    margin-bottom: 8px;
}

.warning-box p {
    color: #e65100;
}

.warning-box.soft {
    background: #f7fbff;
    border-color: #b3d4ff;
}

.warning-box.soft strong,
.warning-box.soft p {
    color: #2962ff;
}

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

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

.data-table th {
    color: var(--text-secondary);
    font-weight: 600;
}

.badge {
    display: inline-block;
    border-radius: 99px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

.badge-success {
    background: #2e7d32;
}

.badge-danger {
    background: #d32f2f;
}

.badge-warning {
    background: #ef6c00;
}

.b-blue {
    background: #1e5eff;
}

.action-link {
    color: var(--primary-color);
    cursor: pointer;
}

.btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text-main);
    cursor: pointer;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.full-width {
    width: 100%;
}

.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

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

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text-main);
}

textarea.form-input {
    resize: vertical;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    background: #f5f8fc;
    border: 1px solid #dbe5f2;
    border-radius: 8px;
    padding: 16px;
    overflow: auto;
    white-space: pre-wrap;
    line-height: 1.5;
    color: #333;
}

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

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

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

.simple-tab {
    padding: 8px 14px;
    border-radius: 8px;
    background: #f6f8fb;
    border: 1px solid var(--line);
    color: var(--text-secondary);
    cursor: pointer;
}

.simple-tab.active {
    background: var(--primary-bg);
    color: var(--primary-color);
    border-color: #c7dbff;
}

.region-panel {
    display: none;
}

.region-panel.active {
    display: block;
}

.inline-actions {
    display: flex;
    gap: 8px;
}

.placeholder-box {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

/* Agent Cards */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.agent-card {
    border-radius: 16px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    transition: all 0.3s;
}

.agent-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(41, 98, 255, 0.1);
}

.agent-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #f2f3f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.agent-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.agent-type {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #f2f3f5;
    padding: 2px 8px;
    border-radius: 10px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 12px;
    background: #e8f5e9;
    color: var(--success);
    border: 1px solid #c8e6c9;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.agent-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.detail-label { color: var(--text-muted); }
.detail-value { font-weight: 500; }

.tag-list {
    display: flex;
    gap: 6px;
}

.tag {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: #f2f3f5;
    border: 1px solid var(--line);
}

@media (max-width: 1200px) {
    .metrics-grid,
    .audit-grid,
    .two-col-grid,
    .agent-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    body {
        flex-direction: column;
        height: auto;
    }

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

    .topbar {
        margin: 16px 16px 0 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .page-body {
        padding: 16px;
    }
}
