:root {
  --bg: #f3f6f4;
  --ink: #17201b;
  --muted: #6d7871;
  --panel: #ffffff;
  --line: #dde5df;
  --green: #16745f;
  --green-soft: #e7f4ee;
  --red: #d9342b;
  --red-soft: #fff0ef;
  --orange: #d88922;
  --blue: #346aa9;
  --teal: #237b83;
  --shadow: 0 18px 45px rgba(26, 41, 33, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.62;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

.sidebar {
  background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  color: white;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.logo-block {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.logo-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f3fff7;
  color: #1e3a8a;
  font-size: 22px;
  font-weight: 900;
}

.logo-block strong,
.logo-block span {
  display: block;
}

.logo-block span {
  margin-top: 4px;
  color: #c8dbf3;
  font-size: 13px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-nav button,
.sidebar-links a,
.shortcut-list a,
.shortcut-list button {
  min-height: 42px;
  border-radius: 8px;
  text-align: left;
  padding: 0 12px;
  background: transparent;
  color: #eaf2ff;
  font-weight: 700;
}

.side-nav button.active {
  background: #eff6ff;
  color: #1e3a8a;
}

.side-nav button:hover,
.sidebar-links a:hover {
  background: rgba(147, 197, 253, 0.36);
  color: #ffffff;
}

.sidebar-links {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.sidebar-links a {
  display: flex;
  align-items: center;
  border: 1px solid rgba(216, 231, 251, 0.26);
}

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

.topbar {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

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

.ghost,
.primary {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

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

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

.page {
  display: none;
}

.page.active {
  display: block;
}

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

.kpi-grid article,
.panel,
.chart-card,
.assessment-grid article,
.activity-board article,
.settlement-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-grid article {
  min-height: 116px;
  padding: 18px;
}

.kpi-grid span,
.kpi-grid em,
.settlement-grid span,
.metric-list span {
  display: block;
  color: var(--muted);
  font-style: normal;
}

.kpi-grid strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 34px;
  line-height: 1;
}

.red,
.danger-text {
  color: var(--red);
}

.dashboard-grid,
.content-grid,
.split-grid,
.family-layout {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
}

.content-grid,
.split-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel.wide {
  min-height: 420px;
}

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

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.store-map {
  position: relative;
  min-height: 430px;
  background:
    linear-gradient(90deg, rgba(22, 116, 95, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(22, 116, 95, 0.08) 1px, transparent 1px),
    #eef5f0;
  background-size: 44px 44px;
}

.map-node {
  position: absolute;
  min-width: 78px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(22, 116, 95, 0.25);
}

.map-node.red {
  background: var(--red);
}

.map-node.orange {
  background: var(--orange);
}

.task-list {
  padding: 14px;
  display: grid;
  gap: 12px;
}

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

.task-list article,
.ai-box,
.phone-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 14px;
}

.task-list article.critical {
  border-color: #efaaa5;
  background: var(--red-soft);
}

.task-list strong {
  display: block;
  margin-bottom: 8px;
}

.task-list p,
.ai-box p,
.profile-card p,
.phone-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.event-table,
.member-table {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.row {
  min-height: 48px;
  border-radius: 8px;
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: #fbfdfb;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
}

.event-table .row {
  grid-template-columns: 54px 1fr 90px 90px 80px;
}

.member-table .row {
  grid-template-columns: 100px 140px 100px minmax(180px, 1fr) 130px;
}

.row.head {
  min-height: 34px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.row.selected {
  border-color: #efaaa5;
  background: var(--red-soft);
}

.row.clickable {
  cursor: pointer;
}

.row.clickable:hover,
.task-list article.clickable:hover,
.activity-board article.clickable:hover,
.assessment-grid article.clickable:hover,
.settlement-grid article.clickable:hover,
.metric-list div.clickable:hover,
.chart-card.clickable:hover,
.map-node:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(26, 41, 33, 0.12);
}

.row.done-row,
.task-list article.done-card {
  border-color: #add8c5;
  background: #f0faf5;
}

.badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-size: 12px;
  font-weight: 900;
}

.badge.red {
  background: var(--red);
}

.badge.orange {
  background: var(--orange);
}

.badge.blue {
  background: var(--blue);
}

.event-command {
  min-height: 560px;
}

.member-strip {
  padding: 18px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
  font-size: 22px;
}

.avatar.large {
  width: 72px;
  height: 72px;
  margin-bottom: 12px;
  font-size: 32px;
}

.member-strip p {
  margin: 6px 0 0;
  color: var(--muted);
}

.sop-flow,
.action-grid {
  padding: 16px 18px;
  display: grid;
  gap: 10px;
}

.sop-flow {
  grid-template-columns: repeat(2, 1fr);
}

.sop-flow button,
.action-grid button,
.shortcut-list button,
.shortcut-list a {
  min-height: 42px;
  border-radius: 8px;
  background: #f3f7f5;
  color: var(--muted);
  font-weight: 800;
}

.sop-flow .done {
  background: var(--green-soft);
  color: var(--green);
}

.sop-flow .current {
  background: var(--red);
  color: white;
}

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

.action-grid button {
  background: #f7fbf9;
  color: var(--ink);
  border: 1px solid var(--line);
}

.action-grid button.done-action,
.shortcut-list button.done-action,
.phone-buttons button.done-action {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid #add8c5;
}

.ai-box {
  margin: 0 18px 18px;
  background: #f6fbf8;
  border-color: #cfe5dc;
}

.profile-card {
  padding: 18px;
}

.profile-card.updated {
  outline: 2px solid rgba(22, 116, 95, 0.28);
  outline-offset: -2px;
}

.tag-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tag-wrap span {
  border-radius: 99px;
  background: #fff2e2;
  color: #835015;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

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

dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.assessment-grid,
.activity-board,
.activity-rules,
.activity-form,
.settlement-grid,
.chart-row {
  padding: 16px;
  display: grid;
  gap: 14px;
}

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

.assessment-grid article,
.activity-board article,
.settlement-grid article,
.chart-card {
  padding: 18px;
}

.score {
  margin: 14px 0 10px;
  font-size: 44px;
  font-weight: 900;
  color: var(--green);
}

.score.red {
  color: var(--red);
}

.score.orange {
  color: var(--orange);
}

.assessment-grid p,
.activity-board p,
.settlement-grid p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.bars {
  height: 280px;
  display: flex;
  gap: 18px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.bars i {
  flex: 1;
  min-width: 18px;
  border-radius: 8px 8px 0 0;
  background: var(--red);
}

.bars.green i {
  background: var(--green);
}

.activity-board {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.activity-rules {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-bottom: 0;
}

.activity-form {
  grid-template-columns: 1.25fr repeat(2, minmax(0, 1fr));
  padding-bottom: 0;
}

.form-copy,
.upload-field {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 16px;
}

.form-copy strong,
.upload-field span,
.upload-field strong,
.upload-field em {
  display: block;
}

.form-copy strong,
.upload-field span {
  margin-bottom: 8px;
  font-weight: 900;
}

.form-copy p,
.upload-field em {
  margin-bottom: 0;
  color: var(--muted);
  font-style: normal;
  line-height: 1.55;
}

.upload-field {
  border-style: dashed;
  cursor: pointer;
}

.upload-field.uploaded {
  border-style: solid;
  border-color: #add8c5;
  background: #f0faf5;
}

.upload-field strong {
  margin-bottom: 6px;
  color: var(--green);
  font-size: 20px;
}

.activity-rules article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf9;
  padding: 14px;
}

.activity-rules strong {
  display: block;
  margin-bottom: 8px;
}

.activity-rules p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.activity-board span {
  display: block;
  color: var(--green);
  font-weight: 900;
  margin-bottom: 12px;
}

.shortcut-list {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.shortcut-list a {
  display: flex;
  align-items: center;
  background: var(--green);
  color: white;
}

.family-layout {
  grid-template-columns: 420px minmax(0, 1fr);
}

.phone {
  min-height: 680px;
  border: 10px solid #17201b;
  border-radius: 28px;
  background: #f7faf8;
  padding: 18px;
  box-shadow: var(--shadow);
}

.phone-bar,
.phone-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.phone-alert {
  margin: 18px 0;
  border-radius: 8px;
  background: var(--red);
  color: white;
  padding: 18px;
}

.phone-alert span {
  font-weight: 900;
  font-size: 12px;
}

.phone-alert p {
  margin-bottom: 0;
  line-height: 1.55;
}

.phone-card {
  margin-bottom: 12px;
}

.phone-buttons button {
  flex: 1;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 900;
}

.phone-buttons button:first-child {
  background: var(--green);
  color: white;
}

.phone-buttons button:last-child {
  border: 1px solid var(--line);
  background: white;
}

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 44px));
}

.toast {
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  animation: toast-in 180ms ease-out;
}

.toast strong {
  display: block;
  margin-bottom: 4px;
}

.toast p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.toast.warn {
  border-left-color: var(--orange);
}

.toast.danger {
  border-left-color: var(--red);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  background: rgba(13, 28, 22, 0.42);
  padding: 22px;
}

.modal-backdrop.open {
  display: grid;
}

.modal {
  width: min(560px, 100%);
  border-radius: 8px;
  background: white;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
}

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

.modal-body {
  padding: 18px;
  color: var(--muted);
  line-height: 1.65;
}

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

.modal-body label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  color: var(--ink);
}

.modal-body textarea {
  grid-column: 1 / -1;
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

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

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #f2f6f3;
  color: var(--ink);
  font-size: 22px;
}

.pulse-once {
  animation: pulse-once 520ms ease-out;
}

@keyframes pulse-once {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 116, 95, 0.24);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(22, 116, 95, 0);
  }
}

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

.settlement-grid strong {
  display: block;
  margin: 10px 0;
  font-size: 30px;
}

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

.metric-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 14px;
}

.metric-list strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

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

  .sidebar {
    position: static;
  }

  .side-nav {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .kpi-grid,
  .assessment-grid,
  .activity-board,
  .settlement-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .main {
    padding: 14px;
  }

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

  .kpi-grid,
  .assessment-grid,
  .activity-board,
  .activity-rules,
  .settlement-grid,
  .chart-row,
  .task-list.columns {
    grid-template-columns: 1fr;
  }

  .event-table .row,
  .member-table .row {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}
