/* ==========================================================================
   autoclaw2api 控制台样式
  设计语言：现代浅色 SaaS 控制台（Linear / Stripe 系）+ 工程终端感装饰
  依据：openai-proxy-service skill 的 ui-design-guide.md
   ========================================================================== */

:root {
  --ink: #101827;
  --muted: #718096;
  --line: #e5e9ef;
  --blue: #4056e8;
  --blue-dark: #3046d2;
  --soft: #f5f7fb;
  --green: #20a16a;
  --red: #d84c61;
  --shadow: 0 18px 50px rgba(18, 32, 61, .08);
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  background: var(--soft);
  color: var(--ink);
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, a, input, select, textarea {
  transition: color .2s ease, background-color .2s ease,
              border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.eyebrow {
  font: 500 10px "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .16em;
  color: var(--blue);
  text-transform: uppercase;
  margin: 0;
}

.meta, .docs, .technical-label, code, pre {
  font-family: "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── 按钮 ─────────────────────────────────────────────────────────────── */
button { font-family: inherit; font-size: 14px; cursor: pointer; border: 0; background: none; }

.primary {
  background: var(--blue);
  color: #fff;
  border-radius: 9px;
  padding: 12px 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.primary:hover { background: var(--blue-dark); transform: translateY(-1px); }
.primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.ghost-button, .secondary-button {
  background: transparent;
  color: #667286;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 600;
  white-space: nowrap;
}
.ghost-button:hover, .secondary-button:hover { background: #e9edf5; color: var(--ink); }
.secondary-button { border: 1px solid #dce2ea; background: #fff; }
.secondary-button.danger { color: var(--red); border-color: #f2ccd3; }
.secondary-button.danger:hover { background: #fdf2f4; color: #b93a4d; }

button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, dialog button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ── 品牌符号 ─────────────────────────────────────────────────────────── */
.brand-mark, .brand-symbol {
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  transform: rotate(-8deg);
  box-shadow: 0 8px 20px rgba(64, 86, 232, .25);
  border-radius: 15px;
}
.brand-muted { color: #a5afbd; font-weight: 500; }

/* ── 登录页 ───────────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 34px;
  display: grid;
  grid-template-columns: 1.06fr .94fr;
  gap: 80px;
  align-items: center;
}

.login-visual { display: flex; flex-direction: column; }
.login-visual .brand-mark { width: 49px; height: 49px; font-size: 17px; margin-bottom: 40px; }
.login-visual .visual-kicker { margin-bottom: 22px; }
.login-visual h1 {
  font-size: clamp(40px, 5vw, 66px);
  line-height: 1.08;
  letter-spacing: -.06em;
  font-weight: 800;
  margin: 0 0 26px;
}
.login-visual h1 em { font-style: normal; color: var(--blue); }
.visual-copy { color: var(--muted); max-width: 410px; line-height: 1.8; margin: 0 0 40px; }
.visual-line {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #a0aaba;
  font: 500 10px "DM Mono", monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.visual-line::before {
  content: "";
  width: 46px;
  height: 1px;
  background: var(--blue);
  opacity: .55;
  flex: none;
}

.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 46px 48px;
  box-shadow: var(--shadow);
  max-width: 450px;
  width: 100%;
  justify-self: end;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  margin-bottom: 40px;
}
.login-brand .brand-symbol { width: 34px; height: 34px; font-size: 12px; border-radius: 11px; }
.login-heading { margin-bottom: 30px; }
.login-heading .eyebrow { margin-bottom: 12px; }
.login-heading h2 {
  font-size: 29px;
  line-height: 1.1;
  letter-spacing: -.06em;
  font-weight: 800;
  margin: 0 0 12px;
}
.login-heading p { color: var(--muted); margin: 0; }

.login-card .field { margin-bottom: 20px; }
.login-card .primary { width: 100%; height: 48px; }
.login-card .login-foot {
  margin-top: 26px;
  color: #a0aaba;
  font-size: 12px;
  text-align: center;
}

label {
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #dce2ea;
  background: #fbfcfe;
  border-radius: 9px;
  padding: 12px 13px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(64, 86, 232, .1);
}
input[type="checkbox"] { width: auto; }

.error {
  min-height: 1.4em;
  color: var(--red);
  font-size: 12px;
  margin: 0 0 12px;
}
.error:empty::before { content: "\00a0"; }

/* ── 控制台 ───────────────────────────────────────────────────────────── */
main.shell { max-width: 1240px; margin: 0 auto; padding: 0 34px 56px; }

.topbar {
  height: 112px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.topbar-brand { display: flex; align-items: center; gap: 14px; }
.topbar-brand .brand-symbol { width: 42px; height: 42px; font-size: 15px; flex: none; }
.topbar-brand .brand-text strong { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
.topbar-brand .brand-text span {
  color: #a5afbd;
  font: 500 10px "DM Mono", monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.online-dot { display: inline-flex; align-items: center; gap: 8px; color: #6c7787; font-size: 12px; font-weight: 600; }
.online-dot i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px #20a16a1f;
}
.online-dot.offline i { background: var(--red); box-shadow: 0 0 0 3px #d84c611f; }

nav.tabs {
  height: 80px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  gap: 30px;
}
nav.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 2px;
  color: #919baa;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
nav.tabs button:hover { color: var(--ink); }
nav.tabs button[aria-selected="true"] { color: var(--blue); border-bottom-color: var(--blue); }
nav.tabs .tab-icon { font-size: 15px; }

.panel { padding-top: 43px; }
.panel[hidden] { display: none; }

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.section-heading .eyebrow { margin-bottom: 11px; }
.section-heading h2 {
  font-size: 29px;
  line-height: 1.1;
  letter-spacing: -.06em;
  font-weight: 800;
  margin: 0 0 9px;
}
.section-subtitle { color: var(--muted); margin: 0; }
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.notice {
  display: flex;
  gap: 13px;
  background: #eff2ff;
  border: 1px solid #e0e4ff;
  border-radius: 12px;
  padding: 15px 18px;
  color: #64719f;
  margin-bottom: 22px;
  align-items: flex-start;
}
.notice p { margin: 0; }
.notice strong { color: #4c5cc6; }
.notice-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 50%;
  background: #d9e0ff;
  color: #4056e8;
  font: 700 11px "DM Mono", monospace;
}

.list { display: flex; flex-direction: column; gap: 11px; }

.row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 20px 22px;
  box-shadow: 0 3px 10px rgba(18, 32, 61, .02);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}
.row:hover { border-color: #cbd3e2; box-shadow: var(--shadow); }
.row strong { display: block; font-size: 14px; font-weight: 700; }
.row .meta { color: #8994a4; font: 11px/1.8 "DM Mono", monospace; margin-top: 5px; word-break: break-all; }
.row .actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.ok { color: var(--green); }
.bad { color: var(--red); }
.dim { color: #919baa; }

.state {
  padding: 42px 22px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 13px;
}
.state.error-state { color: var(--red); border-color: #f2ccd3; }

/* ── 文档面板 ─────────────────────────────────────────────────────────── */
.docs {
  background: #111a2c;
  color: #dce7ff;
  font: 12px/1.8 "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 24px;
  border-radius: 14px;
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.docs-copy {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* ── 模态框 ───────────────────────────────────────────────────────────── */
dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  width: min(680px, calc(100% - 30px));
  box-shadow: 0 25px 80px rgba(16, 24, 39, .22);
}
dialog::backdrop { background: rgba(15, 23, 42, .48); backdrop-filter: blur(3px); }
.dialog-inner { padding: 32px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-header h3 { font-size: 22px; letter-spacing: -.04em; margin: 8px 0 0; font-weight: 800; }
.dialog-close {
  width: 34px; height: 34px;
  border-radius: 9px;
  color: #667286;
  font-size: 17px;
  line-height: 1;
  flex: none;
}
.dialog-close:hover { background: #e9edf5; color: var(--ink); }
.dialog-note { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 15px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 26px; }

.oauth-link-box {
  background: #fbfcfe;
  border: 1px solid #dce2ea;
  border-radius: 9px;
  padding: 12px 13px;
  font: 11px/1.7 "DM Mono", monospace;
  color: #344054;
  word-break: break-all;
  min-height: 44px;
}

/* ── OAuth 结果页 ─────────────────────────────────────────────────────── */
.oauth-body { display: grid; place-items: center; min-height: 100vh; padding: 34px; }
.oauth-result {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 46px 48px;
  box-shadow: var(--shadow);
  max-width: 520px;
  width: 100%;
}
.oauth-result .brand-mark { width: 49px; height: 49px; font-size: 17px; margin-bottom: 30px; }
.oauth-result h1 { font-size: 34px; letter-spacing: -.06em; margin: 12px 0 16px; font-weight: 800; }
.oauth-message { color: var(--muted); margin: 0 0 20px; }

/* ── OAuth 回环回调提示与步骤条 ───────────────────────────────────────── */
.oauth-wide { max-width: 680px; }

.steps {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0;
  margin: 0 0 22px;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #a0aaba;
  font-weight: 700;
  font-size: 13px;
}
.step[data-state="active"] { color: var(--blue); }
.step[data-state="done"] { color: var(--green); }
.step[data-state="error"] { color: var(--red); }
.step-no {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: #e9edf5;
  color: #667286;
  font: 700 11px "DM Mono", monospace;
}
.step[data-state="active"] .step-no { background: #e0e4ff; color: var(--blue); }
.step[data-state="done"] .step-no { background: #d8f3e6; color: var(--green); }
.step[data-state="error"] .step-no { background: #fbe0e5; color: var(--red); }

.oauth-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.oauth-result textarea { margin-bottom: 4px; }
.oauth-result .notice code { color: #4c5cc6; word-break: break-all; }

/* ── 响应式降级 ───────────────────────────────────────────────────────── */
@media (max-width: 780px) {
  main.shell { padding: 0 18px 42px; }
  .login-shell { grid-template-columns: 1fr; gap: 0; padding: 30px 18px; align-items: start; }
  .login-visual { display: none; }
  .login-card { padding: 34px 26px; max-width: none; justify-self: stretch; }
  .topbar { height: 90px; }
  .topbar-actions .online-dot { display: none; }
  nav.tabs { height: 68px; gap: 22px; }
  .panel { padding-top: 32px; }
  .section-heading { flex-direction: column; align-items: stretch; }
  .heading-actions { width: 100%; }
  .heading-actions button { flex: 1 1 auto; justify-content: center; }
  .row { flex-direction: column; align-items: stretch; }
  .row .actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .dialog-inner { padding: 24px; }
  .docs { max-height: 60vh; padding: 18px; }
}
