/* ==========================================================================
   LobsterAI 控制面板 — 样式（暗色默认 + 亮色主题）
   ========================================================================== */

:root {
  --bg: #0b0d13;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #1b1f31 0%, transparent 60%),
             radial-gradient(900px 500px at 100% 0%, #1d1626 0%, transparent 55%);
  --side: rgba(16, 19, 27, .92);
  --surface: #141822;
  --surface-2: #1a1f2c;
  --surface-3: #202636;
  --line: #252d3d;
  --line-soft: #1e2532;
  --text: #e9edf5;
  --text-dim: #aab3c5;
  --muted: #7f8899;
  --brand-1: #ff7a45;
  --brand-2: #ff4d8d;
  --brand: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  --ok: #35c07f;
  --warn: #e8b13c;
  --err: #ee5c53;
  --info: #58a6ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .25);
  --r: 14px;
  --r-sm: 9px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-grad: radial-gradient(1100px 520px at 10% -15%, #e6ecff 0%, transparent 60%),
             radial-gradient(900px 480px at 100% 0%, #ffe9f2 0%, transparent 55%);
  --side: rgba(255, 255, 255, .9);
  --surface: #ffffff;
  --surface-2: #f5f7fc;
  --surface-3: #eceff7;
  --line: #e2e7f1;
  --line-soft: #eef1f7;
  --text: #161c2b;
  --text-dim: #43506b;
  --muted: #6f7a92;
  --shadow: 0 10px 30px rgba(23, 33, 61, .10);
  --shadow-sm: 0 4px 14px rgba(23, 33, 61, .07);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.62 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.sprite { display: none; }
svg { width: 17px; height: 17px; fill: currentColor; flex: none; }
em { font-style: normal; }
h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: .2px; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 8px; margin-left: auto; }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 2px 0; }

/* ---------------------------------------------------------------- 登录页 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop .35s ease both;
}
.login-card .logo { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.login-card h1 { font-size: 19px; }
.login-card .field { text-align: left; margin: 18px 0 14px; }
.msg { color: var(--err); min-height: 18px; font-size: 13px; margin: 10px 0 0; }

/* ------------------------------------------------------------ 表单控件 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px rgba(255, 122, 69, .16);
}
textarea { resize: vertical; min-height: 92px; margin: 12px 0; font-family: var(--mono); font-size: 13px; }
input.mini, select.mini { width: auto; min-width: 120px; }
input.search { min-width: 190px; }
input[type="time"] { min-width: 118px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s, border-color .15s, background .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { border-color: var(--brand-1); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 77, 141, .28);
}
.btn.primary:hover { box-shadow: 0 8px 22px rgba(255, 77, 141, .38); }
.btn.ghost { background: transparent; }
.btn.icon { padding: 8px; }
.btn.block { width: 100%; justify-content: center; padding: 10px 14px; }
.btn.danger { color: var(--err); border-color: rgba(238, 92, 83, .35); background: rgba(238, 92, 83, .08); }
.btn.danger:hover { border-color: var(--err); background: rgba(238, 92, 83, .16); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; margin-bottom: 14px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 42px; height: 24px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--line);
  position: relative; transition: background .2s, border-color .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s;
}
.switch input:checked + .track { background: var(--brand); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(18px); background: #fff; }

/* ---------------------------------------------------------------- 布局 */
.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  background: var(--side);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side-brand .logo { font-size: 22px; }
.side-title { display: flex; flex-direction: column; font-weight: 700; letter-spacing: .3px; line-height: 1.25; }
.side-title em { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 10px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim); font: inherit; font-size: 13.5px;
  cursor: pointer; text-align: left; width: 100%;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(255, 122, 69, .16), rgba(255, 77, 141, .12));
  border-color: rgba(255, 122, 69, .32);
  color: var(--text);
  font-weight: 600;
}
.nav-item.active svg { color: var(--brand-1); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 3px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.nav-item.subtly { font-size: 13px; }
.side-note { color: var(--muted); font-size: 11px; margin: 8px 6px 0; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 15px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.dot-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-dim);
  background: var(--surface); border: 1px solid var(--line);
  padding: 5px 12px; border-radius: 999px;
}
.dot-pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 3px rgba(127, 136, 153, .16);
}
.dot-pill.ok { color: var(--ok); border-color: rgba(53, 192, 127, .35); }
.dot-pill.ok::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(53, 192, 127, .18); animation: pulse 2.4s infinite; }
.dot-pill.err { color: var(--err); border-color: rgba(238, 92, 83, .35); }
.dot-pill.err::before { background: var(--err); box-shadow: 0 0 0 3px rgba(238, 92, 83, .18); }

.content { padding: 20px 24px 64px; display: flex; flex-direction: column; gap: 16px; max-width: 1240px; }
.view { display: flex; flex-direction: column; gap: 16px; animation: fade .25s ease both; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes slidein { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.card-body { padding: 16px 18px; }
.card-body > *:last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 3px;
  position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px;
  border-radius: 50%; background: rgba(255, 122, 69, .07);
}
.stat.accent::after { background: rgba(255, 77, 141, .12); }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat b { font-size: 26px; font-weight: 700; letter-spacing: .3px; }
.stat b.small { font-size: 17px; }
.stat.accent b { background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-sub { color: var(--muted); font-size: 12px; min-height: 18px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt, .kv .k { color: var(--muted); font-size: 12.5px; }
.kv .v { text-align: right; word-break: break-all; }

.summary-row { display: flex; gap: 22px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
.summary-row > div { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: var(--muted); }
.summary-row b { font-size: 20px; color: var(--text); }
.summary-row .brand b { color: transparent; background: var(--brand); -webkit-background-clip: text; background-clip: text; }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; border-radius: var(--r-sm); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table thead th {
  color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap;
  background: var(--surface-2);
  position: sticky; top: 0; z-index: 1;
}
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable::after { content: "↕"; opacity: .35; margin-left: 5px; font-size: 10px; }
.table th.sortable.asc::after { content: "↑"; opacity: .9; color: var(--brand-1); }
.table th.sortable.desc::after { content: "↓"; opacity: .9; color: var(--brand-1); }
.sub { color: var(--muted); font-size: 11.5px; }

.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: rgba(53, 192, 127, .35); background: rgba(53, 192, 127, .09); }
.badge.warn { color: var(--warn); border-color: rgba(232, 177, 60, .35); background: rgba(232, 177, 60, .1); }
.badge.err { color: var(--err); border-color: rgba(238, 92, 83, .35); background: rgba(238, 92, 83, .1); }
.badge.info { color: var(--info); border-color: rgba(88, 166, 255, .35); background: rgba(88, 166, 255, .1); }

/* 分段选择（账号挑选策略等） */
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 16px; }
.seg-btn {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  text-align: left; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text); font: inherit;
  cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.seg-btn b { font-size: 13.5px; }
.seg-btn em { font-style: normal; font-size: 12px; color: var(--muted); }
.seg-btn:hover:not(:disabled) { border-color: var(--brand-1); background: var(--surface-3); }
.seg-btn.active {
  border-color: rgba(255, 122, 69, .55);
  background: linear-gradient(135deg, rgba(255, 122, 69, .14), rgba(255, 77, 141, .1));
  box-shadow: 0 0 0 1px rgba(255, 122, 69, .25) inset;
}
.seg-btn.active b { background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.seg-btn:disabled { opacity: .55; cursor: not-allowed; }

.meter { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 6px; min-width: 96px; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--ok); }
.meter > i.warn { background: var(--warn); }
.meter > i.err { background: var(--err); }

.empty { text-align: center; padding: 42px 16px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); }
.empty-icon { font-size: 34px; margin-bottom: 6px; opacity: .85; }
.empty p { margin: 4px 0 14px; }

.skel { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%); background-size: 400px 100%; animation: shimmer 1.3s infinite linear; }

.mini-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.mini-row:last-child { border-bottom: none; }
.mini-row .uid { font-family: var(--mono); font-size: 12px; }
.mini-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px; color: var(--text-dim);
}
.chip .x { cursor: pointer; color: var(--muted); font-size: 13px; line-height: 1; }
.chip .x:hover { color: var(--err); }
.chip.ok { color: var(--ok); border-color: rgba(53, 192, 127, .32); }
.chip.warn { color: var(--warn); border-color: rgba(232, 177, 60, .32); }
.chip.err { color: var(--err); border-color: rgba(238, 92, 83, .32); }
.chip-btn {
  background: var(--surface-2); border: 1px dashed var(--line); color: var(--text-dim);
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip-btn:hover { border-color: var(--brand-1); color: var(--text); }

.log {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 14px;
  margin: 0;
  max-height: 460px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-dim);
}
.log.tall { max-height: 60vh; }
.log.short { max-height: 200px; }

/* 只读代码/地址行（网关地址、密钥等） */
.code-line {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-dim);
}

/* ---------------------------------------------------------------- 弹窗 */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(6, 9, 16, .6); backdrop-filter: blur(6px); animation: fade .18s ease both; }
.modal-box {
  width: min(680px, 100%); max-height: 86vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); animation: pop .22s ease both;
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { flex: 1; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 18px 18px; }
.modal ol { padding-left: 20px; margin: 0 0 12px; }
.modal ol li { margin-bottom: 8px; font-size: 13px; color: var(--text-dim); }
.url-box { display: flex; gap: 8px; margin: 10px 0; }
.url-box input { font-family: var(--mono); font-size: 12px; }

/* ---------------------------------------------------------------- 提示 */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 9px; max-width: min(420px, calc(100vw - 36px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 11px; padding: 11px 14px; font-size: 13px;
  box-shadow: var(--shadow); animation: slidein .22s ease both;
  white-space: pre-wrap; word-break: break-word;
}
.toast.err { border-left-color: var(--err); }
.toast.info { border-left-color: var(--info); }

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; height: auto; z-index: 30;
    flex-direction: row; align-items: center; gap: 8px;
    padding: 10px 12px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line);
  }
  .side-brand { padding: 0 8px 0 2px; }
  .side-title em { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav-item { width: auto; padding: 8px 12px; white-space: nowrap; }
  .nav-item span { display: none; }
  .nav-item.active span { display: inline; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; border: none; padding: 0; }
  .side-foot .nav-item span, .side-note { display: none; }
  .content { padding: 16px 14px 56px; }
  .topbar { padding: 12px 14px; }
  .stat b { font-size: 22px; }
}
@media (max-width: 620px) {
  .card-head { align-items: flex-start; }
  .row.tight { margin-left: 0; width: 100%; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 10px; padding: 6px 4px; background: var(--surface-2); }
  .table td { border: none; display: flex; justify-content: space-between; gap: 14px; padding: 7px 12px; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  .table td:empty { display: none; }
}
