:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  color: #1f2937;
  background: #f3f5f7;
  font-synthesis: none;
  --blue: #1f5f8b;
  --blue-dark: #174e74;
  --muted: #596574;
  --line: #e1e6eb;
  --soft: #f5f7f9;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select, output { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #89abc2; outline-offset: 2px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0 0 8px; font-size: 1.55rem; }
h2 { margin: 0 0 8px; font-size: 1.22rem; }
h3 { margin: 0 0 4px; font-size: 1.02rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); line-height: 1.55; }
.mono { font-variant-numeric: tabular-nums; }

.login-page { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 29px; box-shadow: 0 16px 50px #0f172a1a; }
.login-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.mark { border-radius: 12px; }
.login-role-switch { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin-top: 19px; padding: 4px; border-radius: 12px; background: #edf1f4; }
.login-role-slider { position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: calc(100% - 8px); border-radius: 9px; background: #fff; box-shadow: 0 1px 5px #0f172a24; transition: transform .2s ease; }
.login-role-switch:has(#adminLogin[aria-pressed="true"]) .login-role-slider { transform: translateX(100%); }
.login-role-option { position: relative; border: 0; background: transparent; color: var(--muted); padding: 10px 8px; border-radius: 9px; font-weight: 700; }
.login-role-option[aria-pressed="true"] { color: var(--blue); }
.stack { display: grid; gap: 14px; margin-top: 20px; }
.stack h2 { margin: 0; }
.compact-stack { margin-top: 8px; }
label { display: block; min-width: 0; }
label span { display: block; font-size: .9rem; margin-bottom: 6px; font-weight: 650; }
input, select, textarea { display: block; width: 100%; min-height: 43px; border: 1px solid #cdd5dd; border-radius: 10px; padding: 9px 11px; background: #fff; color: #111827; }
input[type="date"] { min-width: 0; }
input[type="file"] { padding: 8px; }
textarea { resize: vertical; line-height: 1.5; }
fieldset { border: 0; margin: 0 0 13px; padding: 0; min-width: 0; }
.checkbox-label, .choice { display: flex; align-items: center; gap: 9px; }
.checkbox-label input, .choice input { width: 17px; min-height: 0; height: 17px; margin: 0; accent-color: var(--blue); flex: none; }
.checkbox-label span, .choice span { margin: 0; }

.primary, .secondary, .danger-outline { border: 1px solid transparent; border-radius: 10px; padding: 10px 13px; font-weight: 720; min-height: 42px; line-height: 1.3; }
.primary { background: var(--blue); color: #fff; }
.primary:hover:not(:disabled) { background: var(--blue-dark); }
.secondary { background: #e8eef3; color: #23445a; }
.secondary:hover:not(:disabled) { background: #dce7ee; }
.danger-outline { background: #fff; color: #9d2b2b; border-color: #e3b4b4; }
.danger-outline:hover:not(:disabled) { background: #fff4f4; }
.small { padding: 7px 10px; font-size: .88rem; min-height: 36px; }
.block { margin-top: 14px; width: 100%; }
.stack .block { margin-top: 0; }

.topbar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px max(20px, calc((100% - 1120px) / 2)); background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 3; }
.brand, .topbar-actions { display: flex; align-items: center; gap: 8px; }
.brand { flex: 1; min-width: 0; gap: 10px; }
.brand img { border-radius: 9px; flex: none; }
.brand strong { display: block; line-height: 1.2; }
.topbar-user { display: block; color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.container { width: min(1120px, calc(100% - 32px)); margin: 23px auto 54px; display: grid; gap: 16px; }
.module-nav { display: flex; gap: 4px; width: fit-content; padding: 4px; background: #e9eef2; border-radius: 12px; }
.module-nav a { padding: 8px 17px; border-radius: 8px; color: #475569; font-weight: 700; text-decoration: none; text-align: center; }
.module-nav a[aria-current="page"] { background: white; color: var(--blue); box-shadow: 0 1px 5px #0f172a16; }
.view-grid { display: grid; grid-template-columns: minmax(0, 1.24fr) minmax(0, 1fr); align-items: start; gap: 18px; }
.full { grid-column: 1 / -1; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 16px; padding: 21px; box-shadow: 0 4px 18px #0f172a09; min-width: 0; }
.section-heading, .dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.section-heading h1, .section-heading h2, .dialog-heading h2 { margin-bottom: 0; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.button-row.flush { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 13px; margin-top: 14px; }
.settings-form { background: var(--soft); border-radius: 11px; padding: 13px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; margin-top: 12px; }
.filter-grid { display: grid; grid-template-columns: minmax(110px, 1.2fr) repeat(3, minmax(104px, 1fr)) auto; align-items: end; gap: 8px; margin-top: 13px; }
.extra-fields { margin-top: 13px; }
.extra-fields summary { cursor: pointer; color: var(--blue); font-weight: 700; padding: 5px 0; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border-radius: 99px; font-size: .8rem; font-weight: 780; white-space: nowrap; }
.badge.neutral, .badge.ready { background: #e8eef3; color: #315872; }
.badge.running, .badge.done { background: #e4f5ea; color: #1c6b38; }
.badge.paused { background: #fff1d9; color: #795000; }
.badge.void { background: #fff0f0; color: #932c2c; }
.job-list { display: grid; gap: 8px; margin-top: 12px; }
.job-list:empty { margin-top: 0; }
.job, .list-item { border: 1px solid var(--line); border-radius: 11px; padding: 12px; min-width: 0; }
.job.active-job { border-color: #b8cedd; background: #fafcfe; }
.job.paused-job { border-color: #e6cc96; background: #fffcf6; }
.job-heading, .list-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.job-heading > div, .list-item > div { min-width: 0; }
.job-meta { color: var(--muted); font-size: .87rem; line-height: 1.45; overflow-wrap: anywhere; }
.job-timing { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.time-stat, .stat { min-width: 0; display: grid; gap: 3px; padding: 7px 9px; border-radius: 9px; background: #edf2f6; }
.time-stat span, .stat span { color: #4e5f6f; font-size: .81rem; overflow-wrap: anywhere; }
.time-stat strong { font-size: clamp(1.02rem, 2.8vw, 1.52rem); line-height: 1.2; color: #244d68; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.timer-actions { display: flex; gap: 8px; margin-top: 12px; }
.timer-actions button { flex: 1; min-width: 0; min-height: 46px; }
.empty-state { border-radius: 10px; background: #f5f7f9; color: var(--muted); padding: 14px 12px; text-align: center; }
.message { margin-top: 10px; padding: 9px 12px; border-radius: 9px; background: #eef3f7; color: #3d5565; line-height: 1.5; overflow-wrap: anywhere; }
main > .message { margin: 0; }
.message.success { background: #e9f6ed; color: #24653a; }
.message.error { background: #fff0f0; color: #9d2b2b; }
.message + .block { margin-top: 10px; }
.prediction-box { background: #f4f7fa; border: 1px solid #e3ebf2; border-radius: 11px; margin-top: 12px; padding: 15px; display: grid; gap: 6px; line-height: 1.45; }
.prediction-box.compact { padding: 10px 12px; }
.prediction-value { font-size: 2rem; font-variant-numeric: tabular-nums; font-weight: 820; line-height: 1.1; color: var(--blue); }
.prediction-box.compact .prediction-value { font-size: 1.38rem; }
.forecast-note { margin: 11px 0 0; font-size: .9rem; }
.stat-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.stat strong { color: var(--blue); font-size: 1.24rem; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.choice { padding: 9px; min-height: 44px; border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; }
.choice:has(input:checked) { background: #edf5fa; border-color: #82a8c2; }
.choice span { overflow-wrap: anywhere; }
.detail-grid { margin: 12px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-grid div { background: var(--soft); padding: 8px 10px; border-radius: 8px; min-width: 0; }
.detail-grid dt { font-size: .8rem; color: var(--muted); }
.detail-grid dd { margin: 2px 0 0; font-size: .91rem; overflow-wrap: anywhere; }
.report-lines { max-height: 250px; overflow: auto; padding: 0 0 0 22px; margin: 5px 0; font-size: .88rem; line-height: 1.5; }
.scroll-rows { max-height: 330px; overflow-y: auto; }
.status-row { padding: 6px 0 0; }

dialog { width: min(590px, calc(100% - 22px)); max-height: calc(100% - 30px); border: 1px solid var(--line); padding: 0; border-radius: 15px; box-shadow: 0 20px 56px #0f172a3b; color: #1f2937; }
dialog::backdrop { background: #182c41a0; }
.dialog-body { padding: 19px; }
.dialog-heading { margin-bottom: 11px; }
.dialog-heading h2 { align-self: center; }
#confirmText { margin: 10px 0 12px; line-height: 1.55; }

@media (max-width: 820px) {
  .view-grid { grid-template-columns: minmax(0, 1fr); }
  .container { width: calc(100% - 24px); margin-top: 14px; }
  .topbar { padding: 8px 13px; }
  .card { padding: 16px; border-radius: 13px; }
  .view-grid { gap: 13px; }
  .module-nav { width: 100%; }
  .module-nav a { flex: 1; }
}
@media (max-width: 540px) {
  .topbar { flex-wrap: wrap; gap: 6px; }
  .topbar-actions { gap: 5px; }
  .topbar-actions .small { padding-inline: 7px; }
  input, select, textarea { font-size: 16px; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid button { grid-column: 1 / -1; }
  .work-card .section-heading { align-items: center; }
  .work-card h1 { font-size: 1.26rem; }
  .time-stat, .stat { padding: 7px; }
  .dialog-body { padding: 15px; }
  dialog { margin: auto auto max(8px, env(safe-area-inset-bottom)); max-height: 89dvh; }
}
@media (max-width: 340px) {
  .form-grid { grid-template-columns: 1fr; }
  .work-card .section-heading { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .login-role-slider { transition: none; }
}
