/* ============================================================
   證書查詢系統 · 設計令牌
   來源：dttaedu.com（匯智數科 DTT）品牌樣式表 :root
   海軍藍 #002454 / 青綠 #00B4C0 / 髮絲線 #DCE3EA / 尖角 2–4px
   ============================================================ */
:root {
  --brand-900: #001529;
  --brand-800: #001C3D;
  --brand-700: #002454;
  --brand-600: #0A3A6E;
  --brand-500: #14508F;
  --brand-400: #2F6EAF;

  --accent-700: #00727C;
  --accent-600: #00848F;
  --accent-500: #00B4C0;
  --accent-400: #22C4CE;
  --accent-300: #6FE3EC;
  --accent-100: #E4F7F9;

  --ink-900: #0A1524;
  --ink-700: #253749;
  --ink-500: #55657A;
  --ink-400: #7C8DA1;
  --ink-300: #B9C4D0;
  --ink-200: #DCE3EA;
  --ink-100: #EDF1F5;
  --ink-050: #F5F7FA;
  --white: #FFFFFF;

  --ok: #0E7A3E;      --ok-bg: #EAF7EF;      --ok-line: #B6E3C6;
  --danger: #B42318;  --danger-bg: #FDF1F0;  --danger-line: #F3C9C6;
  --info: #14539B;    --info-bg: #EDF4FD;    --info-line: #C3DCF8;

  --r-sm: 2px;
  --r-md: 3px;
  --r-lg: 4px;
  --r-full: 999px;

  --font-sans: "PingFang TC", "PingFang SC", "Hiragino Sans GB", "Microsoft JhengHei",
    "Microsoft YaHei", "Noto Sans CJK TC", "Noto Sans CJK SC", system-ui, -apple-system,
    "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Roboto Mono", "Liberation Mono", "Courier New", monospace;

  --shadow-1: 0 1px 2px rgba(0, 21, 41, .04);
  --shadow-2: 0 2px 8px rgba(0, 21, 41, .06), 0 12px 28px rgba(0, 21, 41, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: var(--font-sans);
  color: var(--ink-900);
  background: var(--ink-050);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* 頂部品牌細條 */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-700) 0%, var(--brand-700) 84%, var(--accent-500) 84%, var(--accent-500) 100%);
  z-index: 60;
}

.wrap { max-width: 680px; margin: 0 auto; padding: 40px 20px 72px; }

/* ---------------- 品牌頭 ---------------- */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.mark {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: var(--brand-700);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .5px;
  position: relative;
  overflow: hidden;
}

.mark::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--accent-500);
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--brand-700);
  line-height: 1.3;
}

.brand p {
  margin: 3px 0 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 2px;
  color: var(--ink-400);
  text-transform: uppercase;
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  padding: 26px 22px;
  box-shadow: var(--shadow-1);
}

.card + .card { margin-top: 14px; }

label.field-label,
.field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-400);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  margin-bottom: 9px;
}

.field { display: flex; gap: 9px; }

input[type="text"],
input[type="password"],
textarea,
select {
  flex: 1;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--ink-900);
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-sm);
  padding: 13px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--accent-100);
}

input::placeholder, textarea::placeholder { color: var(--ink-300); }

textarea { width: 100%; resize: vertical; line-height: 1.6; font-family: var(--font-mono); font-size: 13px; }

button {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #fff;
  background: var(--brand-700);
  border: 1px solid var(--brand-700);
  border-radius: var(--r-sm);
  padding: 13px 24px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .1s, border-color .15s;
}

button:hover { background: var(--brand-600); border-color: var(--brand-600); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.ghost {
  background: var(--white);
  color: var(--ink-700);
  border: 1px solid var(--ink-200);
}
button.ghost:hover { border-color: var(--ink-300); background: var(--ink-050); }

.hint {
  margin: 11px 0 0;
  font-size: 12.5px;
  color: var(--ink-400);
  letter-spacing: .2px;
}

/* ---------------- 三步說明 ---------------- */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  overflow: hidden;
}

.step { padding: 16px 16px 18px; border-right: 1px solid var(--ink-200); }
.step:last-child { border-right: none; }

.step .n {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent-600);
  letter-spacing: 2px;
  margin-bottom: 7px;
}

.step .t { font-size: 13.5px; font-weight: 600; color: var(--ink-900); }
.step .d { font-size: 12px; color: var(--ink-400); margin-top: 4px; line-height: 1.55; }

@media (max-width: 640px) {
  .steps { grid-template-columns: 1fr; }
  .step { border-right: none; border-bottom: 1px solid var(--ink-200); }
  .step:last-child { border-bottom: none; }
}

/* ---------------- 狀態 ---------------- */
.status { margin-top: 16px; font-size: 14px; }
.status:empty { display: none; }

.status.err {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-left: 3px solid var(--danger);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}

.status.info {
  color: var(--ink-700);
  background: var(--accent-100);
  border: 1px solid #BFE9EE;
  border-left: 3px solid var(--accent-500);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}

/* ---------------- 結果 ---------------- */
.results { margin-top: 18px; display: grid; gap: 10px; }

.result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-sm);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.result:hover {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--accent-100);
}

.result .thumb {
  width: 44px;
  height: 56px;
  flex: 0 0 44px;
  border-radius: var(--r-sm);
  border: 1px solid var(--ink-200);
  background: var(--ink-050);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-700);
  position: relative;
}

.result .thumb::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-500);
}

.result .meta { flex: 1; min-width: 0; }

.result .meta .t1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result .meta .t2 {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-400);
  margin-top: 4px;
  letter-spacing: .6px;
}

.result .arrow { color: var(--accent-600); font-size: 20px; flex: 0 0 auto; }

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  vertical-align: middle;
  text-transform: uppercase;
}

.badge.ok { color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-line); }
.badge.revoked { color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger-line); }

/* ---------------- 證書頁 ---------------- */
.cert-shell { max-width: 900px; margin: 0 auto; padding: 24px 16px 110px; }

.cert-frame {
  background: var(--white);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--ink-200);
  box-shadow: var(--shadow-2);
  position: relative;
}

.cert-frame img { display: block; width: 100%; height: auto; }

.cert-frame .loading {
  padding: 90px 20px;
  text-align: center;
  color: var(--ink-400);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 2px;
}

.spinner {
  width: 24px;
  height: 24px;
  margin: 0 auto 14px;
  border: 2px solid var(--ink-200);
  border-top-color: var(--brand-700);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--ink-200);
  display: flex;
  justify-content: center;
  z-index: 40;
}

.actionbar .inner { display: flex; gap: 9px; width: 100%; max-width: 900px; }

.actionbar button,
.actionbar a.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  padding: 13px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--brand-700);
  cursor: pointer;
  color: #fff;
  background: var(--brand-700);
  transition: background .15s;
}

.actionbar a.btn:hover, .actionbar button:hover { background: var(--brand-600); }

.actionbar .btn.ghost {
  background: var(--white);
  color: var(--ink-700);
  border: 1px solid var(--ink-200);
  flex: 0 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}
.actionbar .btn.ghost:hover { background: var(--ink-050); }

.tip {
  max-width: 900px;
  margin: 14px auto 0;
  font-size: 12px;
  color: var(--ink-400);
  text-align: center;
  line-height: 1.75;
}

/* ---------------- 證書資訊卡 ---------------- */
.card-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--brand-700);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink-200);
}

.info-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.info-list .row {
  padding: 12px 0;
  border-bottom: 1px solid var(--ink-100);
}

.info-list .row:nth-child(odd) { padding-right: 16px; }

.info-list .k {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-400);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.info-list .v {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

/* ---------------- 看圖燈箱 ---------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 21, 41, .96);
  display: none;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 40px 0;
}

.lightbox.show { display: block; }

.lightbox img {
  display: block;
  width: 1240px;
  max-width: none;
  height: auto;
  margin: 0 auto;
}

.lightbox .close {
  position: fixed;
  top: 12px; right: 14px;
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .22);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  letter-spacing: 0;
  z-index: 201;
}

.zoomable { cursor: zoom-in; }

/* ---------------- 後台 ---------------- */
.admin-shell { max-width: 1120px; margin: 0 auto; padding: 36px 20px 80px; }

.toolbar {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ink-100);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-400);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  background: var(--ink-050);
  border-bottom: 1px solid var(--ink-200);
  position: sticky;
  top: 0;
}

tbody tr:hover { background: var(--ink-050); }

td.actions { text-align: right; }

td.actions a, td.actions button {
  font-size: 12px;
  padding: 5px 10px;
  letter-spacing: .5px;
  margin-left: 5px;
  border-radius: var(--r-sm);
  display: inline-block;
  text-decoration: none;
  vertical-align: middle;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .full { grid-column: 1 / -1; }

.hidden { display: none !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%) translateY(8px);
  background: var(--brand-900);
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: var(--r-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99;
  white-space: nowrap;
  border-left: 3px solid var(--accent-500);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .wrap { padding: 28px 16px 56px; }
  .field { flex-direction: column; }
  .field button { width: 100%; }
}

/* ---------------- 審核狀態頁 ---------------- */
.state-card { text-align: center; padding: 44px 24px 40px; }

.state-icon {
  width: 66px; height: 66px;
  border-radius: 50%;
  display: grid; place-items: center;
  margin: 0 auto 20px;
  font-size: 30px; line-height: 1;
}

.state-icon.pending { background: #FFF6E7; color: #93540A; border: 1px solid #F2D9AE; }
.state-icon.approved { background: #EAF7EF; color: #0E7A3E; border: 1px solid #B6E3C6; }
.state-icon.rejected { background: #FDF1F0; color: #B42318; border: 1px solid #F3C9C6; }

.state-title { font-size: 21px; font-weight: 700; letter-spacing: 2px; color: var(--ink-900); }
.state-desc { font-size: 13.5px; color: var(--ink-500); margin-top: 10px; line-height: 1.9; }
.state-desc b { color: var(--ink-700); }

.state-meta {
  margin: 22px auto 0;
  max-width: 380px;
  border-top: 1px solid var(--ink-200);
  padding-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 8px;
  text-align: left;
}

.state-meta .k {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-400);
  letter-spacing: 1.4px;
  text-transform: uppercase;
}
.state-meta .v { font-size: 13.5px; font-weight: 600; color: var(--ink-900); margin-top: 3px; }

/* ---------------- 後台：批次操作列 ---------------- */
.bulkbar {
  display: none;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  padding: 11px 14px;
  background: var(--accent-100);
  border: 1px solid #BFE9EE;
  border-left: 3px solid var(--accent-500);
  border-radius: var(--r-sm);
  margin-bottom: 12px;
}
.bulkbar.show { display: flex; }
.bulkbar .count { font-size: 13px; font-weight: 600; color: var(--brand-700); margin-right: 4px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

.tab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--ink-200);
  background: var(--white);
  color: var(--ink-500);
  cursor: pointer;
}
.tab:hover { border-color: var(--ink-300); }
.tab.on { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.tab .n { font-family: var(--font-mono); font-size: 11px; opacity: .75; margin-left: 5px; }

tbody tr.sel { background: #F0FAFB; }
tbody tr.sel:hover { background: #E6F7F9; }

input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--brand-700);
  cursor: pointer;
  vertical-align: middle;
}

.dropzone {
  border: 1.5px dashed var(--ink-300);
  border-radius: var(--r-md);
  padding: 26px 20px;
  text-align: center;
  color: var(--ink-400);
  font-size: 13px;
  background: var(--ink-050);
  cursor: pointer;
  transition: all .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand-500); background: var(--accent-100); color: var(--brand-700); }
.dropzone b { color: var(--brand-700); }

.badge.pending { color: #93540A; background: #FFF6E7; border: 1px solid #F2D9AE; }

.result .meta .t3 {
  font-size: 12px;
  color: var(--ink-400);
  margin-top: 4px;
}
