:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --blue: #1677ff;
  --blue-soft: #eaf3ff;
  --red: #f04438;
  --red-soft: #fff1f0;
  --orange: #fa8c16;
  --orange-soft: #fff7ed;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

html {
  height: 100%;
}

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

button {
  cursor: pointer;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 64px;
  height: 64px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
}

.brand-mark svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button {
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  height: 34px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--text);
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.ghost-button:hover,
.primary-button:hover,
.icon-button:hover {
  filter: brightness(0.97);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 270px minmax(720px, 1fr) 420px;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
  padding: 12px 14px;
  min-height: 0;
  height: calc(100vh - 64px);
  overflow: hidden;
}

.sidebar,
.content,
.right-rail,
.detail,
.date-panel,
.table-panel,
.date-sentinel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.sidebar,
.right-rail {
  height: calc(100vh - 88px);
  min-height: 0;
  overflow: hidden;
  align-self: stretch;
}

.right-rail {
  background: transparent;
  border: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar {
  display: flex;
  flex-direction: column;
}

.content {
  background: transparent;
  border: 0;
  border-radius: 0;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
  height: calc(100vh - 88px);
  overflow: hidden;
  align-self: stretch;
}

.panel-header {
  height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h2 {
  font-size: 14px;
}

.panel-header span {
  color: var(--muted);
  font-size: 12px;
}

.search-box,
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 32px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  padding: 9px 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.taxonomy-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 10px 12px;
}

.taxonomy-group + .taxonomy-group {
  margin-top: 4px;
}

.all-risks,
.level1,
.level1-toggle,
.level2 {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.all-risks,
.level2 {
  width: 100%;
}

.all-risks,
.level1 {
  min-height: 32px;
  padding: 5px 8px;
  border-radius: 5px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.level1-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  border-radius: 5px;
}

.level1-row.active,
.level1-row:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.level1-toggle {
  width: 24px;
  height: 28px;
  padding: 0;
  border-radius: 5px;
  display: grid;
  place-items: center;
}

.level1 {
  width: 100%;
  padding-left: 0;
}

.all-risks {
  margin-bottom: 6px;
  border: 0;
  background: transparent;
}

.level1 em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
}

.all-risks em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
}

.chevron {
  width: 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  text-align: center;
}

.level2-list {
  padding: 2px 0 4px 8px;
}

.level2 {
  min-height: 28px;
  padding: 5px 8px 5px 24px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 12px;
}

.all-risks:hover,
.all-risks.active,
.level2:hover,
.level2.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 150px 150px;
  gap: 10px;
}

.field-wide {
  min-width: 0;
}

.date-sentinel {
  margin: 0;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 8px 10px;
  align-items: center;
  min-width: 0;
  border: 0;
  border-radius: 0;
  max-height: none;
  overflow: hidden;
}

.date-alert {
  border-color: #f2b4b4;
  background: var(--red-soft);
  box-shadow: none;
}

.date-main {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.date-label,
.date-picker span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.date-main strong {
  display: block;
  font-size: 18px;
  line-height: 1.15;
}

.date-main span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.date-picker {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}

.date-status {
  border: 0;
  border-radius: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  font-weight: 700;
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.status-dot.hot {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(200, 30, 30, 0.12);
}

.date-hits {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  min-width: 0;
  max-height: 132px;
  overflow: auto;
}

.date-hits > p {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}

.calendar-hit {
  border: 1px solid #ffd6d2;
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.calendar-hit h3 {
  margin-top: 5px;
  font-size: 13px;
}

.calendar-hit p {
  margin-top: 4px;
  color: #4b1f1f;
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.calendar-hit small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-hit a {
  color: var(--blue);
}

.calendar-hit button {
  align-self: center;
  height: 30px;
  border: 1px solid #e6a2a2;
  border-radius: 4px;
  background: #fff;
  color: var(--red);
  font-weight: 700;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.metric-row div {
  height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-row strong {
  display: block;
  font-size: 24px;
}

.metric-row span {
  color: var(--muted);
  font-size: 12px;
}

.table-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.table-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
}

td:first-child {
  min-width: 0;
}

.select-col {
  width: 42px;
  min-width: 42px;
  text-align: center;
}

.select-col input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.id-col,
th:nth-child(2),
td:nth-child(2) {
  width: 118px;
  min-width: 118px;
  color: #4b5563;
}

th:nth-child(3),
td:nth-child(3) {
  min-width: 280px;
}

th:nth-child(4),
td:nth-child(4) {
  min-width: 135px;
}

th:nth-child(5),
td:nth-child(5) {
  min-width: 160px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 76px;
  min-width: 76px;
}

th:nth-child(9),
td:nth-child(9) {
  width: 116px;
  min-width: 116px;
}

td strong {
  display: block;
  font-size: 13px;
}

td span:not(.tag) {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: var(--blue-soft);
}

.status-enabled {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #374151;
  font-size: 12px;
}

.status-enabled i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
}

.empty-row td {
  padding: 28px 18px;
  color: var(--muted);
  cursor: default;
}

.empty-row strong {
  color: var(--text);
  font-size: 15px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.high {
  background: var(--red-soft);
  color: var(--red);
}

.tag.medium {
  background: var(--orange-soft);
  color: var(--orange);
}

.tag.low {
  background: var(--green-soft);
  color: var(--green);
}

.tag.evidence {
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.date-panel {
  flex: 0 0 auto;
  min-height: 0;
  overflow: hidden;
}

.date-widget {
  padding: 10px 12px 12px;
}

.detail-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px 14px;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-meta {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px 10px;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.detail-meta div {
  display: contents;
}

.detail-meta span {
  color: var(--muted);
}

.detail-meta strong {
  color: var(--text);
  font-weight: 500;
}

.detail-title {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.detail-title h2 {
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.35;
}

.detail-title p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.detail-section {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.detail-section h3 {
  margin-bottom: 8px;
  font-size: 13px;
}

.detail-section p,
.detail-section li {
  color: #394150;
  font-size: 12px;
  line-height: 1.6;
}

.detail-section ul {
  margin: 0;
  padding-left: 18px;
}

.incident-list {
  display: grid;
  gap: 7px;
}

.incident-list li {
  padding-left: 1px;
}

.incident-list li::marker {
  color: #6b7280;
}

.inline-link-icon {
  width: 22px;
  height: 22px;
  margin-left: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-soft);
  color: #6b7280;
  display: inline-grid;
  place-items: center;
  vertical-align: -5px;
  text-decoration: none;
}

.inline-link-icon:hover,
.inline-link-icon:focus-visible {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  outline: none;
}

.inline-link-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-list span {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 8px;
  color: #394150;
  background: var(--surface-soft);
  font-size: 12px;
}

.link-list {
  display: grid;
  gap: 7px;
}

.link-list a {
  color: var(--blue);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.evidence-line {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.evidence-line span {
  color: var(--muted);
}

.detail-edit-form {
  display: grid;
  gap: 10px;
  padding-bottom: 10px;
}

.detail-edit-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-edit-form input,
.detail-edit-form select,
.detail-edit-form textarea {
  color: var(--text);
  font-weight: 400;
}

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.empty,
.load-error {
  color: var(--muted);
}

dialog {
  width: min(820px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.entry-form {
  padding: 18px;
}

.dialog-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.dialog-title h2 {
  font-size: 18px;
}

.dialog-title p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px 0;
}

.form-grid label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.span-2 {
  grid-column: span 2;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  html,
  body,
  .app-shell {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  body {
    min-width: 0;
  }

  .topbar {
    height: auto;
    padding: 14px;
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .workspace {
    display: block;
    padding: 10px;
    height: auto;
    overflow: visible;
  }

  .sidebar,
  .right-rail,
  .detail,
  .date-panel {
    min-height: auto;
    height: auto;
    margin-bottom: 10px;
  }

  .taxonomy-list {
    height: 280px;
  }

  .filters,
  .date-sentinel,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .table-panel {
    height: 520px;
    margin-bottom: 10px;
  }
}
