:root {
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --primary-soft: rgba(25, 118, 210, 0.1);
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #d32f2f;
  --radius: 12px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-2: 0 12px 32px rgba(16, 24, 40, 0.16);
}

* {
  box-sizing: border-box;
}

/* 作者样式（如 .field{display:block}）会盖掉 UA 的 [hidden]，这里统一兜底 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.appbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}

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

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

/* ---------- 布局 ---------- */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 24px 72px;
}

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

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

.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  background: none;
  border: none;
  padding: 12px 16px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  font-size: 15px;
  margin: 0;
}

.panel-head .hint {
  color: var(--muted);
  font-size: 12px;
  margin-left: 8px;
  font-weight: 400;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.col-check {
  width: 40px;
  padding-right: 0;
}

.col-check input {
  width: auto;
  margin: 0;
  vertical-align: middle;
}

/* ---------- 表格 ---------- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #fafbfe;
  font-weight: 500;
}

td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

tbody tr:hover {
  background: #f9fafc;
}

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

.row-actions {
  white-space: nowrap;
  text-align: right;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, color 0.15s;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(25, 118, 210, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-text {
  background: transparent;
  color: var(--primary);
  padding: 6px 10px;
}

.btn-text:hover {
  background: var(--primary-soft);
}

.btn-text.danger {
  color: var(--danger);
}

.btn-text.danger:hover {
  background: rgba(211, 47, 47, 0.08);
}

.btn-block {
  width: 100%;
}

/* ---------- 表单 ---------- */

.field {
  display: block;
  margin-bottom: 16px;
}

.field > span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #cfd6e4;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input:disabled {
  background: #f3f4f8;
  color: var(--muted);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

/* ---------- 登录页 ---------- */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e3ecfb 0%, var(--bg) 62%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 32px 32px;
}

.login-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}

.login-card h1 {
  font-size: 20px;
  text-align: center;
  margin: 0 0 6px;
}

.login-card .muted {
  text-align: center;
  margin: 0 0 28px;
}

/* ---------- 状态标签 ---------- */

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.chip-green {
  background: #e8f5e9;
  color: #2e7d32;
}

.chip-amber {
  background: #fff4e5;
  color: #b26a00;
}

.chip-blue {
  background: #e3f2fd;
  color: #1565c0;
}

.chip-red {
  background: #fdecea;
  color: #c62828;
}

.chip-gray {
  background: #eceff1;
  color: #546e7a;
}

/* ---------- 弹窗 ---------- */

dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: var(--shadow-2);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

dialog.dialog-wide {
  width: min(720px, calc(100vw - 32px));
}

.dialog-head {
  padding: 22px 24px 4px;
  font-size: 17px;
  font-weight: 600;
}

.dialog-body {
  padding: 16px 24px 4px;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 24px 20px;
}

/* ---------- 提示条 ---------- */

.snackbar {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: #263238;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: min(560px, calc(100vw - 32px));
}

.snackbar.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.snackbar.error {
  background: var(--danger);
}

/* ---------- 工具类 ---------- */

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

.small {
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.strong {
  font-weight: 600;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 12px;
}

/* ---------- 应用控制台 ---------- */

.app-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  margin-bottom: 16px;
}

.app-card-main {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}

.app-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 600;
  flex-shrink: 0;
}

.app-card-info {
  min-width: 0;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 32px;
  margin-top: 12px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.meta-label {
  color: var(--muted);
  font-size: 12px;
}

.meta-item span:last-child {
  overflow-wrap: anywhere;
}

.app-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 12px;
}

.back-link:hover {
  text-decoration: underline;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}

.page-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.section-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-body {
  padding: 16px 20px;
}

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

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
}

.checkbox-row input {
  width: auto;
}

.checkbox-row span {
  color: var(--text);
  font-size: 14px;
}

/* ---------- 推送 ---------- */

.hour-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hour-range select {
  width: auto;
  flex: 0 0 104px;
}

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

.app-picker {
  border: 1px solid #e3e8f1;
  border-radius: 10px;
  max-height: 190px;
  overflow: auto;
  padding: 4px 6px;
  background: #fbfcfe;
}

.app-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.app-option:hover {
  background: var(--primary-soft);
}

.app-option input {
  width: auto;
  flex-shrink: 0;
}

.app-option-name {
  font-size: 13px;
  font-weight: 500;
}

.app-option-package {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-body .hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.btn-danger:hover {
  background: #b71c1c;
}

/* ---------- 密码签发 ---------- */

.key-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}

.key-meta {
  color: var(--muted);
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field-head .btn {
  padding: 2px 8px;
}

.key-actions {
  display: flex;
  gap: 4px;
}

.key-pem {
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
  resize: vertical;
  background: #fbfcfe;
}

.key-sample-card {
  margin-top: 16px;
}

.code-tabs {
  display: flex;
  gap: 4px;
}

.code-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.code-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
}

.code-block {
  margin: 0 0 12px;
  padding: 14px 16px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  tab-size: 4;
}

.crypto-usage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.panel-body .hint {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 12px;
}

.crypto-usage code,
.panel-body .hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  background: #eef2f7;
  color: #1f2937;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

@media (max-width: 860px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .app-card {
    flex-direction: column;
  }

  .meta-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .container {
    padding: 16px 16px 56px;
  }

  .appbar-inner {
    padding: 0 16px;
  }

  .user {
    display: none;
  }

  .panel-head {
    padding: 14px 16px;
  }

  th,
  td {
    padding: 10px 16px;
  }
}
