:root {
  --green: #2fa94f;
  --green-deep: #1b7d3a;
  --green-soft: #e9f7ec;
  --green-line: #cfe8d6;
  --bg: #eef8f0;
  --card: #ffffff;
  --line: #e9f1eb;
  --text: #1d2b22;
  --muted: #8ba294;
  --blue-tag: #e8f3fb;
  --blue-text: #4a86ad;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ============ 登录 ============ */
#loginView {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #f2fbf4 0%, #e8f6ec 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#loginView.hidden { display: none; }

.login-card {
  width: 460px;
  background: #fff;
  border-radius: 18px;
  padding: 34px 38px 30px;
  box-shadow: 0 18px 50px rgba(31, 122, 58, .12);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }

.logo-round {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(145deg, #43be61, #1f8f3e);
  color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(47, 169, 79, .28);
}

.login-brand h1 { margin: 0; font-size: 19px; }
.login-brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.tabs { display: flex; background: #eef8f0; border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.tabs button {
  flex: 1; border: 0; background: transparent; padding: 9px 0;
  border-radius: 8px; font-size: 14px; color: #5d7a68;
}
.tabs button.on { background: var(--green); color: #fff; font-weight: 600; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: #55705f; margin-bottom: 7px; }
.field input {
  width: 100%; height: 44px; border: 1px solid #dfeadf; border-radius: 10px;
  padding: 0 13px; font-size: 14px; background: #f7fcf8; outline: none;
}
.field input:focus { border-color: var(--green); background: #fff; }

.btn-primary {
  border: 0; background: var(--green); color: #fff;
  border-radius: 10px; height: 44px; padding: 0 20px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 16px rgba(47, 169, 79, .22);
}
.btn-primary:hover { background: #2aa04a; }
.btn-primary.wide { width: 100%; }

/* ============ 主框架 ============ */
#mainView { display: none; min-height: 100vh; }
#mainView.on { display: flex; }

.sidebar {
  width: 228px; flex: 0 0 228px;
  background: #f4fbf5;
  border-right: 1px solid #e6f2e9;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 26px; }
.brand .logo-round { width: 38px; height: 38px; font-size: 15px; }
.brand h2 { margin: 0; font-size: 16px; letter-spacing: .5px; }

.nav { padding: 0 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px; margin-bottom: 6px;
  font-size: 14px; color: #4a6355; cursor: pointer;
  border: 1px solid transparent;
}
.nav-item.on { background: var(--green-soft); color: #1d7a3c; border-color: #bfe3c8; font-weight: 600; }
.nav-item:hover:not(.on) { background: #edf8ef; }

.side-foot { padding: 16px 22px 22px; font-size: 13px; color: #93a99a; display: flex; align-items: center; gap: 8px; }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.eyebrow { font-size: 12px; color: #7d9a88; margin-bottom: 4px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 700; }

.user-pill {
  display: flex; align-items: center; gap: 9px;
  background: #fff; border: 1px solid #e6f0e8; border-radius: 999px;
  padding: 6px 14px 6px 8px;
}
.user-pill .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #1f8f3e; color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-pill b { font-size: 13px; display: block; }
.user-pill span { font-size: 11px; color: var(--muted); display: block; }
.user-pill .caret { color: #9db3a5; font-size: 12px; }

/* 统计 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 24px 16px;
  box-shadow: 0 1px 2px rgba(16, 70, 35, .03);
}
.stat-label { font-size: 13px; color: #7e9989; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--green-deep); line-height: 1; }

/* 区块标题 */
.sec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 0 0 16px; }
.sec-head h2 { margin: 0 0 4px; font-size: 18px; }
.sec-head p { margin: 0; font-size: 13px; color: #8ba294; }

.btn-ghost {
  border: 1px solid #e4eee6; background: #fff; color: #35533f;
  border-radius: 10px; height: 38px; padding: 0 16px; font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-ghost:hover { border-color: #c7e3cf; }
.btn-sm { height: 38px; padding: 0 16px; font-size: 13px; box-shadow: none; border-radius: 10px; display: inline-flex; align-items: center; gap: 7px; }
.btn-row { display: flex; gap: 10px; align-items: center; }

/* 口令卡 */
.token-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.token-card {
  position: relative; background: var(--card); border: 1px solid #e8f1ea;
  border-radius: 16px; padding: 16px 18px 12px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(16, 70, 35, .03);
}
.token-card:hover { border-color: #c8e5d0; }
.token-card.on { border: 2px solid #3cb75d; padding: 15px 17px 11px; box-shadow: 0 4px 14px rgba(47, 169, 79, .13); }

.tc-head { display: flex; align-items: center; gap: 8px; }
.key-ico { color: #9bb3a4; display: inline-flex; }
.tc-code { font-size: 20px; font-weight: 700; color: #16361f; letter-spacing: .6px; }
.tc-code.used { color: #9aa9a0; }
.check-badge {
  position: absolute; top: 13px; right: 14px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #3cb75d; color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(60, 183, 93, .35);
}
.lock-ico { position: absolute; top: 15px; right: 16px; color: #b9c9bf; display: inline-flex; }

.tc-nums { display: grid; grid-template-columns: 1fr 1fr 1fr; margin: 14px 0 12px; }
.tc-nums div + div { padding-left: 12px; }
.tc-nums label { display: block; font-size: 11px; color: #93a89a; margin-bottom: 4px; }
.tc-nums b { font-size: 14px; color: #22342a; font-weight: 700; }
.tc-pending { display: inline-block; margin-left: 5px; font-size: 10px; font-style: normal; color: #b9802a; background: #fff4dd; border-radius: 4px; padding: 0 4px; vertical-align: 2px; }

.tc-foot { border-top: 1px solid #f0f5f1; padding-top: 9px; display: flex; align-items: center; justify-content: space-between; }
.tc-times { display: flex; flex-direction: column; gap: 2px; }
.tc-time { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #9bafa2; }
.tc-del {
  border: 0; background: transparent; color: #b6c6ba; padding: 4px;
  border-radius: 6px; display: inline-flex; opacity: .8;
}
.tc-del:hover { color: #e05656; background: #fdf0f0; opacity: 1; }

/* 应用区 */
.apps { margin-top: 30px; }
.app-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.app-grid.compact { grid-template-columns: repeat(4, 1fr); }

.add-card {
  border: 2px dashed #bfe0c6; background: #fbfefb; border-radius: 16px;
  min-height: 300px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; cursor: pointer;
  color: #2c6b42; transition: border-color .15s, background .15s;
}
.add-card:hover { border-color: #7fc694; background: #f4fcf6; }
.add-plus {
  width: 56px; height: 56px; border-radius: 50%; background: #eaf7ec;
  color: #35a955; font-size: 26px; display: flex; align-items: center; justify-content: center;
}
.add-card b { font-size: 16px; font-weight: 600; }
.add-card span { font-size: 13px; color: #8fa79a; }

.app-card {
  position: relative; background: #fff; border: 1px solid #e8f1ea;
  border-radius: 14px; padding: 12px 14px 0; display: flex; flex-direction: column;
  box-shadow: 0 1px 2px rgba(16, 70, 35, .03);
  cursor: grab;
}
.app-card.dragging { opacity: .5; }
.app-card.drop-target { border-color: #3cb75d; }

.ac-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ac-idx {
  width: 22px; height: 22px; border-radius: 6px; background: #eef8ef;
  color: #3c8a54; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.ac-cb { display: inline-flex; }
.ac-cb input { width: 15px; height: 15px; accent-color: var(--green); cursor: pointer; }

.ac-head { display: flex; gap: 11px; align-items: flex-start; padding-bottom: 10px; }
.ac-icon {
  width: 42px; height: 42px; border-radius: 10px; object-fit: cover;
  background: #f1f8f2; flex: 0 0 42px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  color: #7fbd93; font-size: 16px; font-weight: 700;
}
.ac-title { flex: 1; min-width: 0; }
.ac-name-row { display: flex; align-items: center; gap: 8px; }
.ac-name { font-size: 14px; font-weight: 700; color: #1c3227; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-ok {
  margin-left: auto; flex: 0 0 auto;
  font-size: 11px; color: #2f9350; background: #eaf7ed;
  border: 1px solid #cfe9d7; border-radius: 999px; padding: 1px 8px;
}
.ac-ver { font-size: 11px; color: #93a89a; margin-top: 3px; }
.stars { color: #f0b23c; font-size: 12px; letter-spacing: 1px; height: 16px; }
.stars .empty { color: #dfe6e1; }

.ac-tags { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid #f1f6f2; }
.tag {
  font-size: 11px; padding: 3px 10px; border-radius: 999px;
  background: var(--blue-tag); color: var(--blue-text);
}

.ac-nums { display: grid; grid-template-columns: 1fr 1fr; text-align: center; padding: 9px 0; border-bottom: 1px solid #f1f6f2; }
.ac-nums div:first-child { border-right: 1px solid #f1f6f2; }
.ac-nums label { display: block; font-size: 11px; color: #93a89a; }
.ac-nums b { font-size: 16px; color: #22342a; }

.ac-desc {
  font-size: 12px; color: #a3b4a8; padding: 9px 0;
  border-bottom: 1px solid #f1f6f2; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ac-desc.has { color: #5d7968; }

.ac-foot { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.ac-acts { display: flex; gap: 6px; }
.ac-btn {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid #e8f1ea;
  background: #fbfdfb; color: #7a9a86; display: inline-flex;
  align-items: center; justify-content: center;
}
.ac-btn:hover { color: #2f9350; border-color: #cfe9d7; background: #f2fbf4; }
.ac-btn.danger:hover { color: #e05656; border-color: #f3d4d4; background: #fdf3f3; }
.ac-time { font-size: 11px; color: #a3b4a8; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 45, 30, .32);
  display: none; align-items: center; justify-content: center; z-index: 60;
}
.modal-mask.on { display: flex; }
.modal {
  width: 560px; max-width: calc(100vw - 40px); max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 16px; padding: 22px 24px 20px;
  box-shadow: 0 24px 60px rgba(18, 60, 38, .22);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-sub { font-size: 12px; color: #8ba294; margin: 2px 0 16px; }
.x-btn { border: 0; background: transparent; font-size: 20px; color: #9db3a5; line-height: 1; }

.drop-zone {
  border: 2px dashed #cfe4d5; border-radius: 12px; background: #fafdfb;
  padding: 22px 16px; text-align: center; cursor: pointer; margin-bottom: 16px;
}
.drop-zone:hover { border-color: #8fcda2; background: #f4fbf6; }
.drop-zone .big { font-size: 24px; color: #46b166; }
.drop-zone b { display: block; font-size: 14px; margin: 6px 0 3px; }
.drop-zone span { font-size: 12px; color: #9bb2a3; }

.parsed {
  display: none; gap: 14px; align-items: center;
  background: #f6fbf7; border: 1px solid #e2f0e7; border-radius: 12px;
  padding: 14px; margin-bottom: 16px;
}
.parsed.on { display: flex; }
.parsed-icon {
  width: 58px; height: 58px; border-radius: 12px; background: #eaf6ec;
  object-fit: cover; flex: 0 0 58px;
  display: flex; align-items: center; justify-content: center;
  color: #46a862; font-size: 20px; font-weight: 700; overflow: hidden;
}
.parsed-info { flex: 1; min-width: 0; font-size: 12px; color: #62796b; line-height: 1.9; }
.parsed-info b { font-size: 14px; color: #1c3227; display: block; }
.kv { display: flex; gap: 6px; }
.kv em { color: #93a89a; font-style: normal; min-width: 42px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-row.full { grid-template-columns: 1fr; }
.form-row label { display: block; font-size: 12px; color: #55705f; margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; border: 1px solid #e2ece4; border-radius: 9px;
  height: 38px; padding: 0 11px; background: #fbfdfb; font-size: 13px; outline: none;
}
.form-row textarea { height: 64px; padding: 9px 11px; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--green); background: #fff; }

.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* 下拉菜单 */
.menu {
  position: absolute; background: #fff; border: 1px solid #e6f0e8;
  border-radius: 10px; box-shadow: 0 10px 28px rgba(20, 60, 38, .14);
  padding: 6px; min-width: 148px; z-index: 30; display: none;
}
.menu.on { display: block; }
.menu button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 7px; font-size: 13px; color: #35533f;
}
.menu button:hover { background: #f1faf3; }
.menu button.danger { color: #d95656; }

/* 公开区卡片 */
.token-card.public-card { position: relative; }
.key-ico.pub { color: #2f9e63; background: #eaf7ef; }
.pub-note { font-size: 11px; color: #7fa592; margin: -2px 0 8px; }

/* 待发布区 */
.pending-wrap {
  border: 1px dashed #eed9ac; background: #fffcf3;
  border-radius: 14px; padding: 14px 16px; margin-bottom: 16px;
}
.pending-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.pending-title { font-size: 14px; color: #8a6633; }
.pending-title b { font-size: 18px; color: #c4862a; margin: 0 2px; }
.pending-title span { display: block; font-size: 12px; color: #a8916a; margin-top: 3px; }
.pending-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pending-card {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid #f0e4ca; border-radius: 10px;
  padding: 10px 12px; min-width: 0;
}
.pending-card.on { border-color: #3cb75d; background: #f7fdf8; box-shadow: 0 0 0 1px rgba(60,183,93,.12); }
.pc-cb { display: inline-flex; flex: 0 0 auto; }
.pc-cb input { width: 16px; height: 16px; accent-color: var(--green); cursor: pointer; }
.pc-icon {
  width: 36px; height: 36px; border-radius: 9px; flex: 0 0 36px;
  object-fit: cover; background: #f5f9f5; color: #7fbd93;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; overflow: hidden;
}
.pc-info { flex: 1; min-width: 0; }
.pc-info b { display: block; font-size: 13px; color: #1c3227; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-info span { display: block; font-size: 11px; color: #9bb2a3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-tag {
  flex: 0 0 auto; font-size: 11px; color: #b9802a;
  background: #fff4dd; border: 1px solid #f4e2bf; border-radius: 999px; padding: 1px 8px;
}
.pc-del { border: 0; background: transparent; color: #c3d1c7; padding: 3px; display: inline-flex; border-radius: 6px; }
.pc-del:hover { color: #e05656; background: #fdf0f0; }

/* 软件下载 / 反馈页 */
.page { display: none; }
.page.on { display: block; }

.panel {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 22px; margin-bottom: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.panel .kvline { font-size: 13px; color: #5d7968; padding: 6px 0; border-bottom: 1px dashed #f0f5f1; }
.panel .kvline span { color: #8ba294; margin-right: 10px; }

.empty-tip { font-size: 13px; color: #9bb2a3; padding: 20px 0; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #16321f; color: #fff; font-size: 13px; padding: 10px 20px;
  border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 90;
}
.toast.on { opacity: .95; }
