:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #667085;
  --line: #d8dee6;
  --panel: #ffffff;
  --page: #f5f7fa;
  --sidebar: #17324d;
  --sidebar-soft: #244766;
  --accent: #1677ff;
  --accent-strong: #0f5ecc;
  --success: #14804a;
  --warning: #b76e00;
  --danger: #c62828;
  --cyan: #0f766e;
  --radius: 8px;
  font-family: "Microsoft YaHei UI", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  background: var(--page);
  color: var(--ink);
}

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

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: #edf6ff;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 28px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .34);
  background: rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.dialog-head h3,
.dialog-head p {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
}

.brand p,
.sidebar-note span {
  color: #bed3e7;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  color: #e2effb;
  background: transparent;
  min-height: 42px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  cursor: pointer;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: var(--sidebar-soft);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, .14);
  font-size: 12px;
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 4px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.actions,
.toolbar,
.dialog-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar h2 {
  font-size: 28px;
  line-height: 1.25;
}

.actions,
.dialog-actions {
  gap: 10px;
}

button {
  border-radius: var(--radius);
  min-height: 38px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.danger-button {
  background: #fff5f5;
  border-color: #ffc9c9;
  color: var(--danger);
}

.icon-button {
  width: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: white;
  font-size: 22px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 8px;
}

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

.metric strong {
  font-size: 28px;
}

.reminder-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  padding: 16px;
}

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

.section-head h3,
.section-head p {
  margin: 0;
}

.section-head h3 {
  font-size: 18px;
}

.section-head > span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.reminder-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.reminder-item {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fbfcfd;
  min-height: 96px;
}

.reminder-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reminder-item strong {
  display: block;
  margin-top: 5px;
}

.reminder-item p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 6px 0 0;
}

.reminder-item.danger {
  border-left-color: var(--danger);
}

.reminder-item.warning {
  border-left-color: var(--warning);
}

.reminder-item.info {
  border-left-color: var(--accent);
}

.reminder-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--muted);
}

.reminder-empty strong {
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}

.workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.toolbar {
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.search-box {
  flex: 1;
  min-width: 260px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: white;
}

.search-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-box input {
  border: 0;
  outline: 0;
  width: 100%;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.toolbar select {
  min-height: 40px;
  padding: 0 10px;
}

.table-wrap {
  overflow-x: auto;
  position: relative;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1320px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #fbfcfd;
  white-space: nowrap;
}

.sort-button {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: inherit;
  font-weight: inherit;
}

.sort-button span {
  width: 12px;
  color: #98a2b3;
  font-size: 11px;
}

.sort-button.active,
.sort-button:hover {
  color: var(--accent-strong);
}

td {
  font-size: 14px;
}

.muted-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 5px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.status,
.level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status.warning {
  background: #fff7e6;
  color: var(--warning);
}

.status.success {
  background: #eaf7ef;
  color: var(--success);
}

.status.info {
  background: #eaf3ff;
  color: var(--accent-strong);
}

.status.muted {
  background: #eef1f5;
  color: #52616f;
}

.level-a {
  background: #fff0f0;
  color: var(--danger);
}

.level-b {
  background: #e7f7f5;
  color: var(--cyan);
}

.level-c {
  background: #f2f4f7;
  color: #52616f;
}

.level-d {
  background: #fff7e6;
  color: var(--warning);
}

.level-none {
  background: #eef1f5;
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
  border-color: var(--line);
  background: white;
}

.contract-list {
  display: grid;
  gap: 6px;
  min-width: 190px;
}

.contract-pill {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: #ffffff;
}

.contract-pill strong,
.contract-pill span {
  display: block;
}

.contract-pill strong {
  color: var(--ink);
  font-size: 12px;
}

.contract-pill span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
}

.empty-state {
  padding: 42px;
  text-align: center;
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
}

dialog {
  width: min(860px, calc(100vw - 32px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 24px 70px rgba(31, 41, 51, .24);
}

dialog::backdrop {
  background: rgba(17, 24, 39, .45);
}

form {
  padding: 22px;
}

.history-panel {
  padding: 22px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.dialog-head h3 {
  font-size: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
}

.form-grid label,
.full-field {
  display: grid;
  gap: 7px;
}

.form-grid input,
.form-grid select,
.full-field textarea {
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
}

.full-field {
  margin-top: 14px;
}

.full-field textarea {
  resize: vertical;
  line-height: 1.5;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  margin-top: 18px;
}

.history-list {
  display: grid;
  gap: 12px;
  max-height: min(62vh, 620px);
  overflow: auto;
  padding-right: 4px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.history-head,
.history-change {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-head {
  justify-content: space-between;
}

.history-head span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.history-changes {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.history-change {
  align-items: flex-start;
  font-size: 13px;
}

.history-change b {
  min-width: 88px;
  color: var(--ink);
}

.history-change span {
  color: var(--muted);
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.history-change em {
  color: var(--accent);
  font-style: normal;
}

.history-actions {
  grid-template-columns: auto 1fr auto;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-note {
    display: none;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .metric-grid,
  .form-grid,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .dialog-actions span {
    display: none;
  }
}
