* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0a0a0a; --bg2: #1a1a1a; --bg3: #1e1e1e; --bg4: #2a2a2a;
  --border: #333; --text: #e0e0e0; --text2: #aaa; --text3: #666;
  --blue: #2563eb; --green: #059669; --red: #dc2626; --purple: #7c3aed;
  --tab-h: 56px; --safe-b: env(safe-area-inset-bottom, 0px);
}
body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif; background: var(--bg); color: var(--text); height: 100dvh; overflow: hidden; }

/* ---- Login ---- */
.login-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100dvh; gap: 16px; }
.login-container form { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.login-container input[type="password"] { padding: 14px 20px; border-radius: 12px; border: 1px solid #444; background: var(--bg4); color: white; font-size: 16px; width: 280px; text-align: center; outline: none; }
.login-container button { width: 280px; padding: 12px; border-radius: 24px; border: none; background: var(--blue); color: white; font-size: 16px; cursor: pointer; font-weight: 600; }

/* ---- Main Layout ---- */
#app { display: none; height: 100dvh; flex-direction: column; }
.tab-content { flex: 1; overflow: hidden; position: relative; }
.tab-page { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: none; flex-direction: column; overflow: hidden; }
.tab-page.active { display: flex; }

/* ---- Bottom Tab Bar ---- */
.tab-bar {
  display: flex; background: var(--bg2); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b); height: calc(var(--tab-h) + var(--safe-b));
  flex-shrink: 0; z-index: 100;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; cursor: pointer; color: var(--text3); font-size: 10px; transition: color 0.2s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.tab-item .tab-icon { font-size: 22px; line-height: 1; }
.tab-item.active { color: var(--blue); }
.tab-item.active .tab-icon { transform: scale(1.1); }

/* ---- Activity Bar ---- */
.activity-bar {
  background: linear-gradient(135deg, #0f172a, #1e1b4b); border-bottom: 1px solid #334155;
  padding: 6px 12px; display: flex; align-items: center; flex-shrink: 0; min-height: 28px;
}
.activity-bar .activity-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.activity-item {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; padding: 3px 10px 3px 7px; font-size: 11px; color: #e2e8f0; white-space: nowrap;
}
.activity-item .act-dot { width: 5px; height: 5px; border-radius: 50%; background: #22c55e; animation: pulse 1.5s ease-in-out infinite; flex-shrink: 0; }
.activity-item .act-label { font-weight: 600; color: #93c5fd; }
.activity-item .act-detail { color: #94a3b8; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.pending-info { font-size: 10px; color: #64748b; }
.pending-count { background: #1e293b; border: 1px solid #334155; padding: 1px 7px; border-radius: 10px; color: #94a3b8; font-size: 10px; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ---- Chat (Tab 1) ---- */
.chat-container { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.message { max-width: 85%; padding: 10px 14px; border-radius: 16px; line-height: 1.6; font-size: 15px; word-wrap: break-word; white-space: pre-wrap; position: relative; }
.user-msg { align-self: flex-end; background: var(--blue); color: white; border-bottom-right-radius: 4px; }
.bot-msg { align-self: flex-start; background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 4px; max-width: 95%; }
.bot-msg.markdown-body { white-space: normal; }
.bot-msg h1 { font-size: 18px; margin: 12px 0 6px; color: #60a5fa; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.bot-msg h2 { font-size: 16px; margin: 10px 0 5px; color: #60a5fa; }
.bot-msg h3 { font-size: 14px; margin: 8px 0 3px; color: #93c5fd; }
.bot-msg p { margin: 3px 0; } .bot-msg ul, .bot-msg ol { margin: 3px 0 3px 18px; } .bot-msg li { margin: 2px 0; }
.bot-msg strong { color: #fbbf24; }
.bot-msg code { background: var(--bg4); padding: 1px 4px; border-radius: 3px; font-size: 13px; }
.bot-msg pre { background: var(--bg2); padding: 8px; border-radius: 6px; overflow-x: auto; margin: 5px 0; }
.bot-msg pre code { background: none; padding: 0; }
.bot-msg img { max-width: 100%; height: auto; border-radius: 8px; margin: 4px 0; }
.bot-msg hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.msg-time { font-size: 11px; color: var(--text3); margin-top: 2px; }
.user-msg + .msg-time { align-self: flex-end; } .bot-msg + .msg-time { align-self: flex-start; }
.msg-quote-btn { display: none; }
.msg-ctx-menu { display: none; position: fixed; z-index: 2000; background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; padding: 4px 0; min-width: 120px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.msg-ctx-menu.show { display: block; }
.msg-ctx-menu .ctx-item { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 14px; color: var(--text); cursor: pointer; white-space: nowrap; }
.msg-ctx-menu .ctx-item:hover { background: rgba(255,255,255,0.06); }
.msg-ctx-menu .ctx-item.danger { color: var(--red); }
.msg-quote-block { border-left: 3px solid var(--green); background: rgba(5,150,105,0.12); padding: 4px 8px; border-radius: 0 6px 6px 0; margin-bottom: 5px; }
.msg-quote-block .msg-quote-text { color: #aaa; font-size: 12px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.quote-preview-bar { display: none; background: var(--bg3); border-top: 1px solid var(--bg4); padding: 6px 14px; align-items: center; gap: 8px; border-left: 3px solid var(--green); }
.quote-preview-bar.active { display: flex; }
.quote-preview-label { color: var(--green); font-size: 11px; font-weight: 600; }
.quote-preview-text { flex: 1; color: #888; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote-cancel-btn { background: none; border: none; color: #555; font-size: 18px; cursor: pointer; line-height: 1; }
.input-area { padding: 10px 14px; background: var(--bg2); border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; }
.input-area textarea { flex: 1; padding: 10px 14px; border-radius: 18px; border: 1px solid #444; background: var(--bg4); color: white; font-size: 15px; outline: none; resize: none; font-family: inherit; min-height: 40px; max-height: 120px; line-height: 1.4; overflow-y: auto; }
.input-area textarea:focus { border-color: var(--blue); }
.input-area button { padding: 10px 16px; border-radius: 22px; border: none; background: var(--blue); color: white; font-size: 15px; cursor: pointer; font-weight: 600; }
.input-area button:disabled { background: #444; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: #333; color: #aaa; font-size: 17px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; padding: 0; }
.icon-btn:hover { background: #444; color: white; }
.status { text-align: center; color: #888; font-size: 13px; padding: 6px; }
.status-polling { animation: pulse 1.5s ease-in-out infinite; }
.load-more { text-align: center; padding: 10px; color: var(--text3); font-size: 13px; cursor: pointer; display: none; }
.date-divider { text-align: center; color: #555; font-size: 12px; padding: 6px 0; position: relative; }
.date-divider::before, .date-divider::after { content: ''; position: absolute; top: 50%; width: 28%; height: 1px; background: var(--border); }
.date-divider::before { left: 6%; } .date-divider::after { right: 6%; }
.progress-bar { width: 100%; height: 3px; background: #333; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--blue); border-radius: 2px; transition: width 0.3s; }

/* ---- Scrollable Page ---- */
.page-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.page-header { padding: 16px 16px 8px; }
.page-header h2 { font-size: 20px; font-weight: 700; }

/* ---- Paper Tab (Tab 2) ---- */
.paper-stats { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.stat-pill { font-size: 12px; padding: 4px 12px; border-radius: 16px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); cursor: pointer; transition: all 0.2s; }
.stat-pill:hover, .stat-pill.active { background: rgba(99,102,241,0.25); border-color: rgba(99,102,241,0.4); }
.paper-search { width: 100%; padding: 8px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.05); color: var(--text); font-size: 14px; outline: none; margin-bottom: 12px; }
.paper-search:focus { border-color: rgba(99,102,241,0.4); }
.paper-search::placeholder { color: #555; }
.paper-card { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 14px; padding: 14px 16px; margin-bottom: 8px; }
.paper-card:hover { border-color: rgba(255,255,255,0.14); }
.paper-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.paper-card h3 { font-size: 15px; font-weight: 600; color: #f1f5f9; line-height: 1.35; flex: 1; }
.paper-card h3 a { color: inherit; text-decoration: none; }
.paper-card .abstract { font-size: 13px; color: #94a3b8; margin-top: 5px; line-height: 1.5; }
.paper-card .meta { font-size: 11px; color: #64748b; margin-top: 5px; }
.paper-card .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.paper-card .tag { font-size: 10px; padding: 2px 7px; border-radius: 8px; background: rgba(99,102,241,0.12); color: #a5b4fc; }
.paper-card .actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.paper-card .actions button, .paper-card .actions a { font-size: 11px; padding: 3px 10px; border-radius: 7px; border: 1px solid rgba(255,255,255,0.12); background: transparent; color: #94a3b8; cursor: pointer; text-decoration: none; transition: all 0.15s; }
.paper-card .actions button:hover, .paper-card .actions a:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.status-badge { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; cursor: pointer; flex-shrink: 0; }
.s-unread { background: #1e3a5f; color: #60a5fa; } .s-reading { background: #1a3a2a; color: #4ade80; }
.s-read { background: #1a2e1a; color: #86efac; } .s-archived { background: #2a2a2a; color: #a1a1aa; }

/* ---- Company Tab (Tab 3) ---- */
.report-card { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 14px; padding: 14px 16px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: border-color 0.15s; }
.report-card:hover { border-color: rgba(255,255,255,0.2); }
.report-icon { font-size: 28px; flex-shrink: 0; }
.report-info { flex: 1; }
.report-info h4 { font-size: 15px; color: #f1f5f9; margin-bottom: 2px; }
.report-info p { font-size: 12px; color: #64748b; }
.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.company-chip { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 10px 12px; text-align: center; }
.company-chip .name { font-size: 14px; font-weight: 600; color: #f1f5f9; }
.company-chip .name-en { font-size: 11px; color: #64748b; margin-top: 2px; }
.section-title { font-size: 14px; font-weight: 600; color: #94a3b8; margin: 16px 0 8px; display: flex; align-items: center; gap: 6px; }

/* ---- Ideas Tab (Tab 4) ---- */
.idea-card { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 14px; padding: 14px 16px; margin-bottom: 8px; }
.idea-card .idea-text { font-size: 15px; color: #f1f5f9; line-height: 1.5; }
.idea-card .idea-meta { font-size: 11px; color: #64748b; margin-top: 6px; }
.idea-card .idea-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.idea-card .idea-tag { font-size: 10px; padding: 2px 8px; border-radius: 8px; background: rgba(251,191,36,0.12); color: #fbbf24; }
.idea-card .idea-papers { margin-top: 8px; padding: 8px 10px; background: rgba(0,0,0,0.2); border-radius: 8px; }
.idea-card .idea-papers .paper-link { font-size: 12px; color: #93c5fd; display: block; margin: 3px 0; text-decoration: none; }
.idea-card .idea-papers .paper-link:hover { text-decoration: underline; }
.idea-input-area { display: flex; gap: 8px; padding: 12px 16px; background: var(--bg2); border-top: 1px solid var(--border); flex-shrink: 0; }
.idea-input-area textarea { flex: 1; padding: 10px 14px; border-radius: 12px; border: 1px solid #444; background: var(--bg4); color: white; font-size: 14px; resize: none; outline: none; font-family: inherit; min-height: 42px; max-height: 100px; }
.idea-input-area textarea:focus { border-color: var(--purple); }
.idea-input-area button { padding: 10px 16px; border-radius: 12px; border: none; background: var(--purple); color: white; font-size: 14px; cursor: pointer; font-weight: 600; align-self: flex-end; }

/* ---- Personal Tab (Tab 5) ---- */
.personal-section { margin-bottom: 20px; }
.personal-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.action-card { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 12px; padding: 14px 10px; text-align: center; cursor: pointer; transition: all 0.15s; }
.action-card:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); }
.action-card .ac-icon { font-size: 26px; margin-bottom: 4px; }
.action-card .ac-label { font-size: 12px; color: #94a3b8; }
.weight-chart { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 12px; padding: 14px; }
.weight-chart canvas { width: 100%; height: 150px; }
.weight-latest { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.weight-latest .big { font-size: 28px; font-weight: 700; color: #f1f5f9; }
.weight-latest .unit { font-size: 14px; color: #64748b; }
.weight-latest .trend { font-size: 13px; padding: 2px 8px; border-radius: 8px; }
.log-item { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; }
.log-item .log-date { font-size: 12px; color: #64748b; margin-bottom: 3px; }
.log-item .log-text { font-size: 13px; color: #cbd5e1; line-height: 1.5; }
.server-info { font-size: 13px; color: #94a3b8; line-height: 1.8; }

/* ---- Modals (shared) ---- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg3); border-radius: 12px; width: 92%; max-width: 500px; max-height: 85vh; display: flex; flex-direction: column; border: 1px solid var(--border); overflow: hidden; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { color: #fff; font-size: 16px; }
.modal-close { background: none; border: none; color: rgba(255,255,255,0.7); font-size: 22px; cursor: pointer; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.modal-hint { font-size: 13px; color: #999; line-height: 1.5; }
.modal-upload { border: 2px dashed #444; border-radius: 10px; padding: 20px; text-align: center; cursor: pointer; transition: all 0.2s; }
.modal-upload:hover { border-color: var(--green); background: rgba(5,150,105,0.05); }
.modal-upload .icon { font-size: 28px; margin-bottom: 6px; }
.modal-upload .label { color: #aaa; font-size: 13px; }
.modal-textarea { width: 100%; min-height: 70px; padding: 10px; border-radius: 8px; border: 1px solid #444; background: var(--bg4); color: white; font-size: 14px; resize: vertical; outline: none; font-family: inherit; }
.modal-textarea:focus { border-color: var(--green); }
.modal-textarea::placeholder { color: #555; }
.modal-submit { width: 100%; padding: 12px; border-radius: 10px; border: none; color: white; font-size: 15px; font-weight: 600; cursor: pointer; }
.modal-submit:disabled { background: #555 !important; cursor: not-allowed; }
.modal-divider { text-align: center; color: #555; font-size: 13px; position: relative; }
.modal-divider::before, .modal-divider::after { content: ''; position: absolute; top: 50%; width: 35%; height: 1px; background: var(--border); }
.modal-divider::before { left: 5%; } .modal-divider::after { right: 5%; }

/* Expense list */
.expense-list-nav { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; border-bottom: 1px solid var(--bg4); background: #242424; }
.expense-list-nav button { background: #333; border: none; color: #aaa; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 16px; }
.expense-list-nav button:hover { background: var(--green); color: white; }
.expense-list-nav .month-label { color: #eee; font-size: 15px; font-weight: 600; }
.expense-list-summary { padding: 8px 18px; background: #242424; border-bottom: 1px solid var(--bg4); color: #aaa; font-size: 13px; }
.expense-list-summary strong { color: #10b981; }
.expense-list-body { overflow-y: auto; flex: 1; }
.expense-item { display: flex; align-items: center; padding: 8px 18px; gap: 8px; border-bottom: 1px solid var(--bg4); }
.expense-item:hover { background: #252525; }
.expense-item-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.expense-item-info { flex: 1; min-width: 0; }
.expense-item-main { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.expense-item-desc { color: #ddd; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-item-amount { color: #10b981; font-size: 14px; font-weight: 600; white-space: nowrap; }
.expense-item-sub { color: #555; font-size: 11px; margin-top: 1px; }
.expense-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.expense-item-btn { background: #333; border: none; color: #aaa; padding: 3px 7px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.expense-item-btn:hover { background: var(--green); color: white; }
.expense-item-btn.del:hover { background: var(--red); }

/* Expense preview grid */
.expense-preview-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.expense-preview-item { position: relative; display: inline-block; }
.expense-preview-item img { max-width: 100px; max-height: 100px; border-radius: 8px; object-fit: cover; }
.expense-preview-item .remove-one { position: absolute; top: -5px; right: -5px; width: 18px; height: 18px; background: #e74c3c; color: white; border: none; border-radius: 50%; font-size: 11px; cursor: pointer; line-height: 18px; padding: 0; }

/* Edit expense fields */
.edit-field { display: flex; flex-direction: column; gap: 4px; }
.edit-field label { color: #999; font-size: 12px; }
.edit-field input, .edit-field select { background: var(--bg4); border: 1px solid #444; color: #eee; padding: 8px 10px; border-radius: 8px; font-size: 14px; outline: none; }
.edit-field input:focus, .edit-field select:focus { border-color: var(--green); }

/* Fitness preview */
.fitness-preview { display: none; text-align: center; }
.fitness-preview img { max-width: 100%; max-height: 180px; border-radius: 8px; margin-bottom: 6px; }
.remove-btn { background: #333; border: none; color: #aaa; padding: 3px 10px; border-radius: 10px; font-size: 11px; cursor: pointer; }
.remove-btn:hover { background: var(--green); color: white; }

/* Task modal */
.task-columns { display: flex; gap: 10px; padding: 14px; overflow-y: auto; flex: 1; min-height: 180px; }
.task-column { flex: 1; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.task-col-pending { background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.2); }
.task-col-success { background: rgba(22,163,74,0.08); border: 1px solid rgba(22,163,74,0.2); }
.task-col-failed { background: rgba(220,38,38,0.08); border: 1px solid rgba(220,38,38,0.2); }
.task-col-title { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.task-col-pending .task-col-title { color: #60a5fa; } .task-col-success .task-col-title { color: #4ade80; } .task-col-failed .task-col-title { color: #f87171; }
.task-card { background: rgba(255,255,255,0.04); border-radius: 6px; padding: 8px; font-size: 11px; color: #ccc; word-break: break-all; }
.task-card .task-prompt { font-size: 12px; color: #eee; margin-bottom: 3px; }
.task-card .task-time { font-size: 10px; color: #888; }
@media (max-width: 600px) { .task-columns { flex-direction: column; } }

/* ---- Note input in paper card ---- */
.note-input { display: none; margin-top: 6px; }
.note-input textarea { width: 100%; padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12); background: rgba(0,0,0,0.3); color: var(--text); font-size: 12px; resize: none; min-height: 50px; outline: none; font-family: inherit; }
.note-input .note-btns { display: flex; gap: 5px; margin-top: 4px; justify-content: flex-end; }
.note-input .note-btns button { font-size: 11px; padding: 3px 12px; border-radius: 7px; border: none; cursor: pointer; }
.btn-save { background: #6366f1; color: white; } .btn-cancel { background: rgba(255,255,255,0.08); color: #94a3b8; }

/* ---- Voice recording button ---- */
.icon-btn.recording { background: rgba(239, 68, 68, 0.3); animation: pulse 1s ease-in-out infinite; }

.empty-state { text-align: center; padding: 40px 20px; color: #555; }
.empty-state p { font-size: 13px; margin-top: 6px; }
