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

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f3f4f6; color: #1f2937; }

header { background: white; border-bottom: 1px solid #e5e7eb; padding: 12px 24px; position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; gap: 24px; }
header h1 { font-size: 18px; font-weight: 700; color: #4f46e5; flex-shrink: 0; }

.page-nav { display: flex; gap: 2px; }
.page-tab { background: none; border: none; padding: 6px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; color: #6b7280; cursor: pointer; transition: background 0.15s, color 0.15s; }
.page-tab:hover { background: #f3f4f6; color: #374151; }
.page-tab.active { background: #eef2ff; color: #4f46e5; }

.filters { background: white; border-bottom: 1px solid #e5e7eb; padding: 12px 24px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; color: #374151; background: white; }

.btn-primary { background: #4f46e5; color: white; border: none; padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; margin-left: auto; }
.btn-primary:hover { background: #4338ca; }

main { max-width: 900px; margin: 0 auto; padding: 20px 24px; }
.count { font-size: 12px; color: #9ca3af; margin-bottom: 12px; }

.card { background: white; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.card.expanded { border-color: #c7d2fe; }
.card-header { padding: 12px 16px; cursor: pointer; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card.expanded .card-header { background: #eef2ff; }
.card-header:hover { background: #f9fafb; }
.card.expanded .card-header:hover { background: #e0e7ff; }
.card-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }

.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.tag-company { background: #dbeafe; color: #1d4ed8; }
.tag-type { background: #f3e8ff; color: #7c3aed; }
.tag-analytical { background: #fef3c7; color: #92400e; }
.tag-date { color: #9ca3af; font-size: 11px; }
.tag-no-answer { background: #fef9c3; color: #a16207; }

.chevron { font-size: 14px; color: #9ca3af; flex-shrink: 0; margin-top: 2px; }
.card.expanded .chevron { color: #4f46e5; }

.card-body { display: none; padding: 16px; border-top: 1px solid #e0e7ff; background: #fafafa; }
.card.expanded .card-body { display: block; }

.answer-label { font-size: 11px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.answer-content { font-size: 13px; line-height: 1.7; color: #374151; }
.answer-content h1, .answer-content h2 { font-size: 15px; margin: 12px 0 6px; }
.answer-content h3 { font-size: 13px; margin: 10px 0 4px; }
.answer-content p { margin-bottom: 8px; }
.answer-content ul, .answer-content ol { padding-left: 20px; margin-bottom: 8px; }
.answer-content table { border-collapse: collapse; width: 100%; margin-bottom: 8px; font-size: 12px; }
.answer-content th, .answer-content td { border: 1px solid #e5e7eb; padding: 6px 10px; }
.answer-content th { background: #f9fafb; font-weight: 600; }
.answer-content strong { font-weight: 600; }
.answer-file-hint { font-size: 10px; color: #d1d5db; text-align: right; margin-top: 10px; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 10px; width: 520px; max-width: 95vw; padding: 24px; position: relative; }
.modal h2 { font-size: 16px; margin-bottom: 16px; }
.modal-close { position: absolute; top: 16px; right: 16px; background: none; border: none; font-size: 18px; cursor: pointer; color: #9ca3af; }

.tabs { display: flex; border-bottom: 2px solid #e5e7eb; margin-bottom: 16px; }
.tab { padding: 8px 20px; font-size: 13px; font-weight: 600; color: #9ca3af; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: #4f46e5; border-bottom-color: #4f46e5; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-full { grid-column: span 2; }
.form-group label { display: block; font-size: 11px; color: #6b7280; margin-bottom: 4px; }
.form-group input, .form-group textarea { width: 100%; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; font-family: inherit; }
.form-group textarea { font-family: monospace; resize: vertical; }
.form-hint { font-size: 11px; color: #9ca3af; margin-bottom: 6px; }
.form-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.form-footer span { font-size: 12px; color: #6b7280; }

/* ── Additional tab ── */
.additional-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.additional-label { font-size: 12px; font-weight: 600; color: #6b7280; flex-shrink: 0; }
.additional-bar select { padding: 7px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; color: #374151; background: white; min-width: 180px; cursor: pointer; }
.additional-bar select:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.additional-search { flex: 1; min-width: 200px; padding: 7px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; color: #374151; background: white; font-family: inherit; }
.additional-search:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.additional-meta { font-size: 12px; color: #9ca3af; margin-bottom: 14px; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }

.tile { background: white; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.tile:hover { border-color: #a5b4fc; box-shadow: 0 2px 8px rgba(79,70,229,0.1); }
.tile-heading { font-size: 13px; font-weight: 600; color: #1f2937; line-height: 1.4; margin-bottom: 6px; }
.tile-snippet { font-size: 12px; color: #6b7280; line-height: 1.5; margin-bottom: 8px; }
.tile-collection { font-size: 10px; font-weight: 700; color: #4f46e5; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.tile-filename { font-size: 10px; color: #d1d5db; font-family: monospace; margin-top: 6px; }
.search-empty { text-align: center; color: #9ca3af; font-size: 13px; padding: 48px 0; grid-column: 1/-1; }

/* ── Article reader ── */
.article-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; align-items: center; justify-content: center; padding: 24px; }
.article-overlay.open { display: flex; }
.article-panel { background: white; border-radius: 10px; width: 100%; max-width: 780px; max-height: 90vh; overflow-y: auto; padding: 32px 36px; position: relative; }
.article-close { position: sticky; top: 0; float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: #9ca3af; line-height: 1; padding: 2px 4px; margin: -4px -4px 12px 12px; }
.article-close:hover { color: #374151; }
.article-panel .answer-content h1 { font-size: 20px; font-weight: 700; color: #1f2937; margin-bottom: 6px; }
.article-panel .answer-content h2 { font-size: 16px; margin: 20px 0 8px; color: #374151; }
.article-panel .answer-content h3 { font-size: 14px; margin: 14px 0 6px; }
.article-panel .answer-content { font-size: 14px; line-height: 1.75; }
