:root {
  --canvas: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #edf4f1;
  --ink: #18312a;
  --muted: #63736e;
  --line: #d4dfda;
  --teal: #0f766e;
  --teal-dark: #0b5d57;
  --green: #4d7c0f;
  --amber: #a16207;
  --orange: #b45309;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(30, 59, 48, 0.08);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.32);
  outline-offset: 2px;
}

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

.sidebar {
  min-height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 26px 18px 18px;
  color: #eef8f3;
  background: #1d4037;
}

.brand-block {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 0 7px 27px;
  border-bottom: 1px solid rgba(237, 250, 244, 0.16);
}

.brand-mark {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 7px;
  color: #1d4037;
  background: #d6efde;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.brand-subtitle {
  margin-top: 3px;
  color: rgba(238, 248, 243, 0.66);
  font-size: 12px;
  line-height: 1.4;
}

.board-nav {
  display: grid;
  min-width: 0;
  gap: 6px;
  padding-top: 21px;
}

.board-nav-button {
  width: 100%;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: rgba(238, 248, 243, 0.86);
  background: transparent;
  text-align: left;
}

.board-nav-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.board-nav-button.is-active {
  border-color: rgba(206, 240, 220, 0.32);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.13);
}

.board-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.board-nav-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.board-nav-count {
  color: rgba(238, 248, 243, 0.6);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.sidebar-bottom {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(237, 250, 244, 0.16);
}

.link-button,
.text-button {
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.link-button {
  padding: 10px 7px;
  color: rgba(238, 248, 243, 0.76);
  font-size: 13px;
}

.link-button:hover {
  color: #ffffff;
}

.main-content {
  min-width: 0;
  padding: 28px clamp(22px, 3vw, 54px) 46px;
}

.topbar,
.section-heading,
.dialog-header,
.dialog-actions,
.settings-row,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  min-height: 58px;
}

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

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

h1 {
  margin-top: 4px;
  font-size: 27px;
  line-height: 1.25;
}

h2 {
  margin-top: 3px;
  font-size: 18px;
  line-height: 1.35;
}

h3 {
  font-size: 14px;
  line-height: 1.4;
}

.topbar-actions,
.record-filter,
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.primary-button,
.secondary-button,
.filter-button,
.icon-button {
  min-height: 36px;
  border-radius: 6px;
  font-weight: 700;
  transition: background-color 130ms ease, border-color 130ms ease, color 130ms ease;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  font-size: 13px;
}

.primary-button {
  border: 1px solid var(--teal);
  color: #ffffff;
  background: var(--teal);
}

.primary-button:hover:not(:disabled) {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.secondary-button:hover {
  border-color: #a9bcb4;
  background: #f7fbf8;
}

.board-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  margin-top: 36px;
  padding: 22px 0 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.board-header-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.board-header-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.board-header h2 {
  margin: 0;
  font-size: 23px;
}

.board-description {
  max-width: 720px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.board-meta {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(270px, 0.85fr);
  gap: 38px;
  padding: 30px 0 34px;
}

.focus-section,
.status-section,
.records-section {
  min-width: 0;
}

.section-heading {
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.text-button {
  padding: 6px 0;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
}

.text-button:hover {
  color: var(--teal);
}

.record-list,
.status-list {
  display: grid;
}

.record-list {
  border-bottom: 1px solid var(--line);
}

.record-summary {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 16px 0 16px 16px;
  border-bottom: 1px solid var(--line);
}

.record-summary:last-child {
  border-bottom: 0;
}

.record-summary::before {
  position: absolute;
  top: 20px;
  bottom: 20px;
  left: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--accent, var(--teal));
  content: "";
}

.record-summary-top,
.record-summary-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.record-summary-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-summary-date,
.record-meta,
.empty-message {
  color: var(--muted);
  font-size: 12px;
}

.record-summary-copy {
  display: -webkit-box;
  overflow: hidden;
  color: #43524d;
  font-size: 13px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid #d7e5de;
  border-radius: 4px;
  color: #416258;
  background: #f7fbf9;
  font-size: 11px;
}

.status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.status-row:last-child {
  border-bottom: 0;
}

.status-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.status-count {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.status-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.records-section {
  padding-top: 30px;
  border-top: 1px solid var(--line);
}

.filter-button {
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
}

.filter-button.is-active {
  border-color: #9ac9bd;
  color: var(--teal-dark);
  background: #e8f5f0;
}

.record-table-wrap {
  overflow-x: auto;
  margin-top: 16px;
  border-bottom: 1px solid var(--line);
}

.record-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  text-align: left;
}

.record-table th,
.record-table td {
  padding: 13px 10px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.record-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.record-table td {
  color: #3e4d48;
  font-size: 13px;
}

.record-table td:first-child,
.record-table th:first-child {
  padding-left: 0;
}

.table-title {
  max-width: 420px;
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.table-action {
  padding: 3px 0;
  border: 0;
  color: var(--teal-dark);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.table-action.danger {
  color: var(--danger);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.is-progress {
  color: #075e54;
  background: #d9f0e9;
}

.status-pill.is-complete,
.status-pill.is-reference {
  color: #466314;
  background: #e6f0d8;
}

.status-pill.is-pending,
.status-pill.is-blocked {
  color: #8a4e05;
  background: #f8ead1;
}

.app-dialog {
  width: min(720px, calc(100vw - 34px));
  max-height: min(860px, calc(100vh - 34px));
  padding: 0;
  border: 1px solid #d1ddd7;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgba(20, 48, 40, 0.36);
}

.app-dialog form,
.context-dialog,
.setup-dialog {
  display: grid;
  gap: 22px;
  padding: 22px;
}

.dialog-header {
  align-items: flex-start;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 23px;
  font-weight: 400;
  line-height: 1;
}

.icon-button:hover {
  color: var(--ink);
  background: #f4f8f6;
}

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

label,
.context-input-label {
  display: grid;
  gap: 7px;
  color: #45544f;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #cdd9d3;
  border-radius: 5px;
  color: var(--ink);
  background: #ffffff;
  font-size: 14px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

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

.dialog-actions {
  justify-content: flex-end;
  padding-top: 2px;
}

.context-dialog {
  width: min(680px, calc(100vw - 34px));
}

.context-result {
  min-height: 74px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #f8fbf9;
  font-size: 13px;
  line-height: 1.65;
}

.context-result.is-recognized {
  border-color: #a8d2c5;
  color: #185a4e;
  background: #eaf6f1;
}

.context-result.is-uncertain {
  border-color: #e5c28b;
  color: #7a500d;
  background: #fff8e9;
}

.context-choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.context-choice-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.context-choice-button {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.context-choice-button:hover,
.context-choice-button.is-selected {
  border-color: #8fc1b3;
  background: #eef8f4;
}

.settings-content {
  display: grid;
  gap: 18px;
  padding: 0 22px 22px;
}

.settings-row {
  align-items: flex-start;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.settings-row p {
  max-width: 540px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.toggle-row {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  padding: 2px 0;
}

.toggle-row input {
  width: 17px;
  min-height: 17px;
  height: 17px;
  accent-color: var(--teal);
}

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

.choice-button {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.choice-button:hover,
.choice-button.is-selected {
  border-color: #8fc1b3;
  background: #eef8f4;
}

.choice-button strong {
  font-size: 14px;
}

.choice-button span,
.dialog-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.cloud-dialog {
  width: min(780px, calc(100vw - 34px));
}

.cloud-content {
  display: grid;
  gap: 0;
  padding: 0 22px 22px;
  overflow-y: auto;
}

.cloud-section {
  display: grid;
  gap: 14px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.cloud-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.cloud-section-heading p,
.cloud-message {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.cloud-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.cloud-login-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.cloud-message.is-error {
  color: var(--danger);
}

.cloud-message.is-success {
  color: var(--teal-dark);
}

.cloud-sync-section {
  gap: 15px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 44px));
  padding: 11px 14px;
  border-radius: 6px;
  color: #ffffff;
  background: #1d4037;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.empty-message {
  padding: 24px 0;
  line-height: 1.6;
}

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

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

  .brand-block {
    padding: 0 0 14px;
  }

  .board-nav {
    display: flex;
    overflow-x: auto;
    padding-top: 14px;
  }

  .board-nav-button {
    flex: 0 0 auto;
    width: auto;
    grid-template-columns: 8px max-content auto;
  }

  .sidebar-bottom {
    display: none;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}

@media (max-width: 650px) {
  .main-content {
    padding: 20px 16px 32px;
  }

  .topbar,
  .section-heading,
  .board-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar,
  .section-heading {
    display: flex;
  }

  .topbar-actions,
  .topbar-actions .primary-button,
  .topbar-actions .secondary-button {
    width: 100%;
  }

  .board-header {
    display: grid;
    gap: 12px;
    margin-top: 24px;
  }

  .board-meta {
    text-align: left;
  }

  h1 {
    font-size: 23px;
  }

  .board-header h2 {
    font-size: 20px;
  }

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

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

  .settings-row,
  .settings-actions,
  .dialog-actions,
  .cloud-inline-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-row .secondary-button,
  .settings-actions .secondary-button,
  .dialog-actions .secondary-button,
  .dialog-actions .primary-button,
  .cloud-inline-actions .secondary-button,
  .cloud-inline-actions .primary-button {
    width: 100%;
  }
}
