/* ============ 成长系统 · 全局样式 ============ */
:root {
  --primary: #4f7cff;
  --primary-2: #6d5df6;
  --primary-soft: rgba(79, 124, 255, .12);
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2733;
  --muted: #7a8499;
  --border: #e6eaf2;
  --danger: #e5484d;
  --ok: #18a058;
  --shadow: 0 4px 18px rgba(31, 45, 80, .08);
  --radius: 14px;
}
html[data-theme="pink"] {
  --primary: #f0568c; --primary-2: #ff8f6b; --primary-soft: rgba(240, 86, 140, .12);
  --bg: #fdf3f6; --border: #f3e2ea; --shadow: 0 4px 18px rgba(160, 60, 100, .08);
}
html[data-theme="green"] {
  --primary: #10a56f; --primary-2: #3ec98a; --primary-soft: rgba(16, 165, 111, .12);
  --bg: #f2faf6; --border: #e0efe7; --shadow: 0 4px 18px rgba(20, 100, 70, .08);
}
html[data-theme="orange"] {
  --primary: #f08018; --primary-2: #ffb02e; --primary-soft: rgba(240, 128, 24, .12);
  --bg: #fdf8f2; --border: #f2e8da; --shadow: 0 4px 18px rgba(140, 80, 20, .08);
}
html[data-theme="dark"] {
  --primary: #8b7bff; --primary-2: #4fa3ff; --primary-soft: rgba(139, 123, 255, .18);
  --bg: #171a23; --card: #22262f; --text: #e8ebf2; --muted: #9aa3b5; --border: #323845;
  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; max-width: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; font-size: 14px; line-height: 1.5;
}
.hidden { display: none !important; }
h2 { font-size: 20px; }

/* ============ 登录 / 初始化 ============ */
.auth-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--bg) 60%),
              radial-gradient(600px 400px at 80% 10%, var(--primary-soft), transparent);
  padding: 16px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 40px 36px; text-align: center;
}
.auth-logo { font-size: 44px; margin-bottom: 8px; }
.auth-title { font-size: 26px; letter-spacing: 2px; }
.auth-sub { color: var(--muted); margin: 8px 0 24px; }
.auth-tip { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ============ 表单元素 ============ */
.field { display: block; text-align: left; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; text-align: left; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, .input {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); font-size: 14px; outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--primary); }
.form-error { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: left; }
.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 10px 18px; border-radius: 10px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 500; transition: transform .1s, opacity .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--card); box-shadow: var(--shadow); padding: 10px 20px;
}
.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }
.brand-sub {
  font-size: 12px; color: #fff; padding: 3px 10px; border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); white-space: nowrap;
}
.topnav { display: flex; gap: 4px; flex: 1; justify-content: center; flex-wrap: wrap; }
.nav-btn {
  padding: 8px 18px; border: none; background: transparent; border-radius: 10px;
  font-size: 14px; color: var(--muted); cursor: pointer; transition: all .15s;
}
.nav-btn:hover { color: var(--primary); background: var(--primary-soft); }
.nav-btn.active { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.my-name { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* 顶栏小色卡 */
.theme-picker { display: flex; gap: 5px; }
.theme-dot {
  width: 16px; height: 16px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform .12s;
}
.theme-dot:hover { transform: scale(1.2); }
.theme-dot.active { border-color: var(--text); }

/* ============ 页面容器 ============ */
.main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 14px;
}
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-actions .input { width: 220px; }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* 分段切换 */
.seg { display: inline-flex; background: var(--card); border-radius: 10px; padding: 4px; box-shadow: var(--shadow); }
.seg.sub { margin-bottom: 16px; }
.seg-btn {
  padding: 7px 16px; border: none; background: transparent; border-radius: 8px;
  font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.seg-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }

/* 统计条 */
.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.stat-item {
  background: var(--card); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow);
}
.stat-item .s-label { font-size: 12px; color: var(--muted); }
.stat-item .s-value { font-size: 20px; font-weight: 700; margin-top: 2px; }
.stat-item .s-value.hl { color: var(--primary); }

/* ============ 表格（无横向滚动条） ============ */
.table-wrap {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px 0; overflow: hidden;
}
.tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tbl th, .tbl td {
  padding: 10px 10px; text-align: left; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; word-break: break-all;
}
.tbl th {
  font-size: 12px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); padding: 12px 10px;
}
.tbl td { font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--primary-soft); }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--border); color: var(--primary); }
.w-num { width: 52px; }
.w-avatar { width: 60px; }
.w-op { width: 150px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: block;
  background: var(--primary-soft); cursor: zoom-in;
}
.avatar-fallback {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; background: var(--primary-soft); color: var(--primary);
  font-size: 15px; font-weight: 600;
}
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px;
  background: var(--primary-soft); color: var(--primary);
}
.tag.gray { background: var(--border); color: var(--muted); }
.tag.red { background: rgba(229, 72, 77, .12); color: var(--danger); }
.op-link { color: var(--primary); cursor: pointer; margin-right: 8px; font-size: 13px; }
.op-link.danger { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 窄屏隐藏次要列，避免出现横向滚动条 */
@media (max-width: 900px) {
  .col-birthday, .col-leave { display: none; }
  .page-actions .input { width: 100%; }
}
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 16px; }
  .topbar-right { margin-left: auto; }
  .my-name { display: none; }
  .topnav { order: 3; width: 100%; flex: none; justify-content: stretch; flex-wrap: nowrap; }
  .nav-btn { flex: 1; padding: 7px 6px; font-size: 13px; text-align: center; white-space: nowrap; }
  .col-camp, .col-team { display: none; }
  .tbl th, .tbl td { padding: 8px 6px; }
  .tbl td, .tbl th { font-size: 12px; }
  .w-op { width: 118px; }
  .main { padding: 14px 10px 50px; }
}

/* ============ 弹窗 ============ */
.modal {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 20, 30, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--card); border-radius: var(--radius); width: 100%; max-width: 760px;
  max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal-sm { max-width: 480px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card); z-index: 2;
}
.modal-close { border: none; background: transparent; font-size: 16px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  position: sticky; bottom: 0; background: var(--card);
}
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 640px) { .form-grid, .form-grid-2 { grid-template-columns: 1fr; } }

/* 照片上传位 */
.photo-slots { display: flex; gap: 12px; flex-wrap: wrap; }
.photo-slot {
  width: 96px; height: 96px; border-radius: 12px; border: 1.5px dashed var(--border);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  position: relative; overflow: hidden; background: var(--bg); transition: border-color .15s;
}
.photo-slot:hover { border-color: var(--primary); }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot .ph-add { color: var(--muted); font-size: 24px; }
.photo-slot .ph-del {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; display: flex;
  align-items: center; justify-content: center; cursor: pointer;
}
.photo-slot.uploading::after {
  content: '上传中…'; position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; background: rgba(255,255,255,.7); color: var(--primary); font-size: 12px;
}

/* ============ 后台管理 ============ */
.org-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.org-col {
  background: var(--card); border-radius: 12px; padding: 14px; box-shadow: var(--shadow);
}
.org-col h4 { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.org-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 8px; border-radius: 8px; font-size: 13px;
}
.org-item:hover { background: var(--primary-soft); }
.org-item .del { color: var(--danger); cursor: pointer; font-size: 12px; }
.org-add { display: flex; gap: 6px; margin-top: 8px; }
.card-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; margin-bottom: 8px; }
.card p { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.code { background: var(--bg); padding: 4px 10px; border-radius: 6px; font-size: 13px; }

/* ============ 设置页 ============ */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.theme-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.theme-card {
  border: 2px solid var(--border); border-radius: 12px; padding: 10px 14px; cursor: pointer;
  display: flex; align-items: center; gap: 10px; background: var(--bg); transition: all .15s;
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.theme-card .tc-colors { display: flex; }
.theme-card .tc-colors i { width: 18px; height: 18px; border-radius: 50%; display: block; margin-left: -6px; border: 2px solid #fff; }
.theme-card .tc-colors i:first-child { margin-left: 0; }
#me-info div { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
#me-info div b:first-child { color: var(--muted); font-weight: normal; }

/* ============ 灯箱 / Toast ============ */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 10px; }
.toast-wrap { position: fixed; top: 66px; left: 50%; transform: translateX(-50%); z-index: 300; }
.toast {
  background: var(--card); color: var(--text); padding: 10px 18px; border-radius: 10px;
  box-shadow: var(--shadow); margin-bottom: 8px; font-size: 13px;
  border-left: 4px solid var(--primary); animation: slideIn .25s;
}
.toast.err { border-left-color: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }
