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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    min-height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============ TOP BAR ============ */
.topbar {
    background: #1e293b;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand h1 { font-size: 18px; font-weight: 600; }
.topbar-logo {
    width: 32px; height: 32px; border-radius: 8px;
    background: #dc2626; display: flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: 16px;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ============ BUTTONS ============ */
.btn {
    padding: 8px 16px; border: none; border-radius: 8px;
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: background 0.15s; text-decoration: none;
}
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-ghost {
    background: rgba(255,255,255,0.1); color: white;
    border: 1px solid rgba(255,255,255,0.2);
}
.btn-ghost:hover { background: rgba(255,255,255,0.2); }

/* ============ MAIN CONTENT ============ */
.main-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ============ STATS ============ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-card-up { border-left: 4px solid #22c55e; }
.stat-card-down { border-left: 4px solid #ef4444; }

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #1e293b;
}

.stat-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

/* ============ PANELS ============ */
.panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
}

.panel-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ============ CHART ============ */
.chart-section {
    margin-bottom: 20px;
}

.chart-container {
    padding: 16px 20px;
    height: 250px;
}

/* ============ TABLE ============ */
.sort-select {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    background: white;
    cursor: pointer;
}

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

.feedback-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.feedback-table th {
    text-align: left;
    padding: 10px 16px;
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.feedback-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.feedback-table tbody tr:hover {
    background: #f8fafc;
}

.col-date { width: 130px; }
.col-rating { width: 100px; }
.col-message { min-width: 300px; }
.col-session { width: 130px; }
.col-actions { width: 80px; text-align: center; }

.message-text {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-text {
    font-family: monospace;
    font-size: 12px;
    color: #64748b;
}

/* ============ RATING BADGES ============ */
.rating-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.rating-up { background: #f0fdf4; color: #16a34a; }
.rating-down { background: #fef2f2; color: #dc2626; }

.btn-detail {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    color: #475569;
}

.btn-detail:hover { background: #e2e8f0; }

.empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 40px 16px !important;
}

/* ============ PAGINATION ============ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: white;
    font-size: 12px;
    cursor: pointer;
}

.pagination button:hover:not(:disabled) { background: #f1f5f9; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: #64748b; }

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 { font-size: 16px; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #64748b;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.modal-close:hover { background: #f1f5f9; }

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

/* Modal detail sections */
.detail-section {
    margin-bottom: 20px;
}

.detail-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    margin-bottom: 8px;
    font-weight: 600;
}

.detail-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.metric-item {
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
}

.metric-item .metric-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-item .metric-value {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-top: 2px;
}

/* ============ CONVERSATION CONTEXT ============ */
.conversation-context {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.context-message {
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    line-height: 1.6;
}

.msg-user {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
}

.msg-assistant {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.msg-rated {
    border: 2px solid #ef4444;
    box-shadow: 0 0 0 2px #fef2f2;
}

.msg-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    margin-bottom: 6px;
}

.msg-content {
    color: #334155;
    white-space: pre-wrap;
    word-break: break-word;
}
