:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dfe4ec;
  --border-strong: #c6cedb;
  --text: #1a2333;
  --text-dim: #5d6880;
  --accent: #2f4b7c;
  --accent-hover: #243c66;
  --accent-soft: #e8eef8;
  --ok: #1f7a4d;
  --warn: #9a5b00;
  --err: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 6px 18px rgba(20, 30, 50, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #10141b;
    --surface: #181e28;
    --surface-2: #1f2733;
    --border: #2b3441;
    --border-strong: #3a4655;
    --text: #e6eaf2;
    --text-dim: #9aa5b8;
    --accent: #6c9bd8;
    --accent-hover: #85afe4;
    --accent-soft: #1e2a3b;
    --ok: #5cc48d;
    --warn: #e0a93f;
    --err: #f08c84;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

/* Must come before any `display` rule below. Author class selectors such as
   .session / .grid-2 / .range outrank the UA stylesheet's
   [hidden] { display: none }, which would leave `hidden` elements visible. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC",
    "Noto Sans TC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- top bar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  flex: none;
}

.brand h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: .01em; }
.brand-sub { margin: 0; font-size: 12.5px; color: var(--text-dim); }

.session { display: flex; align-items: center; gap: 12px; }
.session-text { display: flex; flex-direction: column; line-height: 1.35; text-align: right; }
.session-text strong { font-size: 13.5px; }
.session-text span { font-size: 12px; color: var(--text-dim); word-break: break-all; }

/* ---------- layout ---------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding-block: 22px 40px;
  padding-inline: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 22px;
  margin-bottom: 18px;
}

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.card-head h2 { margin: 0; font-size: 15.5px; font-weight: 650; }

.step {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  flex: none;
}

.card-desc { margin: 0 0 16px; color: var(--text-dim); font-size: 12.8px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0 20px;
}

/* ---------- fields ---------- */
.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-weight: 600;
  font-size: 12.8px;
  margin-bottom: 6px;
}
.field small { display: block; margin-top: 5px; color: var(--text-dim); font-size: 12px; }

input[type=text], input[type=password], input[type=date], textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

textarea { resize: vertical; min-height: 62px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

input:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: var(--surface);
}

.check { display: flex; gap: 9px; align-items: flex-start; font-size: 12.8px; margin-bottom: 16px; }
.check input { margin-top: 3px; flex: none; }

.range { display: flex; align-items: center; gap: 9px; margin-top: 9px; }
.range span { color: var(--text-dim); flex: none; }

/* ---------- segmented control ---------- */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-2);
  flex-wrap: wrap;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 7px 14px;
  font: inherit;
  font-size: 12.8px;
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--accent-soft); color: var(--accent); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.status { font-size: 12.8px; color: var(--text-dim); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.err { color: var(--err); }

/* ---------- section picker ---------- */
.section-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 9px;
}

.pick {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  cursor: pointer;
}
.pick:hover { border-color: var(--border-strong); }
.pick input { margin-top: 3px; flex: none; }
.pick strong { display: block; font-size: 13px; font-weight: 620; }
.pick span { display: block; font-size: 12px; color: var(--text-dim); }

.advanced {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: var(--surface-2);
}
.advanced summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.advanced[open] summary { margin-bottom: 12px; }
.advanced code {
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ---------- results ---------- */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  background: var(--surface-2);
}
.stat .k { font-size: 11.5px; color: var(--text-dim); text-transform: none; }
.stat .v { font-size: 19px; font-weight: 650; line-height: 1.3; }
.stat .v.small { font-size: 13.5px; font-weight: 600; }

.sticky-actions {
  position: sticky;
  top: 74px;
  background: var(--surface);
  padding: 10px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.rgroup { margin-top: 20px; }

.rgroup-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.rgroup-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.badge {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
}
.jql {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.8px;
  color: var(--text-dim);
  word-break: break-all;
  flex-basis: 100%;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }

table { border-collapse: collapse; width: 100%; min-width: 780px; font-size: 12.8px; }

th, td {
  text-align: left;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  background: var(--surface-2);
  font-weight: 620;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr.off { opacity: .42; }
td.c-pick, th.c-pick { width: 34px; padding-right: 0; }
td.c-key { white-space: nowrap; font-family: ui-monospace, Consolas, monospace; }
td.c-sum { min-width: 300px; }
td.c-nowrap { white-space: nowrap; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.breakdown {
  margin: 0 0 10px;
  color: var(--text-dim);
  font-size: 12.4px;
  line-height: 1.7;
}

.empty {
  padding: 16px;
  color: var(--text-dim);
  font-size: 12.8px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  text-align: center;
}

.footnote { color: var(--text-dim); font-size: 12px; text-align: center; margin-top: 24px; }

@media (max-width: 560px) {
  .sticky-actions { position: static; }
  th { position: static; }
}
