:root {
  --navy: #092765;
  --navy-2: #12357f;
  --bg: #eef2f7;
  --card: #fff;
  --line: #d9e0ec;
  --text: #1b2433;
  --muted: #5d6b80;
  --urgent: #b42318;
  --soon: #b54708;
  --ok: #067647;
  --fail: #b42318;
  --chip: #e8eef8;
  --row: #f7f9fc;
  --shadow: 0 1px 2px rgba(9, 39, 101, .06);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mobile-only { display: none; }

.top {
  background: var(--navy);
  color: #fff;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 220px; }
.mark { width: 14px; height: 28px; background: #f3c15a; border-radius: 2px; }
.top h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .02em; }
.top .subhead { margin: 1px 0 0; font-size: 13px; font-weight: 600; opacity: .95; }
.top p { margin: 2px 0 0; font-size: 12px; opacity: .85; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; justify-content: flex-end; }
.pill {
  font-size: 12px;
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 3px 8px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: #98a2b3; display: inline-block; }
.pill.ok i { background: #6ce9a6; }
.pill.partial i { background: #fec84b; }
.pill.fail i { background: #fda29b; }

.find {
  flex: none;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 10px;
}
.find-row { display: flex; gap: 8px; align-items: center; }
.q-wrap { flex: 1; min-width: 0; }
.q-wrap input {
  width: 100%;
  font-size: 16px;
  padding: 10px 14px;
  border: 1.5px solid var(--navy);
  border-radius: 10px;
  background: #fff;
}
.q-wrap input:focus { outline: 3px solid rgba(9,39,101,.18); }
.origin { position: relative; flex: none; }
#origin-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 650;
  white-space: nowrap;
}
#origin-btn:hover { background: var(--navy-2); }
.origin-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  width: 320px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(9,39,101,.16);
  padding: 6px;
}
.origin-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--navy);
  text-decoration: none;
}
.origin-menu a:hover { background: var(--chip); }
.origin-menu strong { display: block; font-size: 14px; }
.origin-menu span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.hints { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hints button {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--navy);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
}
.hints button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.find-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
mark { background: #ffe08a; color: inherit; padding: 0 1px; border-radius: 2px; }

.layout { display: flex; flex: 1; min-height: 0; }
.side {
  width: 292px;
  flex: none;
  background: var(--card);
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 14px 14px 24px;
}
.side-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  font-size: 14px;
}
.search input:focus { outline: 2px solid rgba(9,39,101,.25); border-color: var(--navy); }
.block { margin-top: 14px; }
.block h2 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.hint { margin: 8px 0 4px; font-size: 12px; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.provinces { max-height: 168px; overflow: auto; padding-right: 2px; }
.cities { max-height: 132px; overflow: auto; padding-right: 2px; }
.checks label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--chip);
  color: var(--navy);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12.5px;
  user-select: none;
}
.checks label.on { background: var(--navy); color: #fff; }
.checks input { accent-color: var(--navy); }
.views { display: flex; flex-direction: column; gap: 6px; }
.views button, .tools button, .pager button, .ghost, .text-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
}
.views button { text-align: left; color: var(--navy); }
.views button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.text-btn { border: none; background: transparent; color: var(--navy); padding: 8px 0; }
.side-foot, footer { color: var(--muted); font-size: 12px; }
.side-foot { margin: 16px 0 0; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 10px 14px 8px; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.stats { font-size: 14px; }
.stats strong { font-size: 20px; color: var(--navy); }
.stats span { color: var(--muted); margin-left: 8px; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; }
.tools button:hover, .pager button:hover, .views button:hover { border-color: var(--navy-2); }
.legend { margin: 6px 0; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin: 0 3px 0 8px; }
.dot.urgent { background: var(--urgent); }
.dot.soon { background: var(--soon); }
.dot.over { background: #98a2b3; }

.table-wrap { flex: 1; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.c-ck { width: 3%; }
.c-title { width: 24%; }
.c-region { width: 9%; }
.c-line { width: 9%; }
.c-stage { width: 5%; }
.c-type { width: 7%; }
.c-buyer { width: 12%; }
.c-budget { width: 6%; }
.c-pub { width: 8%; }
.c-due { width: 7%; }
.c-src { width: 10%; }
th, td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
td.stage, th.stage { white-space: nowrap; text-align: center; }
td.region, td.source, td.buyer, td.line { line-height: 1.35; }
td.source { font-size: 12px; }
td.title, td.buyer, td.source, td.region, td.line { overflow-wrap: break-word; }
th.date, td.date, th.num, td.num { white-space: nowrap; }
th {
  position: sticky; top: 0; background: #f4f7fb; z-index: 2;
  font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap;
}
.sortable { cursor: pointer; color: var(--navy); }
.sortable .arr { font-size: 10px; margin-left: 2px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.title a { color: var(--navy); font-weight: 650; text-decoration: none; }
.title a:hover { text-decoration: underline; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tag {
  display: inline-block; background: var(--chip); color: var(--navy);
  border-radius: 4px; padding: 0 5px; margin: 0 4px 2px 0; font-size: 12px; white-space: normal;
}
.tag.award { background: #e7f6ee; color: var(--ok); }
.tag.urgent { background: #fee4e2; color: var(--urgent); }
.due.urgent { color: var(--urgent); font-weight: 700; }
.due.soon { color: var(--soon); font-weight: 700; }
.due.over { color: #98a2b3; }
tr:hover td { background: var(--row); }
.ck { width: 32px; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

.pager { display: flex; gap: 10px; align-items: center; padding: 8px 2px 4px; flex-wrap: wrap; }
.pager select { margin-left: 4px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: #fff; }
footer { padding: 4px 2px 8px; }

#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 8px 14px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30;
}
#toast.show { opacity: 1; }

.print-only { display: none; }

@media (max-width: 1440px) {
  .side { width: 240px; }
  main { padding: 8px 10px 6px; }
}
@media (max-width: 960px) {
  .mobile-only { display: inline-flex; }
  .find-row { flex-wrap: wrap; }
  .origin, #origin-btn { width: 100%; }
  .origin-menu { left: 0; right: 0; width: auto; }
  .layout { height: auto; display: block; min-height: 0; flex: none; }
  .side {
    position: fixed; z-index: 25; top: 0; left: 0; bottom: 0; width: min(320px, 88vw);
    transform: translateX(-105%); transition: transform .2s ease;
  }
  .side.open { transform: none; }
  .mask { display: none; position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 24; }
  .mask.show { display: block; }
  main { padding: 10px; }
  .top { flex-wrap: wrap; }
  .sources { margin-left: 0; }
}
@media print {
  .top, .find, .side, .mask, .toolbar, .legend, .pager, footer, #toast { display: none !important; }
  .layout { display: block; height: auto; }
  main { padding: 0; }
  .table-wrap { overflow: visible; border: none; box-shadow: none; }
  table { min-width: 0; font-size: 11px; }
  th { position: static; }
  a { color: #000; text-decoration: none; }
  .ck, .ck input { display: none; }
  .title a::after {
    content: " " attr(href);
    display: block;
    font-weight: 400;
    font-size: 10px;
    color: #333;
    word-break: break-all;
  }
  .print-head { display: block; margin-bottom: 8px; }
  .print-head h1 { font-size: 18px; margin: 0; color: #092765; }
  .print-head p { margin: 4px 0; color: #333; }
}
