* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; background: #f5f6f8; color: #1f2329; }
:root { --green: #07c160; --blue: #1989fa; --red: #ee0a24; --line: #ebedf0; --muted: #969799; }
input, textarea, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #fff; }
input:focus, textarea:focus { border-color: var(--green); }
button { font: inherit; cursor: pointer; }
.btn { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #1f2329; }
.btn:hover { border-color: var(--green); }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--red); border-color: #f5c2c7; }
.muted { color: var(--muted); font-size: 13px; }
code { background: #eef0f2; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 340px; background: #fff; padding: 32px 26px; border-radius: 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, .08); }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { margin-bottom: 18px; }
.login-card input { width: 100%; margin-bottom: 12px; }
.login-card .btn { width: 100%; }
.msg { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1f2329; color: #fff; display: flex; flex-direction: column; }
.brand { padding: 18px 16px; font-size: 17px; font-weight: 600; border-bottom: 1px solid #333; }
.sidebar nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-item { display: block; padding: 11px 14px; border-radius: 8px; color: #c8ccd0; cursor: pointer; margin-bottom: 2px; }
.nav-item:hover { background: #2b3038; }
.nav-item.active { background: var(--green); color: #fff; }
.side-foot { padding: 12px 16px; border-top: 1px solid #333; }
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 18px; font-weight: 600; gap: 12px; }
.menu-toggle { display: none; background: none; border: none; font-size: 22px; }
.page-body { padding: 20px; overflow-y: auto; }

/* 概览卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card { background: #fff; border-radius: 12px; padding: 18px; box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.card-ico { font-size: 22px; }
.card-num { font-size: 26px; font-weight: 700; margin: 6px 0 2px; }
.card-label { color: var(--muted); font-size: 13px; }
.page-body h3 { margin: 18px 0 10px; font-size: 15px; }

/* 表格 */
.table-wrap { overflow-x: auto; background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { background: #fafbfc; color: var(--muted); font-weight: 600; }
.tbl tbody tr:hover { background: #fafbfc; }
.ops { display: flex; gap: 4px; flex-wrap: wrap; }
.icon-field { display: inline-flex; align-items: center; gap: 6px; }
.ico-prev { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 20px; overflow: hidden; background: #fafbfc; margin-bottom: 4px; }
.ico-prev img { width: 100%; height: 100%; object-fit: contain; }

/* 工具栏/表单 */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 120px; }
.form-list { display: flex; flex-direction: column; gap: 10px; max-width: 720px; background: #fff; padding: 18px; border-radius: 12px; }
.form-list input, .form-list textarea { width: 100%; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; flex-wrap: wrap; }
.row-label { min-width: 130px; font-weight: 600; }
.row-label small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.row .ad-id { flex: 1; min-width: 160px; }
.switch { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }

.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, .8); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 99; }

/* 自适应：窄屏抽屉式侧栏 */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; width: 200px; }
  body.nav-open .sidebar { transform: translateX(0); }
  .menu-toggle { display: block; }
  .topbar { position: sticky; top: 0; z-index: 10; }
  /* 表单行竖向堆叠，输入框占满宽度 */
  .row { flex-direction: column; align-items: stretch; }
  .row-label { min-width: 0; }
  .form-list { max-width: 100%; }
  .toolbar input, .toolbar select { flex: 1 1 100%; }
  .toolbar .btn { flex: 1 1 auto; }
  .page-body { padding: 12px; }
  .card { padding: 14px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  /* 表格单元格允许换行，避免溢出 */
  .tbl th, .tbl td { white-space: normal; vertical-align: top; }
}

/* 超窄屏（手机竖屏）进一步收紧间距 */
@media (max-width: 480px) {
  .brand { font-size: 15px; }
  .tbl th, .tbl td { padding: 8px 8px; font-size: 12px; }
  .ico-prev { width: 30px; height: 30px; }
}
