/* 健保檢核網站樣式 — 醫療藍綠、大字、長輩友善（WCAG AAA 取向） */
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&family=Noto+Sans+TC:wght@400;500;700&display=swap');

:root {
  --primary: #0891B2;        /* 醫療藍綠 */
  --primary-dark: #0E7490;
  --secondary: #22D3EE;
  --cta: #22C55E;            /* 健康綠 */
  --cta-dark: #16A34A;
  --bg: #F0FDFA;             /* 淺薄荷 */
  --surface: #FFFFFF;
  --text: #134E4A;           /* 深墨綠 */
  --text-soft: #475569;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --danger-text: #991B1B;
  --warn-bg: #FEF9C3;
  --border: #CBD5E1;
  --shadow: 0 4px 16px rgba(15, 118, 110, .10);
  --shadow-lg: 0 10px 30px rgba(15, 118, 110, .16);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Noto Sans TC', 'Figtree', 'Microsoft JhengHei', '微軟正黑體', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Figtree', 'Noto Sans TC', '微軟正黑體', sans-serif; }

a { color: var(--primary-dark); }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ---- 頂部橫幅 ---- */
.topbar {
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 18px 0;
  box-shadow: var(--shadow);
}
.topbar .inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 700; }
.topbar .brand svg { width: 30px; height: 30px; flex: none; }
.topbar .logout {
  color: #fff; text-decoration: none; font-size: 16px;
  border: 1.5px solid rgba(255,255,255,.55); padding: 6px 16px; border-radius: 999px;
  transition: background .2s;
}
.topbar .logout:hover { background: rgba(255,255,255,.18); }

/* ---- 登入頁 ---- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #CCFBF1 0%, var(--bg) 55%);
}
.login-card {
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg);
  padding: 44px 40px; width: 100%; max-width: 440px; text-align: center;
}
.login-card .logo {
  width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card .logo svg { width: 42px; height: 42px; color: #fff; }
.login-card h1 { font-size: 27px; margin: 0 0 6px; }
.login-card .sub { color: var(--text-soft); font-size: 16px; margin: 0 0 28px; }

.field { text-align: left; margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 17px; }
.input {
  width: 100%; padding: 15px 16px; font-size: 20px; border: 2px solid var(--border);
  border-radius: 12px; outline: none; transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(8,145,178,.18); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-family: inherit; font-size: 20px; font-weight: 700; cursor: pointer;
  border: none; border-radius: 12px; padding: 15px 28px; transition: background .2s, transform .06s, box-shadow .2s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--cta); color: #fff; box-shadow: 0 6px 16px rgba(34,197,94,.32); }
.btn-primary:hover { background: var(--cta-dark); }
.btn-block { width: 100%; }
.btn-lg { font-size: 22px; padding: 18px 32px; }
.btn:focus-visible { outline: 4px solid rgba(8,145,178,.5); outline-offset: 2px; }

.btn-disabled {
  background: #E2E8F0; color: #94A3B8; cursor: not-allowed; box-shadow: none;
}
.btn-disabled:hover { background: #E2E8F0; }

/* ---- 提示訊息 ---- */
.alert {
  border-radius: 12px; padding: 14px 18px; margin-bottom: 22px; font-size: 17px;
  white-space: pre-line; text-align: left;
}
.alert-error { background: var(--danger-bg); color: var(--danger-text); border: 1.5px solid #FCA5A5; }

/* ---- 卡片 ---- */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px; margin-bottom: 24px;
}
.card h2 { margin: 0 0 6px; font-size: 22px; }
.card .hint { color: var(--text-soft); font-size: 16px; margin: 0 0 18px; }

/* ---- 上傳區 ---- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 3px dashed var(--primary); border-radius: 18px; background: #ECFEFF;
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.dropzone:hover, .dropzone.dragover { background: #CFFAFE; border-color: var(--primary-dark); }
.dropzone svg { width: 64px; height: 64px; color: var(--primary); margin-bottom: 14px; }
.dropzone .big { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.dropzone .small { color: var(--text-soft); font-size: 16px; }
.dropzone .fname { margin-top: 14px; font-size: 18px; font-weight: 600; color: var(--primary-dark); }

.steps { list-style: none; padding: 0; margin: 0 0 6px; }
.steps li {
  display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; font-size: 17px;
}
.steps .num {
  flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--primary);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 16px;
}

/* ---- 處理中遮罩 ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(240,253,250,.92);
  display: none; align-items: center; justify-content: center; flex-direction: column; z-index: 50;
}
.overlay.show { display: flex; }
.spinner {
  width: 64px; height: 64px; border: 6px solid #A5F3FC; border-top-color: var(--primary);
  border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay .msg { font-size: 22px; font-weight: 700; color: var(--text); }
.overlay .sub { font-size: 17px; color: var(--text-soft); margin-top: 6px; }

/* ---- 結果統計 ---- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; text-align: center;
}
.stat .num { font-size: 40px; font-weight: 700; line-height: 1.1; font-family: 'Figtree', sans-serif; }
.stat .lbl { font-size: 16px; color: var(--text-soft); margin-top: 4px; }
.stat.ok .num { color: var(--cta-dark); }
.stat.bad .num { color: var(--danger); }
.stat.total .num { color: var(--primary-dark); }

/* ---- 規則小卡 ---- */
.rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.rule-chip {
  border-radius: 12px; padding: 12px 14px; border: 1.5px solid var(--border); background: #fff;
}
.rule-chip.hit { background: var(--warn-bg); border-color: #FDE047; }
.rule-chip.zero { opacity: .5; }
.rule-chip .code { font-weight: 700; font-size: 16px; }
.rule-chip .cnt { float: right; font-weight: 700; font-size: 18px; }
.rule-chip.hit .cnt { color: var(--danger); }
.rule-chip .desc { font-size: 13px; color: var(--text-soft); line-height: 1.4; margin-top: 4px; }

/* ---- 動作列 ---- */
.actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 8px 0 24px; }

/* ---- 問題明細表 ---- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); background:#fff; }
table.detail { border-collapse: collapse; width: 100%; font-size: 14px; white-space: nowrap; }
table.detail thead th {
  position: sticky; top: 0; background: var(--primary); color: #fff; font-weight: 600;
  padding: 10px 10px; text-align: left; z-index: 1;
}
table.detail td { padding: 8px 10px; border-bottom: 1px solid #EEF2F6; }
table.detail tbody tr:nth-child(even) { background: #F8FAFC; }
table.detail td.desc { white-space: normal; min-width: 320px; color: var(--danger-text); font-weight: 500; }
table.detail td.rownum { color: var(--text-soft); font-variant-numeric: tabular-nums; }

.notice { font-size: 15px; color: var(--text-soft); margin: 12px 2px; }

.footer { text-align: center; color: var(--text-soft); font-size: 14px; padding: 8px 0 0; }

/* ---- 響應式 ---- */
@media (max-width: 720px) {
  body { font-size: 17px; }
  .stat-row { grid-template-columns: 1fr; }
  .stat .num { font-size: 34px; }
  .container { padding: 16px 14px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
