:root {
  --bg: #f6f7f8;
  --ink: #1f2528;
  --muted: #697277;
  --panel: #ffffff;
  --line: #e1e5e7;
  --green: #247662;
  --green-soft: #eaf3ef;
  --red: #c84b56;
  --red-soft: #fff2f3;
  --orange: #b67a23;
  --blue: #3d6f9d;
  --teal: #337d82;
  --shadow: 0 1px 2px rgba(31, 37, 40, 0.04), 0 8px 24px rgba(31, 37, 40, 0.05);
}

* {
  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;
}

.system-shell[hidden],
.hq-login-page[hidden],
.permission-hidden {
  display: none !important;
}

.hq-login-page {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(420px, 1.08fr) minmax(440px, 0.92fr);
  background: #fff;
}

.hq-login-visual {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: #163c32;
}

.hq-login-visual::after {
  position: absolute;
  inset: 0;
  background: rgba(13, 46, 37, 0.5);
  content: "";
}

.hq-login-visual > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.78);
}

.hq-login-visual-copy {
  position: absolute;
  right: 8%;
  bottom: 8%;
  left: 9%;
  z-index: 1;
  color: #fff;
}

.hq-login-visual-copy > span {
  display: inline-block;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 600;
}

.hq-login-visual-copy h1 {
  max-width: 620px;
  margin: 20px 0 13px;
  font-size: 52px;
  line-height: 1.15;
  letter-spacing: 0;
}

.hq-login-visual-copy > p {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  line-height: 1.8;
}

.hq-login-visual-copy > div {
  display: flex;
  gap: 42px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.28);
}

.hq-login-visual-copy > div span {
  display: flex;
  flex-direction: column;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
}

.hq-login-visual-copy > div strong {
  margin-bottom: 3px;
  color: #fff;
  font-size: 21px;
}

.hq-login-area {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 44px clamp(38px, 6vw, 92px);
  background: #fff;
}

.hq-login-box {
  width: min(430px, 100%);
}

.hq-login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.hq-login-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.hq-login-brand span,
.hq-login-brand strong,
.hq-login-brand small {
  display: block;
}

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

.hq-login-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.hq-login-heading {
  margin: 45px 0 25px;
}

.hq-login-heading > span {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.hq-login-heading h2 {
  margin: 7px 0;
  font-size: 27px;
  letter-spacing: 0;
}

.hq-login-heading p {
  margin: 0;
  color: var(--muted);
}

.hq-login-form > label {
  display: block;
  margin-top: 15px;
}

.hq-login-form > label > span {
  display: block;
  margin-bottom: 7px;
  color: #46534f;
  font-size: 12px;
  font-weight: 600;
}

.hq-input-wrap {
  display: flex;
  height: 44px;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid #d5ddda;
  border-radius: 6px;
}

.hq-input-wrap:focus-within {
  border-color: #72a897;
  box-shadow: 0 0 0 3px rgba(22, 116, 95, 0.08);
}

.hq-input-wrap svg {
  width: 16px;
  color: #7d8985;
}

.hq-input-wrap input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
}

.hq-login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 13px;
}

.hq-login-options label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.hq-login-options input {
  accent-color: var(--green);
}

.hq-login-options button {
  padding: 3px 0;
  color: var(--green);
  background: transparent;
  font-size: 11px;
}

.hq-login-error {
  min-height: 18px;
  margin: 8px 0 2px;
  color: var(--red);
  font-size: 11px;
}

.hq-login-submit {
  display: flex;
  width: 100%;
  height: 45px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 6px;
  font-weight: 600;
}

.hq-login-submit:hover {
  background: #115747;
}

.hq-login-submit svg {
  width: 16px;
}

.hq-demo-account {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.hq-demo-account > div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.hq-demo-account > div span {
  font-size: 11px;
  font-weight: 600;
}

.hq-demo-account > div small {
  color: #919b97;
  font-size: 10px;
}

.hq-demo-account > .hq-demo-account-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hq-demo-account-grid > button {
  display: flex;
  width: 100%;
  height: 54px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: #4f5c58;
  background: #f7f9f8;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: left;
}

.hq-demo-account-grid > button:hover {
  color: var(--green);
  background: var(--green-soft);
  border-color: #b9d3ca;
}

.hq-demo-account-grid > button svg {
  flex: 0 0 18px;
  width: 18px;
}

.hq-demo-account-grid > button span,
.hq-demo-account-grid > button strong,
.hq-demo-account-grid > button small {
  display: block;
  min-width: 0;
}

.hq-demo-account-grid > button strong {
  font-size: 11px;
  white-space: nowrap;
}

.hq-demo-account-grid > button small {
  margin-top: 2px;
  overflow: hidden;
  color: #84908c;
  font-size: 10px;
  text-overflow: ellipsis;
}

.hq-login-box > footer {
  margin-top: 34px;
  color: #9aa39f;
  font-size: 10px;
  text-align: center;
}

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

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

.header-actions,
.hq-account {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 14px;
}

.hq-account {
  min-width: 190px;
  gap: 9px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.hq-account-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 50%;
  font-weight: 800;
}

.hq-account > span:nth-child(2) {
  min-width: 0;
}

.hq-account strong,
.hq-account small {
  display: block;
  white-space: nowrap;
}

.hq-account strong {
  font-size: 13px;
}

.hq-account small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.hq-account button {
  display: grid;
  width: 34px;
  height: 34px;
  margin-left: auto;
  place-items: center;
  color: var(--muted);
  background: #f2f6f3;
  border-radius: 6px;
}

.hq-account button:hover {
  color: var(--red);
  background: var(--red-soft);
}

.hq-account button svg {
  width: 17px;
}

.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: 110px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.logo-img {
  width: 42px;
  height: 38px;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  background: #fff;
}

.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,
.kpi-grid .kpi-card,
.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,
.kpi-grid .kpi-card {
  min-height: 116px;
  padding: 18px;
}

.kpi-grid .kpi-card {
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.kpi-grid .kpi-card:hover {
  border-color: #9fc7b7;
  box-shadow: 0 12px 30px rgba(24, 55, 43, 0.14);
  transform: translateY(-1px);
}

.kpi-grid .kpi-card:focus-visible {
  outline: 3px solid rgba(22, 116, 95, 0.24);
  outline-offset: 2px;
}

.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;
}

.map-toolbar,
.map-city-control {
  display: flex;
  align-items: center;
}

.map-toolbar {
  gap: 12px;
}

.map-city-control {
  gap: 7px;
}

.map-city-control span {
  font-size: 12px;
  font-weight: 600;
}

.map-city-control select {
  width: 104px;
  height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.map-city-control select:focus {
  outline: 2px solid rgba(22, 116, 95, 0.2);
  border-color: var(--green);
}

.store-map {
  position: relative;
  min-height: 430px;
  background: #e9efec;
}

.store-map:empty::before {
  content: "地图加载中";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.store-map .leaflet-control-zoom a {
  color: var(--ink);
  border-color: var(--line);
}

.store-map .leaflet-control-zoom a:focus-visible {
  outline: 2px solid rgba(22, 116, 95, 0.35);
  outline-offset: 1px;
}

.store-map .leaflet-control-attribution {
  color: #66736d;
  font-size: 10px;
}

.store-map .leaflet-div-icon {
  border: 0;
  background: transparent;
}

.store-map-marker {
  position: relative;
  width: max-content;
  min-width: 68px;
  height: 32px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  border-radius: 6px;
  background: var(--green);
  color: white;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 5px 14px rgba(21, 46, 36, 0.28);
}

.store-map-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 10px;
  height: 10px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}

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

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

.store-map .leaflet-popup-content-wrapper {
  border-radius: 6px;
  box-shadow: 0 8px 26px rgba(20, 39, 31, 0.2);
}

.store-map .leaflet-popup-content {
  margin: 12px 14px;
  color: var(--ink);
  line-height: 1.6;
}

.store-map .leaflet-popup-content strong,
.store-map .leaflet-popup-content span {
  display: block;
}

.store-map .leaflet-popup-content span {
  color: var(--muted);
  font-size: 12px;
}

.management-panel {
  margin-top: 16px;
}

.management-head > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.management-add {
  min-height: 36px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 6px;
  font-weight: 800;
}

.management-add svg {
  width: 16px;
  height: 16px;
}

.management-tools {
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: #fafcfa;
}

.management-tools label {
  min-width: 220px;
  flex: 1;
  position: relative;
}

.management-tools label svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
}

.management-tools input,
.management-tools select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.management-tools input {
  padding: 0 12px 0 35px;
}

.management-tools select {
  width: 150px;
  padding: 0 30px 0 10px;
}

.management-table-wrap {
  overflow-x: auto;
}

.management-table {
  min-width: 760px;
  padding: 10px 14px 14px;
  display: grid;
  gap: 6px;
}

.management-row {
  min-height: 52px;
  padding: 8px 10px;
  display: grid;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font-size: 12px;
}

.assessment-question-table .management-row {
  grid-template-columns: 86px minmax(250px, 1fr) 100px 66px 78px 44px;
}

.chronic-question-table .management-row {
  grid-template-columns: 86px minmax(220px, 1fr) minmax(170px, 0.8fr) 88px 78px 44px;
}

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

.management-row > span:nth-child(2),
.management-row > span:nth-child(3) {
  line-height: 1.5;
}

.management-status,
.management-edit {
  min-height: 30px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
}

.management-status {
  background: #eaf5ef;
  color: var(--green);
}

.management-status.off {
  background: #f0f2f1;
  color: var(--muted);
}

.management-edit {
  display: grid;
  place-items: center;
  background: #f2f6f3;
  color: var(--ink);
}

.management-edit svg {
  width: 15px;
  height: 15px;
}

.management-empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.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;
}

.system-entry {
  display: grid;
  gap: 10px;
}

.system-entry p {
  margin-bottom: 0;
}

.entry-button {
  width: fit-content;
  border-radius: 8px;
  background: var(--green);
  color: white;
  padding: 9px 12px;
  font-weight: 800;
}

.entry-button:hover {
  background: #176955;
  color: white;
}

.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,
.store-map-marker: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: 3100;
  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: 3000;
  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.wide {
  width: min(900px, 100%);
}

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

.store-list-summary div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf8;
}

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

.store-list-summary strong {
  color: var(--ink);
  font-size: 18px;
}

.store-list-summary span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.store-list-wrap {
  max-height: min(460px, 58vh);
  overflow: auto;
}

.store-list-table {
  min-width: 720px;
  display: grid;
  gap: 5px;
}

.store-list-row {
  min-height: 42px;
  padding: 7px 10px;
  display: grid;
  grid-template-columns: 70px 100px 86px 90px 90px minmax(140px, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  font-size: 12px;
}

.store-list-row.head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 32px;
  border: 0;
  background: white;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.store-list-status {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 4px;
  background: #eaf5ef;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.store-list-status.red {
  background: var(--red-soft);
  color: var(--red);
}

.store-list-status.orange {
  background: #fff3df;
  color: #9b6317;
}

.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-body .modal-field-full,
.modal-form-error {
  grid-column: 1 / -1;
}

.modal-form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}

.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) {
  .hq-login-page {
    grid-template-columns: 1fr;
  }

  .hq-login-visual {
    display: none;
  }

  .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) {
  .hq-login-area {
    padding: 30px 22px;
  }

  .hq-login-heading {
    margin-top: 34px;
  }

  .hq-demo-account > .hq-demo-account-grid {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 14px;
  }

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

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

  .hq-account {
    padding: 10px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .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;
  }
}

/* Compact operational dashboard layer. */
.system-shell {
  grid-template-columns: 232px minmax(0, 1fr);
  background: var(--bg);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px 14px;
  gap: 16px;
  overflow-y: auto;
  color: var(--ink);
  background: #fbfcfc;
  border-right: 1px solid #dfe4e6;
}

.logo-block {
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  padding: 0 8px 16px;
  border-bottom: 1px solid #e5e8e9;
}

.logo-img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

.logo-block strong {
  font-size: 15px;
  line-height: 1.25;
}

.logo-block span {
  margin-top: 3px;
  color: #7a8387;
  font-size: 11px;
}

.side-nav {
  gap: 3px;
}

.side-nav button {
  min-height: 39px;
  padding: 0 11px;
  border-radius: 6px;
  color: #556064;
  font-size: 13px;
  font-weight: 600;
  transition: background 140ms ease, color 140ms ease;
}

.side-nav button:hover {
  color: var(--ink);
  background: #f0f3f3;
}

.side-nav button.active {
  color: #165f4d;
  background: #eaf3ef;
  box-shadow: inset 3px 0 0 #2a806b;
}

.side-nav button:focus-visible {
  outline: 2px solid rgba(36, 118, 98, 0.38);
  outline-offset: 1px;
}

.sidebar-links {
  gap: 3px;
  padding-top: 12px;
  border-top: 1px solid #e5e8e9;
}

.sidebar-links a {
  min-height: 32px;
  padding: 0 10px;
  color: #7a8387;
  border: 0;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
}

.sidebar-links a:hover {
  color: var(--ink);
  background: #f0f3f3;
}

.main {
  padding: 0 24px 30px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 82px;
  margin: 0 -24px 20px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 15px;
}

.header-actions {
  gap: 12px;
}

.top-actions {
  gap: 8px;
}

.ghost,
.primary {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.ghost:hover {
  background: #f0f4f2;
}

.primary:hover {
  background: #0f5e4c;
}

.hq-account {
  min-width: 176px;
  gap: 8px;
  padding-left: 12px;
}

.hq-account-avatar {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  border-radius: 6px;
  font-size: 13px;
}

.hq-account strong {
  font-size: 12px;
}

.hq-account small {
  font-size: 9px;
}

.hq-account button {
  width: 32px;
  height: 32px;
}

.page.active {
  max-width: 1540px;
  margin: 0 auto;
}

.kpi-grid {
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-grid article,
.kpi-grid .kpi-card,
.panel,
.chart-card,
.assessment-grid article,
.activity-board article,
.settlement-grid article {
  box-shadow: var(--shadow);
}

.kpi-grid article,
.kpi-grid .kpi-card {
  min-height: 102px;
  padding: 15px 16px;
  border-top-width: 3px;
}

.kpi-grid > :nth-child(1) {
  border-top-color: var(--green);
}

.kpi-grid > :nth-child(2) {
  border-top-color: var(--blue);
}

.kpi-grid > :nth-child(3) {
  border-top-color: var(--red);
}

.kpi-grid > :nth-child(4) {
  border-top-color: var(--orange);
}

.kpi-grid strong {
  margin: 8px 0 6px;
  font-size: 30px;
}

.kpi-grid span,
.kpi-grid em {
  font-size: 12px;
}

.dashboard-grid,
.content-grid,
.split-grid,
.family-layout {
  gap: 14px;
  align-items: start;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.65fr);
}

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

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

.panel.wide,
.event-command {
  min-height: 0;
}

.panel-head {
  min-height: 54px;
  padding: 13px 15px;
  background: #fcfdfd;
}

.panel-head span {
  font-size: 11px;
  font-weight: 600;
}

.store-map {
  min-height: 360px;
}

.task-list {
  gap: 8px;
  padding: 12px;
}

.task-list article,
.ai-box,
.phone-card {
  padding: 12px;
  border-radius: 6px;
  background: #fafbfb;
}

.task-list article.critical {
  border-color: #e9afb5;
  border-left: 3px solid var(--red);
}

.task-list strong {
  margin-bottom: 5px;
  font-size: 13px;
}

.task-list p,
.ai-box p,
.profile-card p,
.phone-card p {
  font-size: 12px;
  line-height: 1.5;
}

.event-table,
.member-table {
  gap: 6px;
  padding: 10px;
}

.row {
  min-height: 44px;
  border-radius: 6px;
  font-size: 12px;
}

.row.head {
  font-size: 11px;
}

.member-strip {
  padding: 14px 16px;
}

.sop-flow,
.action-grid {
  gap: 8px;
  padding: 12px 16px;
}

.sop-flow button,
.action-grid button,
.shortcut-list button,
.shortcut-list a {
  min-height: 38px;
  border-radius: 6px;
  font-size: 12px;
}

.assessment-grid,
.activity-board,
.activity-rules,
.activity-form,
.settlement-grid,
.chart-row {
  gap: 10px;
  padding: 12px;
}

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

.score {
  margin: 10px 0 8px;
  font-size: 36px;
}

.settlement-grid strong {
  font-size: 26px;
}

#ai .content-grid {
  grid-template-columns: minmax(0, 1.8fr) minmax(330px, 0.8fr);
}

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

#ai .task-list article {
  min-height: 104px;
}

.metric-list {
  gap: 8px;
  padding: 12px;
}

.metric-list div {
  min-height: 108px;
  padding: 13px;
  border-radius: 6px;
  background: #fafbfb;
}

.role-owner .hq-account-avatar {
  background: #9a7130;
}

.role-admin .hq-account-avatar {
  background: var(--green);
}

.role-staff .hq-account-avatar {
  background: var(--blue);
}

.metric-list strong {
  margin-top: 6px;
  font-size: 26px;
}

.metric-list span {
  font-size: 12px;
}

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

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
  }

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

  .sidebar-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 0;
  }

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

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

  .topbar {
    position: static;
    margin: 0 -14px 14px;
    padding: 14px;
  }

  .header-actions {
    width: 100%;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1;
  }

  .hq-account {
    width: 100%;
  }

  .kpi-grid,
  .assessment-grid,
  .activity-board,
  .settlement-grid,
  #ai .task-list,
  #ai .metric-list {
    grid-template-columns: 1fr;
  }

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

  .sidebar-links {
    display: none;
  }

  .task-list.columns,
  .activity-rules,
  .activity-form,
  .chart-row {
    grid-template-columns: 1fr;
  }

  .management-head {
    align-items: flex-start;
  }

  .management-head > div {
    display: block;
  }

  .management-tools {
    display: grid;
  }

  .management-tools label,
  .management-tools select {
    width: 100%;
    min-width: 0;
  }

  .store-list-summary {
    grid-template-columns: 1fr;
  }
}
