:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e6e8eb;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --brand: #3370ff;
  --brand-dark: #245bdb;
  --brand-bg: #eef3ff;
  --ok: #1d9e75;
  --danger: #d4380d;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.hidden { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }

.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 44px 52px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(31, 35, 41, 0.06);
  width: 420px;
}
.logo {
  width: 60px; height: 60px;
  margin: 0 auto 18px;
  border-radius: 15px;
  background: var(--brand);
  color: #fff;
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
}
.logo.small { width: 30px; height: 30px; font-size: 15px; border-radius: 8px; margin: 0; }
.login-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.login-card p { margin-bottom: 20px; }

.btn-primary {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 26px;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost {
  color: var(--text-2);
  text-decoration: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--bg); }
.btn-ghost.danger { color: var(--danger); border-color: #ffccc7; }

.dev-box { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border); }
.dev-box .input { margin: 8px 0; }

.input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: var(--surface);
  font-family: inherit;
}
.input:focus { border-color: var(--brand); }

.app-view { min-height: 100vh; }
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.user-box { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-bg); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-name { color: var(--text-2); }
.badge {
  background: var(--brand-bg); color: var(--brand);
  border-radius: 5px; padding: 2px 8px; font-size: 12px;
}

.tabs {
  display: flex; gap: 4px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab {
  background: none; border: none; cursor: pointer;
  padding: 12px 16px; font-size: 14px; color: var(--text-2);
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

.content { padding: 24px; max-width: 1100px; }
.panel-head { margin-bottom: 16px; }
.panel-head h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
  max-width: 560px;
}
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.scope-box { display: flex; flex-wrap: wrap; gap: 12px; padding: 6px 0; }
.scope-box label { display: inline-flex; align-items: center; gap: 5px; margin: 0; color: var(--text); cursor: pointer; }

.token-result {
  background: #f0fdf7;
  border: 1px solid #9fe1cb;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
  max-width: 720px;
}
.token-result h3 { font-size: 14px; font-weight: 600; color: #0f6e56; margin-bottom: 10px; }
.token-value {
  display: block;
  background: #1f2329; color: #e6e8eb;
  padding: 12px; border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; word-break: break-all;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 13px;
}
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--bg); color: var(--text-2); font-weight: 500; }
.table tr:last-child td { border-bottom: none; }
.table code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text-2); }
.state-ok { color: var(--ok); }
.state-off { color: var(--text-3); }

.app-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.app-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.app-card .aid { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--brand); }
.app-card .ep { font-size: 12px; color: var(--text-3); word-break: break-all; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 1px 8px; font-size: 12px; color: var(--text-2); }
.empty { color: var(--text-3); padding: 30px 0; text-align: center; }
