* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #16a34a;
  --danger: #dc2626;
  --background: #f1f5f9;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --border: #dbe2ea;
  --good: #047857;
}
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: radial-gradient(circle at 10% 20%, #dbeafe 0%, #f8fafc 45%, #e2e8f0 100%);
  min-height: 100vh;
  padding: 20px;
  color: var(--text-primary);
}
.container {
  max-width: 1500px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.14);
}
header { text-align: center; margin-bottom: 26px; }
h1 { font-size: 36px; color: #0b3b85; margin-bottom: 8px; letter-spacing: 1px; }
.subtitle { color: var(--text-secondary); font-size: 14px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}
.card h2 {
  font-size: 18px;
  margin-bottom: 14px;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.form-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
label {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 13px;
}
input, select {
  padding: 11px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s;
  background: var(--card-bg);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: white; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-secondary { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat-card {
  background: #f8fafc;
  padding: 14px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-card h3 { font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; }
.stat-card .value { font-size: 22px; font-weight: 800; color: #1d4ed8; }
.value-positive { color: var(--good) !important; }
.value-negative { color: var(--danger) !important; }
.chart-container { position: relative; height: 260px; margin-top: 8px; }
.filter-section {
  background: var(--background);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}
.filter-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.table-container {
  overflow-x: auto;
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 18px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}
th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
th {
  background: #1d4ed8;
  color: white;
  font-weight: 700;
  position: sticky;
  top: 0;
}
th.sortable { cursor: pointer; }
tr:hover { background: #f8fafc; }
.tag {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 4px;
}
.tag-dividend { background: #dcfce7; color: #166534; }
.tag-potential { background: #fef3c7; color: #92400e; }
.tag-stable { background: #dbeafe; color: #1e40af; }
.tag-warning { background: #fef3c7; color: #92400e; }
.tag-safe { background: #ecfdf5; color: #065f46; }
.actions { display: flex; gap: 6px; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 16px;
}
.yield-display {
  font-weight: 800;
  color: #2563eb;
  font-size: 15px;
  margin-top: 6px;
}
.yield-good { color: #15803d; }
.mini-note { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.forecast-highlight { font-size: 26px; font-weight: 800; color: #0f766e; margin-top: 4px; }
.toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 30px));
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 10px 18px rgba(2, 6, 23, 0.25);
  animation: slideIn 0.2s ease;
}
.toast.success { background: #166534; }
.toast.warning { background: #92400e; }
.toast.error { background: #991b1b; }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 768px) {
  body { padding: 10px; }
  .container { padding: 14px; }
  h1 { font-size: 28px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .btn-group .btn { flex: 1 1 auto; }
}
