:root {
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --orange-500: #f97316;
  --orange-600: #ea580c;
  --emerald-50: #ecfdf5;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --rose-50: #fff1f2;
  --rose-600: #e11d48;
  --amber-100: #fef3c7;
  --amber-800: #92400e;
  --amber-900: #78350f;
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }
html, body { margin: 0; max-width: 100%; }
body {
  min-height: 100dvh;
  background: var(--slate-50);
  color: var(--slate-800);
  font-family: Inter, "Noto Sans TC", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--slate-900);
  color: white;
  border-bottom: 1px solid var(--slate-800);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  padding-top: var(--safe-t);
}
.header-inner { max-width: 80rem; margin: 0 auto; padding: 0 1rem; }
.header-top {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.875rem 0 0.25rem;
}
.brand { font-size: 1.25rem; font-weight: 900; letter-spacing: -0.025em; color: white; }
.brand-sub { margin-top: 0.125rem; font-size: 0.75rem; color: var(--slate-400); }
.auth-slot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  padding-top: 0.25rem;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.75rem 1.25rem;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0.5rem 0.5rem 0 0;
  background: transparent;
  color: var(--slate-400);
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
}
.tab.active { border-bottom-color: var(--orange-500); color: white; background: rgb(30 41 59 / 0.6); }

.page { max-width: 80rem; margin: 0 auto; padding: 1.5rem 1rem calc(2rem + var(--safe-b)); }
.stack { display: flex; flex-direction: column; gap: 1.5rem; }
.card {
  background: white;
  border: 1px solid rgb(226 232 240 / 0.8);
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
.card-pad { padding: 1.25rem; }

.btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 44px;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.375rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
}
.btn-login, .btn-primary { background: var(--orange-500); color: white; box-shadow: 0 1px 2px rgb(0 0 0 / 0.05); }
.btn-login:hover, .btn-primary:hover { background: var(--orange-600); }
.btn-register { background: var(--slate-800); color: white; border-color: var(--slate-600); }
.btn-register:hover { background: var(--slate-700); }
.btn-soft { background: var(--slate-100); color: var(--slate-800); }
.btn-soft:hover { background: var(--slate-200); }
.btn-sky { background: #f0f9ff; color: #0369a1; border-color: #bae6fd; min-height: 36px; padding: 0.375rem 0.625rem; }
.btn-quiet { background: var(--slate-100); color: var(--slate-500); min-height: 36px; padding: 0.375rem 0.625rem; }
.btn-quiet:hover { background: var(--rose-50); color: var(--rose-600); }
.pending-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgb(245 158 11 / 0.2);
  border: 1px solid rgb(245 158 11 / 0.4);
  color: #fcd34d;
  border-radius: 0.75rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--slate-800);
  border: 1px solid var(--slate-700);
  border-radius: 0.75rem;
  padding: 0.375rem 0.75rem;
}
.avatar {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: #10b981;
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 900;
}
.linkish { background: none; border: 0; color: var(--slate-400); font-size: 0.75rem; font-weight: 600; min-height: 44px; padding: 0 0.5rem; }
.linkish:hover { color: #fb7185; }

.gate-card {
  max-width: 32rem;
  margin: 2rem auto;
  background: white;
  border-radius: 1.5rem;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  border: 1px solid var(--slate-200);
}
.gate-card.pending { border-color: #fde68a; }
.gate-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 0.5rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  font-size: 1.875rem;
  background: var(--slate-900);
}
.gate-card h2 { font-size: 1.25rem; font-weight: 800; color: var(--slate-900); }
.gate-card p { margin-top: 0.5rem; font-size: 0.875rem; color: var(--slate-500); line-height: 1.625; }
.gate-actions { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.25rem; }
.gate-actions .btn { width: 100%; min-height: 48px; font-size: 0.875rem; }

.hero-row, .toolbar, .subnav-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.kicker { font-size: 0.75rem; color: var(--slate-400); }
.hero-title { margin-top: 0.125rem; font-size: 1.25rem; font-weight: 800; color: var(--slate-900); }
.date-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.date-row select, .filters select, .filters input, .field input, .field select {
  min-height: 44px;
  border-radius: 0.75rem;
  border: 1px solid var(--slate-300);
  background: var(--slate-50);
  padding: 0.5rem 0.75rem;
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-800);
}
.date-row select:focus, .filters select:focus, .filters input:focus, .field input:focus, .field select:focus {
  outline: none;
  border-color: var(--orange-500);
  background: white;
}
.fx-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--slate-600);
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 0.75rem;
  padding: 0.5rem 0.875rem;
}
.index-grid, .summary-grid, .split-3, .stat-pair { display: grid; gap: 1rem; }
.index-grid, .stat-pair { grid-template-columns: 1fr; }
.index-card { padding: 1.25rem; }
.index-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.5rem; }
.index-name { font-size: 0.75rem; font-weight: 700; color: var(--slate-400); text-transform: uppercase; }
.index-value { margin-top: 0.125rem; font-size: 1.5rem; font-weight: 800; color: var(--slate-900); letter-spacing: -0.025em; }
.index-note { font-size: 0.75rem; color: var(--slate-500); }
.badge { display: inline-flex; padding: 0.25rem 0.625rem; border-radius: 0.5rem; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.badge.up { background: var(--emerald-50); color: var(--emerald-600); }
.badge.down { background: var(--rose-50); color: var(--rose-600); }
.badge.flat, .badge.bps { background: var(--slate-100); color: var(--slate-600); }
.dir {
  font-size: 11px;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid;
}
.dir.long { background: var(--emerald-50); color: var(--emerald-700); border-color: #a7f3d0; }
.dir.short { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.section-title { display: flex; align-items: center; gap: 0.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--slate-100); font-size: 1rem; font-weight: 700; color: var(--slate-900); }
.catalyst { display: flex; gap: 0.75rem; align-items: flex-start; font-size: 0.875rem; color: var(--slate-700); line-height: 1.625; }
.num-dot {
  width: 1.25rem; height: 1.25rem; border-radius: 999px; background: #ffedd5; color: var(--orange-600);
  font-size: 0.75rem; font-weight: 700; display: grid; place-items: center; flex: none; margin-top: 0.125rem;
}
.risk-card { background: rgb(255 251 235 / 0.7); border: 1px solid rgb(253 230 138 / 0.8); }
.risk-card .section-title { border-bottom-color: rgb(253 230 138 / 0.6); color: var(--amber-900); }
.risk-item { background: rgb(255 255 255 / 0.8); border: 1px solid rgb(253 230 138 / 0.6); border-radius: 0.75rem; padding: 0.75rem; color: rgb(120 53 15 / 0.9); font-size: 0.75rem; }
.empty, .error-box, .notice { border-radius: 1rem; padding: 0.875rem 1rem; font-size: 0.875rem; }
.empty { background: white; color: var(--slate-500); border: 1px solid rgb(226 232 240 / 0.8); }
.error-box { background: white; border: 1px solid #fecdd3; }
.notice { background: #fff7ed; border: 1px solid #fed7aa; color: var(--slate-700); font-size: 0.75rem; }
.fine-print { margin-top: 1.5rem; font-size: 0.6875rem; line-height: 1.6; color: var(--slate-500); }
.fine-print p { margin: 0.25rem 0; }

.pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill {
  min-height: 44px;
  border: 0;
  border-radius: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--slate-100);
  color: var(--slate-600);
  font-size: 0.875rem;
  font-weight: 700;
}
.pill.active { background: var(--slate-900); color: white; box-shadow: 0 1px 2px rgb(0 0 0 / 0.05); }
.sync {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.75rem;
  background: var(--emerald-50);
  color: var(--emerald-700);
  border: 1px solid #a7f3d0;
  font-size: 0.75rem;
  font-weight: 600;
}
.dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: #10b981; }
.summary-grid { grid-template-columns: 1fr 1fr; }
.summary-hero { background: var(--slate-900); color: white; border-radius: 1rem; padding: 1rem 1.25rem; grid-column: 1 / -1; }
.summary-hero .label, .metric-label { font-size: 0.75rem; color: var(--slate-400); font-weight: 600; }
.summary-hero .value { margin-top: 0.25rem; font-size: 1.5rem; font-weight: 800; white-space: nowrap; }
.summary-hero .sub { margin-top: 0.25rem; font-size: 11px; color: #fb923c; font-weight: 500; }
.metric { background: white; border: 1px solid rgb(226 232 240 / 0.8); border-radius: 1rem; padding: 1rem 1.25rem; box-shadow: 0 1px 2px rgb(0 0 0 / 0.05); }
.metric-value { margin-top: 0.25rem; font-size: 1.125rem; font-weight: 800; color: var(--slate-900); white-space: nowrap; }
.metric-sub { margin-top: 0.25rem; font-size: 11px; color: var(--slate-500); }
.up { color: var(--emerald-600); }
.down { color: var(--rose-600); }
.list-head, .pos-row, .screen-row {
  display: grid;
  gap: 0.75rem;
  align-items: center;
}
.list-head {
  display: none;
  padding: 0.625rem 1.25rem;
  background: var(--slate-50);
  color: var(--slate-500);
  font-size: 0.75rem;
  font-weight: 700;
  border-bottom: 1px solid rgb(226 232 240 / 0.8);
}
.pos-row, .screen-row { padding: 1rem 1.25rem; border-bottom: 1px solid var(--slate-100); }
.sym { font-size: 1rem; font-weight: 900; color: var(--slate-900); }
.muted { color: var(--slate-400); font-size: 0.75rem; }
.pair { display: flex; justify-content: space-between; gap: 0.75rem; }
.pair b, .money { font-size: 0.875rem; font-weight: 700; color: var(--slate-900); }
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.375rem; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--slate-100);
}
.card-head h3 { font-size: 1rem; font-weight: 800; color: var(--slate-900); }
.count { font-size: 0.75rem; font-weight: 700; padding: 0.125rem 0.5rem; border-radius: 999px; background: var(--slate-100); color: var(--slate-600); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.875rem; }
th { padding: 0.75rem 1rem; background: var(--slate-50); color: var(--slate-500); font-size: 0.75rem; border-bottom: 1px solid var(--slate-200); }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--slate-100); }
th.num, td.num { text-align: right; white-space: nowrap; }
.screen-grid { display: grid; gap: 0.75rem; }
.tv-link {
  background: #131722;
  color: white;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 7px 14px;
  border: 1px solid rgb(51 65 85 / 0.8);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.tv-link:hover { opacity: 0.9; }
.filters { display: grid; gap: 0.625rem; }
.expand { grid-column: 1 / -1; padding-top: 0.5rem; border-top: 1px solid var(--slate-100); margin-top: 0.25rem; }
.thesis { margin-top: 0.5rem; font-size: 0.875rem; color: var(--slate-700); overflow-wrap: anywhere; }
.tag { font-size: 11px; font-weight: 700; padding: 0.125rem 0.625rem; border-radius: 999px; border: 1px solid #a7f3d0; background: var(--emerald-50); color: var(--emerald-700); }
.mkt { font-size: 10px; font-weight: 700; padding: 0.125rem 0.375rem; border-radius: 0.25rem; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field span, .field small { font-size: 0.75rem; font-weight: 700; color: var(--slate-600); }
.field small { font-weight: 500; color: var(--slate-500); }
.form-grid, .choice { display: grid; gap: 0.75rem; }
.choice { grid-template-columns: 1fr 1fr; }
.choice label { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; }
.form-error { color: var(--rose-600); margin: 0; font-size: 0.875rem; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(15 23 42 / 0.48);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  width: min(36rem, 100%);
  max-height: min(92dvh, 100%);
  overflow: auto;
  background: white;
  border-radius: 1.5rem 1.5rem 0 0;
  padding: 1rem 1rem calc(1rem + var(--safe-b));
}
.modal-bar { display: flex; justify-content: space-between; align-items: center; }
.modal-bar h2 { font-size: 1.125rem; font-weight: 800; }
.icon-btn { width: 44px; background: transparent; border: 0; font-size: 1.5rem; }
.modal-form { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
/* Inline new-entry form (item 2): same form, shown in the holdings table. */
.inline-form { margin-top: 0; padding-bottom: 1rem; }
.inline-form > .form-grid, .inline-form > .form-error { padding-left: 1.25rem; padding-right: 1.25rem; }
.inline-form > .actions { padding-left: 1.25rem; padding-right: 1.25rem; }
.inline-form .card-head { border-bottom: 1px solid var(--slate-100); }
.quote-note { font-size: 0.75rem; color: var(--slate-500); }
.google-btn-host { min-height: 44px; }
#toast {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + var(--safe-b));
  background: var(--slate-900);
  color: white;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  max-width: min(92vw, 24rem);
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  font-size: 0.875rem;
}
#toast.show { opacity: 1; }
.loading { color: var(--slate-500); }

@media (min-width: 640px) {
  .brand { font-size: 1.5rem; }
  .index-grid, .stat-pair { grid-template-columns: 1fr 1fr; }
  .gate-actions { flex-direction: row; justify-content: center; }
  .gate-actions .btn { width: auto; }
  .hero-row, .toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .header-inner { padding: 0 1.5rem; }
  .page { padding-left: 1.5rem; padding-right: 1.5rem; }
}
@media (min-width: 768px) {
  .header-top { flex-direction: row; align-items: center; justify-content: space-between; }
  .list-head { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 2fr) minmax(0, 2fr) minmax(0, 3fr); }
  .pos-row { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 2fr) minmax(0, 2fr) minmax(0, 3fr); }
  .screen-head, .screen-row {
    grid-template-columns: minmax(180px, 2.2fr) minmax(110px, 1.2fr) minmax(180px, 2.2fr) minmax(150px, 1.6fr) 160px;
  }
  .screen-head { display: grid; }
  .pair { display: block; text-align: right; }
  .filters { grid-template-columns: 1fr 1fr 1.2fr; }
  .modal-backdrop { align-items: center; padding: 1.5rem; }
  .modal { border-radius: 1.5rem; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .index-grid { grid-template-columns: 1fr 1fr 1fr; }
  .summary-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .summary-hero { grid-column: auto; }
  .split-3 { grid-template-columns: 2fr 1fr; }
  .page, .header-inner { padding-left: 2rem; padding-right: 2rem; }
}

/* 大盤報價區（2026-11-23）：延遲備註、板塊表、自動刷新 */
.delay-remark { font-weight: 800; color: var(--amber-900); background: var(--amber-100); border: 1px solid rgb(253 230 138 / 0.8); border-radius: 0.75rem; padding: 0.5rem 0.75rem; font-size: 0.875rem; }
.sector-list { display: grid; gap: 0; }
.sector-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 0.8fr); gap: 0.5rem; align-items: center; padding: 0.5rem 0.25rem; border-bottom: 1px solid var(--slate-100); font-size: 0.875rem; }
.sector-row:last-child { border-bottom: 0; }
.sector-head { font-size: 0.75rem; font-weight: 700; color: var(--slate-400); text-transform: uppercase; }
.sector-name strong { font-weight: 800; }
.sector-name span { color: var(--slate-500); font-size: 0.75rem; }
.sector-value { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.sector-num { text-align: right; }
.sector-row .badge { justify-self: end; }
.sector-pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.sector-pct.up { color: var(--emerald-600); }
.sector-pct.down { color: var(--rose-600); }
.sector-pct.flat { color: var(--slate-400); }
