:root {
  --paper: #eef1f6;
  --ticket: #ffffff;
  --ink: #152033;
  --muted: #5d6676;
  --line: #e2e6ee;
  --line-strong: #c8d0dc;
  --rust: #1d4ed8;
  --rust-ink: #163ea8;
  --stamp-pending: #c2410c;
  --stamp-doing: #b45309;
  --stamp-returned: #4b5563;
  --stamp-done: #3f6212;
  --danger: #be123c;
  --pending-bg: #fff7ed;
  --doing-bg: #fffbeb;
  --returned-bg: #f3f4f6;
  --done-bg: #f0fdf4;
  --warn-bg: #fff1f2;
  --current-bg: #eff6ff;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(21, 32, 51, 0.05);
  --shadow-md: 0 8px 24px rgba(21, 32, 51, 0.08);
  --focus: 0 0 0 3px rgba(29, 78, 216, 0.16);
  --display: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  --side: 220px;
  --hover: #f5f7fa;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--rust); }
a:hover { color: var(--rust-ink); }

button, input, select, textarea { font: inherit; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  width: var(--side);
  height: 100vh;
  flex-shrink: 0;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
  background: #f7f8fb;
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0 18px;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: block;
  color: var(--ink);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid transparent;
}

.nav-link:hover { background: var(--hover); color: var(--ink); }
.nav-link.active {
  background: var(--ticket);
  border-color: var(--line);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.side-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.who-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.who-box:hover { background: var(--hover); }

.who-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dbe4f5;
  color: var(--rust-ink);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.who { font-weight: 600; font-size: 13px; }
.who-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-sub { color: var(--muted); margin-top: 4px; font-size: 13px; }

.crumb {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }

.stamps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stamps-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stamps-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stamp-num { min-width: 0; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
body.member-home .dash-grid {
  grid-template-columns: minmax(0, 1fr);
}
.dash-top, .dash-mid { align-items: start; }

.panel {
  background: var(--ticket);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.panel-body {
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 220px;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.panel-body.tall { max-height: 320px; }
.panel-body.short { max-height: 168px; }
.dash-top .panel { height: 360px; }
.dash-top .panel-body { flex: 1; max-height: none; }

.progress-list { list-style: none; }
.progress-list li { border-bottom: 1px solid var(--line); }
.progress-list li:last-child { border-bottom: 0; }
.progress-list a { display: block; color: inherit; text-decoration: none; padding: 10px 0; }
.progress-title { font-weight: 500; display: flex; gap: 8px; align-items: center; }
.progress-body { color: var(--ink); font-size: 13px; margin: 6px 0 4px; }
.progress-meta { color: var(--muted); font-size: 12px; }
.cfg-form { max-width: 520px; }

.bar-row {
  display: grid;
  grid-template-columns: 7.5em 1fr 4.2em;
  gap: 8px;
  align-items: center;
  margin: 7px 0;
  font-size: 13px;
}
.bar-lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-lab a { color: inherit; text-decoration: none; }
.bar-track { height: 6px; background: var(--hover); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--ink); border-radius: 99px; }
.bar-fill.pending { background: var(--stamp-pending); }
.bar-fill.doing { background: var(--stamp-doing); }
.bar-fill.returned { background: var(--stamp-returned); }
.bar-fill.done { background: var(--stamp-done); }
.bar-n { font-family: var(--mono); font-size: 12px; text-align: right; color: var(--muted); }

.spark {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 80px;
  padding-top: 8px;
}
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; }
.spark-bar { width: 100%; max-width: 18px; background: var(--rust); border-radius: 2px 2px 0 0; }
.spark-d { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 4px; }

.due-list { list-style: none; }
.due-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.due-list li:last-child { border-bottom: 0; }
.due-list a { color: inherit; text-decoration: none; }
.due-list a:hover { color: var(--rust); }
.due-list span { color: var(--muted); white-space: nowrap; font-size: 12px; }
.due-h {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.git-root {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.stamp-num {
  background: var(--ticket);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
}
.stamp-num.warn { background: var(--warn-bg); border-color: #fecdd3; }
.stamp-num.warn .n { color: var(--danger); }

.stamp-num .n {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stamp-num .l {
  margin-top: 7px;
  font-size: 12px;
  color: var(--muted);
}

.section { margin-bottom: 24px; }

.section-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.section-h h2 {
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-h .btn,
.section-h .page-sub {
  flex-shrink: 0;
}

.cards { display: flex; flex-direction: column; gap: 8px; }

.work-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--ticket);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.work-card:hover {
  background: var(--ticket);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  color: inherit;
}

.work-row {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 10px 4px 10px 0;
  border-bottom: 1px solid var(--line);
  max-width: 100%;
}
.work-row:last-child { border-bottom: 0; }
.work-row:hover { background: var(--hover); color: inherit; }
.work-row.is-late { box-shadow: inset 3px 0 0 var(--danger); padding-left: 8px; }
.work-row-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.work-row-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-row-mid { color: var(--ink); font-size: 13px; margin: 5px 0 4px; line-height: 1.45; overflow-wrap: anywhere; word-break: break-word; }
.work-row-meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.due-week { color: var(--stamp-doing); font-size: 11px; font-weight: 600; white-space: nowrap; }

.flow-legend {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  max-width: 46em;
  line-height: 1.5;
}

.flow-steps {
  display: flex;
  list-style: none;
  margin: 0 0 8px;
  border: 1px solid var(--line);
  background: var(--ticket);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.flow-steps li {
  flex: 1;
  text-align: center;
  padding: 9px 6px;
  font-size: 13px;
  color: var(--muted);
  border-right: 1px solid var(--line);
}
.flow-steps li:last-child { border-right: 0; }
.flow-steps li.done { color: var(--stamp-done); background: var(--done-bg); }
.flow-steps li.current { color: var(--rust-ink); font-weight: 600; background: var(--current-bg); }
.flow-steps li.warn { color: var(--danger); background: var(--warn-bg); }
.flow-note { font-size: 12px; color: var(--muted); margin: 0 0 16px; }

.login-demo {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 18px;
  padding: 10px 12px;
  background: var(--hover);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.load-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  min-width: 0;
}
.load-row:last-child { border-bottom: 0; }
.load-name {
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.load-name:hover { color: var(--rust); }
.load-n {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  flex: 0 1 auto;
  overflow-wrap: anywhere;
}

.work-card .row1 {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.work-no {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.work-title {
  font-size: 15px;
  font-weight: 600;
  margin: 4px 0 8px;
  max-width: 42em;
}

.work-meta {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.work-foot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.due-late { color: var(--danger); font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.pending { color: var(--stamp-pending); background: var(--pending-bg); border-color: #fed7aa; }
.badge.doing { color: var(--stamp-doing); background: var(--doing-bg); border-color: #fde68a; }
.badge.returned { color: var(--stamp-returned); background: var(--returned-bg); border-color: #e5e7eb; }
.badge.done { color: var(--stamp-done); background: var(--done-bg); border-color: #bbf7d0; }

.btn {
  font-size: 13px;
  border: 1px solid var(--line-strong);
  background: var(--ticket);
  color: var(--ink);
  padding: 6px 12px;
  cursor: pointer;
  min-height: 34px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover { background: var(--hover); color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  background: var(--rust);
  border-color: var(--rust);
  color: #fff;
}
.btn.primary:hover { background: var(--rust-ink); border-color: var(--rust-ink); color: #fff; }

.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover { background: var(--hover); border-color: transparent; }

.btn.danger { border-color: #fecdd3; color: var(--danger); background: var(--warn-bg); }
.btn.danger:hover { background: #ffe4e6; color: var(--danger); }

.btn.sm,
.section-h .btn,
.table-wrap .btn,
.side-foot .btn {
  min-height: 30px;
  padding: 3px 10px;
  font-size: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filters input,
.filters select,
.field input,
.field select,
.field textarea {
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  background: var(--ticket);
  color: var(--ink);
  border-radius: var(--radius-sm);
}

.filters input { min-width: 180px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field textarea { min-height: 96px; resize: vertical; }
.field input, .field select, .field textarea { width: 100%; }
.check-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--ticket);
}
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); font-weight: 400; }
.check-grid input[type=checkbox] { width: auto; margin: 0; }
.gl-repo { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.gl-repo:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.gl-repo h3 { font-size: 14px; margin-bottom: 6px; }
.gl-repo h3 a { color: inherit; text-decoration: none; }
.gl-repo h3 a:hover { color: var(--rust); }

.meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 12px 0;
  margin: 4px 0 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.meta-bar b { font-weight: 600; color: var(--ink); }
.meta-bar a { color: inherit; text-decoration: none; }
.meta-bar a:hover { color: var(--rust); }

.body-text {
  white-space: pre-wrap;
  max-width: 46em;
  margin-bottom: 22px;
}

.actions {
  background: var(--current-bg);
  border: 1px solid #dbeafe;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions .hint { color: var(--muted); font-size: 12px; margin-right: auto; }

.track { list-style: none; }
.track li {
  position: relative;
  padding: 0 0 16px 22px;
  border-left: 1px solid var(--line-strong);
}

.track li:last-child { border-left-color: transparent; padding-bottom: 0; }

.track li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 6px;
  width: 9px;
  height: 9px;
  background: var(--ticket);
  border: 2px solid var(--rust);
  border-radius: 50%;
}

.track .when {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.track .what { font-weight: 600; margin-top: 2px; }
.track .why { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: pre-wrap; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--ticket);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
}
tr:last-child td { border-bottom: 0; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--hover); }

.table-wrap td .btn { margin: 0 4px 0 0; }

.row-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--ticket);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.row-card:hover {
  background: var(--ticket);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  color: inherit;
}
.row-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.row-card p { color: var(--muted); font-size: 13px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.empty {
  padding: 32px 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.empty a { color: var(--rust); }

.feed { list-style: none; }
.feed li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.feed li:last-child { border-bottom: 0; }
.feed a { color: inherit; text-decoration: none; }
.feed a:hover { color: var(--rust); }
.feed .when { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, #dbe4f5 0%, transparent 60%),
    var(--paper);
}

.login-card {
  width: min(400px, 100%);
  background: var(--ticket);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 28px 26px 24px;
}

.login-card .brand { font-size: 22px; }

.person-block { margin-bottom: 28px; }
.person-h {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 10px;
}
.person-name {
  font-size: 18px;
  font-weight: 700;
}
.person-name a { color: inherit; text-decoration: none; }
.person-name a:hover { color: var(--rust); }
.person-h > div:last-child {
  display: flex;
  align-items: center;
  gap: 10px;
}
.person-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 1px solid var(--line);
  background: var(--ticket);
  color: var(--ink);
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}

dialog::backdrop { background: rgba(21, 32, 51, 0.36); }

.dlg-h {
  padding: 18px 18px 10px;
  font-size: 18px;
  font-weight: 700;
}

.dlg-b { padding: 0 18px 8px; }
.dlg-f {
  padding: 12px 18px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.err { color: var(--danger); font-size: 13px; min-height: 1.2em; }

.attach-list button.linkish {
  border: 0;
  background: none;
  padding: 0;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
}
.attach-list button.linkish:hover { text-decoration: underline; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  background: var(--ink);
  color: #f8fafc;
  padding: 10px 14px;
  font-size: 13px;
  display: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.note-card {
  background: var(--ticket);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  cursor: pointer;
}

.note-card:hover {
  background: var(--ticket);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}
.note-card h3 { font-size: 15px; font-weight: 600; margin: 4px 0 6px; }
.note-tags { color: var(--muted); font-size: 12px; }

@media print {
  .sidebar, .no-print, .toast, .side-foot { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  .panel, .work-card, .table-wrap { box-shadow: none; }
  body { background: #fff; }
}

@media (max-width: 960px) {
  .stamps-5, .stamps-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }
  .brand { font-size: 18px; margin: 0; }
  .brand-sub, .side-foot { display: none; }
  .sidebar > div:first-child { width: 100%; }
  .sidebar .side-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
  .main { padding: 18px 14px 36px; }
  .stamps, .stamps-5, .stamps-6, .grid-2, .dash-grid { grid-template-columns: 1fr; }
  .dash-top .panel { height: 300px; }
  .page-title { font-size: 22px; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
