:root {
  --primary: #1a56db;
  --primary-light: #ebf2ff;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --green-bg: #dcfce7;
  --green-text: #166534;
  --amber-bg: #fef3c7;
  --amber-text: #92400e;
  --red-bg: #fee2e2;
  --red-text: #991b1b;
  --blue-bg: #dbeafe;
  --blue-text: #1e40af;
  --gray-bg: #f1f5f9;
  --gray-text: #475569;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%;
  overflow-x: hidden;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  padding: 16px 24px;
}
.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}
header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #fff;
  padding: 24px;
  border-radius: 14px;
  margin-bottom: 18px;
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.header-title-wrap {
  flex: 1;
  min-width: 260px;
}
header h1 { font-size: 1.58rem; margin-bottom: 8px; line-height: 1.35; }
header p { font-size: 0.93rem; color: #cbd5e1; max-width: 980px; }
.header-meta {
  margin-top: 10px;
  font-size: 0.82rem;
  color: #93c5fd;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.top-nav {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.top-nav a {
  display: inline-block;
  text-decoration: none;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 600;
}
.top-nav a:hover,
.top-nav a.active {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.article-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 18px;
  max-width: 1080px;
}
.article-wrap h2 {
  font-size: 1.2rem;
  color: #0f172a;
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.article-wrap h2:first-child { margin-top: 0; }
.article-wrap p { margin-bottom: 12px; color: #334155; font-size: 0.94rem; }
.article-wrap ul { margin: 8px 0 14px 20px; color: #334155; font-size: 0.92rem; }
.article-wrap li { margin-bottom: 6px; }
.article-wrap a { color: var(--primary); font-weight: 600; text-decoration: none; }
.article-wrap a:hover { text-decoration: underline; }
.article-table { margin: 12px 0 18px; }
@media (max-width: 768px) {
  .article-wrap { padding: 16px; }
}
.lang-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.lang-btn {
  display: inline-block;
  text-decoration: none;
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  transition: all 0.15s ease;
}
.lang-btn:hover { color: #fff; }
.lang-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.kpi-label { font-size: 0.82rem; color: var(--muted); margin-bottom: 4px; }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.kpi-sub { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.hsp-box {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 0.88rem;
}
.hsp-box strong { color: #0f172a; }
.hsp-box a { color: var(--primary); font-weight: 600; text-decoration: none; }
.hsp-box a:hover { text-decoration: underline; }
.hsp-meta {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #334155;
  line-height: 1.55;
}

.controls {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  align-items: end;
}
.control-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}
.control-group input,
.control-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.88rem;
  background: #fff;
  color: var(--text);
}
.btn-reset {
  width: 100%;
  padding: 9px 14px;
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
}
.btn-reset:hover { background: #e2e8f0; }

.result-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.86rem;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 8px;
}

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  width: 100%;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}
thead { background: #f1f5f9; }
th {
  text-align: left;
  padding: 12px 14px;
  font-weight: 700;
  color: #334155;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:hover { background: #f8fafc; }
.school-name { font-weight: 700; color: #0f172a; font-size: 0.95rem; }
.school-meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.source-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.source-link:hover { text-decoration: underline; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  margin: 2px 4px 2px 0;
  white-space: nowrap;
}
.b-green { background: var(--green-bg); color: var(--green-text); }
.b-amber { background: var(--amber-bg); color: var(--amber-text); }
.b-red { background: var(--red-bg); color: var(--red-text); }
.b-blue { background: var(--blue-bg); color: var(--blue-text); }
.b-gray { background: var(--gray-bg); color: var(--gray-text); }

.exclude-note {
  margin-top: 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 0.84rem;
  color: #475569;
}
.exclude-note h2 { font-size: 0.96rem; color: #0f172a; margin-bottom: 6px; }

footer.disclaimer {
  margin-top: 20px;
  background: #f1f5f9;
  border-top: 3px solid #94a3b8;
  border-radius: 10px;
  padding: 18px 20px;
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.65;
}
footer.disclaimer strong { color: #1e293b; }
footer.disclaimer a { color: var(--primary); font-weight: 600; text-decoration: none; }
footer.disclaimer a:hover { text-decoration: underline; }
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--muted);
}

@media (max-width: 768px) {
  body { padding: 10px; }
  header { padding: 18px 16px; border-radius: 12px; }
  header h1 { font-size: 1.25rem; }
  header p { font-size: 0.85rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-value { font-size: 1.25rem; }
  .controls { grid-template-columns: 1fr; padding: 14px; }

  .table-wrap {
    background: transparent;
    border: none;
    overflow-x: visible;
  }
  table, thead, tbody, th, td, tr {
    display: block;
    width: 100%;
  }
  thead { display: none; }
  tbody tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  }
  tbody tr:hover { background: var(--card); }
  td {
    padding: 8px 0;
    border-bottom: 1px dashed #e2e8f0;
    text-align: left;
  }
  td:first-child {
    padding-top: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
  }
  td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }
  td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 3px;
  }
  td:first-child::before { display: none; }
  .school-name { font-size: 1.05rem; color: var(--primary); }
}

/* HSP Calculator */
.hsp-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px 18px; margin: 16px 0; }
.hsp-field label { display: block; font-weight: 600; margin-bottom: 4px; }
.hsp-field select, .hsp-field input[type="number"] { width: 100%; padding: 7px 9px; }
.hsp-field .hint { font-size: 0.85em; opacity: 0.75; margin-top: 2px; }
.hsp-check { display: flex; align-items: center; gap: 8px; }
.hsp-check label { font-weight: 600; }
.hsp-result { margin: 20px 0; }
.hsp-result table { width: 100%; border-collapse: collapse; }
.hsp-result th, .hsp-result td { border: 1px solid var(--border, #ccc); padding: 6px 10px; text-align: left; }
.hsp-result td:nth-child(2), .hsp-result td:nth-child(3), .hsp-result th:nth-child(2), .hsp-result th:nth-child(3) { text-align: right; }
.hsp-status { font-size: 1.05em; margin: 12px 0 4px; }
.hsp-warn { border: 2px solid #c0392b; color: #c0392b; border-radius: 6px; padding: 10px 14px; margin: 12px 0; font-weight: 600; }
