:root {
    --accent: #2563EB;
    --accent-light: #3b82f6;
    --accent-dark: #1d4ed8;
    --sidebar-width: 320px;
    --toast-bg: #1f2937;
    --code-font: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
    --font-heading: 'Satoshi', 'IBM Plex Sans', system-ui, sans-serif;
    --font-mono: var(--code-font);
    --input-focus-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    font-family: var(--font-sans);
    min-height: 100vh;
    background: #f8fafc;
    color: #1e293b;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-heading);
}

code {
    font-family: var(--code-font);
    color: #1e293b;
    background: #f1f5f9;
    padding: 0.125em 0.375em;
    border-radius: 4px;
    font-size: 0.85em;
}

pre {
    font-family: var(--code-font);
}

/* Override Bootstrap primary color */
.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-dark);
    --bs-btn-hover-border-color: var(--accent-dark);
    --bs-btn-active-bg: var(--accent-dark);
    --bs-btn-active-border-color: var(--accent-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-active-bg: var(--accent);
    --bs-btn-active-border-color: var(--accent);
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Form controls */
.form-control:focus {
    border-color: var(--accent);
    box-shadow: var(--input-focus-shadow);
}

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

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
    margin-bottom: 0.375rem;
}

input[type="checkbox"], input[type="radio"] {
    accent-color: var(--accent);
    cursor: pointer;
}

input[type="date"] {
    color-scheme: light;
    min-width: 130px;
}

/* HTTP method badges */
.badge-method {
    font-size: 0.75rem;
    padding: 0.25em 0.6em;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-method.get { background: #16a34a; color: #fff; }
.badge-method.post { background: var(--accent); color: #fff; }
.badge-method.put { background: #f59e0b; color: #fff; }
.badge-method.patch { background: #9333ea; color: #fff; }
.badge-method.delete { background: #dc2626; color: #fff; }

/* JSON pretty-print */
.json-display {
    background: #f1f5f9;
    color: #1e293b;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-family: var(--code-font);
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.json-display .json-key { color: var(--accent); }
.json-display .json-string { color: #16a34a; }
.json-display .json-number { color: #f59e0b; }
.json-display .json-boolean { color: #7c3aed; }
.json-display .json-null { color: #dc2626; }
.json-display .json-bracket { color: #64748b; }

/* Toast notifications */
.toast-custom {
    background: var(--toast-bg);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
    max-width: 360px;
    word-break: break-word;
    margin-bottom: 8px;
}

.toast-snippet {
    color: #94a3b8;
    font-size: 0.8rem;
    display: block;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 320px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes flashNew {
    0% { background-color: #f8fafc; }
    100% { background-color: transparent; }
}

@keyframes pulseBadge {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.badge-pulse { animation: pulseBadge 0.5s ease; }

/* Sidebar layout */
.master-detail-layout {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 160px);
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    padding: 0;
    height: calc(100vh - 160px);
    position: sticky;
    top: 70px;
}

.detail-panel {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: #fff;
}

/* Message list */
.message-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.message-list-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
    transition: background 0.15s ease;
}

.message-list-item:hover {
    background: #f1f5f9;
}

.message-list-item.active {
    background: #f8fafc;
    border-left: 3px solid var(--accent);
}

.message-list-item .message-timestamp {
    font-size: 0.75rem;
    color: #64748b;
}

.message-list-item .message-method {
    font-weight: 600;
    font-size: 0.8rem;
    min-width: 48px;
    display: inline-block;
}

.message-list-item .message-path {
    font-size: 0.85rem;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Stats bar (homepage) */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.stat-icon.blue { background: var(--accent); }
.stat-icon.green { background: #16a34a; }
.stat-icon.amber { background: #f59e0b; }
.stat-icon.purple { background: #7c3aed; }

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    color: #0f172a;
}

.stat-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Endpoint card */
.endpoint-card {
    transition: box-shadow var(--transition-base), transform var(--transition-base);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.endpoint-card:hover {
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.10);
    transform: translateY(-2px);
    border-color: var(--accent-light);
}

.ep-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.ep-status-dot.active { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); }
.ep-status-dot.inactive { background: #64748b; }

.ep-name {
    font-weight: 600;
    font-size: 1rem;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ep-url {
    font-family: var(--code-font);
    font-size: 0.8rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ep-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

/* Shared endpoint card */
.shared-card {
    border: 1px dashed #0891b2;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.shared-card:hover {
    box-shadow: 0 4px 16px rgba(32, 156, 238, 0.10);
    transform: translateY(-1px);
}

/* Section heading */
.section-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.section-heading::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: #fff;
    border: 2px dashed #e2e8f0;
    border-radius: 12px;
    transition: border-color 0.2s ease;
}

.empty-state:hover {
    border-color: var(--accent-light);
}

.empty-state-icon {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: #64748b;
}

.empty-state h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: #1e293b;
}

.empty-state p {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 1.25rem;
}

/* Copy button */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    font-size: 0.75rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #64748b;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.copy-btn:hover { background: #f8fafc; }
.json-wrapper { position: relative; }

/* Tab panes */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Diff colors */
.diff-added { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
.diff-removed { background: rgba(239, 68, 68, 0.15); color: #dc2626; }
.diff-modified { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

/* Status indicator */
.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-indicator.active { background: #16a34a; }
.status-indicator.inactive { background: #64748b; }

/* Messages page */
.messages-container {
    display: flex;
    height: calc(100vh - 210px);
    min-height: 500px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.messages-list-panel {
    display: flex;
    flex-direction: column;
    width: 38%;
    min-width: 240px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
}

.pinned-section {
    background: rgba(255, 193, 7, 0.08);
    border-bottom: 1px solid #e2e8f0;
}

.pinned-header {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #f59e0b;
    border-bottom: 1px solid #e2e8f0;
}

.pinned-list {
    max-height: 180px;
    overflow-y: auto;
}

.filter-bar {
    padding: 0.6rem 0.75rem;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.filter-bar .filter-heading {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.45rem;
}

.filter-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.filter-row .form-select,
.filter-row .form-control {
    font-size: 0.8rem;
    height: 2rem;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
    border-radius: 5px;
}

.filter-search-group {
    display: flex;
    gap: 0;
}

.filter-search-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    flex: 1;
    min-width: 0;
}

.filter-search-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    height: 2rem;
}

.filter-date-group {
    display: flex;
    gap: 0.3rem;
}

.filter-date-group .form-control {
    flex: 1;
    min-width: 0;
}

.message-list-toolbar {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.8rem;
    gap: 0.5rem;
}

.message-list-toolbar .message-count {
    color: #64748b;
    flex: 1;
}

.message-item {
    cursor: pointer;
    transition: background 0.12s ease, border-left-color 0.12s ease;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid transparent;
}

.message-item:hover {
    background: #f1f5f9;
}

.message-item.is-selected {
    background: #f8fafc;
    border-left-color: var(--accent);
}

.message-item.is-pinned {
    background: rgba(255, 193, 7, 0.06);
}

.message-item .message-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.message-item .method-tag {
    flex-shrink: 0;
    width: 52px;
    text-align: center;
    font-weight: 600;
    font-size: 0.7rem;
}

.message-item .message-info {
    flex: 1;
    min-width: 0;
}

.message-item .message-label {
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1e293b;
}

.message-item .message-time {
    font-size: 0.7rem;
    color: #64748b;
}

.message-item .message-size {
    font-size: 0.7rem;
    color: #64748b;
    flex-shrink: 0;
    white-space: nowrap;
}

.message-item .pin-btn {
    font-size: 0.85rem;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.message-item .pin-btn:hover {
    transform: scale(1.15);
}

.message-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    font-size: 0.8rem;
}

.message-pagination .page-info {
    color: #64748b;
}

.panel-divider {
    cursor: col-resize;
    width: 5px;
    background: #e2e8f0;
    flex-shrink: 0;
    user-select: none;
    transition: background 0.15s ease;
    position: relative;
    z-index: 1;
}

.panel-divider:hover,
.panel-divider:active {
    background: var(--accent);
}

.detail-panel-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

#detailPanel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #64748b;
    padding: 2rem;
    text-align: center;
}

.detail-placeholder svg {
    opacity: 0.4;
    margin-bottom: 1rem;
}

.detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.detail-header .detail-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.detail-header .detail-meta-text {
    font-size: 0.75rem;
    color: #64748b;
}

.detail-header .detail-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.detail-label-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.detail-label-bar .label-text {
    font-size: 0.8rem;
    color: #64748b;
    flex-shrink: 0;
}

.detail-label-bar .label-input {
    max-width: 280px;
    font-size: 0.8rem;
    height: 1.9rem;
    padding-top: 0;
    padding-bottom: 0;
}

.detail-tabs {
    margin-bottom: 0;
    padding: 0 0.75rem;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.detail-tabs .nav-link {
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
    color: #64748b;
    border: none;
    border-bottom: 2px solid transparent;
}

.detail-tabs .nav-link.active {
    color: var(--accent);
    background: transparent;
    border-bottom-color: var(--accent);
}

.detail-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.detail-tab-content .tab-pane {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.detail-tab-content .tab-pane.active {
    display: flex;
}

.detail-tab-content .tab-pane pre {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 1rem;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-all;
    overflow: auto;
    background: #fff;
    border: none;
    border-radius: 0;
}

.detail-tab-content .tab-pane #schemaPanel {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

/* JSON Schema filter */
.schema-filter-toggle {
    font-size: 0.78rem;
    padding: 0.3rem 0.6rem;
    border-radius: 5px;
    transition: all var(--transition-fast);
}

.schema-filter-toggle.has-filter {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.schema-filter-toggle.has-filter code {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.valid { background: #16a34a; }
.status-dot.invalid { background: #dc2626; }
.status-dot.empty { background: #cbd5e1; }

.schema-filter-toolbar {
    display: flex;
    gap: 0.3rem;
    padding: 0.35rem 0.5rem;
}

.schema-filter-toolbar .btn {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    height: 1.6rem;
}

.schema-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.35rem 0.5rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.schema-examples .example-btn {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--code-font);
    white-space: nowrap;
}

.schema-examples .example-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(37,99,235,0.05);
}

/* Config page */
.config-container {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}
.config-sidebar { overflow-y: auto; }
.preset-item { transition: background 0.15s ease; cursor: pointer; }
.preset-item:hover { background: #f1f5f9; }

/* Loading spinner */
.message-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #64748b;
    font-size: 0.9rem;
    gap: 0.5rem;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Responsive */
@media (max-width: 767.98px) {
    .master-detail-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: 40vh;
    }
    .detail-panel { padding: 1rem; }

    .messages-container {
        flex-direction: column;
        height: auto;
        min-height: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .messages-list-panel {
        width: 100% !important;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: 50vh;
    }

    .panel-divider {
        display: none;
    }

    .filter-row {
        flex-direction: column;
    }
}
