/* 客户管理助手 · 管理端样式
   配色取自客户端 LOGO：青翠绿为主色，深松绿为墨色，整体浅色留白、圆角卡片。 */
:root {
  --bg: #f2f7f2;
  --card: #ffffff;
  --ink: #1d3327;
  --muted: #617a6a;
  --line: #e0eae2;
  --brand: #22a35c;
  --brand-dark: #178048;
  --brand-soft: #e6f5ec;
  --ok: #1d9d57;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(29, 51, 39, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 顶栏：白底 + 底部细线，LOGO + 品牌名居左 */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 28px;
  height: 60px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: .02em; white-space: nowrap; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; box-shadow: 0 1px 4px rgba(23, 128, 72, .25); }

.topbar nav { display: flex; gap: 6px; flex: 1; }
.topbar nav a {
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}
.topbar nav a:hover { background: var(--brand-soft); color: var(--brand-dark); text-decoration: none; }
.topbar nav a.active { color: var(--brand-dark); background: var(--brand-soft); font-weight: 600; }

.container { max-width: 1440px; margin: 0 auto; padding: 28px 32px 40px; }

.flash {
  padding: 11px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid;
}
.flash.ok { background: var(--brand-soft); border-color: #bfe6cd; color: #14663a; }
.flash.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.card h2 { margin: 0 0 4px; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 16px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
/* 概览顶部统计块与下方卡片之间留出间隔，避免粘连 */
.container > .grid { margin-bottom: 20px; }

.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; color: var(--ink); }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f7faf7; }
tbody tr:hover { background: #f7fbf7; }
tbody tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; border: 1px solid transparent; }
.badge.pending { background: #f1f5f3; color: #51645a; }
.badge.fetched { background: var(--brand-soft); color: var(--brand-dark); }
.badge.requested { background: #fff7ed; color: #c2410c; }
.badge.success { background: var(--brand-soft); color: #14663a; }
.badge.already_friend { background: #eefaf4; color: #0f766e; }
.badge.not_found { background: #fefce8; color: #a16207; }
.badge.failed { background: #fef2f2; color: #b91c1c; }
.badge.active { background: var(--brand-soft); color: #14663a; }
.badge.disabled { background: #f1f5f3; color: #64748b; }
.badge.offline { background: #fef2f2; color: #b91c1c; }
.badge.on { background: var(--brand-soft); color: #14663a; }
.badge.off { background: #fef2f2; color: #b91c1c; }

form { margin: 0; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  font: inherit;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}
textarea { width: 100%; min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfe6cd; border-color: var(--brand); }

button, .button {
  font: inherit;
  padding: 8px 15px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
button:hover, .button:hover { border-color: #bcd4c3; text-decoration: none; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 6px rgba(34, 163, 92, .25); }
button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
button.danger { color: var(--err); border-color: #fecaca; background: #fff5f5; }
button.link { border: none; background: none; color: var(--muted); padding: 4px 8px; }
button.link:hover { color: var(--brand-dark); }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

/* 自定义文件选择控件：隐藏原生 input，用 .file-picker 作为外观，避免直接暴露原始控件 */
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: var(--brand-soft);
  border-color: #bfe6cd;
  color: var(--brand-dark);
  font-weight: 600;
}
.file-picker:hover { background: #d9efe2; border-color: var(--brand); }
.file-name { font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.block-title { margin: 0 0 8px; font-size: 14px; color: var(--ink); }

.form-stack label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.form-stack input[type="password"], .form-stack input[type="text"] { width: 100%; }

.empty { color: var(--muted); text-align: center; padding: 32px 0; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); }

.bars { display: flex; gap: 8px; align-items: flex-end; height: 90px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; text-align: center; }
.bars .bar .fill { background: linear-gradient(180deg, #8eddb0, var(--brand)); border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .bar .label { font-size: 11px; color: var(--muted); }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

/* 页面内二次确认框：不依赖原生 window.confirm，浏览器屏蔽弹窗时仍可操作 */
dialog.confirm-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(360px, calc(100vw - 40px));
  box-shadow: 0 18px 44px rgba(15, 23, 42, .28);
}
dialog.confirm-dialog::backdrop { background: rgba(15, 23, 42, .38); }
dialog.confirm-dialog .confirm-text { margin: 0; padding: 22px 22px 6px; font-size: 14px; line-height: 1.6; }
dialog.confirm-dialog .confirm-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px 20px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.login-wrap { max-width: 380px; margin: 9vh auto 0; }
.login-wrap .card { padding: 32px 30px; text-align: left; }
.login-logo { display: block; width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 14px; box-shadow: 0 4px 14px rgba(23, 128, 72, .28); }
.login-wrap h1 { font-size: 18px; margin: 0 0 4px; text-align: center; }
.login-wrap .sub { margin-bottom: 20px; text-align: center; }
.login-wrap label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.login-wrap input { width: 100%; margin-bottom: 14px; }
.login-wrap button { width: 100%; }

.error-list { max-height: 260px; overflow: auto; }
