/* ============================================================
   Jade Atelier — admin panel
   ============================================================ */

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

.admin-body {
  margin: 0;
  background: #f2f1ec;
  font-family: "Inter", -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: #1b2422;
  display: flex;
  min-height: 100vh;
}

.admin-side {
  width: 226px;
  flex: 0 0 226px;
  background: #16241f;
  color: #cfd8d2;
  padding: 26px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-brand {
  font-family: Georgia, "Songti SC", serif;
  font-size: 1.05rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #f6f4ee;
  margin-bottom: 26px;
  display: block;
}
.admin-brand small { display: block; font-family: inherit; font-size: 0.6rem; letter-spacing: 0.18em; color: #7f8d86; margin-top: 6px; }
.admin-side a {
  color: #cfd8d2;
  text-decoration: none;
  padding: 9px 12px;
  font-size: 0.84rem;
  letter-spacing: 0.03em;
  border-left: 2px solid transparent;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.admin-side a:hover { background: rgba(255, 255, 255, 0.05); }
.admin-side a.active { background: rgba(255, 255, 255, 0.07); border-left-color: #a8874f; color: #fff; }
.admin-side .count { font-size: 0.68rem; color: #a8874f; }
.admin-side .spacer { flex: 1; }
.admin-side form button {
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #cfd8d2;
  padding: 8px 12px;
  font-size: 0.78rem;
  cursor: pointer;
}
.admin-side form button:hover { border-color: #a8874f; color: #fff; }

.admin-main { flex: 1; padding: 32px 36px 60px; min-width: 0; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.admin-head h1 { font-family: Georgia, "Songti SC", serif; font-size: 1.9rem; font-weight: 400; margin: 0 0 4px; }
.admin-head p { margin: 0; color: #6d756f; font-size: 0.84rem; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat { background: #fff; border: 1px solid #e4e2d9; padding: 20px 22px; }
.stat span { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: #7c837d; }
.stat strong { display: block; font-family: Georgia, serif; font-size: 1.9rem; font-weight: 400; margin-top: 8px; }
.stat small { font-size: 0.72rem; color: #93a09a; }

.panel { background: #fff; border: 1px solid #e4e2d9; margin-bottom: 22px; }
.panel-head { padding: 16px 22px; border-bottom: 1px solid #eeece4; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.panel-head h2 { font-size: 0.92rem; font-weight: 600; letter-spacing: 0.04em; margin: 0; text-transform: uppercase; color: #3d4a44; }
.panel-body { padding: 22px; }

.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7c837d;
  border-bottom: 1px solid #e4e2d9;
  font-weight: 500;
}
.table td { padding: 13px 14px; border-bottom: 1px solid #f0eee7; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #faf9f4; }
.table img.thumb { width: 42px; height: 52px; object-fit: cover; background: #eeece4; }
.table .actions { display: flex; gap: 8px; align-items: center; white-space: nowrap; }

.tag { display: inline-block; font-size: 0.64rem; letter-spacing: 0.1em; text-transform: uppercase; padding: 3px 8px; border: 1px solid currentColor; }
.tag.pending { color: #9a6b1f; }
.tag.paid, .tag.processing, .tag.shipped, .tag.open { color: #2f6354; }
.tag.completed, .tag.closed, .tag.cancelled, .tag.refunded, .tag.answered { color: #7c837d; }
.tag.off { color: #b04a3a; }

.btn-a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #16241f;
  color: #f6f4ee;
  border: 1px solid #16241f;
  padding: 9px 16px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.btn-a:hover { background: #2f6354; border-color: #2f6354; }
.btn-a.ghost { background: transparent; color: #2f6354; border-color: #cfd8d2; }
.btn-a.ghost:hover { border-color: #2f6354; }
.btn-a.danger { background: transparent; color: #b04a3a; border-color: #e6cfca; }
.btn-a.danger:hover { background: #b04a3a; color: #fff; border-color: #b04a3a; }
.btn-a.small { padding: 6px 11px; font-size: 0.72rem; }

.a-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.a-field { display: flex; flex-direction: column; gap: 6px; }
.a-field.full { grid-column: 1 / -1; }
.a-field label { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: #7c837d; }
.a-field input, .a-field select, .a-field textarea {
  border: 1px solid #dcd9cf;
  background: #fff;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  color: inherit;
}
.a-field textarea { min-height: 120px; resize: vertical; }
.a-field input:focus, .a-field select:focus, .a-field textarea:focus { outline: none; border-color: #2f6354; }
.a-field .hint { font-size: 0.72rem; color: #93a09a; }
.check-row { display: flex; gap: 22px; align-items: center; font-size: 0.85rem; }
.check-row label { display: flex; gap: 7px; align-items: center; text-transform: none; letter-spacing: 0; font-size: 0.85rem; color: #3d4a44; }
.img-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.img-strip figure { margin: 0; width: 84px; }
.img-strip img { width: 84px; height: 104px; object-fit: cover; border: 1px solid #e4e2d9; }
.img-strip figcaption { font-size: 0.66rem; color: #93a09a; margin-top: 4px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: #16241f; padding: 24px; }
.login-card { width: 100%; max-width: 372px; background: #f7f5ef; padding: 38px 34px; }
.login-card h1 { font-family: Georgia, serif; font-size: 1.5rem; font-weight: 400; letter-spacing: 0.12em; text-transform: uppercase; text-align: center; margin: 0 0 6px; }
.login-card p { text-align: center; font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase; color: #7c837d; margin: 0 0 26px; }
.login-card .a-field { margin-bottom: 14px; }
.login-card .btn-a { width: 100%; margin-top: 8px; padding: 11px; }
.login-error { background: #f7e8e4; color: #b04a3a; font-size: 0.8rem; padding: 9px 12px; margin-bottom: 14px; }

.thread-a { display: flex; flex-direction: column; gap: 14px; max-height: 460px; overflow-y: auto; padding-right: 6px; margin-bottom: 18px; }
.msg-a { border: 1px solid #eceae2; padding: 12px 14px; font-size: 0.86rem; white-space: pre-line; background: #fbfaf6; }
.msg-a.support { background: #eef3ef; border-color: #d5e2da; }
.msg-a .who { font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: #7c837d; margin-bottom: 6px; }
.empty-a { padding: 40px; text-align: center; color: #93a09a; font-size: 0.86rem; }

/* ---------- live chat ---------- */
.admin-side .count.live { background: #b4432f; color: #fff; border-radius: 9px; padding: 1px 7px; font-size: 0.64rem; letter-spacing: 0.02em; }
.table tr.row-unread td { background: #fbf6ec; }
.table tr.row-unread td:first-child { box-shadow: inset 3px 0 0 #a8874f; }
.table .sub, .sub { font-size: 0.75rem; color: #93a09a; }
.table td.preview { max-width: 380px; font-size: 0.83rem; color: #3d4a44; }
.table td.preview .who { display: block; font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: #a0a89f; margin-bottom: 3px; }
.badge-a { display: inline-block; min-width: 20px; text-align: center; background: #b4432f; color: #fff; border-radius: 10px; font-size: 0.68rem; padding: 2px 6px; }

.chat-admin-grid { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.chat-panel-a { display: flex; flex-direction: column; }
.chat-thread { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; height: clamp(300px, calc(100vh - 420px), 560px); overflow-y: auto; background: #fbfaf6; }
.cmsg { max-width: 76%; display: flex; flex-direction: column; gap: 4px; }
.cmsg.visitor { align-self: flex-start; }
.cmsg.staff { align-self: flex-end; align-items: flex-end; }
.cmsg.system { align-self: center; max-width: 90%; opacity: 0.85; }
.cmsg-who { font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: #a0a89f; }
.cmsg-body {
  padding: 10px 13px;
  font-size: 0.86rem;
  line-height: 1.65;
  white-space: pre-line;
  word-break: break-word;
  background: #fff;
  border: 1px solid #e6e2d8;
  border-radius: 10px;
}
.cmsg.staff .cmsg-body { background: #2f6354; border-color: #2f6354; color: #f4f7f4; }
.cmsg.system .cmsg-body { background: #f0eee6; border-style: dashed; color: #5d6b64; font-size: 0.8rem; }
.cmsg time { font-size: 0.62rem; color: #a0a89f; }

.quick-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 22px 0; border-top: 1px solid #eeece4; }
.quick-chip {
  border: 1px solid #dcd9cf;
  background: #fdfcf8;
  color: #3d4a44;
  font-size: 0.72rem;
  padding: 6px 10px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: inherit;
}
.quick-chip:hover { border-color: #2f6354; color: #2f6354; }

.chat-reply { display: flex; gap: 12px; padding: 14px 22px 20px; align-items: flex-end; }
.chat-reply textarea {
  flex: 1;
  min-width: 0;
  border: 1px solid #dcd9cf;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  resize: none;
  max-height: 160px;
  line-height: 1.6;
}
.chat-reply textarea:focus { outline: none; border-color: #2f6354; }

@media (max-width: 1080px) {
  .chat-admin-grid { grid-template-columns: 1fr; }
  .chat-thread { height: 380px; }
}

@media (max-width: 900px) {
  .admin-body { flex-direction: column; }
  .admin-side { width: 100%; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .admin-side .spacer { display: none; }
  .admin-main { padding: 20px 16px 40px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .a-form { grid-template-columns: 1fr; }
  .panel { overflow-x: auto; }
  .table { min-width: 620px; }
  .admin-head { flex-wrap: wrap; }
}