﻿* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", "Noto Sans TC", sans-serif; background: #f0f2f5; color: #1a1a2e; line-height: 1.5; }
button, input, select, textarea { font: inherit; }

/* Sidebar */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 200px; background: #0f2537; color: #fff; z-index: 1000; display: flex; flex-direction: column; }
.sidebar-brand { padding: 20px 16px 4px; text-align: center; }
.sidebar-logo { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.sidebar-sub { font-size: 9px; color: rgba(255,255,255,0.2); text-align: center; padding: 0 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); letter-spacing: 1px; }
.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: rgba(255,255,255,0.5); font-size: 14px; cursor: pointer; text-decoration: none; transition: all 0.15s; border-left: 3px solid transparent; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.04); }
.nav-item.active { color: #fff; background: rgba(255,255,255,0.06); border-left-color: #4a9eff; }
.nav-icon { width: 20px; text-align: center; font-size: 15px; }
.sidebar-footer { padding: 12px 16px; font-size: 10px; color: rgba(255,255,255,0.15); text-align: center; border-top: 1px solid rgba(255,255,255,0.06); }

/* Main */
.main-wrapper { margin-left: 200px; min-height: 100vh; }
.top-bar { height: 52px; background: #fff; border-bottom: 1px solid #e4e7ec; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 999; }
.top-bar-title { font-size: 16px; font-weight: 600; color: #1a1a2e; }
.top-bar-user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #566074; }
.top-link { color: #1565C0; text-decoration: none; font-weight: 500; }
.top-link:hover { text-decoration: underline; }
.top-link.danger { color: #c62828; }
.flash { max-width: 1200px; margin: 12px auto 0; }
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; border-radius: 6px; padding: 10px 16px; margin-bottom: 12px; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; border-radius: 6px; padding: 10px 16px; margin-bottom: 12px; }

.main-content { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Common */
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.page-title small { font-size: 13px; font-weight: 400; color: #888; }
.card { background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); padding: 20px; margin-bottom: 20px; }
.section { margin-bottom: 24px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-title { font-size: 16px; font-weight: 600; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); padding: 20px; text-align: center; }
.stat-card .num { font-size: 32px; font-weight: 700; }
.stat-card .lbl { font-size: 13px; color: #888; margin-top: 4px; }
.c-info .num { color: #2196F3; }
.c-ok .num { color: #4CAF50; }
.c-warn .num { color: #FF9800; }
.c-danger .num { color: #f44336; }

/* Tabs */
.tab-bar { display: flex; border-bottom: 1px solid #e4e7ec; margin-bottom: 20px; gap: 0; }
.tab-btn { padding: 10px 20px; color: #888; cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent; transition: all 0.15s; background: none; border-top: none; border-left: none; border-right: none; }
.tab-btn:hover { color: #1565C0; }
.tab-btn.active { color: #1565C0; border-bottom-color: #1565C0; font-weight: 500; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; font-weight: 600; color: #666; border-bottom: 2px solid #e4e7ec; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
.data-table tr:hover td { background: #f8f9fb; }
.project-link { color: #1565C0; text-decoration: none; font-weight: 500; }
.project-link:hover { text-decoration: underline; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.b-active { background: #fff3e0; color: #e65100; }
.b-finished { background: #e8f5e9; color: #2e7d32; }
.b-overdue { background: #fbe9e7; color: #c62828; }
.b-upcoming { background: #fff3e0; color: #e65100; }
.b-done { background: #e8eaf6; color: #283593; }
.b-received { background: #e8f5e9; color: #1b5e20; }
.b-pending { background: #fff3e0; color: #e65100; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; border: none; cursor: pointer; text-decoration: none; transition: all 0.2s; }
.btn-primary { background: #1565C0; color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 12px; border-radius: 4px; border: 1px solid #ddd; background: #fff; cursor: pointer; }
.btn-primary.btn-sm,
.btn-sm.btn-primary {
    background: #1565C0;
    border-color: #1565C0;
    color: #fff;
}
.btn-sm:hover { background: #f5f5f5; }
.btn-primary.btn-sm:hover,
.btn-sm.btn-primary:hover {
    background: #0f5fa8;
    border-color: #0f5fa8;
    color: #fff;
}

/* Stages */
.stage-list { list-style: none; }
.stage-item { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0f0f0; gap: 12px; }
.stage-item:last-child { border-bottom: none; }
.stage-num { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.s-active { background: #e3f2fd; color: #1565C0; }
.s-done { background: #e8f5e9; color: #2e7d32; }
.s-pending { background: #f5f5f5; color: #999; }
.stage-info { flex: 1; }
.stage-trigger { font-size: 13px; }
.stage-pct { font-size: 14px; font-weight: 600; text-align: right; white-space: nowrap; }

/* Progress bar */
.progress-bar { height: 8px; background: #e0e0e0; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.p-received { background: #4CAF50; }
.p-partial { background: #FF9800; }

/* Detail meta */
.detail-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 13px; color: #555; margin-bottom: 20px; }

/* Reminder items */
.reminder-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.reminder-item:last-child { border-bottom: none; }
.reminder-info { flex: 1; }
.reminder-info .desc { font-size: 14px; margin: 2px 0; }
.reminder-info .meta { font-size: 12px; color: #888; }
.reminder-action { flex-shrink: 0; }

/* Chat */
.chat-container { display: grid; grid-template-columns: 260px 1fr; gap: 20px; min-height: 500px; }
.chat-sidebar { background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); padding: 16px; }
.chat-sidebar h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; margin-top: 16px; }
.chat-sidebar h3:first-child { margin-top: 0; }
.chat-main { display: flex; flex-direction: column; background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.chat-msgs { flex: 1; padding: 20px; overflow-y: auto; max-height: 500px; }
.chat-input-area { display: flex; padding: 12px 16px; border-top: 1px solid #e4e7ec; gap: 8px; }
.chat-input { flex: 1; padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.msg { margin-bottom: 16px; max-width: 80%; }
.msg.me { margin-left: auto; }
.msg.ai { margin-right: auto; }
.msg-bubble { padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.6; }
.msg.me .msg-bubble { background: #1565C0; color: #fff; border-radius: 8px 8px 0 8px; }
.msg.ai .msg-bubble { background: #f0f2f5; border-radius: 8px 8px 8px 0; }

/* Form */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #555; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.form-group input:focus { outline: none; border-color: #1565C0; }
.form-group .help { font-size: 12px; color: #888; margin-top: 4px; }
.form-group textarea { min-height: 100px; resize: vertical; }

/* Messages */
.message-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.message-form { margin-bottom: 20px; }
.message-list { display: grid; gap: 12px; margin-top: 18px; }
.message-item { border: 1px solid #e4e7ec; border-radius: 6px; padding: 14px; background: #fff; }
.message-item.is-unread { border-color: #1565C0; background: #f7fbff; }
.message-head { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: #667085; margin-bottom: 8px; }
.message-subject { font-weight: 600; margin-bottom: 6px; }
.message-body { font-size: 13px; color: #344054; white-space: pre-wrap; }

/* Evidence center */
.evidence-grid,
.evidence-detail-grid { grid-template-columns: 1.1fr 0.9fr; }
.evidence-shell { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr); gap: 20px; align-items: start; }
.evidence-main,
.evidence-ai-panel { margin-bottom: 0; }
.evidence-record-list { display: grid; gap: 12px; }
.evidence-record-card { border: 1px solid #e4e7ec; border-radius: 8px; padding: 14px; background: #fff; }
.evidence-record-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.evidence-record-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; font-size: 12px; color: #667085; }
.evidence-record-actions { margin-top: 8px; }
.evidence-chat-box { min-height: 480px; }
.evidence-chat-box .chat-msgs { max-height: 420px; min-height: 420px; }
.evidence-filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.evidence-filter-row input[type="text"],
.evidence-filter-row input[type="date"] { width: 150px; padding: 8px 10px; border: 1px solid #d0d5dd; border-radius: 6px; }
.evidence-inline-check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: #475467; }
.evidence-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.evidence-media-grid.compact { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.evidence-media-card { display: block; text-decoration: none; color: inherit; border: 1px solid #e4e7ec; border-radius: 8px; overflow: hidden; background: #fff; }
.evidence-media-thumb { aspect-ratio: 1 / 1; background: #f2f4f7; }
.evidence-media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.evidence-media-thumb.compact { aspect-ratio: 1 / 1; }
.evidence-media-meta { display: grid; gap: 4px; padding: 10px; font-size: 12px; color: #667085; }
.evidence-media-meta strong { color: #1d2939; font-size: 13px; }
.evidence-sync-card .detail-meta { margin-bottom: 0; }
.evidence-timeline { display: grid; gap: 14px; }
.evidence-timeline-item { border: 1px solid #e4e7ec; border-radius: 8px; padding: 14px; background: #fff; }
.evidence-timeline-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 12px; color: #667085; margin-bottom: 8px; }
.evidence-inline-media { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.evidence-inline-media-item { width: 88px; height: 88px; border-radius: 8px; overflow: hidden; border: 1px solid #e4e7ec; background: #f8fafc; }
.evidence-inline-media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.evidence-recall-form { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.evidence-recall-form select { width: 120px; padding: 6px 8px; border: 1px solid #d0d5dd; border-radius: 6px; }
.evidence-side-section + .evidence-side-section { margin-top: 18px; }

/* Info */
.info-box { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.info-warn { background: #fff3e0; border: 1px solid #ffe0b2; color: #e65100; }
.info-ok { background: #e8f5e9; border: 1px solid #c8e6c9; color: #2e7d32; }
.info-blue { background: #e3f2fd; border: 1px solid #bbdefb; color: #1565C0; }

.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px; background: linear-gradient(135deg, #0f2537 0%, #173b57 100%); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 10px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18); padding: 28px; }
.auth-logo { width: 180px; display: block; margin: 0 auto 18px; }
.auth-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 8px; color: #1a1a2e; }
.auth-subtitle { font-size: 13px; color: #667085; text-align: center; margin-bottom: 24px; }
.auth-note { font-size: 12px; color: #667085; text-align: center; margin-top: 16px; }

.admin-grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.password-box { margin-bottom: 16px; font-size: 13px; }
.muted { color: #667085; font-size: 12px; }
.permission-list { display: grid; gap: 8px; margin-top: 8px; }
.permission-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #344054; }
.permission-item input { width: auto; margin: 0; }
.permission-inline { margin-top: 10px; padding-top: 10px; border-top: 1px solid #eef2f7; }
.permission-editor { min-width: 220px; }
.permission-save { margin-top: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.edit-btn { float: right; font-size: 12px; padding: 4px 12px; border: 1px solid #ddd; border-radius: 4px; background: #fff; cursor: pointer; }
.edit-btn:hover { background: #f5f5f5; }
.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45); z-index: 2000; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-box { background: #fff; border-radius: 8px; width: 100%; max-width: 600px; max-height: 85vh; overflow-y: auto; padding: 28px; box-shadow: 0 12px 40px rgba(0,0,0,0.2); }
.modal-box h3 { font-size: 17px; margin-bottom: 16px; }
.modal-close { float: right; border: none; background: none; font-size: 24px; line-height: 1; color: #667085; cursor: pointer; }
.modal-close:hover { color: #1d2939; }
