/* SW Issue Board — self-hosted, no external resources (China-friendly) */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --good-text: #006300;
  --bad: #d03b3b;
  --bad-bg: rgba(208, 59, 59, 0.08);
  --good-bg: rgba(12, 163, 12, 0.08);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 4px 16px rgba(11, 11, 11, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --good: #0ca30c;
    --good-text: #0ca30c;
    --bad: #e66767;
    --bad-bg: rgba(230, 103, 103, 0.12);
    --good-bg: rgba(12, 163, 12, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 50;
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-size: 15px; letter-spacing: .2px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.logo {
  width: 28px; height: 28px; border-radius: 7px; flex: none;
  background: var(--accent);
  background-image: linear-gradient(0deg, transparent 0, transparent 100%);
  position: relative;
}
.logo::after {
  content: ""; position: absolute; inset: 7px 6px;
  background:
    linear-gradient(#fff, #fff) 0 0 / 100% 3px no-repeat,
    linear-gradient(#fff, #fff) 0 50% / 100% 3px no-repeat,
    linear-gradient(#fff, #fff) 0 100% / 64% 3px no-repeat;
  border-radius: 2px;
}
.logo.big { width: 44px; height: 44px; border-radius: 11px; margin: 0 auto; }
.actions { display: flex; align-items: center; gap: 10px; }

/* tabs */
.tabs-scroll { overflow-x: auto; scrollbar-width: thin; }
.tabs { display: flex; gap: 2px; padding-bottom: 0; white-space: nowrap; }
.tab {
  padding: 7px 12px 9px; color: var(--ink-2); border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent; font-size: 13px;
}
.tab em { font-style: normal; color: var(--muted); font-size: 11px; margin-left: 2px; }
.tab:hover { background: var(--page); text-decoration: none; }
.tab.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.tab.on em { color: var(--accent); }

/* ---------- buttons, pills, badges ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.wide { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.btn.small-btn { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.right { margin-left: auto; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 99px; font-size: 12px; white-space: nowrap;
  border: 1px solid var(--border); color: var(--ink-2); background: var(--surface);
}
.pill .dot { width: 7px; height: 7px; border-radius: 99px; flex: none; }
.pill.ok { color: var(--good-text); background: var(--good-bg); border-color: transparent; }
.pill.ok .dot { background: var(--good); }
.pill.no { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.pill.no .dot { background: var(--bad); }
.pill.na { color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
  background: var(--page); border: 1px solid var(--hairline); color: var(--ink-2); white-space: nowrap;
}
.badge2 { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; border: 1px solid var(--hairline); color: var(--ink-2); }
.badge2.a-create { color: var(--good-text); border-color: var(--good); }
.badge2.a-delete { color: var(--bad); border-color: var(--bad); }

/* ---------- main layout ---------- */
main.wrap { padding-top: 16px; padding-bottom: 32px; }
.pagehead { margin: 4px 0 14px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pagehead h1 { font-size: 20px; margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pagehead h1 small { font-size: 13px; color: var(--muted); font-weight: 400; }
.pagehead .meta { font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sub { color: var(--muted); font-size: 12.5px; }
.center { text-align: center; }

.flash {
  background: var(--good-bg); border: 1px solid var(--good);
  color: var(--good-text); padding: 9px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px;
}
.flash.err { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

.card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card h2 small { color: var(--muted); font-weight: 400; }
.card.narrow { max-width: 480px; }

/* ---------- filters ---------- */
.filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px;
}
.filters .search {
  flex: 1 1 220px; min-width: 180px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13px;
}
.filters select {
  padding: 7px 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13px;
}
.filters .count { color: var(--muted); font-size: 12.5px; margin-left: 4px; }

/* ---------- table ---------- */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list thead th {
  text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600;
  padding: 10px 10px; border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; background: var(--surface); z-index: 5; white-space: nowrap;
}
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr.rowlink { cursor: pointer; }
table.list tbody tr.rowlink:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
@supports not (background: color-mix(in srgb, red 5%, blue)) {
  table.list tbody tr.rowlink:hover { background: var(--page); }
}
td.num, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num-h { text-align: right !important; }
td.num { text-align: right; }
td.main { min-width: 260px; }
td.equip a { color: var(--ink); font-weight: 600; }
td.empty { text-align: center; color: var(--muted); padding: 28px 10px !important; }
.w-seq { width: 44px; } .w-date { width: 92px; } .w-done { width: 104px; }
.w-pay { width: 86px; } .w-owner { width: 90px; } .w-upd { width: 96px; } .w-sheet { width: 96px; } .w-equip { width: 130px; }
.clamp1, .clamp2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.clamp1 { -webkit-line-clamp: 1; }
.clamp2 { -webkit-line-clamp: 2; }
tr.dim td { color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 16px 0; color: var(--ink-2); }

/* ---------- forms ---------- */
.editform .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 14px; }
.editform .grid.four { grid-template-columns: repeat(4, 1fr); }
.editform .grid.one { grid-template-columns: 1fr; }
.editform label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.editform label.full { grid-column: 1 / -1; }
.editform input[type="text"], .editform input[type="date"], .editform input[type="password"],
.editform select, .editform textarea {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--page); color: var(--ink); font-family: inherit; font-size: 13.5px; font-weight: 400;
}
.editform textarea { resize: vertical; min-height: 38px; }
.editform input:focus, .editform select:focus, .editform textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent);
}
@supports not (outline: color-mix(in srgb, red 5%, blue)) {
  .editform input:focus, .editform select:focus, .editform textarea:focus { outline: 2px solid var(--accent); }
}
.formbar { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.hiddenform { display: none; }

/* ---------- history ---------- */
.history h2 small { color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { padding: 10px 0 10px 18px; border-left: 2px solid var(--hairline); position: relative; margin-left: 6px; }
.timeline > li::before {
  content: ""; position: absolute; left: -6px; top: 16px; width: 10px; height: 10px;
  border-radius: 99px; background: var(--surface); border: 2px solid var(--accent);
}
.tl-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.tl-changes { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tl-changes li { font-size: 12.5px; }
.fname { display: inline-block; min-width: 150px; color: var(--muted); font-weight: 600; font-size: 12px; }
.diff del, .diff-inline del { color: var(--bad); text-decoration: line-through; background: var(--bad-bg); border-radius: 4px; padding: 0 4px; }
.diff ins, .diff-inline ins { color: var(--good-text); text-decoration: none; background: var(--good-bg); border-radius: 4px; padding: 0 4px; }
.diff { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.diff-inline { word-break: break-word; }
details summary { cursor: pointer; color: var(--accent); font-size: 12px; }

/* ---------- stats ---------- */
.stattiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.tile {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px;
}
.tile .tlabel { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile .tvalue { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.tile .tvalue small { font-size: 16px; font-weight: 600; color: var(--ink-2); margin-left: 1px; }
.tile .tvalue.good { color: var(--good-text); }
.tile .tvalue.bad { color: var(--bad); }

table.stats td { vertical-align: middle; }
.w-meter { min-width: 170px; }
.meter { display: flex; align-items: center; gap: 10px; }
.meter .track {
  flex: 1; height: 10px; border-radius: 5px; background: var(--hairline); overflow: hidden; min-width: 90px;
}
.meter .fill { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.meter .mval { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-2); min-width: 38px; text-align: right; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--hairline); font-size: 13px;
}
.feed li:last-child { border-bottom: 0; }
.feed .fwhen { font-variant-numeric: tabular-nums; font-size: 12px; }
.feed .fwho { font-weight: 600; }
.feed .fdesc { color: var(--ink-2); max-width: 420px; }
.feed .ffields { font-size: 12px; }

/* ---------- menu ---------- */
details.menu { position: relative; }
details.menu summary {
  list-style: none; cursor: pointer; color: var(--ink-2); font-size: 13px;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
}
details.menu summary::-webkit-details-marker { display: none; }
details.menu[open] summary { background: var(--page); }
details.menu .pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; z-index: 60; display: flex; flex-direction: column;
}
details.menu .pop a, details.menu .pop button {
  padding: 8px 10px; border-radius: 7px; color: var(--ink); background: none; border: 0;
  text-align: left; font: inherit; font-size: 13px; cursor: pointer; width: 100%;
}
details.menu .pop a:hover, details.menu .pop button:hover { background: var(--page); text-decoration: none; }

.inline { display: inline-flex; gap: 6px; align-items: center; }
.inline-details { display: inline-block; }
.inline-details summary { list-style: none; display: inline-flex; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details form { margin-top: 6px; }
.inline-details input { padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--page); color: var(--ink); font-size: 12px; }
.actions-cell { white-space: nowrap; }
.actions-cell > * { margin-right: 6px; }

/* ---------- login ---------- */
body.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px;
}
.login-box {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand h1 { font-size: 20px; margin: 10px 0 2px; }
.login-brand p { color: var(--muted); font-size: 12.5px; margin: 0; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.login-form input {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--page); color: var(--ink); font-size: 14px; font-family: inherit;
}
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ---------- confirm dialog ---------- */
dialog.confirm {
  border: 1px solid var(--hairline); border-radius: 12px; background: var(--surface); color: var(--ink);
  padding: 20px; max-width: 320px; box-shadow: var(--shadow);
}
dialog.confirm::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog.confirm p { margin: 0 0 16px; font-size: 14px; }
dialog.confirm .dlg-bar { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- footer ---------- */
.foot { padding: 10px 16px 24px; color: var(--muted); font-size: 11.5px; }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .editform .grid, .editform .grid.four { grid-template-columns: 1fr 1fr; }
  .stattiles { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .hide-m { display: none !important; }
  body { font-size: 13.5px; }
  .brand small { display: none; }
}
@media (max-width: 560px) {
  .editform .grid, .editform .grid.four { grid-template-columns: 1fr; }
  .filters .search { flex-basis: 100%; }
  .pagehead h1 { font-size: 17px; }
}
