:root {
  --primary: #6064ff;
  --primary-dark: #4a4ee6;
  --primary-soft: #ece9ff;
  --blue: #007bfc;
  --green: #3fbf70;
  --orange: #fca426;
  --red: #e31519;
  --bg: #eff2f7;
  --card: #ffffff;
  --sidebar: #2a3042;
  --sidebar-dim: #8f9bb3;
  --text: #495057;
  --title: #343a40;
  --muted: #70757d;
  --border: #e9ecef;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--primary); }

.hidden { display: none !important; }

.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6064ff 0%, #7a7dff 45%, #9b6bff 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 10px;
  padding: 40px 36px 32px;
  box-shadow: 0 18px 50px rgba(38, 42, 70, .28);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand .mark {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.login-brand h1 {
  font-size: 19px;
  color: var(--title);
  margin: 0 0 6px;
  font-weight: 600;
}

.login-brand p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--title);
  margin-bottom: 6px;
  font-weight: 500;
}

.input, .select, .textarea {
  width: 100%;
  border: 1px solid #ced4da;
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(96, 100, 255, .14);
}

.textarea { resize: vertical; min-height: 110px; line-height: 1.6; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-ghost { background: #fff; border-color: #ced4da; color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c51216; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.shell { display: flex; min-height: 100%; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--sidebar);
  color: var(--sidebar-dim);
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar .brand .mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.nav { list-style: none; margin: 0; padding: 14px 12px; flex: 1; }

.nav li { margin-bottom: 2px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-dim);
  font-size: 14px;
  transition: background .15s, color .15s;
}

.nav a svg { width: 17px; height: 17px; flex: 0 0 17px; }

.nav a:hover { color: #fff; background: rgba(255, 255, 255, .05); }

.nav a.active { color: #fff; background: var(--primary); }

.sidebar .foot {
  padding: 14px 20px;
  font-size: 12px;
  color: #6c7689;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 64px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.topbar h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--title);
}

.topbar .who {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

.view { padding: 24px; flex: 1; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--title);
}

.card-body { padding: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 4px; }

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat .k { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.stat .v { font-size: 24px; font-weight: 600; color: var(--title); line-height: 1.2; }

.stat .v small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.product {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s;
}

.product:hover { border-color: var(--primary); box-shadow: 0 4px 16px rgba(96, 100, 255, .12); }

.product h4 { margin: 0; font-size: 15px; color: var(--title); font-weight: 600; }

.product .price { font-size: 20px; font-weight: 600; color: var(--primary); }

.product .price small { font-size: 12px; color: var(--muted); font-weight: 400; }

.product .desc { font-size: 12px; color: var(--muted); line-height: 1.6; max-height: 54px; overflow: hidden; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 18px;
}

.tag-active { background: rgba(63, 191, 112, .12); color: var(--green); }
.tag-pending { background: rgba(252, 164, 38, .14); color: #d98a05; }
.tag-off { background: rgba(227, 21, 25, .1); color: var(--red); }
.tag-paid { background: rgba(63, 191, 112, .12); color: var(--green); }
.tag-unpaid { background: rgba(252, 164, 38, .14); color: #d98a05; }
.tag-grey { background: #f1f3f5; color: var(--muted); }

table { width: 100%; border-collapse: collapse; }

th, td { text-align: left; padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }

th { color: var(--muted); font-weight: 500; background: #fafbfc; white-space: nowrap; }

tbody tr:hover { background: #fafbfc; }

td.num, th.num { text-align: right; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 13px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 0 28px; font-size: 13px; color: var(--muted); }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }

.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
}

.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.mask {
  position: fixed;
  inset: 0;
  background: rgba(33, 37, 60, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 20px;
  z-index: 60;
  overflow-y: auto;
}

.modal {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(20, 24, 48, .3);
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--title); }

.modal-body { padding: 20px; max-height: calc(100vh - 220px); overflow-y: auto; }

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.close { background: none; border: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }

.opt-group { margin-bottom: 16px; }

.opt-group > label { display: block; font-size: 13px; color: var(--title); margin-bottom: 8px; font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid #ced4da;
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 500; }

.thread { display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; gap: 10px; }

.msg .bubble {
  background: #f6f7fb;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  max-width: 88%;
}

.msg.self { flex-direction: row-reverse; }

.msg.self .bubble { background: var(--primary-soft); }

.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 5px; }

.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a3042;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 90;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .24);
}

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; font-size: 13px; }

.kv dt { color: var(--muted); }

.kv dd { margin: 0; color: var(--title); word-break: break-all; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -240px; top: 0; bottom: 0; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .view { padding: 16px; }
  .topbar { padding: 0 14px; }
  .burger { display: inline-flex !important; }
}

.burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--title);
}
