@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;700&family=Merriweather:wght@400;700&display=swap");

:root {
  --bg: #f8f9fa;
  --card: #ffffff;
  --ink: #4a4a4a;
  --muted: #5a7d8a;
  --accent: #0077b6;
  --accent-strong: #219ebc;
  --ok: #2a7a44;
  --bad: #b43131;
  --nav-bg: #f08c3a;
  --nav-ink: #3a1d0b;
  --nav-panel: var(--nav-bg);
  --nav-panel-ink: var(--nav-ink);
  --nav-panel-border: rgba(255, 255, 255, 0.2);
  --nav-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  --card-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

img,
video,
svg {
  max-width: 100%;
  height: auto;
}

canvas {
  max-width: 100%;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", Arial, sans-serif;
  line-height: 1.8;
  color: var(--ink);
  background-color: var(--bg);
  transition: background-color 0.3s;
}

html {
  scroll-behavior: smooth;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 20px 50px;
  background-color: var(--nav-bg);
  box-shadow: var(--nav-shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  overflow: visible;
}

.site-header > * {
  min-width: 0;
}

.site-header h1 {
  margin: 0;
  font-size: 24px;
  font-family: "Merriweather", serif;
  color: var(--nav-ink);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--nav-ink);
  font-weight: 700;
  font-size: 14px;
}

.header-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.18);
}

.header-user-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-user-points {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
}

.header-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--nav-ink);
  font-weight: 700;
  text-decoration: none;
}

.header-login:hover {
  background: rgba(255, 255, 255, 0.28);
}

.toast-container {
  position: fixed;
  right: 24px;
  top: 90px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(58, 29, 11, 0.92);
  color: #fff3e6;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(58, 29, 11, 0.2);
  transform: translateY(-10px);
  opacity: 0;
  animation: toast-enter 0.3s ease forwards, toast-exit 0.4s ease forwards 2.4s;
}

.toast.positive {
  background: rgba(42, 122, 68, 0.92);
}

.toast.notice {
  background: rgba(217, 119, 6, 0.92);
}

@keyframes toast-enter {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes toast-exit {
  to {
    transform: translateY(-10px);
    opacity: 0;
  }
}

.site-title a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.site-title-icon {
  width: 28px;
  height: 28px;
  color: var(--nav-ink);
}

.nav-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  overflow-x: auto;
  overflow-y: visible;
  white-space: nowrap;
}

.nav-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nav-toggle-label {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid #d07228;
  background: #e57f2f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(112, 52, 12, 0.25);
}

.nav-toggle-bars {
  position: relative;
  width: 20px;
  height: 2px;
  background: var(--nav-ink);
  border-radius: 2px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--nav-ink);
  border-radius: 2px;
  transition: transform 0.2s ease;
}

.nav-toggle-bars::before {
  top: -6px;
}

.nav-toggle-bars::after {
  top: 6px;
}

.nav-toggle:checked + .nav-toggle-label .nav-toggle-bars {
  background: transparent;
}

.nav-toggle:checked + .nav-toggle-label .nav-toggle-bars::before {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle:checked + .nav-toggle-label .nav-toggle-bars::after {
  transform: translateY(-6px) rotate(-45deg);
}

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 48, 71, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1200;
}

.nav-drawer {
  position: fixed;
  top: 0;
  left: -340px;
  width: 320px;
  max-width: calc(100vw - 32px);
  height: 100vh;
  background: var(--nav-panel);
  box-shadow: 12px 0 40px rgba(112, 52, 12, 0.2);
  padding: 18px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: left 0.25s ease;
  z-index: 1400;
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--nav-panel-border);
}

.nav-drawer-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--nav-panel-ink);
  letter-spacing: 0.08em;
}

.nav-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--nav-panel-ink);
  cursor: pointer;
}

.nav-auth {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--nav-panel-border);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--nav-panel-ink);
  font-size: 14px;
  font-weight: 700;
}

.nav-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.18);
}

.nav-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-auth-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--nav-panel-ink);
  font-weight: 700;
  text-decoration: none;
}

.nav-auth-link:hover {
  background: rgba(255, 255, 255, 0.28);
}

.nav-section {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--nav-panel-border);
}

.nav-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.nav-title {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--nav-panel-ink);
  margin: 12px 0 6px;
}

.nav-title-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--nav-panel-ink);
  text-decoration: none;
  margin: 12px 0 6px;
}

.nav-title-link:hover {
  color: var(--nav-panel-ink);
}

.nav-drawer a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--nav-panel-ink);
  font-weight: 700;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.nav-drawer a:hover {
  background: transparent;
}

.nav-toggle:checked ~ .nav-overlay {
  opacity: 1;
  pointer-events: auto;
}

.nav-toggle:checked ~ .nav-drawer {
  left: 0;
}

nav a {
  margin-right: 0;
}

h1,
h2,
h3 {
  font-family: "Merriweather", serif;
  color: #023047;
}

h2 {
  font-size: 1.4em;
  border-bottom: 2px solid #8ecae6;
  padding-bottom: 8px;
  margin-top: 20px;
}

.home-section-title {
  font-size: 20px;
}

h3 {
  font-size: 1.2em;
  color: var(--accent-strong);
}

.container {
  max-width: 1400px;
  width: min(1400px, calc(100% - 80px));
  margin: 20px auto;
  background-color: var(--card);
  padding: 5px 10px;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}

.container.grid-layout {
  max-width: 1600px;
  width: min(1600px, calc(100% - 80px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.container.overview-page {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}

.container.grid-layout.overview-page {
  width: 100vw !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.container.grid-layout .card {
  margin-bottom: 0;
}

.card.full {
  grid-column: 1 / -1;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: var(--card-shadow);
  margin-bottom: 30px;
}

.card > :first-child {
  margin-top: 0;
}

.performance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.perf-card {
  border: 1px solid #edf2f7;
  border-radius: 12px;
  padding: 16px;
  background: #f9fbfd;
}

.perf-title {
  font-weight: 700;
  color: #023047;
  margin-bottom: 6px;
}

.label-link {
  color: inherit;
  text-decoration: none;
}

.label-link:hover {
  color: #1d4e89;
  text-decoration: underline;
}

.perf-meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.perf-date {
  white-space: nowrap;
}

.perf-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.perf-item {
  background: #ffffff;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  border: 1px solid #edf2f7;
}

.perf-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.perf-value {
  font-size: 14px;
  font-weight: 700;
  color: #023047;
}

.perf-up {
  color: var(--bad);
}

.perf-down {
  color: var(--ok);
}

.news-click-count {
  margin-left: 6px;
  font-size: 12px;
  color: var(--muted);
}

.overlap-news-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.overlap-news-item {
  border: 1px solid #edf2f7;
  border-radius: 12px;
  padding: 12px 14px;
  background: #ffffff;
}

.overlap-news-item:target {
  border-color: #8ecae6;
  box-shadow: 0 0 0 3px rgba(142, 202, 230, 0.35);
}

.overlap-news-title {
  font-weight: 700;
  color: #023047;
  margin-bottom: 8px;
}

.theme-news-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.theme-news-item {
  border: 1px solid #edf2f7;
  border-radius: 12px;
  padding: 12px 14px;
  background: #ffffff;
}

.theme-news-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  color: #023047;
  margin-bottom: 8px;
}

mark {
  background: #fde68a;
  color: inherit;
  padding: 0 2px;
  border-radius: 4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.grid > * {
  min-width: 0;
}

.label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.value {
  font-size: 18px;
  font-weight: 700;
  color: #023047;
}

.small {
  font-size: 13px;
  color: var(--muted);
}

.summary-grid {
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-grid > * {
  min-width: 0;
}

.summary-grid .label {
  font-size: 14px;
}

.summary-list {
  line-height: 1.4;
  margin-top: 6px;
}

.data-table tr.overlap-4 td {
  background-color: #ffe1d6;
}

.data-table tr.overlap-3 td {
  background-color: #fff0cc;
}

.data-table tr.overlap-2 td {
  background-color: #f1f5f9;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 999px;
  background: linear-gradient(45deg, var(--accent-strong), var(--accent));
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 6px;
}

.filter-input,
.filter-select {
  border-radius: 10px;
  border: 1px solid #e1e7ec;
  padding: 8px 12px;
  font-size: 13px;
}

.filter-input {
  min-width: 240px;
  flex: 1 1 240px;
}

.data-table th,
.data-table td {
  padding: 10px;
  border-bottom: 1px solid #eaecee;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.data-table .num {
  text-align: right;
}

.favorite-col,
.favorite-cell {
  text-align: center;
  width: 84px;
}

.favorite-btn {
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: rgba(255, 255, 255, 0.65);
  color: #5b2b12;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.favorite-btn.is-added {
  border-color: #2a7a44;
  color: #2a7a44;
  background: rgba(42, 122, 68, 0.12);
}

.favorite-btn.is-limit {
  border-color: #d97706;
  color: #9a5b1a;
  background: rgba(217, 119, 6, 0.12);
}

.favorite-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.drag-handle {
  cursor: grab;
  user-select: none;
  white-space: nowrap;
}

.fav-stock-table tr.dragging {
  opacity: 0.6;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.group-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.group-id {
  font-size: 12px;
  color: var(--muted);
  margin-left: 4px;
}

.rename-group-btn {
  margin-left: 8px;
}

.admin-stats {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.admin-points-input {
  width: 90px;
  padding: 4px 8px;
  border: 1px solid #e1e7ec;
  border-radius: 8px;
  font-size: 13px;
}

.news-table {
  table-layout: fixed;
}

.news-table th:nth-child(1),
.news-table td:nth-child(1) {
  width: 52%;
  word-break: break-word;
}

.news-table th:nth-child(2),
.news-table td:nth-child(2) {
  width: 14%;
}

.news-table th:nth-child(3),
.news-table td:nth-child(3) {
  width: 20%;
}

.news-table th:nth-child(4),
.news-table td:nth-child(4) {
  width: 14%;
  word-break: break-word;
}

.points-up {
  color: #2a7a44;
  font-weight: 700;
}

.points-down {
  color: #b43131;
  font-weight: 700;
}

.news-item {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #e5ebf2;
  border-radius: 14px;
  background: #f8fafc;
}

.news-item h3 {
  margin: 0 0 8px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.news-item + .news-item {
  margin-top: 12px;
}

.ok {
  color: var(--ok);
}

.bad {
  color: var(--bad);
}

.delta-up {
  color: var(--bad);
}

.delta-down {
  color: var(--ok);
}

.qr {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qr img {
  width: 240px;
  max-width: 70vw;
  height: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.support-actions {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #dbe3ea;
  font-size: 13px;
  color: #0f172a;
}

.topic-count {
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  color: #475569;
  background: #e2e8f0;
}

.chart-box {
  width: 100%;
  max-width: 520px;
  height: 360px;
  margin: 0 auto;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-box-pie {
  width: 100%;
  max-width: 520px;
  height: 520px;
}

.chart-box-bar {
  width: 100%;
  height: 520px;
}

.pp-5BDKWZQVQL7TA {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: none;
  border-radius: 0.25rem;
  min-width: 11.625rem;
  padding: 0 2rem;
  height: 2.625rem;
  font-weight: bold;
  background-color: #ffd140;
  color: #000000;
  font-family: Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.25rem;
  cursor: pointer;
  text-decoration: none;
}

.pp-5BDKWZQVQL7TA:hover {
  background-color: #e6be2f;
  color: #111;
}

@media (max-width: 720px) {
  .site-header {
    padding: 16px;
    gap: 12px;
  }

  .container {
    padding: 0;
    margin: 0;
    width: 100%;
  }

  .container.overview-page {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .container.grid-layout {
    display: block;
  }

  .container.grid-layout .card {
    width: 100%;
    margin-bottom: 16px;
  }

  .card {
    border-radius: 0;
    margin-bottom: 12px;
    padding: 16px;
  }

  .chart-box-bar {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .chart-box-pie {
    width: 100%;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }

  .site-header h1 {
    font-size: 16px;
  }

  h2 {
    font-size: 13px;
    line-height: 1.35;
  }

  h3 {
    font-size: 13px;
    line-height: 1.35;
  }

  .card-header h2 {
    font-size: 13px;
  }

  .nav-wrap {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .nav-drawer a {
    font-size: 15px;
  }

  .data-table {
    font-size: 13px;
  }

  .chart-box {
    width: 100%;
    max-width: 100%;
    height: clamp(280px, 70vw, 360px);
  }

  .chart-box-pie {
    width: 100%;
    max-width: 420px;
    height: clamp(320px, 80vw, 440px);
  }

  .chart-box-bar {
    height: clamp(320px, 80vw, 520px);
  }

  .overview-page .chart-box-bar,
  .overview-page .chart-box-pie {
    width: calc(100% + 32px);
    max-width: none;
    margin-left: -16px;
    margin-right: -16px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .summary-grid .label {
    font-size: 11px;
  }

  .summary-grid .value {
    font-size: 14px;
  }

  .summary-list {
    font-size: 12px;
  }

}

@media (max-width: 1200px) {
  .container.grid-layout {
    grid-template-columns: 1fr;
  }
}

.news-articles-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-article-card {
  padding: 12px;
  border-radius: 8px;
  background-color: #fff;
  border: 1px solid #e5e7eb;
  transition: box-shadow 0.2s ease;
}

.news-article-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

@media (max-width: 720px) {
  .news-articles-container {
    gap: 2px;
  }

  .card.full {
    padding-top: 2px;
  }

  .card-header {
    margin-bottom: 2px;
  }

  .card-header h2 {
    margin: 0;
  }

  .card.full #news-container {
    margin-top: 0;
  }

  .card.full .news-item:first-child {
    margin-top: 0;
  }

  .news-item {
    margin-top: 2px;
  }

  .news-item + .news-item {
    margin-top: 2px;
  }

  .news-article-card {
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .news-article-card:hover {
    box-shadow: none;
  }
}

.news-article-title {
  display: block;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.news-article-title:hover {
  text-decoration: underline;
}

.news-article-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 6px;
}

.news-article-source {
  font-weight: 700;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-header h2 {
  margin: 0;
  border: none;
  padding: 0;
}

.news-controls {
  display: flex;
  gap: 8px;
}

.news-control-btn {
  background: #f1f5f9;
  border: 1px solid #dbe3ea;
  color: #475569;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.news-control-btn:hover {
  background: #e2e8f0;
}

.news-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.news-item-header h3 {
  margin: 0;
}

.news-toggle-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--muted);
}

.news-articles-container.hidden {
  display: none;
}
