* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    min-height: 100vh; color: #e0e0e0;
}
.app-container { max-width: 1400px; margin: 0 auto; padding: 12px; min-height: 100vh; }
.app-header { text-align: center; padding: 10px 0; margin-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo { font-size: 1.5rem; font-weight: 700; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.subtitle { font-size: 0.8rem; color: #888; margin-top: 4px; }
.main-content { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; height: calc(100vh - 85px); min-height: 520px; }
.chat-panel, .doc-panel {
    background: rgba(255,255,255,0.035);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.07);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.panel-header {
    padding: 10px 16px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0;
}
.panel-icon { font-size: 1.1rem; }
.panel-header h3 { font-size: 0.9rem; font-weight: 600; color: #fff; }

/* Chat */
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.message { display: flex; gap: 8px; max-width: 95%; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.bot-message { align-self: flex-start; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }
.message-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255,255,255,0.08);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; flex-shrink: 0;
}
.message-content {
    background: rgba(255,255,255,0.06);
    padding: 8px 12px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.04);
    color: #e0e0e0; font-size: 0.82rem; line-height: 1.4;
}
.user-message .message-content { background: rgba(79, 172, 254, 0.15); border-color: rgba(79, 172, 254, 0.2); }
.message-content p { margin-bottom: 5px; }
.message-content p:last-child { margin-bottom: 0; }
.chat-input-area {
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex; gap: 6px;
    flex-shrink: 0;
}
#chatInput {
    flex: 1; padding: 8px 14px; border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05); color: #fff;
    font-size: 0.82rem; outline: none;
}
#chatInput::placeholder { color: #666; }
#sendBtn {
    width: 34px; height: 34px; border-radius: 50%; border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff; font-size: 0.9rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* History */
.history-section {
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    max-height: 180px;
}
.history-header {
    padding: 8px 14px;
    background: rgba(255,255,255,0.03);
    cursor: pointer;
    display: flex; justify-content: space-between;
    align-items: center; font-size: 0.82rem; color: #aaa;
    transition: background 0.2s;
}
.history-header:hover { background: rgba(255,255,255,0.06); }
.history-list {
    max-height: 140px;
    overflow-y: auto;
    padding: 4px 0;
}
.history-item {
    padding: 6px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
    transition: background 0.15s;
}
.history-item:hover { background: rgba(255,255,255,0.05); }
.history-item-name { color: #ccc; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item-date { color: #666; font-size: 0.7rem; margin-left: 8px; }
.history-item-type { font-size: 0.65rem; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.history-item-type.docx { background: rgba(40,167,69,0.15); color: #28a745; }
.history-item-type.pdf { background: rgba(220,53,69,0.15); color: #dc3545; }
.history-empty { padding: 10px 14px; font-size: 0.75rem; color: #555; text-align: center; }

/* Doc Panel */
.doc-panel { padding-bottom: 10px; overflow-y: auto; }

/* Steps */
.step-section {
    display: flex; gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    align-items: flex-start;
}
.step-badge {
    width: 24px; height: 24px; border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff; font-size: 0.75rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 2px;
}
.step-content { flex: 1; }
.step-content h4 { font-size: 0.8rem; color: #fff; margin-bottom: 6px; font-weight: 600; }

/* Upload zones */
.upload-zone {
    border: 2px dashed rgba(255,255,255,0.12);
    border-radius: 8px; padding: 20px 12px; text-align: center;
    cursor: pointer; transition: all 0.3s;
    background: rgba(255,255,255,0.02);
}
.upload-zone:hover { border-color: rgba(79, 172, 254, 0.4); background: rgba(79, 172, 254, 0.04); }
.upload-zone.dragover { border-color: #4facfe; background: rgba(79, 172, 254, 0.08); }
.upload-zone.small { padding: 10px 8px; display: flex; align-items: center; gap: 8px; text-align: left; }
.upload-icon { font-size: 2rem; margin-bottom: 6px; }
.upload-icon-small { font-size: 1.3rem; }
.upload-text { font-size: 0.85rem; color: #ccc; }
.upload-text-small { font-size: 0.78rem; color: #aaa; }
.upload-hint { font-size: 0.7rem; color: #555; }

/* Template help */
.template-help {
    margin-top: 6px;
    font-size: 0.7rem;
    color: #777;
    line-height: 1.5;
}
.template-help code {
    background: rgba(255,255,255,0.06);
    padding: 1px 5px;
    border-radius: 4px;
    color: #4facfe;
    font-family: monospace;
}
.template-help a {
    color: #20c997;
    text-decoration: none;
    margin-left: 6px;
}
.template-help a:hover { text-decoration: underline; }

/* OCR bar */
.ocr-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    flex-wrap: wrap;
}
.toggle-label {
    display: flex; align-items: center; gap: 6px;
    cursor: pointer; font-size: 0.78rem; color: #aaa;
}
.toggle-label input { display: none; }
.toggle-slider {
    width: 30px; height: 17px; background: rgba(255,255,255,0.12);
    border-radius: 9px; position: relative; transition: 0.3s;
}
.toggle-slider::after {
    content: ''; position: absolute; width: 13px; height: 13px;
    background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: 0.3s;
}
.toggle-label input:checked + .toggle-slider { background: #28a745; }
.toggle-label input:checked + .toggle-slider::after { left: 15px; }
.ocr-bar select {
    background: rgba(255,255,255,0.06); color: #aaa; border: 1px solid rgba(255,255,255,0.1);
    border-radius: 5px; padding: 3px 6px; font-size: 0.72rem;
}
.ocr-status-inline { font-size: 0.7rem; color: #28a745; }
.ocr-status-inline.loading { color: #ffc107; }

/* Status */
.status-section { padding: 0 14px; margin: 6px 0; }
.status-badge {
    display: inline-block; padding: 5px 12px; border-radius: 14px;
    font-size: 0.75rem;
}
.status-badge.success { background: rgba(40,167,69,0.1); color: #28a745; border: 1px solid rgba(40,167,69,0.2); }
.status-badge.error { background: rgba(220,53,69,0.1); color: #dc3545; border: 1px solid rgba(220,53,69,0.2); }
.status-badge.warning { background: rgba(255,193,7,0.1); color: #ffc107; border: 1px solid rgba(255,193,7,0.2); }

/* Data Preview */
.data-preview { padding: 0 14px; margin-bottom: 8px; }
.data-preview h4 { font-size: 0.8rem; color: #fff; margin-bottom: 8px; font-weight: 600; }
.data-grid { display: grid; grid-template-columns: 1fr; gap: 5px; }
.data-item {
    display: grid; grid-template-columns: 1fr 1fr;
    padding: 6px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 5px; border: 1px solid rgba(255,255,255,0.03);
}
.data-item .label { font-size: 0.68rem; color: #666; text-transform: uppercase; }
.data-item .value { font-size: 0.78rem; color: #ddd; font-weight: 500; text-align: right; }

/* Template Preview */
.template-preview { padding: 0 14px; margin-bottom: 8px; }
.template-preview h4 { font-size: 0.8rem; color: #fff; margin-bottom: 8px; font-weight: 600; }
.template-info {
    padding: 8px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.05);
    font-size: 0.75rem;
    color: #aaa;
}

/* Templates Section */
.templates-section { padding: 0 14px; margin-bottom: 10px; }
.templates-section h4 { font-size: 0.8rem; color: #fff; margin-bottom: 8px; font-weight: 600; }
.template-buttons { display: flex; flex-direction: column; gap: 6px; }
.template-btn {
    display: grid; grid-template-columns: auto 1fr auto;
    align-items: center; gap: 8px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px; cursor: pointer;
    transition: all 0.2s; text-align: left;
    color: #e0e0e0;
}
.template-btn:hover {
    background: rgba(79, 172, 254, 0.08);
    border-color: rgba(79, 172, 254, 0.25);
    transform: translateX(3px);
}
.template-icon { font-size: 1.2rem; }
.template-name { font-size: 0.8rem; font-weight: 600; }
.template-format { font-size: 0.68rem; color: #777; background: rgba(255,255,255,0.05); padding: 2px 7px; border-radius: 8px; }

/* Download */
.download-section { padding: 0 14px; margin-bottom: 10px; }
.download-section h4 { font-size: 0.8rem; color: #fff; margin-bottom: 8px; font-weight: 600; }
.download-btn {
    display: block; width: 100%; padding: 10px 14px;
    border-radius: 8px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff; text-align: center; text-decoration: none;
    font-weight: 600; font-size: 0.85rem; transition: all 0.2s;
}
.download-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 12px rgba(40,167,69,0.3); }

/* Actions */
.action-section { padding: 0 14px; margin-bottom: 8px; }
.action-btn {
    width: 100%; padding: 8px 12px; border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    color: #999; font-size: 0.78rem; cursor: pointer;
    transition: all 0.2s;
}
.action-btn:hover { background: rgba(255,255,255,0.08); }

/* Mapping */
.mapping-info { padding: 0 14px; margin-top: 6px; }
.mapping-info h4 { font-size: 0.8rem; color: #fff; margin-bottom: 8px; font-weight: 600; }
.mapping-table {
    background: rgba(255,255,255,0.015);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.04);
    overflow: hidden;
}
.mapping-row {
    display: grid; grid-template-columns: 1fr auto 1fr;
    gap: 6px; padding: 6px 10px;
    font-size: 0.68rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    align-items: center;
}
.mapping-row:last-child { border-bottom: none; }
.mapping-row.header { background: rgba(255,255,255,0.03); font-weight: 600; color: #777; }
.mapping-row span:first-child { color: #4facfe; text-align: left; }
.mapping-row span:nth-child(2) { color: #555; font-weight: 600; }
.mapping-row span:last-child { color: #20c997; text-align: right; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Responsive */
@media (max-width: 900px) {
    .main-content { grid-template-columns: 1fr; height: auto; }
    .chat-panel, .doc-panel { min-height: 400px; }
}
