:root {
    --primary-color: #4a90e2;
    --background-color: #f4f7fa;
    --card-background: #ffffff;
    --text-color: #333;
    --subtle-text-color: #777;
    --border-color: #e0e6ed;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --approved-color: #28a745;
    --pending-color: #ffc107;
    --rejected-color: #dc3545;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

#app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

#header-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#header-subtitle {
    margin: 0;
    font-size: 0.8em;
    color: var(--subtle-text-color);
    font-weight: 400;
    letter-spacing: 0.01em;
}

#header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

#user-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82em;
}

.user-name {
    color: var(--subtle-text-color);
    font-weight: 500;
}

.btn-logout {
    text-decoration: none;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background 0.15s;
}
.btn-logout:hover {
    background: var(--background-color);
}

.dev-badge {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.82em;
    font-weight: 500;
}

.user-id-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #e8f4fd;
    color: #1a5b8a;
    border: 1px solid #b8d8f0;
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 0.97em;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.reviewer-input {
    width: 100%;
    max-width: 360px;
    padding: 8px 12px;
    border: 2px solid var(--primary-color);
    border-radius: 6px;
    font-size: 0.97em;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.reviewer-input:focus {
    border-color: #2a70c2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.18);
}

.hint-required {
    display: block;
    margin-top: 5px;
    color: var(--rejected-color);
    font-size: 0.82em;
}

h1, h2, h3 {
    margin: 0;
}

#main-content {
    transition: opacity 0.3s ease;
}

/* Breadcrumbs */
#breadcrumbs a {
    text-decoration: none;
    color: var(--primary-color);
}
#breadcrumbs span {
    margin: 0 5px;
    color: var(--subtle-text-color);
}

/* Card styles */
.card {
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-color);
    padding: 20px;
    margin-bottom: 20px;
    transition: box-shadow 0.2s ease-in-out;
}
.card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* Products View */
#products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}
.product-card {
    cursor: pointer;
}
.product-card h2 {
    margin-bottom: 15px;
}
.product-card .counts {
    display: flex;
    justify-content: space-around;
    text-align: center;
}
.product-card .counts .count-item span {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
}
.product-card .counts .approved span { color: var(--approved-color); }
.product-card .counts .rejected span { color: var(--rejected-color); }
.product-card .counts .pending span { color: var(--pending-color); }

/* Records List View */
#records-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
#records-list-header input, #records-list-header select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}
.record-item {
    display: grid;
    grid-template-columns: 1fr 40px;
    gap: 15px;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}
.record-item:last-child {
    border-bottom: none;
}
.record-item:hover {
    background-color: #f9fafb;
}
.record-item .question {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.record-item .user-id-input {
    display: none;
}
.record-status {
    font-size: 1.0em;
    font-weight: bold;
    text-align: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.record-status.approved { background: #d4edda; color: #28a745; }
.record-status.rejected { background: #f8d7da; color: #dc3545; }
.record-status.pending  { background: #f0f0f0; color: #999; }
.comment-indicator {
    color: var(--primary-color);
    font-size: 1.2em;
}

/* Record Detail View */
.record-detail-view .detail-item {
    margin-bottom: 20px;
}
.record-detail-view h3 {
    font-size: 0.9em;
    color: var(--subtle-text-color);
    text-transform: uppercase;
    margin-bottom: 5px;
}
.record-detail-view .assistant-answer {
    background: #fdfdfd;
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
}
.record-detail-view .assistant-answer table {
    width: 100%;
    border-collapse: collapse;
    font-family: monospace;
}
.record-detail-view .assistant-answer th,
.record-detail-view .assistant-answer td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
.record-detail-view .assistant-answer th {
    background-color: #f2f2f2;
}
.record-detail-view .comment-textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

/* Products header */
#products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.btn-export {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9em;
}
.btn-export:hover {
    opacity: 0.85;
}

/* Check/X component (used in detail view and tool call cards) */
.check-x-container,
.thumbs-container {
    display: flex;
    gap: 8px;
}
.cx-btn,
.thumb {
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 2px solid #ccc;
    background: #f5f5f5;
    color: #999;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.cx-btn:hover:not(.disabled),
.thumb:hover:not(.disabled) {
    cursor: pointer;
    transform: scale(1.1);
    filter: none;
}
.cx-btn.check.selected,
.thumb.up.selected {
    background: #d4edda;
    border-color: #28a745;
    color: #28a745;
    transform: scale(1.1);
}
.cx-btn.cross.selected,
.thumb.down.selected {
    background: #f8d7da;
    border-color: #dc3545;
    color: #dc3545;
    transform: scale(1.1);
}
.cx-btn.disabled,
.thumb.disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

/* Tool call cards */
.tool-call-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
.tool-call-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
}
.tool-call-title {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--text-color);
}
.tool-call-body {
    padding: 12px;
}
.tool-call-body .json-viewer {
    max-height: 200px;
    margin: 0;
}

/* Detail meta tags */
.detail-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    background: #e8f0fe;
    color: #1a73e8;
}
.tag-bop {
    background: #e6f4ea;
    color: #188038;
}
.user-question-text {
    font-size: 1.05em;
    line-height: 1.5;
}
.reviewer-section input {
    width: 280px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95em;
}
.overall-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.95em;
    margin-top: 4px;
}
.overall-badge.approved { background: #d4edda; color: #28a745; }
.overall-badge.rejected { background: #f8d7da; color: #dc3545; }
.overall-badge.pending  { background: #f0f0f0; color: #888; }
.overall-hint {
    display: block;
    margin-top: 4px;
    color: var(--subtle-text-color);
    font-size: 0.8em;
}

/* Save Changes button */
#save-changes {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 11px 28px;
    font-size: 0.95em;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(74, 144, 226, 0.35);
    transition: background 0.18s, box-shadow 0.18s, transform 0.1s;
    letter-spacing: 0.02em;
}
#save-changes::before {
    content: '\2713';
    font-size: 1.05em;
}
#save-changes:hover {
    background: linear-gradient(135deg, #357abd 0%, #2868a8 100%);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.45);
    transform: translateY(-1px);
}
#save-changes:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(74, 144, 226, 0.3);
}

/* Answer Preference Toggles */
.answer-prefs-section {
    background: linear-gradient(135deg, #f5f7ff 0%, #f0f4ff 100%);
    border: 1px solid #d8e0f5;
    border-radius: 12px;
    padding: 18px 22px 14px;
}
.answer-prefs-heading {
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #5c6bc0;
    margin-bottom: 14px;
}
.pref-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.pref-row:last-child {
    margin-bottom: 0;
}
.pref-icon {
    font-size: 1.15em;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    cursor: default;
}
.pref-label {
    font-size: 0.8em;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    width: 160px;
    flex-shrink: 0;
}
.pref-pill {
    display: flex;
    align-items: stretch;
    flex: 1;
    border-radius: 20px;
    border: 1.5px solid #d0d7e8;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.pref-opt {
    flex: 1;
    padding: 6px 14px;
    font-size: 0.82em;
    font-weight: 500;
    text-align: center;
    color: #999;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, font-weight 0.1s;
    white-space: nowrap;
    line-height: 1.4;
}
.pref-opt:hover {
    background: rgba(0,0,0,0.04);
    color: #555;
}
.pref-opt.active {
    background: var(--pref-color, #4a90e2);
    color: #fff;
    font-weight: 700;
}
.pref-opt.left.active {
    border-radius: 18px 0 0 18px;
}
.pref-opt.right.active {
    border-radius: 0 18px 18px 0;
}
.pref-sep {
    width: 1px;
    background: #e0e6ed;
    flex-shrink: 0;
    align-self: stretch;
}

/* JSON Viewer */
.json-viewer {
    background: #2d2d2d;
    color: #f1f1f1;
    padding: 15px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9em;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}
.json-viewer .key { color: #9cdcfe; }
.json-viewer .string { color: #ce9178; }
.json-viewer .number { color: #b5cea8; }
.json-viewer .boolean { color: #569cd6; }
.json-viewer .null { color: #569cd6; }

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}
.toast.show {
    opacity: 1;
}
