/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ===== Theme Tokens (Dark) ===== */
:root{
  --bg: #0b0f13;
  --surface: #12171e;
  --surface-2: #161c24;
  --accent: #22c55e;             /* 綠色重點色 */
  --accent-2: #16a34a;
  --accent-soft: rgba(34,197,94,.12);
  --text: #e6e6e6;
  --text-muted: #a3b0be;
  --text-faint: #6b7684;
  --border: rgba(255,255,255,.08);
  --shadow: 0 8px 28px rgba(0,0,0,.45);
  --radius: 14px;
}

/* Page Layout */
html, body { height: 100%; }
body{
  font-family: "Inter","Noto Sans TC", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 70% -10%, rgba(34,197,94,.12), transparent 50%) ,
              linear-gradient(180deg, #0b0f13 0%, #0a0d11 100%);
  color: var(--text);
  line-height: 1.65;
  padding: 32px 16px;
}

/* Container */
.container{
  max-width: 720px;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  position: relative;
}

/* Header */
header{
  text-align: center;
  margin-bottom: 14px;
}

/* Top-right page nav (程式選股 / 市場分析) */
.page-nav{
  position: absolute;
  top: 28px;
  right: 28px;
  display: flex;
  gap: 8px;
}
.page-nav-link{
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0f141a;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: transform .12s ease, background .2s ease, border-color .2s ease, color .2s ease;
}
.page-nav-link:hover{ transform: translateY(-1px); border-color: rgba(255,255,255,.16); color: var(--text); }
.page-nav-link.active{
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #08110a;
  font-weight: 700;
  border-color: transparent;
}
h1{
  font-size: 30px;
  letter-spacing: .6px;
  color: #fff;
  font-weight: 750;
}
header p{
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 6px;
}
.update-time{
  font-size: 12px !important;
  color: var(--text-faint) !important;
  margin-top: 10px !important;
}

/* Tabs */
.tab-nav{
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 18px 0 20px;
}

/* 導覽清單（list） */
.tab-list{
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 14px 0 18px;
  overflow-x: auto;  /* 手機可橫向滑動 */
}
.tab-list li{ flex: 0 0 auto; }

.tab-btn{
  appearance: none;
  border: 1px solid var(--border);
  background: #0f141a;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  white-space: nowrap;
  transition: transform .12s ease, background .2s ease, border-color .2s ease, color .2s ease;
}
.tab-btn:hover{ transform: translateY(-1px); border-color: rgba(255,255,255,.16); }
.tab-btn:focus-visible{ outline: 2px solid var(--accent); outline-offset: -3px; }
.tab-btn.active{
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #08110a;
  font-weight: 700;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(34,197,94,.28);
}

/* Sections (pages) */
.stock-list-container{ display: none; }
.stock-list-container.active{
  display: block;
  animation: fade-in .18s ease;
}
@keyframes fade-in{
  from{ opacity: 0; transform: translateY(4px); }
  to{ opacity: 1; transform: translateY(0); }
}

.section-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.stock-list-container h2{
  font-size: 18px;
  font-weight: 700;
  color: #e9f8ee;
  letter-spacing: .4px;
}
.count-badge{
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.stock-list{
  margin-top: 8px;
  padding: 10px;
  background: #0e1319;
  border-radius: calc(var(--radius) - 6px);
  border: 1px solid var(--border);
  max-height: 60vh;
  overflow-y: auto;
}
.stock-list::-webkit-scrollbar{ width: 8px; }
.stock-list::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.12); border-radius: 8px; }
.stock-list::-webkit-scrollbar-track{ background: transparent; }

/* Stock item cards */
ul{ list-style: none; }
.stock-list li{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin: 8px 0;
  background: linear-gradient(180deg, #0f151c 0%, #0c1218 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0,0,0,.28);
  transition: transform .12s ease, border-color .2s ease, background .2s ease;
}
.stock-list li:hover{
  transform: translateY(-1px);
  border-color: rgba(34,197,94,.25);
  background: linear-gradient(180deg, #0f181f 0%, #0c1419 100%);
}
.stock-list li:first-child{ margin-top: 0; }
.stock-list li:last-child{ margin-bottom: 0; }

/* Left: code + name */
.item-left{
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}
.ticker{
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .4px;
  background: var(--accent-soft);
  color: #a6f4c5;
  border: 1px solid rgba(34,197,94,.28);
  padding: 4px 10px;
  border-radius: 10px;
  flex-shrink: 0;
}
.name{
  color: #dfe6ee;
  opacity: .95;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.name{ text-decoration: none; }
a.name:hover{ text-decoration: underline; }

/* Right: badge (狀態/標籤) */
.badge{
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: #0b1015;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Loading / empty / error state row */
.state-row{
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  background: transparent;
  box-shadow: none;
  border-style: dashed;
  cursor: default;
}
.state-row:hover{ transform: none; }

/* Pagination (市場分析頁) */
.pager{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}
.pager-btn{
  appearance: none;
  border: 1px solid var(--border);
  background: #0f141a;
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  transition: transform .12s ease, border-color .2s ease, opacity .2s ease;
}
.pager-btn:hover:not(:disabled){ transform: translateY(-1px); border-color: rgba(255,255,255,.16); }
.pager-btn:disabled{ opacity: .35; cursor: default; }
.pager-label{
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Footer */
footer{
  text-align: center;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Admin page: login form + drop zone */
.admin-form{
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  margin: 0 auto;
}
.admin-form label{
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}
.admin-form input{
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0e1319;
  color: var(--text);
  font-size: 14px;
}
.admin-form input:focus-visible{ outline: 2px solid var(--accent); outline-offset: -2px; }
.admin-form button{ margin-top: 14px; }

.error-text{
  color: #f87171;
  font-size: 13px;
  margin-top: 8px;
  min-height: 1em;
}

.drop-zone{
  margin-top: 8px;
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  background: #0e1319;
  border: 1px dashed var(--border);
  border-radius: calc(var(--radius) - 6px);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.drop-zone.drag-over{
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-status{
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 12px;
  min-height: 1em;
}

/* Small screens */
@media (max-width: 560px){
  .container{ padding: 20px; }
  .page-nav{ position: static; justify-content: center; margin-bottom: 14px; }
  .stock-list li{ flex-direction: column; align-items: flex-start; }
  .item-left{ width: 100%; }
  .name{ white-space: normal; }
}
