:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --text: #202421;
  --muted: #66706a;
  --line: #d8dfda;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #9a5b00;
  --danger: #b42318;
  --focus: #2f80ed;
  --shadow: 0 10px 28px rgba(20, 35, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow-y: auto;
}

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

button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.app-shell {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #000;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

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

.top-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.nav-btn {
  min-width: 78px;
  background: transparent;
  color: var(--muted);
}

.nav-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(20, 35, 28, 0.08);
}

.nav-btn span {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  place-items: center;
  border-radius: 999px;
  background: #dde8e4;
  color: var(--text);
  font-size: 12px;
}

.top-actions,
.stacked-actions {
  display: flex;
  gap: 8px;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
}

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

.ghost-btn {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  padding: 0 12px;
}

.ghost-btn:hover {
  background: #f8faf8;
}

.danger-btn {
  background: #fff3f1;
  border-color: #ffd0c9;
  color: var(--danger);
  padding: 0 12px;
}

.icon-btn {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
  font-size: 22px;
}

main {
  width: min(1500px, calc(100vw - 32px));
  margin: 18px auto 48px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-tile,
.panel,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-tile {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  text-align: left;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.metric-tile:hover {
  border-color: #aab8b1;
  transform: translateY(-1px);
}

.metric-tile.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12), var(--shadow);
}

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

.metric-tile strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  line-height: 1.1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1.5fr) repeat(2, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

.table-wrap {
  overflow: visible;
}

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

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

th {
  position: sticky;
  top: 0;
  background: #f9fbfa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

th:last-child,
td:last-child {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -8px 0 12px rgba(20, 35, 28, 0.04);
}

th:last-child {
  background: #f9fbfa;
}

tbody tr:hover {
  background: #fbfcfb;
}

.resource-title {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 560px;
}

.title-btn {
  min-height: 0;
  width: fit-content;
  max-width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.title-btn:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.resource-title a {
  color: var(--accent-strong);
  overflow-wrap: anywhere;
  text-decoration: none;
}

.resource-title p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.notes-cell {
  max-width: 260px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 310px;
}

.flag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 120px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #edf5f3;
  color: #19544f;
  padding: 2px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.attachment-count {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: #eef1f6;
  color: #35445d;
  padding: 2px 8px;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  min-width: 88px;
  justify-content: center;
  border-radius: 999px;
  background: #f1f4f1;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill.muted {
  background: #f5f6f5;
  color: #7b847e;
  display: none;
}

.flag-important {
  background: #fff1df;
  color: #7a3f00;
}

.flag-tracking {
  background: #e8f2ff;
  color: #1f4f87;
}

.flag-needs-verification {
  background: #fff6dd;
  color: #8a5a00;
}

.score {
  display: inline-flex;
  width: 46px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #eef7ef;
  color: #1b6430;
  font-weight: 700;
}

.score.mid {
  background: #fff6dd;
  color: var(--warn);
}

.score.low {
  background: #f4eeee;
  color: #7f2b24;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  min-width: 66px;
}

.split-layout,
.profile-layout,
.data-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(420px, 1.4fr);
  gap: 14px;
}

.profile-layout {
  grid-template-columns: minmax(420px, 1.1fr) minmax(320px, 0.9fr);
}

.data-grid {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.panel {
  padding: 16px;
}

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

.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.panel-heading h2 {
  margin: 0;
}

.candidate-list {
  display: grid;
  gap: 10px;
}

.candidate-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.candidate-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.candidate-head strong {
  overflow-wrap: anywhere;
}

.candidate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.candidate-actions {
  display: flex;
  gap: 8px;
}

.code-editor {
  min-height: 360px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.profile-form {
  display: grid;
  gap: 12px;
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  margin-top: 12px;
  overflow: hidden;
}

summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--text);
  font-weight: 700;
}

.advanced-editor {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.advanced-editor button {
  justify-self: start;
}

.file-drop {
  margin-top: 10px;
  padding: 16px;
  border: 1px dashed #b5c3bc;
  border-radius: 8px;
  background: #fbfcfb;
}

.file-drop span {
  color: var(--text);
  font-weight: 700;
}

.file-drop input {
  margin-top: 10px;
  padding: 6px;
}

.file-drop.compact {
  margin-top: 0;
}

.attachment-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px;
}

.attachment-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.attachment-head h3 {
  margin: 0;
  font-size: 15px;
}

.attachment-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.attachment-actions {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(320px, 1.25fr);
  gap: 12px;
}

.paste-box {
  display: grid;
  gap: 8px;
}

.paste-box button {
  justify-self: start;
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.attachment-item strong,
.attachment-item span {
  display: block;
  overflow-wrap: anywhere;
}

.attachment-item span,
.empty-attachments {
  color: var(--muted);
  font-size: 12px;
}

.attachment-item-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.empty-attachments {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.state-list {
  margin: 0;
}

.state-list div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.state-list dt {
  color: var(--muted);
  font-weight: 700;
}

.state-list dd {
  margin: 0;
}

dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(20, 35, 28, 0.22);
}

dialog::backdrop {
  background: rgba(20, 35, 28, 0.42);
}

#resourceForm,
.detail-dialog {
  padding: 18px;
}

.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-heading {
  margin-bottom: 14px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 4px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.flag-fieldset {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px 10px;
}

.flag-fieldset legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 0 4px;
}

.check-option {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 3px 9px;
  font-size: 13px;
  font-weight: 600;
}

.check-option input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.dialog-actions .danger-btn {
  margin-right: auto;
}

.detail-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 4px;
}

.detail-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px 12px;
}

.detail-row-long {
  grid-column: 1 / -1;
}

.detail-row h3 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
}

.detail-row span,
.detail-row a {
  color: var(--text);
  overflow-wrap: anywhere;
}

.detail-row a {
  color: var(--accent-strong);
  text-decoration: none;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.hidden {
  display: none !important;
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: none;
  max-width: 420px;
  border-radius: 8px;
  background: #20312c;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

#toast.show {
  display: block;
}

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

  .top-nav,
  .top-actions {
    overflow-x: auto;
  }

  .toolbar,
  .metrics,
  .split-layout,
  .profile-layout,
  .data-grid {
    grid-template-columns: 1fr;
  }

  th {
    top: 0;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100vw - 20px, 1500px);
    margin-top: 10px;
  }

  .app-shell {
    padding: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .nav-btn {
    min-width: 88px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .detail-content {
    grid-template-columns: 1fr;
  }

  .attachment-actions,
  .attachment-item {
    grid-template-columns: 1fr;
  }

  .attachment-item {
    display: grid;
  }
}
