/* Introspect Studio - Dark Terminal Theme */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;

    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --accent-blue: #58a6ff;
    --accent-purple: #a371f7;

    --color-success: #22c55e;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;

    --border-default: #30363d;
    --border-strong: #484f58;

    /* Aliases for templates using short names */
    --accent: #58a6ff;
    --border: #30363d;
    --info: #3b82f6;
    --warning: #f59e0b;
    --error: #ef4444;
    --success: #22c55e;

    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-size-sm: 12px;
    --font-size-base: 13px;
    --font-size-lg: 14px;

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

/* Hidden scrollbars (keep scrolling functional) */
* {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

*::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Base */
html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--font-size-base);
    line-height: 1.5;
}

/* Utility classes */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: var(--font-size-sm); }
.flex-1 { flex: 1; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: #79c0ff;
    border-color: #79c0ff;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

/* Form elements */
input, textarea {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-base);
    padding: 10px 14px;
    transition: border-color 0.15s ease;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

/* Login page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
}

.login-form .btn {
    margin-top: 8px;
    width: 100%;
    padding: 12px;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
}

/* App container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-default);
    height: 56px;
}

.header-left {
    flex-shrink: 0;
}

.logo {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-blue);
}

.header-center {
    flex: 1;
    max-width: 700px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Force Refresh Toggle */
.force-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-tertiary);
    transition: all 0.15s ease;
}

.force-refresh-toggle:hover {
    border-color: var(--border-strong);
}

.force-refresh-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent-yellow);
    cursor: pointer;
}

.force-refresh-toggle .toggle-label {
    font-size: 11px;
    color: var(--text-secondary);
    user-select: none;
}

.force-refresh-toggle:has(input:checked) {
    border-color: var(--accent-yellow);
    background: rgba(210, 153, 34, 0.1);
}

.force-refresh-toggle:has(input:checked) .toggle-label {
    color: var(--accent-yellow);
}

/* Database Source Toggle (Inspector) */
.header-center .source-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: 6px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.header-center .source-btn {
    padding: 3px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.header-center .source-btn.active {
    color: white;
}

.header-center .source-btn.active[data-source="prod"] {
    background: #22c55e;
}

.header-center .source-btn.active[data-source="dev"] {
    background: #f97316;
}

.header-center .source-btn.active[data-source="both"] {
    background: var(--accent-blue);
}

.header-center .source-btn:hover:not(.active) {
    background: var(--bg-secondary);
}

/* Source badges (shared across templates) */
.source-badge {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 6px;
}

.source-badge.prod {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.source-badge.dev {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.url-input-wrapper {
    position: relative;
    width: 100%;
}

.url-input {
    width: 100%;
    padding: 8px 14px;
}

.recent-urls-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.recent-urls-dropdown.show {
    display: block;
}

.recent-url-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-url-item:last-child {
    border-bottom: none;
}

.recent-url-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    margin-left: auto;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-email {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Panels container */
.panels-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Panel */
.panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-default);
    overflow: hidden;
}

.panel:last-child {
    border-right: none;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

/* Breadcrumb Navigation */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
}

.breadcrumb-item {
    color: var(--text-secondary);
}

.breadcrumb-item.active {
    color: var(--text-primary);
}

.breadcrumb-item.clickable {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.breadcrumb-item.clickable:hover {
    background: var(--bg-hover);
    color: var(--accent-blue);
}

.breadcrumb-separator {
    color: var(--text-muted);
    font-weight: 400;
}

/* Agent controls in panel header */
.panel-header .agent-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header .mode-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: none;
    font-weight: 400;
}

.panel-header .mode-toggle input {
    accent-color: var(--accent-blue);
}

.panel-header .btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
}

.panel-header .btn-icon:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.panel-header .btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.panel-header .mode-toggle.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Dividers (for resizing) */
.divider {
    width: 4px;
    background: var(--border-default);
    cursor: col-resize;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.divider:hover,
.divider.dragging {
    background: var(--accent-blue);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 150px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 16px;
}

/* Loading indicator (manual control via .show class) */
.loading-indicator {
    opacity: 0;
    transition: opacity 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--accent-blue);
    pointer-events: none;
}

.loading-indicator.show {
    opacity: 1;
}

/* Loading spinner */
.spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Panel loading overlay */
.panel-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-text {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* Sessions list */
.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    position: relative;
}

.session-item .session-content {
    flex: 1;
    min-width: 0;
}

.session-item:hover {
    background: var(--bg-tertiary);
}

.session-item .card-menu {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.session-item:hover .card-menu {
    opacity: 1;
}

.session-item.active {
    background: var(--bg-tertiary);
    border-color: var(--accent-blue);
}

.session-name {
    font-size: var(--font-size-base);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.session-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    align-items: center;
}

.session-stats-row .token-summary {
    color: var(--text-secondary);
}

.session-stats-row .dim {
    color: var(--text-muted);
    font-size: 10px;
}

.session-stats-row .credits {
    color: var(--accent-green);
}

.session-stats-row .credits.high {
    color: var(--accent-red);
}

/* Executions */
.executions-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-default);
}

.summary-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.summary-title-row h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0;
}

.session-summary h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: 6px;
}

.summary-stats {
    display: flex;
    gap: 16px;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

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

.executions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Execution items - similar to session items */
.execution-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.execution-item:hover {
    background: var(--bg-tertiary);
}

.execution-item.active {
    background: var(--bg-tertiary);
    border-color: var(--accent-blue);
}

.execution-item.high-cost {
    border-color: var(--accent-red);
    background: rgba(248, 81, 73, 0.05);
}

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

.execution-title {
    font-size: var(--font-size-base);
    font-weight: 500;
    margin-bottom: 4px;
}

.execution-meta {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.execution-preview {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.execution-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 12px;
}

.stat-tokens {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.stat-credits {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.stat-credits.high {
    color: var(--accent-red);
    font-weight: 500;
}

/* Turns - New Design */
.turns-header {
    margin-bottom: 12px;
}

.turns-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.turns-toolbar .search-input {
    flex: 1;
    max-width: 200px;
}

.turns-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.stat-separator {
    color: var(--text-muted);
}

.turns-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.turn-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.turn-item .turn-content {
    flex: 1;
    min-width: 0;
}

.turn-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-strong);
}

.turn-item .card-menu {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.turn-item:hover .card-menu {
    opacity: 1;
}

.turn-item.active {
    background: var(--bg-tertiary);
    border-color: var(--accent-blue);
}

.turn-item.high-cost {
    border-color: var(--accent-red);
    background: rgba(248, 81, 73, 0.05);
}

.turn-message {
    font-size: var(--font-size-base);
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 6px;
    word-break: break-word;
}

.turn-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.turn-counter {
    color: var(--text-secondary);
    font-weight: 500;
}

.turn-time {
    color: var(--text-muted);
}

.turn-tokens {
    color: var(--text-secondary);
}

.turn-credits {
    color: var(--text-secondary);
}

.turn-credits.high {
    color: var(--accent-red);
    font-weight: 500;
}

/* Card Menu (three-dot dropdown) */
.card-menu {
    position: relative;
    flex-shrink: 0;
}

.card-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.card-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.card-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    min-width: 140px;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.card-menu.open .card-menu-dropdown {
    display: block;
}

.card-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.card-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.card-menu-item svg {
    flex-shrink: 0;
    color: var(--text-muted);
}

.card-menu-item:hover svg {
    color: var(--text-secondary);
}

/* Export Toast */
.export-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 13px;
    color: var(--text-primary);
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1000;
}

.export-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.export-toast.success svg {
    color: var(--accent-green);
}

.export-toast.error svg {
    color: var(--accent-red);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
}

.badge-high {
    background: rgba(248, 81, 73, 0.2);
    color: var(--accent-red);
}

.badge-medium {
    background: rgba(210, 153, 34, 0.2);
    color: var(--accent-yellow);
}

.badge-low {
    background: rgba(88, 166, 255, 0.2);
    color: var(--accent-blue);
}

.badge.clickable {
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.badge.clickable:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.badge.active {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

.badge-clear {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    margin-left: 8px;
}

.badge-clear:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Detection highlight on turns */
.turn-item.detection-highlight {
    position: relative;
}

.turn-item.detection-highlight::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 2px 0 0 2px;
}

.turn-item.highlight-cost_spike {
    background: rgba(210, 153, 34, 0.1);
}

.turn-item.highlight-cost_spike::before {
    background: var(--accent-yellow);
}

.turn-item.highlight-failure_loop {
    background: rgba(248, 81, 73, 0.1);
}

.turn-item.highlight-failure_loop::before {
    background: var(--accent-red);
}

/* Flagged turn marker (always visible) */
.turn-item.flagged-cost_spike,
.turn-item.flagged-failure_loop {
    border-left: 3px solid transparent;
}

.turn-item.flagged-cost_spike {
    border-left-color: var(--accent-yellow);
}

.turn-item.flagged-failure_loop {
    border-left-color: var(--accent-red);
}

/* Metrics bar */
.metrics-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.metric {
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    border-right: 1px solid var(--border-default);
}

.metric:last-child {
    border-right: none;
}

.metric-value {
    font-size: 16px;
    font-weight: 600;
}

.metric-value.low {
    color: var(--accent-red);
}

.metric-value.high {
    color: var(--accent-green);
}

.metric-label {
    font-size: 10px;
    color: var(--text-muted);
}

.metric.detections {
    flex-direction: row;
    gap: 6px;
}

/* Analysis Report */
.analysis-report {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.report-content {
    font-size: var(--font-size-sm);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* When markdown is rendered, use normal whitespace to avoid double line breaks */
.report-content.markdown {
    white-space: normal;
}

.report-content h1,
.report-content h2,
.report-content h3,
.report-content h4 {
    color: var(--text-primary);
    margin-top: 16px;
    margin-bottom: 8px;
}

.report-content h2 { font-size: 16px; }
.report-content h3 { font-size: 14px; }
.report-content h4 { font-size: 13px; }

.report-content p {
    margin-bottom: 12px;
}

.report-content ul,
.report-content ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.report-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.report-content pre {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: 12px;
}


.chat-message {
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: var(--radius-md);
}

.chat-message.user {
    background: var(--bg-tertiary);
}

.chat-message.assistant {
    background: rgba(63, 185, 80, 0.1);
}

.chat-message.error {
    background: rgba(248, 81, 73, 0.1);
    color: var(--accent-red);
}

.chat-message.loading {
    opacity: 0.6;
}

.message-content {
    font-size: var(--font-size-sm);
    white-space: pre-wrap;
}

/* When markdown is rendered, use normal whitespace to avoid double line breaks */
.message-content.markdown {
    white-space: normal;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.chat-input {
    flex: 1;
}

/* Analysis streaming */
.analysis-streaming {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.streaming-indicator {
    font-size: var(--font-size-sm);
    color: var(--accent-blue);
    margin-bottom: 12px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.analysis-output {
    flex: 1;
    overflow-y: auto;
    font-size: var(--font-size-sm);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* No analysis state */
.no-analysis {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* API calls list */
.api-calls-list {
    font-size: var(--font-size-sm);
}

.api-calls-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.api-calls-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.toggle-view-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.toggle-view-btn.active {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

.toggle-icon {
    font-size: 9px;
}

/* API call cards */
.api-calls-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.api-call-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.15s ease;
}

.api-call-card:hover {
    border-color: var(--border-strong);
}

.api-call-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    font-size: var(--font-size-sm);
}

.api-call-summary .call-num {
    color: var(--text-muted);
    min-width: 32px;
}

.api-call-summary .call-time {
    color: var(--text-secondary);
    min-width: 70px;
}

.api-call-summary .call-model {
    color: var(--text-primary);
    flex: 0 0 auto;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Role badges */
.call-role {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    text-transform: uppercase;
}

.call-role.user {
    background: rgba(74, 158, 255, 0.15);
    color: #4a9eff;
}

.call-role.assistant {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.call-type {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 2px 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    flex: 1;
}

/* Modal role styling */
.detail-role {
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
}

.detail-role.user {
    background: rgba(74, 158, 255, 0.15);
    color: #4a9eff;
}

.detail-role.assistant {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.detail-type {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.call-tokens-inline {
    display: flex;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}

.token-in {
    color: var(--accent-blue);
}

.token-out {
    color: var(--accent-green);
}

.call-cost {
    color: var(--accent-yellow);
    font-weight: 500;
    margin-left: 8px;
}

.footer-cost {
    color: var(--accent-yellow);
    font-weight: 600;
    margin-left: 8px;
}

/* API call details (expandable) */
.api-call-details {
    display: none;
    padding: 0 12px 10px 12px;
    border-top: 1px solid var(--border-default);
    background: var(--bg-secondary);
}

.api-call-card.expanded .api-call-details {
    display: block;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    font-size: 11px;
    line-height: 1.4;
}

.detail-row:first-child {
    padding-top: 10px;
}

.detail-label-inline {
    color: var(--text-muted);
    min-width: 50px;
    flex-shrink: 0;
    font-weight: 500;
}

.detail-preview {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.more-btn {
    flex-shrink: 0;
    padding: 2px 8px;
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--accent-blue);
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.more-btn:hover {
    background: var(--accent-blue);
    color: var(--bg-primary);
    border-color: var(--accent-blue);
}

/* API calls footer */
.api-calls-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    margin-top: 8px;
    border-top: 2px solid var(--border-default);
    font-weight: 600;
}

.footer-label {
    color: var(--text-secondary);
}

.footer-tokens {
    font-variant-numeric: tabular-nums;
}

/* Legacy table styles kept for reference - now using card layout */
.api-calls-hint {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: normal;
}

/* API Call Detail Modal */
.api-call-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-header {
    display: flex;
    gap: 16px;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-default);
}

.detail-model {
    font-weight: 600;
    color: var(--accent-blue);
}

.detail-time {
    color: var(--text-secondary);
}

.detail-tokens {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.detail-cost {
    color: var(--accent-yellow);
    font-weight: 600;
    margin-left: auto;
}

.detail-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-content {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    margin: 0;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: var(--accent-blue);
    color: var(--bg-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    max-width: 800px;
    max-height: 80vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-tertiary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.user-badge {
    background: rgba(88, 166, 255, 0.2);
    color: var(--accent-blue);
}

.assistant-badge {
    background: rgba(63, 185, 80, 0.2);
    color: var(--accent-green);
}

/* Markdown content styling */
.markdown-content {
    font-size: var(--font-size-base);
    line-height: 1.7;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 600;
}

.markdown-content h1 { font-size: 20px; }
.markdown-content h2 { font-size: 18px; }
.markdown-content h3 { font-size: 16px; }
.markdown-content h4 { font-size: 14px; }

.markdown-content p {
    margin-bottom: 16px;
}

.markdown-content ul,
.markdown-content ol {
    margin-left: 24px;
    margin-bottom: 16px;
}

.markdown-content li {
    margin-bottom: 8px;
}

.markdown-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.markdown-content pre {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-content pre code {
    background: none;
    padding: 0;
}

.markdown-content blockquote {
    border-left: 3px solid var(--accent-blue);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
}

.markdown-content a {
    color: var(--accent-blue);
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* More button */
.more-link {
    color: var(--accent-blue);
    cursor: pointer;
    font-size: var(--font-size-sm);
    margin-left: 4px;
}

.more-link:hover {
    text-decoration: underline;
}

/* Legacy color dot helpers */
.color-dot.yellow { background: var(--accent-yellow); }
.color-dot.red { background: var(--accent-red); }

/* Search Bar */
.search-bar {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-default);
}

.search-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input-sm {
    width: 120px;
    padding: 4px 8px;
    font-size: 11px;
}

/* Settings Button */
.settings-btn {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.settings-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.settings-btn svg {
    width: 16px;
    height: 16px;
}

/* Dashboard Button */
.dashboard-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--accent-blue);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.15s ease;
}

.dashboard-btn:hover {
    background: #4a9eff;
}

.dashboard-btn svg {
    width: 14px;
    height: 14px;
}

/* Analysis Panel Tabs */
.analysis-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tab-nav {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.tab-btn {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.tab-btn:hover:not(.disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--bg-tertiary);
    border-color: var(--border-default);
    color: var(--text-primary);
}

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

.tab-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 4px;
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

#tab-chat.active {
    overflow: hidden;
}

/* Chat styles updates */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-default);
    color: var(--text-primary);
    font-weight: 500;
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.chat-header .chat-hint {
    font-weight: normal;
    color: var(--text-muted);
    font-size: 11px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 0;
}

.chat-welcome {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.6;
}

.chat-welcome ul {
    margin: 8px 0 0 16px;
    padding: 0;
}

.chat-welcome li {
    margin: 4px 0;
}

.chat-message {
    margin-bottom: 12px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
}

.chat-message .message-role {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.chat-message.user {
    background: var(--bg-tertiary);
}

.chat-message.user .message-role {
    color: var(--color-info);
}

.chat-message.assistant {
    background: rgba(34, 197, 94, 0.1);
    border-left: 2px solid var(--color-success);
}

.chat-message.assistant .message-role {
    color: var(--color-success);
}

.chat-message .message-content {
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.chat-message .message-content ul,
.chat-message .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-message .message-content li {
    margin: 4px 0;
}

.chat-message .message-content p {
    margin: 8px 0;
}

.chat-message .message-content p:first-child {
    margin-top: 0;
}

.chat-message .message-content p:last-child {
    margin-bottom: 0;
}

.chat-message .message-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.chat-message .message-content pre {
    background: var(--bg-tertiary);
    padding: 10px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}

.chat-message .message-content pre code {
    background: none;
    padding: 0;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border-default);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-sm);
}

.chat-input:focus {
    outline: none;
    border-color: var(--color-info);
}

.chat-disabled {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* =============================================================================
   Classification Badges
   ============================================================================= */

.classification-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-default);
}

.classification-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    font-weight: 500;
    text-transform: capitalize;
    white-space: nowrap;
    transition: opacity 0.15s ease;
}

.classification-badge:hover {
    opacity: 0.8;
}

/* Classification loading state — pulsing indicator for unclassified turns */
.classifying-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
}
.pulse-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: pulse-classify 1.4s ease-in-out infinite;
}
@keyframes pulse-classify {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Re-classifying state — old badges dimmed with shimmer while new results arrive */
.classification-badges.reclassifying .classification-badge {
    opacity: 0.35;
    animation: reclassify-shimmer 2s ease-in-out infinite;
}
@keyframes reclassify-shimmer {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 0.55; }
}

/* =============================================================================
   Classification Dropdown Button
   ============================================================================= */

.classify-dropdown {
    position: relative;
    margin-left: 8px;
}

.classify-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all 0.15s ease;
}

.classify-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.classify-btn svg {
    flex-shrink: 0;
}

.classify-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--accent-blue);
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 8px;
}

.classify-check {
    color: var(--color-success);
}

.dropdown-arrow {
    margin-left: 2px;
    transition: transform 0.15s ease;
}

.classify-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.classify-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.15s ease;
}

.classify-dropdown.open .classify-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.classify-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    text-align: left;
    cursor: pointer;
    transition: background 0.1s ease;
}

.classify-dropdown-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.classify-dropdown-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.classify-dropdown-item:only-child {
    border-radius: var(--radius-md);
}

.classify-dropdown-item:hover {
    background: var(--bg-hover);
}

.classify-dropdown-item svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.classify-dropdown-divider {
    height: 1px;
    background: var(--border-default);
    margin: 4px 0;
}

/* Loading state */
.classify-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.classify-btn.loading svg:first-child {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* =============================================================================
   Settings Modal (Unified)
   ============================================================================= */

.settings-modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-md);
}

.settings-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 12px;
}

.settings-modal-header h2 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

/* Tabs */
.settings-tabs {
    display: flex;
    gap: 0;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-default);
}

.settings-tab {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: -1px;
}

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

.settings-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-blue);
}

/* Panel body */
.settings-body {
    flex: 1;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.settings-panel {
    display: none;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

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

/* Flex panel layout (fixed header/footer, scrollable middle) */
.settings-panel.panel-flex {
    display: none;
    flex-direction: column;
    overflow: hidden;
    padding: 20px;
    flex: 1;
}

.settings-panel.panel-flex.active {
    display: flex;
}

.panel-header {
    flex-shrink: 0;
    padding-bottom: 12px;
    background: transparent;
}

.panel-header .panel-intro {
    margin-bottom: 0;
    text-transform: none;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    background: transparent;
    padding: 0;
    border: none;
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.panel-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-default);
    background: var(--bg-secondary);
}

.panel-intro {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Settings table */
.settings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.settings-table th {
    text-align: left;
    padding: 8px 12px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-default);
}

.settings-table td {
    padding: 10px 12px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-default);
    vertical-align: middle;
}

.settings-table tbody tr:hover {
    background: var(--bg-tertiary);
}

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

/* Classification table columns */
.classification-table .col-color { width: 40px; }
.classification-table .col-name { width: 160px; font-weight: 500; }
.classification-table .col-desc { color: var(--text-secondary); }
.classification-table .col-actions { width: 60px; text-align: right; }

/* Color dot */
.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Inline edit form */
.editing-row {
    background: var(--bg-tertiary);
}

.editing-row:hover {
    background: var(--bg-tertiary);
}

.editing-row td {
    padding: 0;
    border-bottom: 1px solid var(--border-default);
}

.label-edit-form {
    padding: 16px 12px;
}

.edit-row {
    margin-bottom: 12px;
}

.edit-row:last-child {
    margin-bottom: 0;
}

.edit-row label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.edit-row input[type="text"],
.edit-row textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
}

.edit-row input:focus,
.edit-row textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.edit-row textarea {
    resize: vertical;
    min-height: 80px;
}

/* Color palette */
.color-palette {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-primary);
}

/* Edit actions */
.edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-default);
}

/* Panel actions (legacy, use panel-footer for flex panels) */
.panel-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-default);
}

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

/* Shortcuts table */
.shortcuts-table td {
    padding: 8px 12px;
}

.shortcut-key {
    width: 60px;
}

.shortcut-key kbd {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
}

/* Detector badges in table */
.detector-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
}

.detector-badge.high {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.detector-badge.medium {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

/* Button variants */
.btn-sm {
    padding: 6px 12px;
    font-size: var(--font-size-sm);
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-danger-ghost {
    background: transparent;
    border: none;
    color: var(--accent-red);
    cursor: pointer;
}

.btn-danger-ghost:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */

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

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-md);
    color: white;
}

.toast-success {
    background: var(--color-success, #22c55e);
}

.toast-error {
    background: var(--color-danger, #ef4444);
}


/* =============================================================================
   Session Insights — Categories, Badges, Insights Page
   ============================================================================= */

/* Category color variables */
:root {
    --cat-landing_page: #3b82f6;
    --cat-ecommerce: #f59e0b;
    --cat-dashboard: #8b5cf6;
    --cat-mobile_app: #10b981;
    --cat-portfolio: #6366f1;
    --cat-blog: #ec4899;
    --cat-saas_app: #14b8a6;
    --cat-documentation: #64748b;
    --cat-component_library: #a855f7;
    --cat-email_template: #f97316;
    --cat-social_media: #06b6d4;
    --cat-game_ui: #ef4444;
    --cat-admin_panel: #84cc16;
    --cat-other: #6b7280;
}

/* Category dot (small circle in bar charts & legends) */
.category-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cat-landing_page, .category-dot.cat-landing_page { background: var(--cat-landing_page); }
.cat-ecommerce, .category-dot.cat-ecommerce { background: var(--cat-ecommerce); }
.cat-dashboard, .category-dot.cat-dashboard { background: var(--cat-dashboard); }
.cat-mobile_app, .category-dot.cat-mobile_app { background: var(--cat-mobile_app); }
.cat-portfolio, .category-dot.cat-portfolio { background: var(--cat-portfolio); }
.cat-blog, .category-dot.cat-blog { background: var(--cat-blog); }
.cat-saas_app, .category-dot.cat-saas_app { background: var(--cat-saas_app); }
.cat-documentation, .category-dot.cat-documentation { background: var(--cat-documentation); }
.cat-component_library, .category-dot.cat-component_library { background: var(--cat-component_library); }
.cat-email_template, .category-dot.cat-email_template { background: var(--cat-email_template); }
.cat-social_media, .category-dot.cat-social_media { background: var(--cat-social_media); }
.cat-game_ui, .category-dot.cat-game_ui { background: var(--cat-game_ui); }
.cat-admin_panel, .category-dot.cat-admin_panel { background: var(--cat-admin_panel); }
.cat-other, .category-dot.cat-other { background: var(--cat-other); }

/* Category badge (inspector session cards) */
.category-badge {
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    vertical-align: middle;
    margin-left: 0.25rem;
    color: white;
}

.cat-bg-landing_page { background: var(--cat-landing_page); }
.cat-bg-ecommerce { background: var(--cat-ecommerce); }
.cat-bg-dashboard { background: var(--cat-dashboard); }
.cat-bg-mobile_app { background: var(--cat-mobile_app); }
.cat-bg-portfolio { background: var(--cat-portfolio); }
.cat-bg-blog { background: var(--cat-blog); }
.cat-bg-saas_app { background: var(--cat-saas_app); }
.cat-bg-documentation { background: var(--cat-documentation); }
.cat-bg-component_library { background: var(--cat-component_library); }
.cat-bg-email_template { background: var(--cat-email_template); }
.cat-bg-social_media { background: var(--cat-social_media); }
.cat-bg-game_ui { background: var(--cat-game_ui); }
.cat-bg-admin_panel { background: var(--cat-admin_panel); }
.cat-bg-other { background: var(--cat-other); }

/* Insights hero panel on dashboard */
.insights-hero {
    margin-bottom: 1.5rem;
}

.insights-hero .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.insights-hero .card-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.btn-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Bar chart component */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bar-chart.compact {
    gap: 0.375rem;
}

.bar-row {
    display: grid;
    grid-template-columns: 140px 1fr auto;
    align-items: center;
    gap: 0.75rem;
}

.bar-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-track {
    height: 18px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 2px;
}

/* Bar fills use category colors via class */
.bar-fill.cat-landing_page { background: var(--cat-landing_page); }
.bar-fill.cat-ecommerce { background: var(--cat-ecommerce); }
.bar-fill.cat-dashboard { background: var(--cat-dashboard); }
.bar-fill.cat-mobile_app { background: var(--cat-mobile_app); }
.bar-fill.cat-portfolio { background: var(--cat-portfolio); }
.bar-fill.cat-blog { background: var(--cat-blog); }
.bar-fill.cat-saas_app { background: var(--cat-saas_app); }
.bar-fill.cat-documentation { background: var(--cat-documentation); }
.bar-fill.cat-component_library { background: var(--cat-component_library); }
.bar-fill.cat-email_template { background: var(--cat-email_template); }
.bar-fill.cat-social_media { background: var(--cat-social_media); }
.bar-fill.cat-game_ui { background: var(--cat-game_ui); }
.bar-fill.cat-admin_panel { background: var(--cat-admin_panel); }
.bar-fill.cat-other { background: var(--cat-other); }

.bar-fill.industry-fill { background: var(--accent-purple); }
.bar-fill.tech-fill { background: var(--accent-blue); }

.bar-value {
    display: flex;
    gap: 0.25rem;
    align-items: baseline;
    font-size: 0.8rem;
    white-space: nowrap;
    min-width: 70px;
    justify-content: flex-end;
}

.bar-count {
    color: var(--text-primary);
    font-weight: 600;
}

.bar-pct {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.bar-footer {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-show-more {
    margin-top: 0.5rem;
    padding: 4px 10px;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
}

.btn-show-more:hover {
    background: var(--bg-tertiary);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    text-align: center;
}

.empty-icon {
    opacity: 0.5;
}

/* Insights nav button in dashboard header */
.insights-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--accent-purple);
    border: none;
    border-radius: 6px;
    color: white;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.insights-nav-btn:hover {
    background: #b886ff;
}

/* ======================== Insights Page ======================== */

.insights-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.insights-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.insights-card .card-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

@media (max-width: 900px) {
    .insights-grid {
        grid-template-columns: 1fr;
    }
}

/* Donut chart */
.donut-layout {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.donut-container {
    flex-shrink: 0;
}

.donut-chart {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    position: relative;
}

.donut-hole {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.donut-total {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.donut-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
    min-width: 200px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.legend-name {
    color: var(--text-primary);
    flex: 1;
}

.legend-count {
    color: var(--text-primary);
    font-weight: 600;
}

.legend-pct {
    color: var(--text-muted);
    font-size: 0.7rem;
    min-width: 35px;
}

/* Complexity bars */
.complexity-bars, .outcome-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.complexity-row, .outcome-row {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    align-items: center;
    gap: 0.75rem;
}

.complexity-label, .outcome-label {
    font-size: 0.8rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.bar-fill.complexity-simple { background: #22c55e; }
.bar-fill.complexity-medium { background: #f59e0b; }
.bar-fill.complexity-complex { background: #ef4444; }

/* Outcome colors */
.outcome-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.outcome-dot.outcome-completed, .bar-fill.outcome-completed { background: #22c55e; }
.outcome-dot.outcome-iterating, .bar-fill.outcome-iterating { background: #3b82f6; }
.outcome-dot.outcome-exploring, .bar-fill.outcome-exploring { background: #f59e0b; }
.outcome-dot.outcome-abandoned, .bar-fill.outcome-abandoned { background: #ef4444; }
.outcome-dot.outcome-unknown, .bar-fill.outcome-unknown { background: #6b7280; }

/* Topic cloud */
.topic-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.topic-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.topic-count {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Recent sessions / intent table */
.intent-table {
    overflow-x: auto;
}

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

.intent-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.intent-table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

.intent-cell {
    color: var(--text-primary);
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =============================================================================
   Inspector — Session Insight Summary Card
   ============================================================================= */

.insight-summary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.625rem 0.75rem;
    margin-top: 0.5rem;
}

.insight-row-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.insight-category-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.insight-subcategory {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.insight-meta-pills {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    flex: 1;
}

.insight-pill {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.insight-pill.complexity-simple { color: #22c55e; border: 1px solid #22c55e40; }
.insight-pill.complexity-medium { color: #f59e0b; border: 1px solid #f59e0b40; }
.insight-pill.complexity-complex { color: #ef4444; border: 1px solid #ef444440; }

.outcome-pill.outcome-completed { color: #22c55e; border: 1px solid #22c55e40; }
.outcome-pill.outcome-iterating { color: #3b82f6; border: 1px solid #3b82f640; }
.outcome-pill.outcome-exploring { color: #f59e0b; border: 1px solid #f59e0b40; }
.outcome-pill.outcome-abandoned { color: #ef4444; border: 1px solid #ef444440; }
.outcome-pill.outcome-unknown { color: #6b7280; border: 1px solid #6b728040; }

.insight-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    transition: transform 0.2s;
    margin-left: auto;
}

.insight-toggle:hover { color: var(--text-secondary); }
.insight-toggle.collapsed { transform: rotate(180deg); }

.insight-details {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.insight-details.hidden {
    display: none;
}

.insight-intent {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.insight-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.insight-tag {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent-blue);
    border: 1px solid rgba(88, 166, 255, 0.2);
}

.insight-tag.tech {
    background: rgba(163, 113, 247, 0.1);
    color: var(--accent-purple);
    border-color: rgba(163, 113, 247, 0.2);
}

.insight-friction {
    font-size: 0.7rem;
    color: var(--accent-yellow);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    opacity: 0.85;
}
