*, *::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); }

/* 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); }

/* 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 { background: #fff; color: #000; }
}

/* 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); }

/* 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; }

/* ========================================
   SCIS-Specific Components
   ======================================== */

/* SCIS: Score Gauge */
.score-gauge { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; font-size: 16px; font-weight: 700; border: 3px solid; }
.score-hot { border-color: var(--score-hot); color: var(--score-hot); }
.score-warm { border-color: var(--score-warm); color: var(--score-warm); }
.score-cool { border-color: var(--score-cool); color: var(--score-cool); }
.score-cold { border-color: var(--score-cold); color: var(--score-cold); }

/* SCIS: Tier Badge */
.tier-hot { background: rgba(239,68,68,.15); color: var(--score-hot); font-weight: 700; }
.tier-warm { background: rgba(245,158,11,.15); color: var(--score-warm); }
.tier-cool { background: rgba(59,130,246,.15); color: var(--score-cool); }
.tier-cold { background: rgba(100,116,139,.2); color: var(--score-cold); }

/* SCIS: Trend Arrow */
.trend-up { color: var(--trend-up); }
.trend-down { color: var(--trend-down); }
.trend-flat { color: var(--trend-flat); }
.trend-arrow { font-size: 14px; font-weight: 600; }

/* SCIS: Factor Bar */
.factor-bars { display: flex; flex-direction: column; gap: 4px; }
.factor-row { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.factor-label { width: 60px; color: var(--text3); text-align: right; flex-shrink: 0; }
.factor-track { flex: 1; background: var(--bg3); height: 6px; border-radius: 3px; overflow: hidden; }
.factor-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }
.factor-value { width: 28px; text-align: right; font-weight: 600; font-size: 11px; }

/* SCIS: Import Zone */
.import-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px; text-align: center; cursor: pointer; transition: var(--transition); }
.import-zone:hover, .import-zone.dragover { border-color: var(--accent); background: var(--accent-bg); }
.import-zone .iz-icon { font-size: 48px; margin-bottom: 12px; }
.import-zone .iz-text { font-size: 14px; color: var(--text2); }
.import-zone .iz-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* SCIS: Recommendation Card */
.rec-card { display: flex; gap: 12px; padding: 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 8px; transition: var(--transition); }
.rec-card:hover { background: rgba(255,255,255,.02); }
.rec-priority { flex-shrink: 0; width: 4px; border-radius: 2px; }
.rec-priority-urgent { background: var(--red); }
.rec-priority-high { background: var(--orange); }
.rec-priority-medium { background: var(--yellow); }
.rec-priority-low { background: var(--text3); }
.rec-body { flex: 1; }
.rec-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.rec-reason { font-size: 12px; color: var(--text2); }
.rec-product { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* SCIS: Heatmap */
.heatmap { display: grid; gap: 2px; }
.heatmap-cell { width: 100%; aspect-ratio: 1; border-radius: 2px; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; }

/* SCIS: Sparkline */
.sparkline { display: inline-flex; align-items: flex-end; gap: 1px; height: 24px; }
.sparkline-bar { background: var(--accent); border-radius: 1px 1px 0 0; min-width: 3px; transition: height .3s ease; }

/* SCIS: Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 500; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* SCIS: Tab sub-navigation */
.sub-nav { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.sub-nav .btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* SCIS: Data freshness */
.freshness { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.freshness-ok { background: rgba(34,197,94,.1); color: var(--green); }
.freshness-stale { background: rgba(245,158,11,.1); color: var(--yellow); }
.freshness-old { background: rgba(239,68,68,.1); color: var(--red); }

/* SCIS: Input */
.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; }
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--text3); }

/* SCIS: Form Group */
.form-group { margin-bottom: 12px; }
.form-label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; font-weight: 500; }

/* Loading spinner */
#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg); z-index: 1000; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading p { color: var(--text2); font-size: 14px; }
