:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --ink: #17201b;
  --muted: #68736d;
  --panel: #ffffff;
  --line: #dfe5df;
  --red: #d9342b;
  --red-dark: #8f1e18;
  --orange: #d98924;
  --green: #16745f;
  --teal: #237b83;
  --blue: #3367a8;
  --shadow: 0 18px 45px rgba(28, 42, 34, 0.12);
}

* {
  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,
input,
select,
textarea {
  font: inherit;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.rail {
  background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  color: white;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
}

.brand {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f4fff7;
  color: #1e3a8a;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #c8dbf3;
  font-size: 12px;
  line-height: 1.35;
}

.rail-nav {
  display: grid;
  gap: 12px;
}

.nav-item {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #eaf2ff;
  font-size: 20px;
}

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

.nav-item:hover {
  background: rgba(147, 197, 253, 0.36);
  color: #ffffff;
}

.shift {
  margin-top: auto;
  writing-mode: vertical-rl;
  display: flex;
  gap: 8px;
  color: #c5d5cb;
  font-size: 12px;
}

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

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

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

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

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

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

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

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

.primary,
.ghost,
.link-button,
.accept-btn,
.quick-actions button,
.toolbar button,
.family-actions button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.link-button {
  display: inline-flex;
  align-items: center;
}

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

.primary.danger {
  background: var(--red);
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.screen-grid {
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 320px;
  gap: 16px;
  height: calc(100vh - 126px);
  min-height: 650px;
}

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

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

.live-dot {
  background: #e9f7ef;
  color: var(--green);
  border: 1px solid #b6dfc8;
  border-radius: 99px;
  padding: 4px 8px;
  font-weight: 800;
  font-size: 12px;
}

.emergency-queue,
.action-panel {
  overflow: auto;
}

.event-card {
  width: calc(100% - 24px);
  margin: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
  color: var(--ink);
  display: block;
  text-align: left;
}

.event-card.selected {
  background: #fff5f4;
  border-color: #f0b1ad;
}

.event-card.critical {
  border-left-color: var(--red);
}

.event-card.warning {
  border-left-color: var(--orange);
}

.event-card.care {
  border-left-color: var(--teal);
}

.event-card.resolved {
  opacity: 0.7;
  border-left-color: var(--green);
}

.event-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(28, 42, 34, 0.1);
}

.event-top,
.event-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.event-top strong {
  font-size: 16px;
}

.event-card p,
.event-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.timer {
  color: var(--red-dark);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.timer.large {
  font-size: 30px;
}

.command-stage {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
}

.alert-banner {
  min-height: 104px;
  border-radius: 8px;
  background: var(--red);
  color: white;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: 0 20px 50px rgba(217, 52, 43, 0.22);
}

.alert-banner.warning {
  background: var(--orange);
  box-shadow: 0 20px 50px rgba(217, 137, 36, 0.22);
}

.alert-banner.care {
  background: var(--teal);
  box-shadow: 0 20px 50px rgba(35, 123, 131, 0.22);
}

.alarm-label {
  display: inline-block;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 99px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.alert-banner h2 {
  font-size: 24px;
}

.accept-btn {
  flex: 0 0 auto;
  min-width: 118px;
  background: white;
  color: var(--red-dark);
}

.accept-btn:disabled {
  cursor: default;
  opacity: 0.78;
}

.pulse {
  animation: pulse-red 1.3s ease-in-out infinite;
}

@keyframes pulse-red {
  0%,
  100% {
    box-shadow: 0 16px 45px rgba(217, 52, 43, 0.18);
  }
  50% {
    box-shadow: 0 16px 70px rgba(217, 52, 43, 0.48);
  }
}

.map-panel {
  min-height: 0;
  background: #eef3ef;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(300px, 1fr) auto;
}

.map-visual {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.6) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.6) 1px, transparent 1px),
    #dbe9df;
  background-size: 44px 44px;
}

.road {
  position: absolute;
  background: #c7d1ca;
}

.road.horizontal {
  left: 0;
  right: 0;
  top: 47%;
  height: 32px;
}

.road.vertical {
  top: 0;
  bottom: 0;
  left: 57%;
  width: 34px;
}

.zone {
  position: absolute;
  width: 92px;
  height: 72px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  border: 2px solid rgba(23, 32, 27, 0.2);
}

.home-zone {
  left: 28%;
  top: 28%;
  background: #fff8e8;
  color: #754913;
}

.store-zone {
  right: 17%;
  bottom: 23%;
  background: #e7f4f0;
  color: #0f5949;
}

.pin {
  position: absolute;
  left: calc(28% + 72px);
  top: calc(28% + 14px);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: var(--red);
  font-size: 26px;
  font-weight: 900;
  animation: pop 1s ease-in-out infinite;
}

@keyframes pop {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
}

.route {
  position: absolute;
  left: 42%;
  top: 40%;
  width: 24%;
  height: 28%;
  border-bottom: 5px dashed var(--green);
  border-right: 5px dashed var(--green);
  border-radius: 0 0 24px 0;
}

.map-info {
  padding: 16px 18px;
  background: white;
}

.map-info p:last-child,
.address-check {
  color: var(--muted);
  margin-bottom: 0;
}

.address-check {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
}

.address-check span {
  border-radius: 99px;
  background: #f1f6f3;
  padding: 4px 8px;
  font-weight: 800;
}

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

.metric-strip div {
  min-height: 76px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  padding: 14px;
}

.metric-strip span,
.info-list dt {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.status-pill {
  border-radius: 99px;
  background: #fff2e6;
  color: #96570e;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.steps {
  margin: 0;
  padding: 14px 16px 4px;
  display: grid;
  gap: 8px;
}

.step {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  width: 100%;
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
}

.step:hover {
  background: #f1f6f3;
  color: var(--ink);
}

.step span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #cbd6cf;
}

.step.current {
  color: var(--red-dark);
  background: #fff2f1;
}

.step.current span {
  border-color: var(--red);
  background: var(--red);
}

.step.done {
  color: var(--green);
}

.step.done span {
  border-color: var(--green);
  background: var(--green);
}

.quick-actions {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-actions button {
  background: #f2f6f3;
  color: var(--ink);
  border: 1px solid var(--line);
}

.quick-actions button.done-action {
  background: #e8f5ee;
  border-color: #acd8c2;
  color: var(--green);
}

.billing-actions button.done-action {
  background: #e8f5ee;
  border-color: #acd8c2;
  color: var(--green);
}

.billing-card {
  margin: 0 16px 14px;
  border: 1px solid #edd3a9;
  border-radius: 8px;
  background: #fffaf2;
  padding: 12px;
}

.billing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.billing-head span {
  border-radius: 99px;
  background: #fff0dc;
  color: #8b5310;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 900;
}

.billing-card dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.billing-card dl div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.billing-card dt {
  color: var(--muted);
  font-size: 12px;
}

.billing-card dd {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

.billing-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.billing-actions button {
  min-height: 34px;
  border-radius: 8px;
  background: white;
  border: 1px solid #edd3a9;
  color: #7c4b12;
  font-weight: 900;
}

.billing-card.authorized {
  border-color: #add8c5;
  background: #f0faf5;
}

.billing-card.authorized .billing-head span {
  background: #e0f3e9;
  color: var(--green);
}

.ai-note {
  margin: 0 16px 16px;
  border-radius: 8px;
  background: #f7fbf9;
  border: 1px solid #cfe5dc;
  padding: 14px;
}

.ai-note p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 320px;
  gap: 16px;
  min-height: calc(100vh - 126px);
}

.profile-panel,
.event-detail,
.timeline-panel {
  padding: 18px;
}

.member-avatar {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e8f3ee;
  color: var(--green);
  font-size: 30px;
  font-weight: 900;
  margin-bottom: 14px;
}

.profile-panel p {
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.tags span {
  border-radius: 99px;
  background: #fff3e2;
  color: #7c4b12;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.info-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.info-list div {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.info-list dd {
  margin: 5px 0 0;
  font-weight: 800;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.process-bar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.process {
  min-height: 40px;
  border-radius: 8px;
  color: var(--muted);
  background: #f3f6f4;
  font-weight: 800;
}

.process.active {
  color: white;
  background: var(--red);
}

.process.done {
  color: var(--green);
  background: #e8f5ee;
}

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

.business-rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.business-rules article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 12px;
}

.business-rules strong {
  display: block;
  margin-bottom: 6px;
}

.business-rules p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

select {
  min-height: 42px;
  padding: 0 10px;
}

textarea {
  min-height: 150px;
  margin: 16px 0;
  padding: 12px;
  resize: vertical;
}

.timeline {
  display: grid;
  gap: 14px;
}

.timeline div {
  border-left: 3px solid var(--green);
  padding-left: 12px;
}

.timeline div.pending {
  border-left-color: var(--orange);
}

.timeline div.system {
  border-left-color: var(--blue);
}

.timeline span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.timeline p {
  margin: 5px 0 0;
  font-weight: 700;
}

.family-phone {
  width: min(420px, 100%);
  margin: 0 auto;
  min-height: calc(100vh - 126px);
  border-radius: 28px;
  border: 10px solid #17201b;
  background: #f7faf8;
  padding: 18px;
  box-shadow: var(--shadow);
}

.phone-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 46px;
}

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

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

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

.family-progress {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.family-progress div {
  min-height: 42px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  border: 1px solid var(--line);
  font-weight: 800;
}

.family-progress .done {
  color: var(--green);
  border-color: #add8c5;
}

.family-progress .current {
  color: var(--red-dark);
  border-color: #f0b1ad;
  background: #fff5f4;
}

.family-alert.care {
  background: var(--teal);
}

.family-alert.warning {
  background: var(--orange);
}

.family-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 14px;
}

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

.family-actions button:last-child {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

.family-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}

.family-card p {
  color: var(--muted);
  margin-bottom: 0;
}

@media (max-width: 1120px) {
  .screen-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .command-stage {
    grid-template-rows: auto 420px auto;
  }

  .action-panel {
    min-height: auto;
  }
}

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

  .rail {
    min-height: 72px;
    flex-direction: row;
    justify-content: space-between;
  }

  .brand {
    grid-template-columns: auto 1fr;
    text-align: left;
    align-items: center;
  }

  .rail-nav {
    display: flex;
  }

  .shift {
    display: none;
  }

  main {
    padding: 14px;
  }

  .topbar,
  .alert-banner,
  .detail-head {
    height: auto;
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 22px;
  }

  .metric-strip,
  .form-grid,
  .process-bar,
  .business-rules {
    grid-template-columns: 1fr 1fr;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
