:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7785;
  --line: #d7dee8;
  --blue: #2f7cf6;
  --blue2: #1f63d8;
  --danger: #c0392b;
  --ok: #1f8a55;
  --warn: #b7791f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(47,124,246,.16), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(47,124,246,.1), transparent 50%),
    var(--bg);
  min-height: 100vh;
}
.muted { color: var(--muted); font-size: 13px; }
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(28,36,48,.08);
}
.login-card {
  width: min(380px, 100%);
  padding: 28px 24px;
  display: grid;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 22px; }
label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #f8fafc;
}
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
}
.btn:hover { background: #f3f6fb; }
.btn.primary {
  background: linear-gradient(180deg, var(--blue), var(--blue2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: rgba(192,57,43,.3); }
.err {
  background: rgba(192,57,43,.08);
  color: var(--danger);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.hide { display: none !important; }
.app { max-width: 1200px; margin: 0 auto; padding: 18px; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.top-actions { display: flex; gap: 8px; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  padding: 14px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
}
.stat b { display: block; font-size: 22px; margin-top: 4px; }
.grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; }
}
.panel { padding: 16px; }
.panel h2, .panel h3 { margin: 0 0 12px; font-size: 16px; }
.form { display: grid; gap: 10px; }
.mt { margin-top: 22px; }
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.wrap { flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 140px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f5f8fc; color: var(--muted); font-weight: 600; }
.key {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2f7;
}
.pill.unused { background: #e8f1ff; color: #1f63d8; }
.pill.active { background: rgba(31,138,85,.12); color: var(--ok); }
.pill.expired { background: rgba(183,121,31,.14); color: var(--warn); }
.pill.disabled { background: rgba(192,57,43,.1); color: var(--danger); }
.ops { display: flex; flex-wrap: wrap; gap: 6px; }
.created { margin-top: 14px; display: grid; gap: 8px; }
.logs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}
.logs li {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 10px;
  background: #f7f9fc;
  border-radius: 8px;
}
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  background: #1c2430;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  transition: opacity .2s;
}
.toast.off { opacity: 0; pointer-events: none; }
.toast.err { background: var(--danger); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.tab.on {
  background: linear-gradient(180deg, var(--blue), var(--blue2));
  color: #fff;
  border-color: transparent;
}
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.tab-pane.hide { display: none !important; }
.panel.narrow { max-width: 480px; }
.small { font-size: 12px; color: var(--muted); }
.dev-row { font-size: 12px; background: #f8fafc; }
.dev-row code { font-family: ui-monospace, Consolas, monospace; }

.fb-list { display: grid; gap: 12px; }
.fb-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fafbfd;
}
.fb-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.fb-body {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.fb-meta { font-size: 12px; margin-bottom: 8px; }
.fb-note {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  margin-bottom: 8px;
  resize: vertical;
}
.pill.open { background: rgba(47,124,246,.12); color: var(--blue); }
.pill.doing { background: rgba(183,121,31,.14); color: var(--warn); }
.pill.done { background: rgba(31,138,85,.12); color: var(--ok); }
.pill.type { background: #eef2f7; color: var(--muted); }

.row-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  grid-template-columns: none !important;
}
.row-check input { width: auto; }
.app-list { display: grid; gap: 14px; }
.app-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fafbfd;
}
.app-item.off { opacity: 0.72; }
.app-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.app-fields {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}
.app-fields textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
}
.btn.sm.primary {
  background: linear-gradient(180deg, var(--blue), var(--blue2));
  border-color: transparent;
  color: #fff;
}

.page-title { margin: 0 0 6px; font-size: 20px; }
.pick-grid { margin-top: 12px; }
.app-picker { display: grid; gap: 10px; }
.app-pick {
  text-align: left;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.app-pick:hover { border-color: rgba(47,124,246,.45); background: #fff; }
.app-pick.off { opacity: .7; }
.app-pick-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.app-pick-enter {
  margin-top: 10px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}

.work-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.work-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.work-name { font-size: 18px; font-weight: 700; }

.api-list { display: grid; gap: 12px; margin-top: 12px; }
.api-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
}
.api-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.api-method {
  display: inline-block;
  min-width: 48px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: #e8f1ff;
  color: #1f63d8;
  font-size: 12px;
  font-weight: 700;
}
.api-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
.api-url {
  flex: 1;
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  word-break: break-all;
  font-size: 12px;
}
.api-sample {
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: #1c2430;
  color: #e8eef7;
  font-size: 12px;
  overflow: auto;
}
.narrow-lg { max-width: 720px; }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pill.ok { background: rgba(31,138,85,.12); color: var(--ok); }
.pill.fail { background: rgba(192,57,43,.1); color: var(--danger); }
.pill.online { background: rgba(47,124,246,.12); color: var(--blue2); }
table.compact th, table.compact td { padding: 8px 10px; font-size: 12px; }
.small { font-size: 12px; }

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  max-width: 100%;
}
.tabs .tab {
  white-space: nowrap;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
}
.tabs .tab.on {
  background: #e8f1ff;
  border-color: rgba(47,124,246,.35);
  color: var(--blue2);
  font-weight: 600;
}

.overview-stats { margin-top: 12px; margin-bottom: 4px; }
.app-pick-meta { margin-top: 4px; }

.tab-select {
  display: none;
  width: 100%;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

/* 手机端：卡密列表卡片化 */
@media (max-width: 768px) {
  .tab-select { display: block !important; }
  #workTabs .tab { display: none; }
  .table-wrap table.card-table-mobile thead { display: none; }
  .table-wrap table.card-table-mobile tbody tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: #f8fafc;
  }
  .table-wrap table.card-table-mobile tbody td {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border: none;
    font-size: 13px;
  }
  .table-wrap table.card-table-mobile tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    flex-shrink: 0;
  }
  .table-wrap table.card-table-mobile tbody td.key {
    display: block;
    font-weight: 600;
    word-break: break-all;
  }
  .table-wrap table.card-table-mobile tbody td.key::before { display: none; }
  .table-wrap table.card-table-mobile tbody td.ops-cell {
    display: block;
    padding-top: 8px;
  }
  .table-wrap table.card-table-mobile tbody td.ops-cell::before { display: none; }
  .table-wrap table.card-table-mobile .ops {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .pick-grid { grid-template-columns: 1fr !important; }
  .work-bar { position: sticky; top: 0; z-index: 20; }
  .gate { padding: 16px; }
}

@media (max-width: 768px) {
  .app { padding: 10px; }
  .top { flex-direction: column; align-items: stretch; }
  .top-actions { justify-content: flex-end; }
  .work-bar { padding: 10px; }
  .work-bar-left { flex-direction: column; align-items: flex-start; }
  .work-name { font-size: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px; }
  .stat b { font-size: 18px; }
  .panel { padding: 12px; }
  .filters { width: 100%; }
  .filters input, .filters select { flex: 1; min-width: 0; }
  .row-between { align-items: flex-start; }
  .ops { gap: 4px; }
  .ops .btn.sm { padding: 5px 8px; font-size: 11px; }
  .toast { left: 12px; right: 12px; bottom: 12px; }
  th, td { padding: 8px; }
  .login-card { padding: 22px 16px; }
  .pick-grid .panel { margin-bottom: 0; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .tabs .tab { padding: 6px 10px; font-size: 11px; }
}

.create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}
.create-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--card);
}
.create-box h3 {
  margin: 0 0 10px;
  font-size: 14px;
}
.inline-team {
  margin-bottom: 16px;
  max-width: 420px;
}
