/* ============ Reset & Base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  font-size: 14px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: #0066cc; text-decoration: none; }
a:hover { text-decoration: underline; }

/* hidden 属性优先级兜底：避免被用户样式覆盖 */
[hidden] { display: none !important; }

/* ============ 登录页 ============ */
.page#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
  background: white;
  padding: 40px 36px;
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  width: 360px;
  text-align: center;
}
.login-card h1 {
  font-size: 24px;
  margin-bottom: 6px;
  color: #1d1d1f;
}
.login-card .subtitle {
  color: #86868b;
  font-size: 13px;
  margin-bottom: 24px;
}
#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#login-form input {
  padding: 12px 14px;
  border: 1px solid #d2d2d7;
  border-radius: 10px;
  background: #fbfbfd;
  transition: all 0.15s;
}
#login-form input:focus {
  outline: none;
  border-color: #0066cc;
  background: white;
}
#login-form button {
  padding: 12px;
  background: #0066cc;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  margin-top: 8px;
  transition: background 0.15s;
}
#login-form button:hover { background: #0055aa; }
.error-msg {
  color: #ff3b30;
  background: #fff5f5;
  border: 1px solid #ffccc7;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 12px;
}

/* ============ 后台主体 ============ */
.page#app-page {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 220px;
  background: #1d1d1f;
  color: #f5f5f7;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}
.brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid #2c2c2e;
}
.brand h2 { font-size: 18px; }
nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
}
.nav-item {
  padding: 11px 20px;
  color: #d2d2d7;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
}
.nav-item:hover { background: #2c2c2e; text-decoration: none; }
.nav-item.active { background: #0066cc; color: white; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #2c2c2e;
  font-size: 12px;
  color: #86868b;
}
#user-info { margin-bottom: 8px; }
.btn-link {
  background: none;
  border: none;
  color: #0066cc;
  padding: 0;
  font-size: 12px;
}
.btn-link:hover { text-decoration: underline; }

.main {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
}
.content { display: none; }
.content.active { display: block; }
.content h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
}

/* ============ Stats Grid ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.stat-card .label { color: #86868b; font-size: 12px; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 600; color: #1d1d1f; }

/* ============ Toolbar ============ */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}
.toolbar input { flex: 1; }
.toolbar input, .toolbar select {
  padding: 8px 12px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: white;
}

/* ============ Buttons ============ */
.btn-primary, .btn-secondary, .btn-danger {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: #0066cc; color: white; }
.btn-primary:hover { background: #0055aa; }
.btn-secondary { background: #f5f5f7; color: #1d1d1f; border: 1px solid #d2d2d7; }
.btn-secondary:hover { background: #e8e8ed; }
.btn-danger { background: #ff3b30; color: white; }
.btn-danger:hover { background: #d70015; }

/* ============ Tables ============ */
table {
  width: 100%;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border-collapse: collapse;
}
th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}
th { background: #fbfbfd; color: #86868b; font-weight: 500; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fbfbfd; }
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.status-draft { background: #f0f0f0; color: #6e6e73; }
.status-published { background: #d1f4e0; color: #00875a; }
.status-archived { background: #ffe4e1; color: #d70015; }

/* ============ Form ============ */
.form { max-width: 720px; }
.form label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  color: #1d1d1f;
  font-weight: 500;
}
.form input, .form select, .form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: white;
  font-weight: normal;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: #0066cc;
}
.form fieldset {
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.form fieldset legend {
  padding: 0 8px;
  font-weight: 500;
  color: #1d1d1f;
}
.hint { color: #86868b; font-size: 12px; margin: 8px 0; }

/* ============ New Key Box ============ */
.new-key-box {
  background: #fff5f5;
  border: 1px solid #ffccc7;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
}
.new-key-box strong { color: #d70015; }

/* ============ Detail / Modal ============ */
.detail-section {
  background: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.detail-section h3 { margin-bottom: 12px; font-size: 16px; }
.kv-row { display: flex; gap: 12px; padding: 6px 0; }
.kv-row .k { color: #86868b; min-width: 100px; }
.kv-row .v { flex: 1; word-break: break-all; }
