/* MarketPulse V4.0.1 Trusted Intelligence Edition — Self-Contained Compiled Stylesheet (Zero External CSS/Tailwind CDN) */
:root {
  color-scheme: dark;
  --bg-body: #070d19;
  --bg-header: rgba(2, 6, 23, 0.96);
  --bg-panel: rgba(15, 23, 42, 0.92);
  --bg-subtle: rgba(15, 23, 42, 0.65);
  --border-main: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --sky: #38bdf8;
  --emerald: #34d399;
  --rose: #fb7185;
  --amber: #fbbf24;
  --indigo: #818cf8;
  --purple: #c084fc;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: transparent; }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: rgba(30, 41, 59, 0.8); padding: 0.1rem 0.35rem; border-radius: 0.25rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.hidden { display: none !important; }
.block { display: block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.shrink-0 { flex-shrink: 0; }
.min-w-0 { min-width: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.num-mono { font-variant-numeric: tabular-nums; }
.w-full { width: 100%; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.inset-0 { inset: 0; }
.inset-x-0 { left: 0; right: 0; }
.top-0 { top: 0; }
.bottom-0 { bottom: 0; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }
.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.pointer-events-none { pointer-events: none; }

/* Spacing */
.container { width: 100%; max-width: 80rem; margin: 0 auto; padding: 0 0.75rem; }
.main-wrap { width: 100%; max-width: 80rem; margin: 0 auto; padding: 1rem 0.75rem 5.5rem; }
.gap-1 { gap: 0.25rem; }
.gap-1-5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-5 > * + * { margin-top: 1.25rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-1-5 { margin-top: 0.375rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.p-2 { padding: 0.5rem; }
.p-2-5 { padding: 0.625rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-1-5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-3 { padding-top: 0.75rem; }
.pt-4 { padding-top: 1rem; }
.pb-3 { padding-bottom: 0.75rem; }

/* Grid Columns */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* Typography */
.text-10 { font-size: 0.625rem; }
.text-11 { font-size: 0.6875rem; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Colors */
.text-white { color: #ffffff; }
.text-slate-200 { color: #e2e8f0; }
.text-slate-300 { color: #cbd5e1; }
.text-slate-400 { color: var(--text-muted); }
.text-slate-500 { color: var(--text-dim); }
.text-sky-300 { color: #7dd3fc; }
.text-sky-400 { color: var(--sky); }
.text-emerald-300 { color: #6ee7b7; }
.text-emerald-400 { color: var(--emerald); }
.text-rose-300 { color: #fda4af; }
.text-rose-400 { color: var(--rose); }
.text-amber-200 { color: #fde68a; }
.text-amber-300 { color: #fcd34d; }
.text-amber-400 { color: var(--amber); }

/* Surfaces */
.app-header {
  border-bottom: 1px solid rgba(30, 41, 59, 0.9);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
}
.brand-badge {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.6rem;
  background: linear-gradient(135deg, #0ea5e9, #4f46e5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.panel {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.95) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-main);
  border-radius: 0.875rem;
  box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.55);
}
.panel-subtle {
  background: var(--bg-subtle);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 0.75rem;
}
.demo-banner {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde68a;
  border-radius: 0.75rem;
  padding: 0.65rem 1rem;
}
.border-t { border-top: 1px solid rgba(30, 41, 59, 0.9); }
.border-b { border-bottom: 1px solid rgba(30, 41, 59, 0.9); }
.border-l-emerald { border-left: 3px solid rgba(52, 211, 153, 0.8); }
.border-l-amber { border-left: 3px solid rgba(251, 191, 36, 0.8); }
.border-sky { border-color: rgba(56, 189, 248, 0.35); }
.border-amber { border-color: rgba(245, 158, 11, 0.35); }

/* Controls */
.btn-primary {
  background: #38bdf8;
  color: #020617;
  font-weight: 600;
  border-radius: 0.5rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.75rem;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: #7dd3fc; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid rgba(71, 85, 105, 0.8);
  border-radius: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-secondary:hover { border-color: #38bdf8; color: #7dd3fc; }

.btn-demo {
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.input-field {
  width: 100%;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.75rem;
  color: #f8fafc;
}
.input-field:focus { outline: none; border-color: #38bdf8; }

.select-inline {
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-size: 0.75rem;
}
.select-inline option { background: #0f172a; color: #e2e8f0; }

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  padding: 0.12rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 600;
}
.badge-pill { border-radius: 9999px; padding: 0.2rem 0.65rem; font-size: 0.75rem; }
.badge-live { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.4); color: #6ee7b7; }
.badge-delayed { background: rgba(14, 165, 233, 0.15); border-color: rgba(14, 165, 233, 0.4); color: #7dd3fc; }
.badge-eod { background: rgba(99, 102, 241, 0.15); border-color: rgba(99, 102, 241, 0.4); color: #a5b4fc; }
.badge-stale { background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.4); color: #fcd34d; }
.badge-manual { background: rgba(168, 85, 247, 0.15); border-color: rgba(168, 85, 247, 0.4); color: #d8b4fe; }
.badge-demo { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.45); color: #fde68a; }
.badge-missing { background: rgba(30, 41, 59, 0.9); border-color: #334155; color: #94a3b8; }
.badge-rose { background: rgba(244, 63, 94, 0.15); border-color: rgba(244, 63, 94, 0.4); color: #fda4af; }

/* Tabs */
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 0.5rem;
  border: 1px solid #1e293b;
  background: rgba(15, 23, 42, 0.75);
  color: #cbd5e1;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.15s ease;
}
.tab-btn.active {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.45);
}

.mobile-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: rgba(2, 6, 23, 0.96);
  border-top: 1px solid rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(12px);
  padding-bottom: max(0.45rem, env(safe-area-inset-bottom));
}
.mobile-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 48px;
  font-size: 0.625rem;
  color: #94a3b8;
  border: none;
  background: transparent;
  padding: 0.25rem 0;
}
.mobile-tab-btn.active { color: #38bdf8; background: transparent; border: none; }

/* Progress Bars */
.bar-track { width: 100%; height: 0.375rem; border-radius: 9999px; background: #1e293b; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 9999px; transition: width 0.3s ease; }
.bg-emerald { background-color: #34d399; }
.bg-sky { background-color: #38bdf8; }
.bg-amber { background-color: #fbbf24; }
.bg-rose { background-color: #fb7185; }
.bg-slate { background-color: #475569; }

/* Tables */
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
table.data-table th { background: rgba(15, 23, 42, 0.95); color: #94a3b8; font-weight: 600; text-align: left; padding: 0.7rem 1rem; font-size: 0.6875rem; }
table.data-table td { padding: 0.75rem 1rem; border-top: 1px solid rgba(30, 41, 59, 0.85); }
table.data-table tbody tr:hover { background: rgba(30, 41, 59, 0.35); }
.divide-y > * + * { border-top: 1px solid rgba(30, 41, 59, 0.85); }

/* Charts */
.gauge-box { position: relative; width: 10rem; height: 10rem; flex-shrink: 0; }
.chart-box { position: relative; width: 100%; height: 16rem; }
canvas { display: block; width: 100%; height: 100%; }

/* Modal & Toast */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(4px);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box { width: 100%; max-width: 44rem; max-height: 90vh; overflow-y: auto; }
.toast-stack { position: fixed; bottom: 4.8rem; right: 0.75rem; z-index: 50; display: flex; flex-direction: column; gap: 0.5rem; }
.toast-item {
  border-radius: 0.5rem;
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: #0f172a;
  color: #bae6fd;
  padding: 0.6rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.55);
}
.toast-success { border-color: rgba(16, 185, 129, 0.45); color: #6ee7b7; }
.toast-error { border-color: rgba(244, 63, 94, 0.45); color: #fda4af; }

.dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 9999px; }
.dot-rose { background: #f43f5e; }
.dot-emerald { background: #10b981; }
.pulse-dot { animation: pulseGlow 2s infinite; }
@keyframes pulseGlow { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.spin { animation: spin360 0.7s linear infinite; }
@keyframes spin360 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

input[type="range"] { accent-color: #38bdf8; width: 100%; cursor: pointer; }
.profile-group { display: inline-flex; border: 1px solid #334155; background: #020617; border-radius: 0.5rem; padding: 0.15rem; gap: 0.15rem; }
.profile-btn { border-radius: 0.375rem; padding: 0.25rem 0.65rem; font-size: 0.75rem; color: #94a3b8; }
.profile-btn.active { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; font-weight: 600; }

/* Responsive Breakpoints */
.desktop-only { display: none; }
.mobile-only { display: flex; }
.mobile-block { display: block; }

@media (min-width: 640px) {
  .container, .main-wrap { padding-left: 1.5rem; padding-right: 1.5rem; }
  .sm-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sm-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sm-flex-row { flex-direction: row; }
}

@media (min-width: 768px) {
  .desktop-only { display: flex !important; }
  .desktop-block { display: block !important; }
  .mobile-only { display: none !important; }
  .mobile-block { display: none !important; }
  .mobile-nav { display: none !important; }
  .main-wrap { padding-top: 1.25rem; padding-bottom: 2rem; }
  .toast-stack { bottom: 1rem; right: 1rem; }
  .md-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .lg-grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .lg-col-span-5 { grid-column: span 5 / span 5; }
  .lg-col-span-7 { grid-column: span 7 / span 7; }
  .lg-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg-grid-cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
