*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: #222226;
  background: #f3f4f6;
  -webkit-font-smoothing: antialiased;
}
a { color: #fc5531; text-decoration: none; }
a:hover { color: #e84a21; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ====== layout ====== */
.admin-layout { display: flex; min-height: 100vh; }
.admin-side {
  width: 220px;
  background: #1f2329;
  color: #c9cdd4;
  display: flex;
  flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
}
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; border-bottom: 1px solid #2a2f36; }
.admin-brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fc5531, #ff7e4a);
  color: #fff; font-weight: 800;
}
.admin-brand-name { font-size: 14px; font-weight: 700; color: #fff; }
.admin-brand-sub { font-size: 11px; color: #7a8594; }
.admin-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  color: #c9cdd4;
  border-radius: 6px;
  font-size: 14px;
}
.admin-nav a:hover { background: #2a2f36; color: #fff; }
.admin-nav a.active { background: #fc5531; color: #fff; }
.admin-user { padding: 14px 18px; border-top: 1px solid #2a2f36; display: flex; align-items: center; gap: 10px; }
.admin-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #fc5531, #ff9466);
  color: #fff; display: grid; place-items: center; font-weight: 700;
}
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { color: #fff; font-weight: 600; font-size: 14px; }
.admin-user-logout { font-size: 12px; color: #7a8594; }
.admin-user-logout:hover { color: #fc5531; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid #eceef1;
  position: sticky; top: 0; z-index: 5;
}
.admin-page-title { margin: 0; font-size: 18px; font-weight: 600; color: #1b1b1b; }
.admin-quick { display: flex; gap: 10px; }
.admin-content { padding: 24px; }

/* ====== forms / buttons / tables ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; height: 34px;
  background: #fff; border: 1px solid #d9dde2;
  color: #3a3a3d;
  border-radius: 6px; cursor: pointer; font-size: 13px;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: #fc5531; color: #fc5531; }
.btn-primary { background: #fc5531; color: #fff; border-color: #fc5531; }
.btn-primary:hover { background: #e84a21; border-color: #e84a21; color: #fff; }
.btn-danger { background: #fff; color: #dc3545; border-color: #f3c7cc; }
.btn-danger:hover { background: #dc3545; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-text { background: transparent; border: 0; color: #6b7079; }
.btn-text:hover { color: #fc5531; background: transparent; }
.btn-sm { height: 28px; padding: 4px 10px; font-size: 12px; }
.btn-lg { height: 40px; padding: 0 20px; font-size: 14px; }

.input, .textarea, .select {
  width: 100%;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #d9dde2;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: #fc5531; }
.textarea { min-height: 80px; resize: vertical; }

.form-row { display: grid; grid-template-columns: 140px 1fr; gap: 14px; align-items: start; margin-bottom: 16px; }
.form-row label { padding-top: 8px; color: #3a3a3d; }
.form-row .hint { font-size: 12px; color: #8a8f98; margin-top: 6px; }

.card {
  background: #fff;
  border: 1px solid #eceef1;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}

.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  background: #fff;
  border: 1px solid #eceef1;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}
.card-header h3 { margin: 0; font-size: 15px; }
.card-body {
  background: #fff; border: 1px solid #eceef1; border-radius: 0 0 8px 8px; padding: 20px;
  margin-bottom: 18px;
}

.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.table th, .table td {
  text-align: left; padding: 10px 14px; border-bottom: 1px solid #eceef1;
  font-size: 13px;
}
.table th { background: #f6f7f8; font-weight: 600; color: #3a3a3d; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbfc; }
.table .col-actions { text-align: right; white-space: nowrap; }
.table .col-actions .btn { margin-left: 6px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  background: #f1f2f4;
  color: #6b7079;
  font-size: 11.5px;
  border-radius: 10px;
  font-weight: 500;
}
.badge.published { background: #e6f5ea; color: #2c8c4a; }
.badge.draft { background: #fff4dd; color: #a06a00; }
.badge.archived { background: #e9ecef; color: #5f646d; }

/* ====== login ====== */
.login-screen {
  display: grid; place-items: center; min-height: 100vh;
  background: linear-gradient(135deg, #fc5531, #ff7e4a);
}
.login-box {
  width: 360px;
  padding: 32px 28px 26px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-box h1 { font-size: 20px; text-align: center; margin: 0 0 22px; color: #1b1b1b; }
.login-box .input { margin-bottom: 14px; height: 40px; }
.login-box .btn { width: 100%; height: 40px; font-size: 14px; }
.login-box .msg { margin: 0 0 10px; color: #dc3545; font-size: 13px; min-height: 18px; }

/* ====== dashboard ====== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: #fff;
  border: 1px solid #eceef1;
  border-radius: 8px;
  padding: 18px 20px;
}
.stat-card .stat-label { font-size: 12.5px; color: #8a8f98; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #1b1b1b; line-height: 1; }

/* ====== posts list ====== */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px;
}
.toolbar .spacer { flex: 1; }
.toolbar .input { width: 260px; }

/* ====== editor page ====== */
.editor-shell { display: grid; grid-template-rows: auto auto 1fr; gap: 14px; }
.editor-title-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.editor-title-row .input { height: 44px; font-size: 17px; font-weight: 600; }
.editor-meta-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px;
}
#vditor {
  min-height: 62vh;
  background: #fff;
  border: 1px solid #eceef1;
  border-radius: 8px;
  overflow: hidden;
}

/* ====== media ====== */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.media-item {
  position: relative;
  background: #fff;
  border: 1px solid #eceef1;
  border-radius: 6px;
  aspect-ratio: 4/3;
  overflow: hidden;
}
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .actions {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 8px;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  display: flex; justify-content: space-between; gap: 8px;
  opacity: 0;
  transition: opacity .15s;
}
.media-item:hover .actions { opacity: 1; }
.media-item .actions button {
  background: rgba(255,255,255,0.9); color: #1b1b1b; border: 0; padding: 4px 8px;
  border-radius: 4px; font-size: 11.5px; cursor: pointer;
}
.media-upload {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: 4/3;
  border: 1.5px dashed #c5c9d0;
  border-radius: 6px;
  color: #8a8f98;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.media-upload:hover { border-color: #fc5531; color: #fc5531; }
.media-upload input { display: none; }

/* ====== history list ====== */
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li {
  padding: 14px 16px; background: #fff; border: 1px solid #eceef1; border-radius: 6px; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.history-list time { color: #6b7079; font-size: 13px; }

.flash { margin-bottom: 16px; padding: 10px 14px; border-radius: 6px; font-size: 13px; }
.flash.ok { background: #e6f5ea; color: #2c8c4a; border: 1px solid #b7e4c4; }
.flash.err { background: #fde8ea; color: #c02841; border: 1px solid #f5c2c8; }

@media (max-width: 720px) {
  .admin-side { width: 60px; }
  .admin-brand-name, .admin-brand-sub, .admin-nav a span, .admin-user-info { display: none; }
  .admin-nav a { justify-content: center; padding: 10px; }
}
