*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans TC', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; overflow-x: hidden; }
a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
#app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
header { grid-column: 1/-1; display: flex; justify-content: space-between; align-items: center; padding: 0 24px; background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; backdrop-filter: blur(8px); }
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-brand .logo { font-size: 28px; }
.header-brand strong { font-size: 16px; color: var(--text); }
.header-brand small { font-size: 12px; color: var(--text2); }
.header-meta { display: flex; gap: 16px; font-size: 13px; color: var(--text2); align-items: center; }
.pulse { display: inline-block; width: 8px; height: 8px; background: var(--green); border-radius: 50%; margin-right: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* Sidebar */
.sidebar { background: var(--bg2); border-right: 1px solid var(--border); padding: 16px 0; overflow-y: auto; position: sticky; top: 56px; height: calc(100vh - 56px); display: flex; flex-direction: column; }
.nav-group { padding: 0 12px; margin-bottom: 8px; }
.nav-group-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; padding: 8px 12px 4px; }
.nav-item { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text2); font: inherit; font-size: 14px; padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent-light); font-weight: 600; }
.sidebar-footer { margin-top: auto; padding: 16px 24px; }
.version-stamp { color: var(--text3); font-size: 11px; }

/* Main */
.main { padding: 24px; overflow-y: auto; }
.tab-panel { display: none; animation: fadeIn .3s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Grid */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-sm { padding: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text2); margin-bottom: 12px; }
.metric-card { text-align: center; padding: 24px 16px; }
.metric-card .mc-value { font-size: 36px; font-weight: 700; line-height: 1.2; }
.metric-card .mc-label { font-size: 13px; color: var(--text2); margin-top: 4px; }
.metric-card .mc-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.mc-amber .mc-value { color: var(--accent); }
.mc-green .mc-value { color: var(--green); }
.mc-blue .mc-value { color: var(--blue); }
.mc-red .mc-value { color: var(--red); }
.mc-purple .mc-value { color: var(--purple); }
.mc-teal .mc-value { color: var(--teal); }

/* Section Title */
.section-title { font-size: 16px; font-weight: 600; margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.section-title:first-child { margin-top: 0; }

/* Badge */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.badge-green { background: rgba(34,197,94,.15); color: var(--green); }
.badge-yellow { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-red { background: rgba(239,68,68,.15); color: var(--red); }
.badge-blue { background: rgba(59,130,246,.15); color: var(--blue); }
.badge-purple { background: rgba(167,139,250,.15); color: var(--purple); }
.badge-orange { background: rgba(251,146,60,.15); color: var(--orange); }
.badge-teal { background: rgba(20,184,166,.15); color: var(--teal); }
.badge-gray { background: rgba(100,116,139,.2); color: var(--text2); }
.badge-accent { background: var(--accent-bg); color: var(--accent); }
.badge-dept-ad { background: rgba(59,130,246,.15); color: var(--dept-ad); }
.badge-dept-qd { background: rgba(34,197,94,.15); color: var(--dept-qd); }
.badge-dept-pd { background: rgba(251,146,60,.15); color: var(--dept-pd); }
.badge-dept-ld { background: rgba(167,139,250,.15); color: var(--dept-ld); }
.badge-dept-sd { background: rgba(20,184,166,.15); color: var(--dept-sd); }
.badge-level-1 { background: rgba(239,68,68,.15); color: var(--red); }
.badge-level-2 { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-level-3 { background: rgba(59,130,246,.15); color: var(--blue); }
.badge-level-4 { background: rgba(100,116,139,.2); color: var(--text2); }
.badge-risk-fatal { background: rgba(239,68,68,.2); color: var(--red); font-weight: 700; }
.badge-risk-high { background: rgba(251,146,60,.15); color: var(--orange); }
.badge-risk-medium { background: rgba(245,158,11,.15); color: var(--yellow); }

/* Progress Bar */
.progress-bar { background: var(--bg3); border-radius: 4px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.pf-green { background: var(--green); }
.pf-amber { background: var(--accent); }
.pf-red { background: var(--red); }
.pf-blue { background: var(--blue); }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--text2); padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); }
.table tr:hover td { background: rgba(255,255,255,.02); }

/* Filter Chips */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-chip { font-size: 12px; padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--text2); cursor: pointer; transition: var(--transition); }
.filter-chip:hover { border-color: var(--accent); color: var(--text); }
.filter-chip.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 12px 0 12px 16px; }
.timeline-item::before { content: ''; position: absolute; left: -20px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg2); }
.timeline-item .tl-date { font-size: 11px; color: var(--text3); }
.timeline-item .tl-title { font-weight: 500; margin: 2px 0; }
.timeline-item .tl-detail { font-size: 12px; color: var(--text2); }

/* Gantt */
.gantt { display: grid; gap: 8px; }
.gantt-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; padding: 8px 0; }
.gantt-label { font-size: 13px; font-weight: 500; }
.gantt-track { background: var(--bg3); border-radius: 4px; height: 28px; position: relative; }
.gantt-bar { position: absolute; height: 100%; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--bg); }

/* Checklist */
.checklist-section { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.checklist-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--bg2); cursor: pointer; user-select: none; }
.checklist-header:hover { background: var(--bg3); }
.checklist-header .ch-title { font-weight: 600; font-size: 14px; }
.checklist-header .ch-count { font-size: 12px; color: var(--text2); }
.checklist-header .ch-toggle { font-size: 12px; color: var(--text3); transition: transform .2s; }
.checklist-section.expanded .ch-toggle { transform: rotate(180deg); }
.checklist-body { display: none; }
.checklist-section.expanded .checklist-body { display: block; }

/* Document Viewer */
.doc-viewer { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; line-height: 1.8; }
.doc-viewer h1 { font-size: 22px; margin: 24px 0 12px; color: var(--accent-light); }
.doc-viewer h2 { font-size: 18px; margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.doc-viewer h3 { font-size: 15px; margin: 16px 0 8px; }
.doc-viewer table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.doc-viewer th, .doc-viewer td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.doc-viewer th { background: var(--bg2); font-weight: 600; color: var(--text2); }
.doc-viewer blockquote { border-left: 3px solid var(--accent); padding: 8px 16px; margin: 12px 0; color: var(--text2); background: var(--accent-bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.doc-viewer ul, .doc-viewer ol { padding-left: 24px; margin: 8px 0; }
.doc-viewer code { background: var(--bg3); padding: 2px 6px; border-radius: 3px; font-size: 12px; }
.doc-viewer pre { background: var(--bg3); padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; margin: 12px 0; }
.doc-viewer hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Action Items */
.action-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); margin-bottom: 8px; }
.action-item:hover { background: rgba(255,255,255,.02); }
.action-item .ai-priority { flex-shrink: 0; }
.action-item .ai-content { flex: 1; }
.action-item .ai-title { font-weight: 500; font-size: 14px; }
.action-item .ai-meta { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* Alert */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; }
.alert-danger { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-warn { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }
.alert-info { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }

/* Stat Row */
.stat-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.stat-row .sr-label { color: var(--text2); }
.stat-row .sr-value { font-weight: 600; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--bg3) 25%, var(--bg-hover) 50%, var(--bg3) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); height: 20px; margin: 8px 0; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Hamburger */
.hamburger { display: none; position: fixed; top: 12px; right: 16px; z-index: 200; background: var(--bg2); border: 1px solid var(--border); color: var(--text); font-size: 24px; width: 44px; height: 44px; border-radius: var(--radius-sm); cursor: pointer; }

/* Print */
@media print {
  .sidebar, .hamburger, .header-meta, .filter-bar { display: none !important; }
  #app { display: block; }
  .main { padding: 0; }
  .tab-panel { display: none !important; }
  .tab-panel.active { display: block !important; }
  body, .card, .doc-viewer { background: #fff; color: #000; }
  .doc-viewer th { background: #eee; }
}

/* Responsive */
@media (max-width: 1024px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  #app { grid-template-columns: 1fr; }
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .sidebar { position: fixed; left: -260px; top: 56px; width: 250px; height: calc(100vh - 56px); z-index: 150; transition: left .3s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .header-meta { display: none; }
}
@media (max-width: 480px) {
  .g4 { grid-template-columns: 1fr; }
  .metric-card .mc-value { font-size: 28px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* Btn */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; transition: var(--transition); }
.btn:hover { background: var(--bg3); border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-light); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Select */
.select { padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.select:focus { outline: none; border-color: var(--accent); }

/* Search */
.search-input { padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 13px; width: 200px; }
.search-input:focus { outline: none; border-color: var(--accent); }
.search-input::placeholder { color: var(--text3); }

/* Doc Meta */
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.doc-meta .dm-item { font-size: 13px; }
.doc-meta .dm-label { color: var(--text3); font-size: 11px; }
.doc-meta .dm-value { font-weight: 500; margin-top: 2px; }

/* Utils */
.mt-0 { margin-top: 0; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
