/* =========================================================
   智慧社区物联网门禁系统 - 前端样式（明亮科技风，无外部依赖）
   ========================================================= */
:root {
  --bg: #f3f6fc;
  --bg-soft: #eaf1fb;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --line: #e3ebf7;
  --line-strong: #c3d5ec;
  --text: #0f1c2f;
  --text-dim: #4e6486;
  --text-mute: #7f91ac;
  --cyan: #0a8cae;
  --cyan-soft: #06a7c9;
  --cyan-deep: #0a7b98;
  --blue: #2f6bff;
  --blue-deep: #1f4fd8;
  --green: #0f9d6e;
  --red: #dd4560;
  --amber: #c07b17;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(23, 52, 102, 0.08);
  --shadow-strong: 0 24px 60px rgba(23, 52, 102, 0.14);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(1000px 600px at 8% -12%, rgba(10, 167, 201, 0.10), transparent 62%),
    radial-gradient(900px 560px at 100% -6%, rgba(47, 107, 255, 0.10), transparent 58%),
    linear-gradient(rgba(47, 107, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 107, 255, 0.035) 1px, transparent 1px);
  background-size: auto, auto, 30px 30px, 30px 30px;
  background-attachment: fixed, fixed, fixed, fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: 0.02em; }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfdff, #f7faff);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-head h3 { font-size: 15px; color: var(--text); }
.card-body { padding: 18px 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: #ffffff; color: var(--text);
  font-size: 13px; cursor: pointer; transition: all .18s ease; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(23, 52, 102, 0.04);
}
.btn:hover { background: #f3f8ff; border-color: var(--blue); color: var(--blue-deep); }
.btn-primary {
  background: linear-gradient(135deg, #2f6bff, #06a7c9);
  border: 1px solid transparent; color: #fff; font-weight: 600;
  box-shadow: 0 8px 20px rgba(47, 107, 255, 0.28);
}
.btn-primary:hover { filter: brightness(1.06); color: #fff; }
.btn-danger { border-color: #f3c2cc; background: #fff6f8; color: var(--red); }
.btn-danger:hover { background: #ffecef; border-color: var(--red); color: #b92a43; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 15px; border-radius: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px;
  border: 1px solid #cfe3f2; color: var(--cyan-deep); background: #eef8fc;
}
.badge.green { color: #0b7e58; border-color: #b9e4d2; background: #edf9f4; }
.badge.red { color: #bd2b45; border-color: #f4c3cc; background: #fff2f5; }
.badge.amber { color: #94600e; border-color: #f1dab2; background: #fff8ec; }
.badge.gray { color: var(--text-dim); border-color: #dde5f0; background: #f4f7fb; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-dim); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid #d7e3f3; background: #fbfdff;
  color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.input:hover, .select:hover, .textarea:hover { border-color: #bccfe8; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--blue); background: #ffffff; box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12);
}
.textarea { min-height: 110px; font-family: var(--mono); font-size: 13px; resize: vertical; }
.hint { font-size: 12px; color: var(--text-mute); margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------------- 后台框架 ---------------- */
.admin-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #ffffff, #f6f9ff);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 22px 20px 18px; border-bottom: 1px solid var(--line); }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #06a7c9, #2f6bff); margin-bottom: 10px;
  font-weight: 700; color: #fff; font-size: 15px; box-shadow: 0 6px 16px rgba(47, 107, 255, .30);
}
.brand h1 { font-size: 15px; line-height: 1.35; }
.brand small { display: block; color: var(--text-mute); font-size: 11px; margin-top: 3px; letter-spacing: .08em; }

.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-dim); font-size: 13.5px; border: 1px solid transparent;
}
.nav a:hover { background: #eff5ff; color: var(--text); }
.nav a.active {
  color: var(--blue-deep); background: linear-gradient(90deg, #e7f0ff, #f7faff);
  border-color: #cfe0ff; font-weight: 600;
  box-shadow: inset 3px 0 0 var(--blue);
}
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 6px rgba(47, 107, 255, .45); }
.nav-sep { margin: 10px 12px 4px; font-size: 11px; letter-spacing: .12em; color: var(--text-mute); }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); }

.admin-main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 26px; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .86); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 18px; }
.topbar .sub { color: var(--text-mute); font-size: 12px; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: 13px; }
.content { padding: 22px 26px 40px; }

/* ---------------- 统计卡 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat {
  padding: 18px; border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(160deg, #ffffff, #f6faff);
  position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.stat::after {
  content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px;
  border-radius: 50%; background: radial-gradient(circle, rgba(47, 107, 255, .14), transparent 65%);
}
.stat .label { color: var(--text-dim); font-size: 12.5px; letter-spacing: .06em; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 6px; font-family: var(--mono); color: var(--text); }
.stat .value small { font-size: 13px; color: var(--text-mute); margin-left: 4px; font-weight: 400; }
.stat .foot { color: var(--text-mute); font-size: 12px; margin-top: 6px; }

/* ---------------- 图表 ---------------- */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 10px 6px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart .bar-wrap { width: 100%; display: flex; justify-content: center; align-items: flex-end; flex: 1; }
.chart .bar {
  width: 60%; max-width: 38px; border-radius: 8px 8px 4px 4px; min-height: 3px;
  background: linear-gradient(180deg, #06a7c9, #2f6bff);
  box-shadow: 0 6px 14px rgba(47, 107, 255, .22);
}
.chart .label { font-size: 12px; color: var(--text-mute); font-family: var(--mono); }
.chart .num { font-size: 12px; color: var(--blue-deep); font-family: var(--mono); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
table.data th, table.data td {
  padding: 11px 12px; text-align: left; border-bottom: 1px solid #eef3fb; vertical-align: middle;
}
table.data th {
  color: var(--text-dim); font-weight: 600; font-size: 12.5px; letter-spacing: .04em;
  background: #f6f9ff; position: sticky; top: 0;
}
table.data tr:hover td { background: #f7fbff; }
table.data td.actions { white-space: nowrap; display: flex; gap: 6px; }
.empty { padding: 34px; text-align: center; color: var(--text-mute); }

/* ---------------- 工具栏 / 分页 ---------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 140px; padding: 8px 10px; }
.toolbar .spacer { flex: 1; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 14px 4px 0; color: var(--text-dim); font-size: 12.5px; }
.pager a, .pager span.cur {
  min-width: 32px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--line); padding: 0 8px; background: #fff;
}
.pager span.cur { background: #e9f1ff; color: var(--blue-deep); border-color: #c8dbff; font-weight: 600; }

/* ---------------- Flash ---------------- */
.flash {
  margin: 0 0 16px; padding: 12px 16px; border-radius: 10px; font-size: 13px;
  border: 1px solid #bde6d6; background: #eefaf5; color: #0b7251;
}
.flash.error { border-color: #f6c4ce; background: #fff4f6; color: #b52842; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 35, 66, .34); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 24px;
}
.modal-mask.open { display: flex; }
.modal {
  width: 100%; max-width: 640px; max-height: 86vh; overflow-y: auto;
  background: #ffffff; border: 1px solid var(--line-strong); border-radius: 16px;
  box-shadow: var(--shadow-strong);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); background: #f9fbff; border-radius: 16px 16px 0 0; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: #fbfdff; border-radius: 0 0 16px 16px; }
.icon-btn { background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; line-height: 1; }
.icon-btn:hover { color: var(--blue); }

/* ---------------- 二维码 ---------------- */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qr-canvas {
  width: 220px; height: 220px; padding: 12px; background: #fff; border-radius: 12px;
  display: grid; place-items: center; border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(23, 52, 102, .08);
}
.qr-canvas img, .qr-canvas canvas { width: 100% !important; height: 100% !important; }
.qr-link { font-family: var(--mono); font-size: 12px; color: var(--text-dim); word-break: break-all; text-align: center; max-width: 320px; }

/* ---------------- Toast ---------------- */
#toast-host { position: fixed; right: 20px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast {
  padding: 11px 16px; border-radius: 10px; font-size: 13px; max-width: 340px;
  background: #ffffff; border: 1px solid var(--line-strong); color: var(--text);
  box-shadow: var(--shadow-strong); animation: toastIn .22s ease;
}
.toast.ok { border-color: #a9dfc8; box-shadow: 0 12px 30px rgba(15, 157, 110, .18); }
.toast.err { border-color: #f3bcc8; box-shadow: 0 12px 30px rgba(221, 69, 96, .16); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }

/* ---------------- 登录页 ---------------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 30px 18px;
}
.auth-card {
  width: 100%; max-width: 420px; padding: 32px 28px; border-radius: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-strong);
  position: relative; overflow: hidden;
}
.auth-card::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: linear-gradient(90deg, #06a7c9, #2f6bff 55%, #7aa4ff);
}
.auth-logo {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #06a7c9, #2f6bff); margin: 0 auto 16px;
  font-size: 20px; font-weight: 700; color: #fff;
  box-shadow: 0 10px 24px rgba(47, 107, 255, .32);
}
.auth-card h2 { text-align: center; font-size: 19px; }
.auth-card .sub { text-align: center; color: var(--text-mute); font-size: 12.5px; margin: 6px 0 24px; letter-spacing: .06em; }
.auth-foot { text-align: center; color: var(--text-mute); font-size: 12px; margin-top: 18px; }

/* ---------------- 手机端 ---------------- */
.mobile-body { background-color: var(--bg); }
.mobile-shell { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.mobile-top {
  padding: 18px 18px 14px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px);
}
.mobile-top .logo-row { display: flex; align-items: center; gap: 10px; }
.mobile-top .logo { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(135deg, #06a7c9, #2f6bff); color: #fff; font-weight: 700; font-size: 13px; box-shadow: 0 4px 12px rgba(47, 107, 255, .26); }
.mobile-top h1 { font-size: 14px; }
.mobile-main { flex: 1; padding: 16px; }

.m-hero {
  border-radius: 18px; padding: 22px 20px; position: relative; overflow: hidden;
  background: linear-gradient(140deg, #e8f5ff, #eef3ff 45%, #ffffff);
  border: 1px solid #cfdff5;
  box-shadow: 0 10px 26px rgba(47, 107, 255, .10);
}
.m-hero::after {
  content: ''; position: absolute; right: -40px; bottom: -60px; width: 190px; height: 190px;
  border-radius: 50%; background: radial-gradient(circle, rgba(47, 107, 255, .16), transparent 62%);
}
.m-hero .tag { font-size: 11px; letter-spacing: .16em; color: var(--text-dim); }
.m-hero h2 { font-size: 22px; margin: 6px 0 4px; color: var(--text); }
.m-hero .meta { color: var(--text-dim); font-size: 12.5px; }

.info-list { display: flex; flex-direction: column; gap: 10px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed #e2eaf5; font-size: 13.5px; }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--text-dim); }
.info-row .v { color: var(--text); font-weight: 500; text-align: right; }

.section { margin-top: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title h3 { font-size: 14px; }
.section-title .more { font-size: 12px; color: var(--text-mute); }

.list-card { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #eef3fb; }
.list-item:last-child { border-bottom: none; }
.list-item .t { font-size: 13.5px; }
.list-item .d { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

.mobile-foot { padding: 16px; border-top: 1px solid var(--line); background: #ffffff; }

.ad-box { margin-top: 14px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #ffffff; }
.ad-box .ad-img { width: 100%; display: block; max-height: 200px; object-fit: cover; }
.ad-box .ad-body { padding: 12px 14px; }
.ad-box .ad-title { font-size: 13.5px; margin-bottom: 4px; }
.ad-box .ad-text { font-size: 12.5px; color: var(--text-dim); white-space: pre-wrap; }
.ad-tag { position: absolute; top: 10px; left: 10px; font-size: 10px; letter-spacing: .1em; padding: 2px 8px; border-radius: 20px; background: rgba(255, 255, 255, .82); border: 1px solid var(--line); color: var(--text-dim); }

.big-open {
  width: 100%; padding: 22px; border-radius: 16px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #2f6bff, #06a7c9);
  color: #fff; font-size: 17px; font-weight: 700; letter-spacing: .08em;
  box-shadow: 0 14px 30px rgba(47, 107, 255, .30);
  transition: transform .15s ease, filter .15s ease;
}
.big-open:active { transform: scale(.98); }
.big-open[disabled] { filter: grayscale(.3); opacity: .7; }

.result-box { padding: 18px; border-radius: 14px; text-align: center; margin-top: 14px; border: 1px solid var(--line); background: #fff; }
.result-box.ok { background: #eefaf5; border-color: #b6e3d1; }
.result-box.fail { background: #fff4f6; border-color: #f5c2cc; }
.result-box .icon { font-size: 34px; line-height: 1; }
.result-box .msg { margin-top: 8px; font-size: 14px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-shell { grid-template-columns: 196px 1fr; }
}
@media (max-width: 820px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { padding: 8px 10px; font-size: 12.5px; }
  .content { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat .value { font-size: 24px; }
}
