/* WhatsHub 手机 H5 样式：按用户提供的正版手机截图重新整理 */
:root {
  color-scheme: light;
  --page-bg: #f3f5f7;
  --card-bg: #ffffff;
  --panel-bg: #f0f2f5;
  --text-color: #172b45;
  --muted-color: #8795a8;
  --border-color: #dce3eb;
  --input-bg: #ffffff;
  --green: #08b989;
  --blue: #0879ff;
  --orange: #ff4b2e;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page-bg: #000000;
    --card-bg: #191919;
    --panel-bg: #202020;
    --text-color: #eeeeee;
    --muted-color: #9a9a9a;
    --border-color: #444444;
    --input-bg: #111111;
  }
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  background: var(--page-bg);
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--page-bg);
  color: var(--text-color);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

.page {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 12px 28px;
}

header {
  margin-bottom: 14px;
}

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

h1,
.heading-row h1 {
  margin: 0 0 5px;
  color: var(--text-color);
  font-size: 19px;
  line-height: 1.35;
  font-weight: 700;
}

.reset {
  color: var(--muted-color);
  font-size: 14px;
  line-height: 1.5;
}

.reset span {
  margin-left: 5px;
  color: var(--muted-color);
}

.admin-btn {
  display: none !important;
}

/* 统计卡片：第一行 6:3:3，下面统计数字平均三列 */
.summary-wrap {
  width: 100%;
  margin: 0 0 12px;
  padding: 10px;
  background: var(--panel-bg);
}

.summary {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  padding: 12px 10px;
  background: var(--card-bg);
  align-items: stretch;
}

.summary .work {
  grid-column: span 6;
}

.summary .meta {
  grid-column: span 3;
}

.summary .total {
  grid-column: span 4;
}

.work,
.meta {
  display: flex;
  min-width: 0;
  min-height: 68px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border-color);
}

.work,
.meta:not(:last-child) {
  border-right: 1px solid var(--border-color);
}

.work small,
.meta small {
  color: var(--muted-color);
  font-size: 13px;
  line-height: 1.35;
}

.work strong {
  display: block;
  overflow: hidden;
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 400;
  white-space: nowrap;
  text-overflow: clip;
}

.meta b {
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 400;
  white-space: nowrap;
}

.total {
  display: flex;
  min-width: 0;
  min-height: 73px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 8px 9px;
  border-right: 1px solid var(--border-color);
}

.total:nth-child(6),
.total:nth-child(9) {
  border-right: 0;
}

.total span {
  color: var(--text-color);
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
}

.total b {
  font-size: 23px;
  line-height: 1.2;
  font-weight: 400;
}

.total b.blue {
  color: var(--blue);
}

.total b.green {
  color: #00ae78;
}

.total b.orange {
  color: var(--orange);
}

/* 筛选及查询 */
.toolbar {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px;
  background: var(--panel-bg);
}

.toolbar nav {
  display: flex;
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 2px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  height: 36px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--text-color);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.tab.active {
  background: var(--green);
  color: #ffffff;
}

#searchForm {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

#apiSearch {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 0;
  outline: none;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 14px;
}

#apiSearch::placeholder {
  color: #a2adbd;
}

#apiSearch:focus {
  border-color: var(--green);
}

#searchForm button {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 12px;
  border-radius: 0;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}

.query {
  border: 1px solid var(--green);
  background: var(--green);
  color: #ffffff;
}

#searchForm .reset {
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--muted-color);
}

/* 表格保留完整列宽，手机上左右滑动查看 */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card-bg);
}

.table-scroll table {
  width: 100%;
  min-width: 950px;
  border-collapse: collapse;
  table-layout: fixed;
  white-space: nowrap;
}

.table-scroll thead {
  background: var(--panel-bg);
}

.table-scroll th {
  height: 56px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  background: var(--panel-bg);
  color: var(--text-color);
  font-size: 15px;
  font-weight: 400;
  text-align: center;
  white-space: nowrap;
}

.table-scroll td {
  height: 56px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  background: var(--page-bg);
  color: var(--text-color);
  font-size: 15px;
  text-align: center;
  white-space: nowrap;
}

.table-scroll th:nth-child(1) { width: 205px; }
.table-scroll th:nth-child(2) { width: 142px; }
.table-scroll th:nth-child(3) { width: 216px; }
.table-scroll th:nth-child(4) { width: 143px; }
.table-scroll th:nth-child(5),
.table-scroll th:nth-child(6) { width: 200px; }
.table-scroll th:nth-child(n+7) { width: 129px; }

.table-scroll i {
  display: inline-grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border-radius: 50%;
  background: #69727d;
  color: #ffffff;
  font-size: 10px;
  font-style: normal;
}

.valid,
.paused {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 2px;
  font-size: 13px;
}

.valid,
.status-toggle.valid {
  border: 1px solid #c6eee2;
  background: #e5f8f2;
  color: #00a97a;
}

.paused,
.status-toggle.paused {
  border: 1px solid #ffd9d9;
  background: #fff0f0;
  color: #e34b4b;
}

.status-toggle {
  cursor: pointer;
}

#empty {
  min-height: 100px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--muted-color);
  font-size: 16px;
}

footer {
  padding: 20px 2px;
  color: var(--muted-color);
  font-size: 12px;
  text-align: center;
}

footer span {
  margin-left: 8px;
}

/* 管理员编辑 */
[contenteditable="true"] {
  outline: none;
  border-radius: 2px;
  cursor: text;
}

[contenteditable="true"]:hover {
  background: #f4fbf8;
}

[contenteditable="true"]:focus {
  background: var(--input-bg);
  border-bottom: 1px dashed var(--green);
  box-shadow: 0 1px 0 var(--green);
}

.admin-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 1000000;
  width: auto;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: var(--card-bg);
  box-shadow: 0 5px 20px #102b4b20;
}

.admin-panel[hidden] {
  display: none;
}

.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-color);
}

.admin-panel-head button {
  border: 0;
  background: transparent;
  color: var(--muted-color);
  font-size: 23px;
}

.admin-panel p {
  color: var(--muted-color);
  font-size: 13px;
  line-height: 1.6;
}

.admin-actions {
  display: flex;
  gap: 9px;
}

.admin-actions button {
  height: 36px;
  padding: 0 16px;
  border-radius: 3px;
}

.save-btn {
  border: 1px solid var(--green);
  background: var(--green);
  color: #ffffff;
}

.exit-btn {
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-color);
}

body.edit-mode [data-editable="true"] {
  min-width: 24px;
  outline: 1px dashed var(--green);
  background: #f2fffb;
  cursor: text;
}

body.edit-mode [data-editable="true"]:focus {
  outline: 2px solid var(--green);
  background: var(--input-bg);
}

/* 5 秒加载页面：独立于系统深浅色 */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: #101418;
  opacity: 1;
  visibility: visible;
  transition: opacity .45s ease, visibility .45s ease;
}

.loading-content {
  width: min(440px, calc(100% - 40px));
  margin: auto;
  color: #ffffff;
  text-align: center;
}

.loading-screen .loading-logo {
  display: block;
  width: 100px;
  height: 100px;
  max-width: 100%;
  margin: 0 auto 25px;
  object-fit: contain;
}

.loading-content h2 {
  margin: 10px 0;
  color: #ffffff;
  font-size: 23px;
  font-weight: 600;
}

.loading-content p {
  margin-bottom: 35px;
  color: #9ba8b5;
  font-size: 14px;
}

.loading-bar {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 20px;
  background: #303b45;
}

.loading-progress {
  width: 0%;
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, #08a96f, #39e6a5);
  transition: width .05s linear;
}

.loading-bottom {
  display: flex;
  justify-content: space-between;
  margin-top: 13px;
  color: #8996a3;
  font-size: 12px;
}

.loading-percent {
  color: #27d99a;
}

.loading-screen.loading-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 极窄屏幕适配 */
@media (max-width: 360px) {
  .page {
    padding-right: 8px;
    padding-left: 8px;
  }

  .summary-wrap {
    padding: 8px;
  }

  .summary {
    padding: 8px 5px;
  }

  .work,
  .meta,
  .total {
    padding-right: 5px;
    padding-left: 5px;
  }

  .work strong {
    font-size: 12px;
  }

  .meta b,
  .total span {
    font-size: 12px;
  }

  #searchForm {
    gap: 5px;
  }

  #searchForm button {
    padding-right: 9px;
    padding-left: 9px;
  }
}
