:root {
  --brand: #00b8d4;
  --brand-deep: #008fa6;
  --bg: #0d131a;
  --card: #16202c;
  --line: #223041;
  --text: #ffffff;
  --mut: #a0aec0;
  --ok: #2fbf5f;
  --warn: #e0a800;
  --danger: #e5534b;
  --transition: .15s ease;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'PingFang TC','Noto Sans TC','Microsoft JhengHei',sans-serif;
  background: var(--bg); color: var(--text);
}
.page { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }

/* 全域控制元件 */
input, select, textarea, button {
  font-family: inherit; color: var(--text);
}
input, select {
  width: 100%; padding: 9px 12px; font-size: 14px;
  background: #0f1721; color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,229,255,.18);
}
label { display: block; font-size: 13px; color: var(--mut); font-weight: 500; margin-bottom: 2px; }
label input, label select { margin-top: 5px; }

button {
  cursor: pointer; border: none; border-radius: var(--radius-sm);
  padding: 10px 18px; font-size: 14px; font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}
button:active { transform: translateY(1px) scale(.99); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg,#00e5ff,#00b8d4); color: #08121c; font-weight: 700;
}
.btn.primary:hover { box-shadow: 0 6px 18px rgba(0,229,255,.35); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.big { width: 100%; padding: 13px; font-size: 15px; }

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0 22px; border-bottom: 1px solid var(--line); margin-bottom: 26px;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.brand span { color: var(--mut); font-weight: 400; font-size: 14px; }
.muted-link, .topbar a { color: var(--brand); text-decoration: none; font-size: 14px; }
.muted-link:hover { text-decoration: underline; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 26px 28px; box-shadow: var(--shadow);
}
.form-card h1 { margin: 0 0 6px; font-size: 22px; }
.form-card .sub { color: var(--mut); margin: 0 0 22px; font-size: 14px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .grid.two { grid-template-columns: 1fr; } }

.result { margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.result.ok { background: rgba(47,191,95,.15); color: #7be09b; }
.result.err { background: rgba(229,83,75,.15); color: #ff9d95; }

/* 登入閘 overlay */
.gate { position: fixed; inset: 0; background: rgba(6,10,16,.8); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; }
.gate[hidden] { display: none; }
.gate-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 30px 32px; width: 340px; box-shadow: var(--shadow); }
.gate-box h2 { margin: 0 0 18px; }
.gate-box label { margin-bottom: 12px; }
.gate-box .btn { width: 100%; margin-top: 6px; }

/* 統計 */
.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 600px) { .stats { grid-template-columns: repeat(2,1fr); } }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px; text-align: center; color: var(--mut); font-size: 13px;
}
.stat-num { font-size: 30px; font-weight: 800; color: var(--text); margin-bottom: 4px; }

/* 篩選列 */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar input[type=text] { width: 240px; }
.filter-bar select { width: 130px; }
.filter-bar input[type=date] { width: 150px; }
.filter-bar .sep { color: var(--mut); }
.filter-bar .spacer { flex: 1; }
.perpage { display: flex; align-items: center; gap: 6px; color: var(--mut); font-size: 13px; }
.perpage select { width: 80px; }

/* 分頁 */
.pager { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; color: var(--mut); font-size: 13px; }
#pgInfo { margin-right: auto; }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 820px; }
thead th {
  background: #101a26; color: var(--mut); text-align: left; font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid #1b2634; white-space: nowrap; }
tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }
tbody tr:hover { background: rgba(0,229,255,.06); }
td .st { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.st-pending { background: rgba(224,168,0,.2); color: #ffd166; }
.st-proc { background: rgba(0,229,255,.18); color: #7de8ff; }
.st-done { background: rgba(47,191,95,.2); color: #7be09b; }
td select { width: 110px; padding: 5px 6px; font-size: 12.5px; }

@media print { .topbar, .filter-bar, .pager, button { display: none !important; } }