:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #d8dde6;
  --text: #1a1f2e;
  --muted: #5c6578;
  --primary: #1a56db;
  --primary-hover: #1446b8;
  --danger: #b42318;
  --success: #067647;
  --warn: #b54708;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --app-max-width: 1360px;
  --list-min-h: 120px;
  font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.view.hidden,
.page.hidden,
.modal-backdrop.hidden {
  display: none !important;
}

.nav-link {
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}

.nav-link:hover {
  text-decoration: none;
  color: var(--primary);
}

.nav-link.active {
  color: var(--primary);
  font-weight: 600;
}

.app-main {
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 0 16px 48px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.layout {
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

#app-nav {
  max-width: var(--app-max-width);
}

.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.nav-brand {
  font-weight: 600;
  margin-right: auto;
}

.nav a {
  color: var(--text);
  font-size: 14px;
}

.nav a.active {
  color: var(--primary);
  font-weight: 600;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card h1,
.card h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-danger {
  color: var(--danger);
  border-color: #fecdca;
}

.form-group {
  margin-bottom: 14px;
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.form-group input[type="checkbox"],
.form-group input[type="radio"] {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}

.form-group > label,
.form-group > .field-label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--muted);
}

.form-group .checkbox-list label span {
  flex: 1;
  min-width: 0;
  word-break: break-all;
}

.share-scope-type {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 8px;
}

.share-scope-type label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.share-scope-fields .checkbox-list {
  max-height: 240px;
  min-height: 80px;
}

.share-group-mode-wrap {
  margin-top: 10px;
}

.share-group-mode-wrap .field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.form-group .checkbox-list label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 0;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-group small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.alert-err {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--danger);
}

.alert-ok {
  background: #ecfdf3;
  border-color: #abefc6;
  color: var(--success);
}

.alert-warn {
  background: #fffaeb;
  border-color: #fedf89;
  color: var(--warn);
}

.list-page-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.list-page-card .table-wrap {
  flex: 1 1 auto;
  min-height: var(--list-min-h);
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  min-height: var(--list-min-h);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.phone-actions-inner,
.cell-actions-inner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  vertical-align: middle;
}

td.cell-actions,
td.phone-actions {
  vertical-align: middle;
  white-space: nowrap;
  line-height: 1.4;
  padding-top: 8px;
  padding-bottom: 8px;
}

.cell-actions-inner .btn-sm,
.phone-actions-inner .btn-sm {
  padding: 2px 8px;
  line-height: 1.3;
}

.cell-inline-actions {
  vertical-align: middle;
}

.cell-inline-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  vertical-align: middle;
}

.cell-remark-personal {
  text-align: right;
}

.cell-remark-personal .cell-inline-inner {
  justify-content: flex-end;
  width: 100%;
}

.cell-inline-text {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-inline {
  flex-shrink: 0;
  padding: 2px 8px;
  line-height: 1.4;
}

.cell-remark.cell-inline-actions .cell-inline-text {
  max-width: 120px;
}

.cell-remark {
  max-width: none;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
}

.remark-shortcuts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
}

.remark-shortcuts-label {
  font-size: 12px;
  flex-shrink: 0;
}

.remark-shortcuts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.remark-shortcut-btn {
  font-size: 12px;
  padding: 4px 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: #fafafa;
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--border);
}

tbody tr:hover td {
  background: #fafafa;
}

tr:last-child td {
  border-bottom: none;
}

input[type="checkbox"].table-cb {
  margin: 0;
  cursor: pointer;
  width: 15px;
  height: 15px;
}

.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: #fdfdfd;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.screenshot-preview {
  margin-top: 12px;
  text-align: center;
}

.screenshot-preview-stage {
  position: relative;
  width: min(360px, 100%);
  aspect-ratio: 9 / 16;
  max-height: min(640px, calc(92vh - 156px));
  margin: 0 auto;
  background: #0f1419;
  border-radius: var(--radius);
  overflow: hidden;
}

.screenshot-preview-loading,
.screenshot-preview-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  font-size: 13px;
}

.screenshot-preview-error {
  color: var(--danger);
}

.screenshot-preview-stage .screenshot-hit {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
  line-height: 0;
}

.screenshot-preview-stage img.screenshot-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.batch-bar.hidden {
  display: none;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.filter-row input[type="search"] {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.filter-row select {
  min-width: 140px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-size {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.pagination-size select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
}

.pagination-jump {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.pagination-jump input {
  width: 56px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  text-align: center;
}

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s, transform 0.2s;
}

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

.toast-ok {
  border-color: #abefc6;
  color: var(--success);
  background: #ecfdf3;
}

.toast-err {
  border-color: #fecdca;
  color: var(--danger);
  background: #fef3f2;
}

.toast-warn {
  border-color: #fedf89;
  color: var(--warn);
  background: #fffaeb;
}

.cell-scanning {
  color: var(--muted);
}

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid var(--border);
}

.status-pending,
.status-dispatched {
  color: var(--warn);
}

.status-running {
  color: var(--primary);
}

.status-success,
.status-completed {
  color: var(--success);
}

.status-failed {
  color: var(--danger);
}

.status-cancelled,
.status-cancel_requested {
  color: var(--muted);
}

.status-partial {
  color: #b45309;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.template-downloads {
  margin: 8px 0 0;
  padding-left: 20px;
  line-height: 1.8;
}

.template-downloads a {
  color: var(--primary, #2563eb);
}

.template-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.template-card h3 {
  font-size: 15px;
  margin-bottom: 6px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: center;
  justify-content: space-between;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.empty {
  text-align: center;
  padding: 32px;
  color: var(--muted);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  padding: 20px;
}

.modal.modal-wide {
  max-width: 640px;
}

/* 截图弹窗：内容适配视口，不出现滚动条 */
.modal.modal-screenshot {
  max-width: 400px;
  width: calc(100% - 32px);
  max-height: 92vh;
  overflow: hidden;
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.modal.modal-screenshot .modal-header {
  flex-shrink: 0;
  margin-bottom: 6px;
}

.modal.modal-screenshot #modal-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal.modal-screenshot .screenshot-modal-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.modal.modal-screenshot .screenshot-modal-hints {
  flex-shrink: 0;
  min-height: 2.75em;
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.4;
}

.modal.modal-screenshot .screenshot-modal-hints p {
  margin: 0 0 4px;
}

.modal.modal-screenshot .screenshot-modal-hints p:last-child {
  margin-bottom: 0;
}

.modal.modal-screenshot .screenshot-preview {
  flex: 0 0 auto;
  margin-top: 0;
}

.modal.modal-screenshot .screenshot-preview-stage {
  max-height: min(640px, calc(92vh - 168px));
}

.modal.modal-screenshot .screenshot-modal-actions {
  flex-shrink: 0;
  margin-top: 12px;
}

.share-manage-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.share-manage-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg);
}

.share-manage-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 6px;
}

.share-manage-head strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.share-manage-scope {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 10px;
}

.share-manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-manage-footer {
  margin-top: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.log-item {
  border-left: 3px solid var(--border);
  padding: 8px 0 8px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.log-item.level-ERROR {
  border-color: var(--danger);
}

.log-item.level-WARN {
  border-color: var(--warn);
}

.checkbox-list {
  min-height: var(--list-min-h);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}

.checkbox-list label {
  display: flex;
  gap: 8px;
  padding: 6px 4px;
  font-size: 13px;
  cursor: pointer;
}

.checkbox-list label:hover {
  background: var(--bg);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-actions .btn {
  padding: 6px 10px;
  font-size: 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
