:root {
  --bg: #f7f9fc;
  --panel: #ffffff;
  --line: #d7e0ea;
  --text: #151a22;
  --muted: #657184;
  --blue: #0f4c81;
  --blue-strong: #073b66;
  --blue-soft: #e8f2fb;
  --green: #0f7a45;
  --green-soft: #e8f7ef;
  --red: #b42318;
  --red-soft: #fff1f0;
  --shadow: 0 18px 46px rgb(25 41 61 / 9%);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }
.asn-app { min-height: 100vh; padding: 22px; }
.topbar, .watch-panel, .detail-panel, .single-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.topbar {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 20px 22px;
}
.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { color: var(--blue-strong); font-size: clamp(24px, 3vw, 34px); line-height: 1.1; margin-bottom: 0; }
h2 { color: var(--blue-strong); font-size: clamp(22px, 2vw, 30px); line-height: 1.18; margin-bottom: 8px; }
h3 { font-size: 16px; margin-bottom: 10px; }
.global-status { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 8px 0 0; max-width: 880px; }
.top-actions, .detail-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.primary-button, .ghost-button, .danger-button {
  align-items: center;
  border-radius: 6px;
  border: 1px solid transparent;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
}
.primary-button { background: var(--blue); color: #fff; }
.ghost-button { background: #f7fbff; border-color: var(--line); color: var(--blue); }
.danger-button { background: var(--red-soft); border-color: #ffd0cc; color: var(--red); }
.compact { min-height: 32px; padding: 0 10px; }
.full { width: 100%; }
.link-button { background: transparent; border: 0; color: var(--blue); font-weight: 900; padding: 0; text-decoration: underline; }
.mini-actions { display: inline-flex; gap: 6px; }
.mini-button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  min-height: 28px;
  padding: 0 9px;
}
.mini-button.block { color: var(--red); }
.tabs {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 4px;
  margin-top: 14px;
  padding: 6px;
}
.tabs button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  font-weight: 900;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
}
.tabs button.active, .tabs button:hover { background: var(--blue-soft); border-color: #bdd8ee; color: var(--blue-strong); }
.tabs span {
  background: var(--blue);
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  min-width: 22px;
  padding: 2px 7px;
  text-align: center;
}
.metrics-grid { display: grid; gap: 12px; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 16px 0; }
.metric-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 94px;
  padding: 16px;
}
.metric-block span, .snapshot-strip span { color: var(--muted); display: block; font-size: 13px; margin-bottom: 8px; }
.metric-block strong, .snapshot-strip strong { color: var(--blue-strong); display: block; font-size: 28px; line-height: 1; }
.workspace { align-items: start; display: grid; gap: 16px; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
.tab-panel { display: none; }
.tab-panel.active { display: grid; }
.single-panel.active { display: block; }
.tag-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
  padding: 18px 22px;
}
.tag-form, .tool-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.tool-panel { background: #f8fbfe; }
.tool-panel p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.tool-search { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; margin-bottom: 14px; }
.tool-links { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-links a {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  padding: 8px 10px;
  text-decoration: none;
}
.table-tools { align-items: center; display: flex; gap: 10px; }
.table-tools input { min-width: 220px; }
.tag-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  padding: 5px 9px;
}
.tag-pill.favorite { background: #fff7da; color: #8a5b00; }
.tag-pill.block { background: var(--red-soft); color: var(--red); }
.tag-pill.watch { background: var(--blue-soft); color: var(--blue); }
.tag-pill.clean { background: var(--green-soft); color: var(--green); }
.tag-pill.risk { background: #fff4e5; color: #9a4d00; }
.note-cell { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.external-cell { display: inline-flex; gap: 8px; }
.watch-panel { padding: 16px; position: sticky; top: 16px; }
.add-form { display: grid; gap: 12px; }
label { color: var(--muted); display: grid; font-size: 13px; font-weight: 800; gap: 6px; }
input, select, textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  padding: 0 12px;
  width: 100%;
}
input, select { height: 42px; }
textarea { line-height: 1.45; min-height: 104px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(15 76 129 / 12%); }
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.list-tools { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.asn-list, .task-list { display: grid; gap: 8px; margin-top: 12px; max-height: calc(100vh - 420px); min-height: 220px; overflow: auto; padding-right: 3px; }
.asn-row, .task-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  min-height: 68px;
  padding: 12px;
  text-align: left;
}
.asn-row { align-items: center; display: flex; gap: 12px; justify-content: space-between; }
.task-row { display: grid; gap: 6px; }
.asn-row:hover, .asn-row.active, .task-row:hover, .task-row.active { background: var(--blue-soft); border-color: #8bb6dc; }
.asn-row.syncing { background: #fff8e5; border-color: #f2c665; }
.asn-row b, .asn-row small { display: block; }
.asn-row b, .task-row b { color: var(--blue-strong); font-size: 16px; }
.asn-row small, .task-row small, .task-row span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.asn-main { min-width: 0; }
.sync-time { margin-top: 4px; }
.sync-time.error { color: var(--red); }
.asn-count { align-items: center; display: grid; justify-items: center; gap: 3px; }
.asn-count small { font-size: 11px; }
.asn-row em {
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue);
  font-style: normal;
  font-weight: 800;
  min-width: 44px;
  padding: 5px 8px;
  text-align: center;
}
.detail-panel { min-height: 640px; overflow: hidden; }
.status-line {
  align-items: center;
  background: #f8fbfe;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 18px;
}
.detail-head { align-items: start; display: flex; gap: 18px; justify-content: space-between; padding: 22px; }
.holder { color: var(--muted); line-height: 1.5; margin-bottom: 0; max-width: 760px; }
.snapshot-strip {
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0 22px 18px;
  overflow: hidden;
}
.snapshot-strip.standalone { margin-top: 22px; }
.snapshot-strip div { background: #fff; min-height: 88px; padding: 14px; }
.change-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 22px 20px; }
.change-box { border: 1px solid var(--line); border-radius: 8px; min-height: 156px; padding: 16px; }
.change-box.add { background: var(--green-soft); border-color: #b8e4c9; }
.change-box.remove { background: var(--red-soft); border-color: #ffd0cc; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span {
  background: white;
  border: 1px solid rgb(15 26 40 / 10%);
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 9px;
}
.table-head { align-items: center; border-top: 1px solid var(--line); display: flex; gap: 14px; justify-content: space-between; padding: 18px 22px 12px; }
.table-head p { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.prefix-table { border: 1px solid var(--line); border-radius: 8px; margin: 0 22px 18px; max-height: 430px; overflow: auto; }
.prefix-table.tall { max-height: 640px; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); font-size: 13px; padding: 11px 12px; text-align: left; vertical-align: middle; white-space: nowrap; }
th { background: #f8fbfe; color: var(--muted); font-weight: 900; position: sticky; top: 0; z-index: 1; }
.mono { color: var(--blue-strong); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 800; }
.state-pill { border-radius: 999px; display: inline-flex; font-size: 12px; font-weight: 900; padding: 5px 8px; }
.state-pill.on { background: var(--green-soft); color: var(--green); }
.state-pill.off { background: #eef2f7; color: var(--muted); }
.history-panel { border-top: 1px solid var(--line); padding: 18px 22px 24px; }
.history-list { display: grid; gap: 8px; }
.history-row { align-items: center; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 10px; grid-template-columns: 110px repeat(4, minmax(0, 1fr)); min-height: 46px; padding: 10px 12px; }
.history-row b { color: var(--blue-strong); }
.history-row span { color: var(--muted); font-size: 13px; }
.empty-state { align-items: center; display: flex; flex-direction: column; justify-content: center; min-height: 560px; padding: 40px; text-align: center; }
.empty-note { color: var(--muted); }
@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace, .tag-layout { grid-template-columns: 1fr; }
  .watch-panel { position: static; }
}
@media (max-width: 760px) {
  .asn-app { padding: 12px; }
  .topbar, .detail-head, .table-head { align-items: stretch; flex-direction: column; }
  .metrics-grid, .snapshot-strip, .change-grid, .form-grid { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
  .tabs { overflow-x: auto; }
  .tabs button { white-space: nowrap; }
  .table-tools, .tool-search { align-items: stretch; flex-direction: column; display: flex; }
  th, td { font-size: 12px; padding: 10px; }
}
