:root {
  color-scheme: light;
  --ink: #202723;
  --muted: #6c746f;
  --line: #d9dedb;
  --soft: #f4f6f4;
  --surface: #ffffff;
  --green-900: #173f35;
  --green-700: #276551;
  --green-100: #e2eee9;
  --red-700: #a84535;
  --red-100: #f6e7e3;
  --gold-700: #8b6818;
  --gold-100: #f4edd6;
  --blue-700: #315f86;
  --blue-100: #e4edf5;
  --shadow: 0 12px 30px rgba(24, 48, 40, 0.12);
  --sidebar-width: 224px;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--soft);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-size: 14px;
  line-height: 1.55;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  background: var(--green-900);
  color: #fff;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 6px;
  background: #f3f0d8;
  color: var(--green-900);
  font-size: 18px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
  letter-spacing: 0;
}

.brand strong {
  font-size: 16px;
}

.brand span {
  margin-top: 1px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
}

.side-nav {
  display: grid;
  gap: 4px;
  margin-top: 20px;
}

.nav-item {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  text-align: left;
}

.nav-item span {
  width: 18px;
  display: inline-grid;
  place-items: center;
  color: #c9d9d2;
  font-size: 16px;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.field-season span,
.field-season strong {
  display: block;
}

.field-season span {
  color: rgba(255, 255, 255, 0.58);
  font-size: 11px;
}

.field-season strong {
  margin-top: 3px;
  font-size: 12px;
}

.text-button {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.64);
  font-size: 11px;
}

.text-button:hover {
  color: #fff;
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  z-index: 15;
}

.page-heading {
  min-width: 180px;
  margin-right: auto;
}

.page-heading h1,
.page-heading p {
  margin: 0;
  letter-spacing: 0;
}

.page-heading h1 {
  font-size: 19px;
  line-height: 1.3;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-switch {
  display: flex;
  min-width: 204px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.role-switch button {
  flex: 1;
  min-width: 62px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.role-switch button.active {
  background: var(--surface);
  color: var(--green-900);
  box-shadow: 0 1px 4px rgba(22, 52, 43, 0.12);
  font-weight: 700;
}

.primary-button,
.secondary-button,
.icon-button,
.compact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 5px;
  font-weight: 650;
  white-space: nowrap;
}

.primary-button,
.secondary-button {
  min-height: 36px;
  padding: 0 13px;
}

.primary-button {
  border: 1px solid var(--green-900);
  background: var(--green-900);
  color: #fff;
}

.primary-button:hover {
  background: var(--green-700);
  border-color: var(--green-700);
}

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

.secondary-button:hover {
  border-color: #aeb8b2;
  background: var(--soft);
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
}

.compact-button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--green-900);
  font-size: 12px;
}

.compact-button:hover {
  border-color: var(--green-700);
}

.content {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px 26px 42px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  min-height: 110px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent, var(--green-700));
  border-radius: 6px;
  background: var(--surface);
}

.kpi-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 8px;
}

.kpi-value strong {
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0;
}

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

.trend {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.trend.up {
  background: var(--red-100);
  color: var(--red-700);
}

.trend.down,
.trend.good {
  background: var(--green-100);
  color: var(--green-700);
}

.dashboard-grid,
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.9fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

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

.panel-header h2,
.panel-header p {
  margin: 0;
  letter-spacing: 0;
}

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

.panel-header p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.panel-body {
  padding: 16px;
}

.chart-frame {
  position: relative;
  height: 246px;
  min-height: 246px;
}

.chart-frame svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-grid-line {
  stroke: #e6eae7;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--red-700);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  fill: rgba(168, 69, 53, 0.08);
}

.chart-dot {
  fill: #fff;
  stroke: var(--red-700);
  stroke-width: 2;
}

.chart-label {
  fill: var(--muted);
  font-size: 10px;
}

.metric-list {
  display: grid;
  gap: 16px;
}

.metric-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 10px;
}

.metric-row span,
.metric-row strong {
  font-size: 12px;
}

.metric-row strong {
  text-align: right;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #e6eae7;
}

.progress-track i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--fill, var(--green-700));
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 10px;
}

.section-heading h2,
.section-heading p {
  margin: 0;
  letter-spacing: 0;
}

.section-heading h2 {
  font-size: 16px;
}

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

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

.filter-group,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-input,
.filter-select,
.form-control {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
  background: #fff;
  color: var(--ink);
}

.filter-input {
  width: min(240px, 100%);
}

.filter-select {
  min-width: 118px;
}

.filter-input:focus,
.filter-select:focus,
.form-control:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(39, 101, 81, 0.11);
}

.segmented {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.segmented button {
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.segmented button.active {
  background: #fff;
  color: var(--green-900);
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

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

.data-table th {
  background: #f8f9f8;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.data-table tbody tr:hover {
  background: #fafcfb;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.cell-main,
.cell-sub {
  display: block;
}

.cell-main {
  font-weight: 650;
}

.cell-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.price-number {
  color: var(--red-700);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

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

.status-green {
  background: var(--green-100);
  color: var(--green-700);
}

.status-red {
  background: var(--red-100);
  color: var(--red-700);
}

.status-gold {
  background: var(--gold-100);
  color: var(--gold-700);
}

.status-blue {
  background: var(--blue-100);
  color: var(--blue-700);
}

.notice-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid #ead9a8;
  border-left: 4px solid var(--gold-700);
  border-radius: 5px;
  background: #fffaf0;
  color: #665522;
}

.notice-strip strong {
  white-space: nowrap;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.kanban-column {
  min-width: 0;
}

.kanban-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 2px;
}

.kanban-heading h2 {
  margin: 0;
  font-size: 14px;
}

.count-badge {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: #e6eae7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

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

.issue-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--priority, var(--blue-700));
  border-radius: 5px;
  background: #fff;
}

.issue-card h3,
.issue-card p {
  margin: 0;
  letter-spacing: 0;
}

.issue-card h3 {
  margin-top: 8px;
  font-size: 13px;
}

.issue-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.issue-meta,
.issue-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.issue-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.entity-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-band {
  padding: 13px 15px;
  border-left: 4px solid var(--accent, var(--green-700));
  background: #fff;
}

.summary-band span,
.summary-band strong {
  display: block;
}

.summary-band span {
  color: var(--muted);
  font-size: 11px;
}

.summary-band strong {
  margin-top: 3px;
  font-size: 20px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 0;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 12px;
  width: 1px;
  background: var(--line);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 16px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  margin: 7px auto 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--green-700);
  box-shadow: 0 0 0 1px var(--green-700);
  z-index: 1;
}

.timeline-item h3,
.timeline-item p {
  margin: 0;
}

.timeline-item h3 {
  font-size: 13px;
}

.timeline-item p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.support-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
  gap: 14px;
}

.support-request-list,
.resource-list {
  display: grid;
}

.support-request,
.resource-item {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.support-request:last-child,
.resource-item:last-child {
  border-bottom: 0;
}

.support-request-head,
.support-meta,
.match-result,
.resource-head,
.resource-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.support-request h3,
.support-request p,
.resource-item h3,
.resource-item p {
  margin: 0;
  letter-spacing: 0;
}

.support-request h3 {
  margin-top: 11px;
  font-size: 15px;
}

.support-request > p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.support-meta {
  margin-top: 11px;
  color: var(--muted);
  font-size: 11px;
}

.match-result {
  margin-top: 13px;
  padding: 11px 12px;
  border-left: 3px solid var(--gold-700);
  background: #fbfaf5;
}

.match-result.matched {
  border-left-color: var(--green-700);
  background: #f4f8f6;
}

.match-result span,
.match-result strong,
.match-result small {
  display: block;
}

.match-result span,
.match-result small {
  color: var(--muted);
  font-size: 10px;
}

.match-result strong {
  margin-top: 2px;
  font-size: 12px;
}

.match-result small {
  margin-top: 2px;
}

.request-actions {
  flex: 0 0 auto;
}

.service-result {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  color: var(--green-700);
  font-size: 11px;
}

.service-result strong {
  flex: 0 0 auto;
}

.resource-panel {
  align-self: start;
}

.resource-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-900);
  font-weight: 800;
}

.resource-head > div:nth-child(2) {
  min-width: 0;
  margin-right: auto;
}

.resource-head h3 {
  font-size: 13px;
}

.resource-head p,
.resource-org {
  color: var(--muted);
  font-size: 10px;
}

.resource-org {
  margin-top: 9px !important;
}

.specialty-list {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 9px;
}

.resource-foot {
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.resource-foot strong {
  color: var(--ink);
}

.match-context {
  padding: 12px;
  border-left: 3px solid var(--green-700);
  background: var(--soft);
}

.match-context span,
.match-context strong,
.match-context small {
  display: block;
}

.match-context span,
.match-context small {
  color: var(--muted);
  font-size: 10px;
}

.match-context strong {
  margin: 3px 0;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 28, 24, 0.52);
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(620px, 100%);
  max-height: min(780px, calc(100vh - 40px));
  overflow: auto;
  border-radius: 7px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  position: sticky;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: #fff;
  z-index: 2;
}

.modal-header {
  top: 0;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  bottom: 0;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.modal-header h2,
.eyebrow {
  margin: 0;
  letter-spacing: 0;
}

.modal-header h2 {
  margin-top: 2px;
  font-size: 17px;
}

.eyebrow {
  color: var(--green-700);
  font-size: 10px;
  font-weight: 800;
}

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

.form-field {
  display: grid;
  gap: 6px;
}

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

.form-field label {
  font-size: 12px;
  font-weight: 700;
}

.form-field textarea {
  min-height: 92px;
  resize: vertical;
}

.form-hint {
  color: var(--muted);
  font-size: 10px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: 5px;
  background: #202723;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 120;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mobile-only,
.mobile-nav {
  display: none;
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .role-switch {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 58px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    width: min(280px, 86vw);
    transition: transform 180ms ease;
    z-index: 40;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  .mobile-only {
    display: inline-flex;
  }

  .topbar {
    min-height: 66px;
    padding: 10px 14px;
    gap: 10px;
  }

  .page-heading h1 {
    font-size: 16px;
  }

  .page-heading p,
  .secondary-button[data-action="export-data"] {
    display: none;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .primary-button {
    min-width: 36px;
  }

  #primaryAction span:last-child {
    display: none;
  }

  .content {
    padding: 14px 12px 26px;
  }

  .kpi-grid,
  .entity-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kpi-card {
    min-height: 100px;
    padding: 13px;
  }

  .kpi-value strong {
    font-size: 22px;
  }

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

  .filter-group,
  .toolbar-actions {
    width: 100%;
  }

  .filter-input,
  .filter-select {
    flex: 1 1 130px;
    width: auto;
  }

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

  .support-layout {
    grid-template-columns: 1fr;
  }

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

  .support-meta,
  .match-result {
    align-items: flex-start;
    flex-direction: column;
  }

  .request-actions {
    width: 100%;
  }

  .request-actions .compact-button {
    width: 100%;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 7px 7px 0 0;
  }

  .modal-body {
    grid-template-columns: 1fr;
  }

  .form-field.full {
    grid-column: auto;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    height: 58px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid var(--line);
    background: #fff;
    z-index: 30;
  }

  .mobile-nav button {
    border: 0;
    background: #fff;
    color: var(--muted);
    font-size: 11px;
  }

  .mobile-nav button.active {
    color: var(--green-900);
    font-weight: 800;
  }

  .toast {
    right: 16px;
    bottom: 72px;
  }
}

@media (max-width: 420px) {
  .kpi-grid,
  .entity-summary {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-label {
    align-items: flex-start;
    flex-direction: column;
  }

  .notice-strip {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
