:root {
  --bg: #0F1216;
  --surface: #171B21;
  --surface-2: #1D222A;
  --border: #2A2F38;
  --text: #F3F5F7;
  --muted: #8A93A3;
  --accent: #5B8CFF;
  --accent-2: #2FD1B0;
  --danger: #F87171;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 14px; min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; padding: 24px; }
.back-link { position: absolute; top: 18px; left: 18px; color: var(--muted); font-size: 12.5px; }
.login-card {
  width: 100%; max-width: 320px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 24px; display: flex; flex-direction: column; align-items: center; text-align: center;
}
.login-icon { width: 46px; height: 46px; border-radius: 12px; background: rgba(91,140,255,0.15); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; font-size: 20px; }
.login-title { font-size: 16px; font-weight: 800; margin: 0 0 16px; }
.login-card input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; color: var(--text); font-size: 13.5px; text-align: center; margin-bottom: 8px;
}
.login-error { color: var(--danger); font-size: 12px; margin-bottom: 8px; }
.login-btn { width: 100%; background: var(--accent); color: #0F1216; border: none; border-radius: 10px; padding: 11px 0; font-weight: 800; font-size: 13.5px; margin-top: 6px; }

/* layout */
.admin-wrap { display: flex; min-height: 100vh; }
.sidebar { width: 216px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.sidebar-top { padding: 2px 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.sidebar-brand { font-weight: 800; font-size: 14px; }
.sidebar-site { font-size: 11px; color: var(--muted); margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-btn { display: flex; align-items: center; gap: 9px; background: none; border: none; color: var(--muted); padding: 9px 10px; border-radius: 9px; font-size: 13px; font-weight: 500; text-align: left; width: 100%; }
.nav-btn.active { background: rgba(91,140,255,0.14); color: var(--accent); font-weight: 700; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 3px; padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar-btn { display: flex; align-items: center; gap: 7px; background: none; border: none; color: var(--muted); padding: 8px 10px; border-radius: 9px; font-size: 12.5px; text-align: left; width: 100%; }
.sidebar-btn.danger { color: var(--danger); }

.admin-main { flex: 1; padding: 26px 30px 60px; max-width: 980px; }
.admin-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.admin-h1 { font-size: 19px; font-weight: 800; margin: 0 0 16px; }
.admin-empty { padding: 50px 0; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 14px; }

.primary-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #0F1216; border: none; border-radius: 10px; padding: 9px 16px; font-weight: 700; font-size: 13px; }
.secondary-btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 9px 16px; font-weight: 600; font-size: 13px; }
.small-btn { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); color: var(--accent); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; font-size: 12px; font-weight: 700; }
.icon-btn { background: none; border: none; color: var(--muted); padding: 4px 7px; border-radius: 7px; font-size: 12px; }

/* table */
.table-wrap { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 14px; background: var(--surface); color: var(--muted); font-size: 11.5px; font-weight: 600; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 14px; color: var(--text); vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.td-name { display: flex; align-items: center; gap: 10px; }
.td-thumb { width: 38px; height: 38px; border-radius: 8px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; font-size: 15px; }
.td-thumb img { width: 100%; height: 100%; object-fit: cover; }
.td-desc { font-size: 11px; color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* editor */
.back-link2 { display: inline-flex; align-items: center; gap: 4px; background: none; border: none; color: var(--muted); font-size: 12.5px; padding: 0; margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.form-col { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.field input, .field textarea,
.sku-row input,
#s-announcement, #s-whatsapp, #s-telegram, #s-qq, #s-sitename, #s-old-pw, #s-new-pw,
#f-image-url {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 11px; color: var(--text); font-size: 13px;
}
.field textarea, #s-announcement { min-height: 90px; resize: vertical; }
.sku-header-row { display: flex; align-items: center; justify-content: space-between; }
.sku-empty { font-size: 12px; color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; padding: 16px; text-align: center; margin-top: 8px; }
.sku-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sku-row { display: flex; gap: 6px; align-items: center; }
.sku-row input:nth-child(1) { flex: 2; }
.sku-row input:nth-child(2), .sku-row input:nth-child(3) { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

.image-upload-row { display: flex; gap: 12px; align-items: flex-start; }
.image-preview { width: 64px; height: 64px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 10px; color: var(--muted); flex-shrink: 0; }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.hint { font-size: 11px; color: var(--muted); margin: 4px 0; }

.panel-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 14px; background: var(--surface); }
.panel-card .mini-label { font-size: 11.5px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.panel-card .mini-label:first-of-type { margin-top: 8px; }
.save-msg { color: var(--accent-2); font-size: 12.5px; font-weight: 700; margin-left: 10px; }

@media (max-width: 760px) {
  .admin-wrap { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar-top { display: none; }
  .nav { flex-direction: row; }
  .sidebar-bottom { flex-direction: row; border-top: none; padding-top: 0; margin-left: auto; }
  .admin-main { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
}
[hidden] { display: none !important; }
