:root {
  --red: #C8161D;
  --blue: #2C90CA;
  --yellow: #FFB300;
  --red-soft: #FDEBEC;
  --blue-soft: #EAF4FA;
  --yellow-soft: #FFF4DD;
  --gradient: linear-gradient(135deg, #C8161D, #FFB300 55%, #2C90CA);
  --ink: #1f2733;
  --muted: #7b8794;
  --line: #eceff3;
  --bg: #f5f7fa;
  --card: #ffffff;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient);
}
.login-card {
  width: 360px;
  max-width: 92vw;
  background: #fff;
  border-radius: 20px;
  padding: 36px 30px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.brand-badge {
  width: 76px; height: 76px; margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 1px; line-height: 1.1; text-align: center;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 22px; margin: 6px 0 2px; }
.login-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 12px; letter-spacing: 1px; }
.login-card label { display: block; text-align: left; color: var(--muted); margin: 12px 0 6px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; outline: none; transition: border .2s;
}
.login-card input:focus { border-color: var(--blue); }
.login-card .err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }
.login-card .hint { color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ---------- layout ---------- */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 220px;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 20;
}
.brand {
  padding: 20px 18px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 50%; background: var(--gradient);
  color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.brand .name { font-weight: 700; font-size: 15px; }
.brand .name small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.nav { padding: 12px 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px; cursor: pointer;
  color: var(--ink); font-size: 14px; margin-bottom: 4px; user-select: none;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--red-soft); color: var(--red); font-weight: 600; }
.nav-item .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .6; }
.sidebar .foot { padding: 14px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.main { margin-left: 220px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .store { font-weight: 600; }
.topbar .store small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.topbar .right { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.content { padding: 24px; }
.view-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.view-sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

/* ---------- cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 8px; }
.stat .bar { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--gradient); opacity: .85; }
.stat.red .value { color: var(--red); }
.stat.blue .value { color: var(--blue); }
.stat.yellow .value { color: #d99400; }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 22px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 50px; align-items: center; gap: 10px; }
.bar-track { background: var(--bg); height: 10px; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--gradient); border-radius: 6px; }
.bar-row .num { text-align: right; color: var(--muted); font-size: 12px; }

.split { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }

/* ---------- table ---------- */
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr:hover { background: #fafcff; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 600;
  background: var(--blue); margin-right: 8px; vertical-align: middle;
}
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; margin: 1px 3px 1px 0; }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.yellow { background: var(--yellow-soft); color: #d99400; }
.tag.gray { background: #eef1f4; color: var(--muted); }
.muted { color: var(--muted); }
.right-action { display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13px; transition: .15s;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: #a91217; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.toolbar .left { font-size: 15px; font-weight: 600; }
select, input.field {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; outline: none;
}
select:focus, input.field:focus { border-color: var(--blue); }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 28, 40, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal { width: 460px; max-width: 96vw; max-height: 90vh; overflow: auto; background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; font-family: inherit; outline: none;
}
.form-row input:focus, .form-row textarea:focus { border-color: var(--blue); }
.form-row textarea { min-height: 64px; resize: vertical; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: 24px; transform: transl(-50%, -20px);
  transform: translateX(-50%) translateY(-20px);
  background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #1f9d55; }
.toast.err { background: var(--red); }

.loading { color: var(--muted); padding: 40px; text-align: center; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

/* ---------- responsive (iPad / narrow) ---------- */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar {
    position: static; width: 100%; height: auto; flex-direction: row;
    border-right: none; border-bottom: 1px solid var(--line); overflow-x: auto;
  }
  .brand { border-bottom: none; border-right: 1px solid var(--line); padding: 12px 14px; }
  .nav { display: flex; padding: 8px; gap: 4px; }
  .nav-item { margin: 0; white-space: nowrap; }
  .nav-item .txt { display: inline; }
  .sidebar .foot { display: none; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .table-wrap { overflow-x: auto; }
}
