:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f7fb;
  color: #19202e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

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

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: #1b6ef3;
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}

button.secondary {
  background: #e8eef7;
  color: #273449;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #ccd5e4;
  border-radius: 8px;
  background: #fff;
  color: #19202e;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.topbar,
.status-strip,
.panel {
  background: #fff;
  border: 1px solid #dce3ee;
  border-radius: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #60708a;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 18px;
}

.session {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #52627a;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
  padding: 16px 20px;
}

.status-strip div,
.subscription-box div {
  display: grid;
  gap: 4px;
}

.label {
  color: #65748a;
  font-size: 12px;
}

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

.panel {
  padding: 18px;
}

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

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.message-form {
  display: grid;
  gap: 10px;
}

.wide {
  width: 100%;
  margin-top: 12px;
}

.list,
.device-list,
.message-list {
  display: grid;
  gap: 10px;
}

.list {
  margin-top: 12px;
}

.family-row,
.device-row,
.message-row {
  border: 1px solid #e1e7f0;
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.family-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.family-row.active {
  border-color: #1b6ef3;
  background: #eef5ff;
}

.device-row {
  display: grid;
  gap: 8px;
}

.device-title,
.message-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.metric {
  border-radius: 8px;
  background: #eef2f7;
  padding: 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #e8eef7;
  color: #31425d;
  font-size: 12px;
  font-weight: 750;
}

.badge.online,
.badge.replied,
.badge.paid {
  background: #e4f7eb;
  color: #146c36;
}

.badge.pending {
  background: #fff4d6;
  color: #8a5a00;
}

.badge.delivered {
  background: #e8f1ff;
  color: #185abc;
}

.badge.low_power {
  background: #ffe9e5;
  color: #ad2f12;
}

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

.message-row {
  display: grid;
  gap: 8px;
}

.provision-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border: 1px solid #d9e2ee;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.provision-box div {
  display: grid;
  gap: 5px;
}

code {
  display: block;
  width: 100%;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: #182235;
  color: #eef6ff;
  padding: 8px;
  font-size: 12px;
}

.message-text {
  color: #243044;
  line-height: 1.55;
}

.reply-text {
  color: #146c36;
  font-weight: 700;
}

.muted {
  color: #6a7890;
  font-size: 13px;
}

.empty {
  color: #6a7890;
  padding: 16px 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100% - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #19202e;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 12px;
  }

  .topbar,
  .session,
  .panel-heading,
  .family-row,
  .device-title,
  .message-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-strip,
  .grid,
  .metrics,
  .inline-form {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }
}
