:root {
  --bg: #eaf7fb;
  --surface: #fbfdfe;
  --surface-soft: #f3fbfd;
  --ink: #142b33;
  --muted: #60757c;
  --line: #cdebf2;
  --brand: #3cb2d3;
  --brand-strong: #167d9a;
  --amber: #d48418;
  --blue: #247ba0;
  --rose: #c6535a;
  --green: #3a9b6d;
  --shadow: 0 16px 42px rgba(20, 43, 51, 0.12);
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(160deg, rgba(60, 178, 211, 0.2), transparent 34%),
    linear-gradient(20deg, rgba(36, 123, 160, 0.14), transparent 32%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 18px;
  line-height: 1.35;
}

.app-shell {
  position: relative;
  width: min(430px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 18px 96px;
}

.topbar,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 16px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.date-pill,
.mini-badge {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.letter-card,
.form-panel,
.proxy-panel,
.status-card,
.history-section,
.admin-panel {
  border: 1px solid rgba(205, 235, 242, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.letter-card {
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
  padding: 18px;
  color: #26434b;
  font-size: 14px;
  line-height: 1.7;
}

.letter-card strong {
  justify-self: end;
  color: var(--brand-strong);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.form-panel,
.status-card,
.history-section,
.admin-panel {
  padding: 18px;
  margin-bottom: 14px;
}

.identity-card {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.identity-card.is-ready {
  border-color: rgba(58, 155, 109, 0.38);
  background: rgba(58, 155, 109, 0.08);
}

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

.identity-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.identity-form input {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.identity-card.is-ready .identity-form {
  display: none;
}

.identity-change {
  justify-self: start;
  display: none;
}

.identity-card.is-ready .identity-change {
  display: inline-flex;
}

.admin-lock {
  display: grid;
  gap: 12px;
}

.admin-lock.is-hidden,
.admin-content.is-locked {
  display: none;
}

.admin-lock label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-lock input {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.admin-content {
  display: block;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.field-group {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.field-group legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.field-group label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  color: #29454d;
  font-size: 14px;
  line-height: 1.35;
}

.field-group input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.proxy-panel {
  margin: 16px 0;
  padding: 14px;
  box-shadow: none;
}

.proxy-list {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.proxy-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.proxy-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 900;
}

.proxy-card select,
.admin-filter input {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.primary-action,
.ghost-button,
.danger-button,
.link-button {
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-action {
  min-width: 86px;
  padding: 12px 18px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(20, 43, 51, 0.18);
}

.primary-action.is-wide {
  width: 100%;
}

.ghost-button,
.danger-button,
.link-button {
  padding: 10px 13px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.danger-button {
  border-color: rgba(198, 83, 90, 0.28);
  background: rgba(198, 83, 90, 0.08);
  color: var(--rose);
}

.link-button {
  padding: 6px 8px;
  background: transparent;
  color: var(--brand-strong);
}

.primary-action:active,
.ghost-button:active,
.danger-button:active,
.tab-item:active {
  transform: translateY(1px);
}

.status-hero {
  display: grid;
  gap: 12px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 0 5px rgba(198, 83, 90, 0.12);
}

.status-dot.is-running {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(58, 155, 109, 0.14);
}

.timer-value {
  font-size: 42px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.status-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.activity-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.activity-row {
  display: grid;
  gap: 4px;
  min-height: 54px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.activity-row strong {
  font-size: 14px;
}

.activity-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.summary-grid article {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.summary-grid span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-grid strong {
  font-size: 21px;
  line-height: 1.2;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
  white-space: nowrap;
}

th {
  background: var(--surface-soft);
  color: var(--brand-strong);
  font-weight: 900;
}

td {
  color: #2d4850;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(430px, 100%);
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.tab-item {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-height: 54px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab-item span {
  font-size: 19px;
  line-height: 1;
}

.tab-item strong {
  font-size: 12px;
}

.tab-item.is-active {
  background: rgba(60, 178, 211, 0.12);
  color: var(--brand-strong);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 92px;
  left: 18px;
  z-index: 10;
  width: min(360px, calc(100% - 36px));
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(20, 43, 51, 0.92);
  color: #fff;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

@media (min-width: 720px) {
  .app-shell {
    padding-top: 34px;
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .status-actions,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
