* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 600;
  color: #1a1a1a;
}

.subtitle {
  margin-top: 8px;
  color: #888;
  font-size: 14px;
}

.panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px 0;
  display: flex;
  align-items: baseline;
  gap: 8px 12px;
  flex-wrap: wrap;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.hint {
  font-size: 12px;
  color: #999;
}

.import-panel textarea {
  display: block;
  width: 100%;
  margin: 0;
  min-height: 140px;
  padding: 12px;
  border: none;
  border-top: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.import-panel .textarea-wrap {
  padding: 12px 16px 0;
}

.import-panel textarea:focus {
  background: #fafcff;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 16px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 20px;
  min-height: 40px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: #409eff;
  color: #fff;
}

.btn-primary:hover {
  background: #66b1ff;
}

.btn-primary:disabled {
  background: #a0cfff;
  cursor: not-allowed;
}

.btn-ghost {
  background: #fff;
  color: #666;
  border: 1px solid #d9d9d9;
}

.btn-ghost:hover {
  color: #409eff;
  border-color: #409eff;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 15px;
}

.badge {
  font-size: 13px;
  color: #409eff;
  background: #ecf5ff;
  padding: 6px 12px;
  border-radius: 12px;
}

.card-list {
  padding: 0 16px 16px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.card-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #303133;
  margin-bottom: 8px;
}

.card-group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 500;
}

.card-group:first-child .card-group-count {
  color: #409eff;
  background: #ecf5ff;
}

.card-group:nth-child(2) .card-group-count {
  color: #e6a23c;
  background: #fdf6ec;
}

.card-group-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #f5f7fa;
  border: 1px solid #e4e7ed;
  border-radius: 4px;
  font-size: 13px;
  font-family: Consolas, monospace;
}

.card-tag .card-phone {
  cursor: pointer;
  padding: 2px 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.card-tag .card-phone:hover,
.card-tag .card-phone:active {
  color: #409eff;
}

.card-tag .remove {
  cursor: pointer;
  color: #c0c4cc;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
}

.card-tag .remove:hover {
  color: #f56c6c;
}

.action-panel .toolbar {
  padding: 16px;
}

.auto-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  min-height: 40px;
}

#refreshInterval {
  padding: 8px 10px;
  min-height: 40px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  background: #fff;
}

.status-text {
  font-size: 13px;
  color: #909399;
  margin-left: auto;
  flex: 1 1 100%;
  min-width: 0;
  word-break: break-all;
}

.status-text.loading {
  color: #e6a23c;
}

.status-text.success {
  color: #67c23a;
}

.status-text.error {
  color: #f56c6c;
}

.table-panel {
  padding: 0;
  position: relative;
  transition: opacity 0.2s ease;
}

.table-panel.is-refreshing {
  opacity: 0.92;
}

.table-panel.is-refreshing::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #409eff, transparent);
  animation: refresh-bar 1s linear infinite;
  pointer-events: none;
}

@keyframes refresh-bar {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sms-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.sms-table thead {
  background: #fafafa;
}

.sms-table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 500;
  font-size: 14px;
  color: #606266;
  border-bottom: 1px solid #ebeef5;
  white-space: nowrap;
}

.sms-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid #ebeef5;
  word-break: break-all;
  vertical-align: top;
}

.sms-table tbody tr:hover {
  background: #f5f7fa;
}

.sms-table .empty-row td {
  text-align: center;
  color: #c0c4cc;
  padding: 60px 20px;
}

.sms-table .phone-copy {
  cursor: pointer;
  font-family: Consolas, monospace;
  display: inline-block;
  padding: 2px 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sms-table .phone-copy:hover,
.sms-table .phone-copy:active {
  color: #409eff;
}

.sms-table .th-hint {
  font-weight: 400;
  font-size: 12px;
  color: #999;
}

.sms-table .content-cell {
  color: #303133;
  font-weight: 500;
  min-width: 200px;
}

.sms-table .code-highlight {
  color: #f56c6c;
  font-weight: 700;
  font-size: 15px;
}

.sms-table .copy-btn {
  display: inline-block;
  margin-top: 6px;
  margin-left: 0;
  padding: 6px 12px;
  font-size: 12px;
  background: #ecf5ff;
  color: #409eff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-height: 32px;
}

.sms-table .copy-btn:hover {
  background: #409eff;
  color: #fff;
}

@media (max-width: 768px) {
  .app {
    padding: 16px 12px 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }

  .panel-header {
    padding: 14px 14px 0;
  }

  .panel-header h2 {
    font-size: 15px;
  }

  .hint {
    flex: 1 1 100%;
  }

  .import-panel .textarea-wrap {
    padding: 10px 12px 0;
  }

  .import-panel textarea {
    min-height: 120px;
    font-size: 12px;
  }

  .toolbar {
    padding: 0 12px 14px;
    gap: 8px;
  }

  .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 8px);
    text-align: center;
  }

  .btn-lg {
    flex: 1 1 100%;
    width: 100%;
  }

  .badge {
    flex: 1 1 100%;
    text-align: center;
  }

  .auto-refresh,
  #refreshInterval {
    flex: 1 1 auto;
  }

  .status-text {
    margin-left: 0;
    margin-top: 4px;
    text-align: center;
  }

  .card-list {
    padding: 0 12px 14px;
    max-height: 200px;
  }

  .action-panel .toolbar {
    padding: 14px 12px;
  }

  .table-wrapper {
    padding: 12px;
    overflow-x: visible;
  }

  .sms-table {
    min-width: 0;
  }

  .sms-table thead {
    display: none;
  }

  .sms-table tbody tr {
    display: block;
    background: #fff;
    border: 1px solid #ebeef5;
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 4px 0;
    overflow: hidden;
  }

  .sms-table tbody tr:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }

  .sms-table tbody tr.empty-row {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .sms-table td {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #f5f5f5;
  }

  .sms-table td:last-child {
    border-bottom: none;
  }

  .sms-table td::before {
    content: attr(data-label);
    flex: 0 0 72px;
    font-size: 12px;
    font-weight: 600;
    color: #909399;
    padding-top: 2px;
  }

  .sms-table .empty-row td {
    display: block;
    padding: 40px 20px;
    text-align: center;
  }

  .sms-table .empty-row td::before {
    display: none;
  }

  .sms-table .content-cell {
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
  }

  .sms-table .content-cell::before {
    margin-bottom: 4px;
  }

  .sms-table .copy-btn {
    margin-top: 8px;
  }

  .sms-table .th-hint {
    display: block;
    margin-top: 2px;
  }
}

@media (min-width: 769px) {
  .status-text {
    flex: 0 1 auto;
    margin-left: auto;
    text-align: right;
  }

  .import-panel .textarea-wrap {
    padding: 12px 20px 0;
  }

  .import-panel textarea {
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    margin-bottom: 12px;
  }

  .import-panel textarea:focus {
    border-color: #409eff;
    background: #fff;
  }

  .toolbar {
    padding: 0 20px 16px;
  }

  .card-list {
    padding: 0 20px 16px;
  }

  .sms-table .copy-btn {
    margin-top: 0;
    margin-left: 8px;
  }
}
