:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --ink: #172033;
  --muted: #647086;
  --line: #dfe6ef;
  --primary: #1677ff;
  --primary-dark: #0f5fd1;
  --danger: #d93025;
  --ok: #178a46;
  --shadow: 0 12px 30px rgba(23, 32, 51, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

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

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

.shell {
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.top p {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 22px;
  margin-bottom: 10px;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

nav a,
.button,
button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

nav a:hover,
.button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
  color: #fff;
}

.danger {
  border-color: #ffd7d4;
  background: #fff4f3;
  color: var(--danger);
}

.card,
.notice,
.flash,
.stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.card {
  margin: 16px 0;
  padding: 20px;
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

.account-bar span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.account-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-avatar {
  display: block;
  width: 40px;
  height: 40px;
  max-width: 40px;
  max-height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #f3f6fa;
  flex: 0 0 auto;
}

.tiny-avatar {
  width: 28px;
  height: 28px;
  max-width: 28px;
  max-height: 28px;
  margin-right: 8px;
  border-radius: 6px;
  object-fit: cover;
  vertical-align: middle;
  border: 1px solid var(--line);
}

.account-bar strong {
  margin-right: 10px;
  font-size: 18px;
}

.account-bar code {
  color: var(--muted);
}

.account-bar small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.account-bar form {
  width: min(320px, 100%);
}

.narrow {
  width: min(520px, 100%);
  margin: 48px auto;
}

.notice {
  margin: 16px 0;
  padding: 14px 16px;
  background: #fffbe8;
}

.flash {
  margin: 14px 0;
  padding: 13px 16px;
  font-weight: 750;
}

.flash.ok {
  border-color: #c7ecd5;
  background: #effaf3;
  color: var(--ok);
}

.flash.bad {
  border-color: #ffd7d4;
  background: #fff4f3;
  color: var(--danger);
}

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

.stat {
  padding: 18px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.stat p,
.card p,
.muted {
  color: var(--muted);
}

.actions,
.split,
.inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.split {
  justify-content: space-between;
  align-items: flex-start;
}

.button-form {
  display: inline;
  margin: 0;
}

form {
  margin: 0;
}

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

label {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  color: var(--muted);
  font-weight: 750;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.helper-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 750;
}

.mini-btn {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13px;
}

label.check {
  display: flex;
  align-items: center;
  grid-column: 1 / -1;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

textarea {
  min-height: 260px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

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

.preview-panel {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fbfcfe;
}

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

.estimate div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.estimate span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.estimate b {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.estimate p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin: 12px 0;
}

.phone-preview {
  margin-top: 12px;
}

.phone-preview article {
  max-width: 430px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 15px;
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.05);
}

.phone-preview b {
  display: block;
  margin-bottom: 10px;
  font-size: 17px;
}

.phone-preview div {
  padding: 9px 0;
  border-top: 1px solid #edf1f6;
}

.phone-preview span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.phone-preview p {
  margin: 2px 0 0;
  color: var(--ink);
  white-space: pre-wrap;
}

.phone-preview small {
  display: block;
  margin-top: 10px;
  color: var(--primary);
  word-break: break-all;
}

.bad-text {
  color: var(--danger);
  font-weight: 750;
}

.failure-summary {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #ffd7d4;
  border-radius: 8px;
  background: #fff7f6;
}

.failure-summary ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.failure-summary li {
  margin: 4px 0;
}

.failure-summary span {
  display: inline-block;
  min-width: 54px;
  color: var(--danger);
  font-weight: 800;
}

.calendar-list {
  display: grid;
  gap: 14px;
}

.calendar-list article {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  padding: 14px;
}

.calendar-list h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.calendar-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.calendar-item p {
  margin: 2px 0;
}

.calendar-item span:not(.badge) {
  color: var(--muted);
  font-size: 13px;
}

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

.qr-card {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
}

.qr-card > img {
  width: 120px;
  height: 120px;
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-card p {
  margin: 5px 0;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

td .actions {
  gap: 6px;
}

th {
  color: var(--muted);
  font-size: 14px;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre.mini {
  max-height: 220px;
  margin: 8px 0;
  padding: 10px;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2f8;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.badge.done {
  background: #effaf3;
  color: var(--ok);
}

.badge.scheduled {
  background: #eef5ff;
  color: var(--primary);
}

.badge.canceled {
  background: #fff4f3;
  color: var(--danger);
}

.badge.sending,
.badge.pending {
  background: #fffbe8;
  color: #8a6d16;
}

code {
  word-break: break-all;
}

pre {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #0f172a;
  color: #dbeafe;
  white-space: pre-wrap;
}

details {
  margin: 14px 0;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

@media (max-width: 820px) {
  .shell {
    width: min(100vw - 24px, 680px);
    padding-top: 14px;
  }

  .top,
  .account-bar,
  .split {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    justify-content: flex-start;
  }

  h1 {
    font-size: 28px;
  }

  .grid,
  .form-grid,
  .estimate {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
  }

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

  .button,
  button,
  .button-form {
    width: 100%;
  }

  .qr-grid,
  .qr-card {
    grid-template-columns: 1fr;
  }

  .qr-card > img {
    width: 104px;
    height: 104px;
  }
}
