/* =============================================
   访客登记系统 v2 - 全局样式
   （访客登记页 移动端优先 + 后台管理）
   ============================================= */

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
    line-height: 1.6;
}

/* =============================================
   访客登记页
   ============================================= */
.page-wrapper { max-width: 420px; margin: 0 auto; padding: 20px 16px 40px; }

.header { text-align: center; margin-bottom: 28px; padding-top: 20px; }
.header-icon { font-size: 48px; margin-bottom: 8px; }
.header h1 { font-size: 24px; font-weight: 700; color: #1a1a1a; }
.header-sub { font-size: 14px; color: #888; margin-top: 4px; }

.gate-badge {
    display: inline-block; margin-top: 10px; padding: 6px 18px;
    background: #fff8e6; border: 1px solid #f0d48a; border-radius: 20px;
    color: #8a6d1a; font-size: 14px;
}

.form-card {
    background: #fff; border-radius: 12px; padding: 24px 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 6px; color: #555; }

.form-input {
    width: 100%; height: 48px; padding: 0 14px; font-size: 16px;
    border: 1.5px solid #e0e0e0; border-radius: 8px; background: #fafafa;
    color: #333; outline: none; transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none; appearance: none;
}
.form-input:focus {
    border-color: #07c160; box-shadow: 0 0 0 3px rgba(7,193,96,0.15); background: #fff;
}
.form-input::placeholder { color: #bbb; }

.form-textarea { height: auto; padding: 10px 14px; resize: none; line-height: 1.5; }

.form-hint { font-size: 12px; color: #aaa; margin-top: 4px; }
.form-legal { text-align: center; font-size: 12px; color: #bbb; margin-top: 12px; }

.org-tag { font-size: 11px; color: #07c160; background: #e8f8ef; padding: 2px 8px; border-radius: 10px; }

/* 探访事由预设选项（chips） */
.reason-options { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.reason-chip { position: relative; cursor: pointer; }
.reason-chip input {
    position: absolute; opacity: 0; width: 0; height: 0;
}
.reason-chip span {
    display: inline-block; padding: 9px 20px; font-size: 14px;
    background: #f5f5f5; color: #555; border: 1.5px solid #e0e0e0;
    border-radius: 20px; transition: all .15s; user-select: none;
}
.reason-chip input:checked + span {
    background: #e8f8ef; color: #07c160; border-color: #07c160; font-weight: 600;
}
.reason-chip input:focus-visible + span {
    box-shadow: 0 0 0 3px rgba(7,193,96,0.25);
}
.reason-custom { display: none; }

/* 定位模块 */
.loc-status {
    padding: 10px 14px; border-radius: 8px; font-size: 13px;
    margin-bottom: 8px; line-height: 1.4;
}
.loc-loading { background: #f0f6ff; color: #3498db; border: 1px solid #d6e9ff; }
.loc-ok      { background: #e8f8ef; color: #07c160; border: 1px solid #b3e8d1; }
.loc-manual  { background: #fff7e6; color: #e67e22; border: 1px solid #ffe0b3; }
.loc-fail    { background: #fdf3f3; color: #e74c3c; border: 1px solid #f5c6c6; }
.loc-city-input { margin-top: 6px; }
.btn-loc-retry {
    margin-top: 8px; padding: 6px 14px; font-size: 13px;
    color: #07c160; background: #fff; border: 1px solid #07c160;
    border-radius: 6px; cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-loc-retry:hover { background: #e8f8ef; }

/* 时间范围筛选 */
.filter-dt {
    padding: 6px 8px; font-size: 13px;
    border: 1.5px solid #e0e0e0; border-radius: 6px;
    background: #fafafa;
    min-width: 35px;
}
.filter-dt:focus { border-color: #07c160; background: #fff; outline: none; }
.filter-sep {
    padding: 0 4px; color: #999; font-size: 13px;
}
.filter-quick {
    display: inline-flex; gap: 4px; margin-left: 4px;
}
.btn-quick {
    padding: 6px 10px; font-size: 12px;
    background: #f5f5f5; color: #555;
    border: 1px solid #e0e0e0; border-radius: 4px;
    cursor: pointer; transition: background .15s, color .15s;
}
.btn-quick:hover { background: #e8f8ef; color: #07c160; border-color: #b3e8d1; }
.filter-summary {
    margin: 0 0 12px; padding: 8px 14px;
    background: #f0f6ff; border-left: 3px solid #3498db;
    color: #555; font-size: 13px; border-radius: 4px;
}
.filter-summary strong { color: #2c3e50; }

/* 后台访客表 - 定位列 */
.loc-cell { font-size: 13px; line-height: 1.5; max-width: 200px; }
.loc-text { color: #555; font-weight: 500; }
.loc-coord { display: block; color: #999; font-size: 11px; margin-top: 2px; }
.loc-tag { display: inline-block; padding: 1px 6px; font-size: 10px; border-radius: 8px; margin-left: 4px; }
.loc-tag.loc-gps     { background: #e8f8ef; color: #07c160; }
.loc-tag.loc-ip      { background: #e3f2fd; color: #1976d2; }
.loc-tag.loc-manual  { background: #fff3e0; color: #e67e22; }
.loc-tag.loc-empty   { background: #f0f0f0; color: #999; }

.btn-submit {
    width: 100%; height: 50px; font-size: 17px; font-weight: 600; color: #fff;
    background: #07c160; border: none; border-radius: 25px; cursor: pointer;
    transition: background .2s, transform .1s; -webkit-appearance: none; appearance: none;
}
.btn-submit:hover { background: #06ad56; }
.btn-submit:active { transform: scale(0.98); }
.btn-submit:disabled { background: #ccc; cursor: not-allowed; transform: none; }

.btn-sm { width: auto; height: 42px; padding: 0 26px; font-size: 15px; border-radius: 21px; }

.success-card {
    background: #fff; border-radius: 12px; padding: 36px 20px; text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06); animation: fadeInUp .4s ease;
}
.success-icon { font-size: 56px; margin-bottom: 12px; }
.success-card h2 { font-size: 22px; color: #07c160; margin-bottom: 4px; }
.success-desc { font-size: 14px; color: #888; margin-bottom: 24px; }

.success-info {
    background: #f6fff9; border: 1px solid #c8f0d8; border-radius: 8px;
    padding: 10px 16px; text-align: left; font-size: 14px; color: #555;
}
.success-info p { display: flex; justify-content: space-between; padding: 6px 0; }
.success-info p + p { border-top: 1px solid #e8f5ee; }
.success-info span:first-child { color: #999; }

.footer { text-align: center; margin-top: 32px; font-size: 12px; color: #bbb; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =============================================
   后台：登录页
   ============================================= */
.admin-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }

.login-box {
    width: 100%; max-width: 380px; background: #fff; border-radius: 14px;
    padding: 36px 28px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); text-align: center;
}
.login-logo { font-size: 44px; margin-bottom: 10px; }
.login-box h2 { font-size: 21px; margin-bottom: 2px; }
.login-sub { color: #999; font-size: 13px; margin-bottom: 24px; }
.login-box .form-group { text-align: left; }
.login-tip { margin-top: 18px; font-size: 12px; color: #bbb; }

.err-msg { color: #e74c3c; font-size: 14px; margin-bottom: 14px; }

/* =============================================
   后台：顶部导航
   ============================================= */
.top-nav {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
    gap: 10px; background: #fff; padding: 12px 20px; border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.05); margin-bottom: 20px;
}
.nav-brand { font-weight: 700; font-size: 17px; color: #07c160; }
.nav-links { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav-links a {
    padding: 6px 14px; border-radius: 6px; text-decoration: none;
    color: #555; font-size: 14px; transition: background .2s, color .2s;
}
.nav-links a:hover { background: #f0faf4; color: #07c160; }
.nav-links a.active { background: #07c160; color: #fff; }
.nav-user { font-size: 13px; color: #888; margin: 0 6px; }
.nav-logout { color: #e74c3c !important; }

.admin-page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }

.admin-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.admin-header h1 { font-size: 22px; }
.admin-toolbar { display: flex; align-items: center; gap: 10px; }

/* =============================================
   后台：统计卡片
   ============================================= */
.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 20px;
}
.stat-card {
    background: #fff; border-radius: 12px; padding: 20px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.05); border-left: 4px solid #07c160;
}
.stat-card.stat-blue   { border-left-color: #3b82f6; }
.stat-card.stat-orange { border-left-color: #f59e0b; }
.stat-card.stat-purple { border-left-color: #8b5cf6; }
.stat-num { font-size: 30px; font-weight: 700; }
.stat-label { font-size: 13px; color: #888; margin-top: 2px; }

/* =============================================
   后台：面板 / 双栏
   ============================================= */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.panel {
    background: #fff; border-radius: 10px; padding: 18px 20px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.05); margin-bottom: 20px;
}
.panel h3 { font-size: 15px; margin-bottom: 14px; color: #444; }
.panel-tip { font-size: 13px; color: #888; }
.panel-tip a { color: #07c160; }

@media (max-width: 720px) { .panel-grid { grid-template-columns: 1fr; } }

/* 趋势柱状图 */
.trend-bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 6px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend-bar {
    width: 100%; max-width: 34px; background: linear-gradient(180deg, #07c160, #4ade80);
    border-radius: 4px 4px 0 0; min-height: 4px; transition: height .3s;
}
.trend-label { font-size: 11px; color: #999; }

/* 门岗统计列表 */
.gate-stats { list-style: none; }
.gate-stats li {
    display: flex; justify-content: space-between; padding: 9px 2px;
    border-bottom: 1px solid #f2f2f2; font-size: 14px;
}
.gate-stats li:last-child { border-bottom: none; }
.gate-name { color: #555; }
.gate-cnt { font-weight: 600; color: #07c160; }

/* =============================================
   后台：表格
   ============================================= */
.table-wrap { background: #fff; border-radius: 10px; overflow-x: auto; box-shadow: 0 1px 6px rgba(0,0,0,0.05); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.data-table th {
    background: #f7f8fa; padding: 12px 14px; text-align: left; font-weight: 600;
    color: #555; border-bottom: 1px solid #eee; white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid #f0f0f0; color: #333; }
.data-table tr:hover td { background: #fafbfc; }
.reason-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-row { text-align: center; padding: 40px 14px !important; color: #bbb; }

/* 标签 */
.tag-gate {
    display: inline-block; padding: 2px 10px; background: #eef4ff; color: #3b82f6;
    border-radius: 12px; font-size: 12px;
}
.tag-ok  { display: inline-block; padding: 2px 10px; background: #e8f8ef; color: #07c160; border-radius: 12px; font-size: 12px; }
.tag-off { display: inline-block; padding: 2px 10px; background: #f3f3f3; color: #999; border-radius: 12px; font-size: 12px; }

/* 按钮 */
.btn-export, .btn-filter, .btn-reset {
    display: inline-block; padding: 7px 18px; font-size: 14px; border-radius: 6px;
    text-decoration: none; cursor: pointer; border: none; transition: background .2s;
}
.btn-export { background: #07c160; color: #fff; }
.btn-export:hover { background: #06ad56; }
.btn-filter { background: #3b82f6; color: #fff; }
.btn-filter:hover { background: #2f6fd8; }
.btn-reset { background: #f0f0f0; color: #666; }
.btn-reset:hover { background: #e0e0e0; }

.btn-mini {
    padding: 4px 12px; font-size: 12px; border: 1px solid #ddd; border-radius: 5px;
    background: #fff; color: #555; cursor: pointer; transition: all .15s; margin: 2px;
}
.btn-mini:hover { border-color: #07c160; color: #07c160; }
.btn-mini-danger { color: #e74c3c; border-color: #f0c4c4; }
.btn-mini-danger:hover { border-color: #e74c3c; color: #e74c3c; background: #fdf3f3; }

.op-cell { white-space: nowrap; }

/* 筛选栏 */
.filter-bar {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px;
}
.filter-q { width: 220px; height: 42px; background: #fff; }
.filter-s, .filter-d { width: auto; height: 42px; background: #fff; }

/* 角色下拉 */
.role-select { height: 34px; width: auto; font-size: 13px; padding: 0 8px; background: #fff; }

/* 行内表单 */
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 提示条 */
.flash { padding: 10px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.flash-ok  { background: #e8f8ef; color: #07c160; border: 1px solid #c8f0d8; }
.flash-err { background: #fdf3f3; color: #e74c3c; border: 1px solid #f5c6c6; }

/* 分页 */
.pagination {
    display: flex; justify-content: center; align-items: center; gap: 16px;
    margin-top: 20px; font-size: 14px;
}
.pagination a {
    color: #07c160; text-decoration: none; padding: 6px 14px;
    border: 1px solid #07c160; border-radius: 6px; transition: background .2s, color .2s;
}
.pagination a:hover { background: #07c160; color: #fff; }
.page-info { color: #888; }

/* =============================================
   后台管理页专用样式
   ============================================= */
.admin-body { background: #f0f2f5; }
.admin-page { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }
.top-nav {
    display: flex; align-items: center; flex-wrap: wrap;
    padding: 12px 0; border-bottom: 1px solid #e8e8e8;
    margin-bottom: 24px; background: #fff;
    position: sticky; top: 0; z-index: 10;
}
.nav-brand { font-size: 16px; font-weight: 700; color: #333; margin-right: 20px; }
.nav-links { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.nav-links a {
    padding: 6px 12px; font-size: 14px; color: #666; text-decoration: none;
    border-radius: 6px; transition: background .15s, color .15s;
}
.nav-links a:hover { background: #f0f0f0; color: #333; }
.nav-links a.active { background: #e8f8ef; color: #07c160; font-weight: 600; }
.nav-user { font-size: 13px; color: #888; padding: 0 8px; }
.nav-logout { color: #e74c3c !important; }
.admin-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.admin-header h1 { font-size: 22px; color: #222; }
.admin-toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
@media (max-width: 640px) { .panel-grid { grid-template-columns: 1fr; } }
.panel {
    background: #fff; border-radius: 10px; padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05); margin-bottom: 16px;
}
.panel h3 { font-size: 15px; color: #333; margin-bottom: 16px; border-bottom: 1px solid #f0f0f0; padding-bottom: 10px; }
.panel-tip { font-size: 13px; color: #888; line-height: 1.7; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { background: #f7f8fa; color: #666; font-size: 13px; padding: 10px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid #eee; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
.data-table tr:hover td { background: #fafafa; }
.empty-row { text-align: center; color: #bbb; padding: 32px !important; }
.reason-cell { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-ok { display: inline-block; padding: 2px 8px; font-size: 11px; color: #07c160; background: #e8f8ef; border-radius: 10px; }
.tag-off { display: inline-block; padding: 2px 8px; font-size: 11px; color: #999; background: #f0f0f0; border-radius: 10px; }
.tag-gate { display: inline-block; padding: 2px 8px; font-size: 11px; color: #888; background: #f0f0f0; border-radius: 10px; }
.op-cell { white-space: nowrap; }
.btn-mini { padding: 3px 10px; font-size: 12px; color: #07c160; background: #e8f8ef; border: 1px solid #b3e8d1; border-radius: 4px; cursor: pointer; transition: background .15s; }
.btn-mini:hover { background: #d0f2e5; }
.btn-mini-danger { color: #e74c3c; background: #fdf3f3; border-color: #f5c6c6; }
.btn-mini-danger:hover { background: #fde8e8; }
.role-select { height: 32px; font-size: 12px; padding: 0 8px; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; }
.form-hint { font-size: 12px; color: #999; margin-top: 10px; }
.flash { padding: 10px 16px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }
.flash-ok { background: #e8f8ef; color: #07c160; border: 1px solid #b3e8d1; }
.flash-err { background: #fdf3f3; color: #e74c3c; border: 1px solid #f5c6c6; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-q { flex: 1; min-width: 180px; }
.filter-s { min-width: 140px; }
.filter-d { min-width: 140px; }
.btn-filter { padding: 10px 20px; font-size: 14px; color: #fff; background: #07c160; border: none; border-radius: 8px; cursor: pointer; }
.btn-filter:hover { background: #06a555; }
.btn-reset { padding: 10px 16px; font-size: 14px; color: #888; background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; text-decoration: none; }
.btn-export { padding: 9px 18px; font-size: 14px; color: #07c160; background: #fff; border: 1px solid #07c160; border-radius: 8px; text-decoration: none; transition: background .15s; }
.btn-export:hover { background: #e8f8ef; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 600px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.stat-num { font-size: 32px; font-weight: 700; color: #222; }
.stat-label { font-size: 13px; color: #888; margin-top: 4px; }
.stat-blue .stat-num { color: #3498db; }
.stat-orange .stat-num { color: #e67e22; }
.stat-purple .stat-num { color: #9b59b6; }
.trend-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.trend-bar { width: 100%; background: #07c160; border-radius: 4px 4px 0 0; min-height: 4px; transition: height .3s; }
.trend-label { font-size: 10px; color: #bbb; white-space: nowrap; }
.gate-stats { list-style: none; padding: 0; }
.gate-stats li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f5f5f5; font-size: 14px; }
.gate-stats li:last-child { border-bottom: none; }
.gate-name { color: #555; }
.gate-cnt { font-weight: 700; color: #07c160; font-size: 18px; }
.login-box { max-width: 380px; margin: 60px auto; background: #fff; border-radius: 16px; padding: 40px 32px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); text-align: center; }
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-box h2 { font-size: 20px; color: #333; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: #999; margin-bottom: 24px; }
.login-tip { font-size: 12px; color: #bbb; margin-top: 16px; }
.err-msg { background: #fdf3f3; color: #e74c3c; border: 1px solid #f5c6c6; border-radius: 6px; padding: 10px 14px; font-size: 14px; text-align: left; margin-bottom: 16px; }

/* =============================================
   响应式
   ============================================= */
@media (max-width: 480px) {
    .page-wrapper { padding: 16px 12px 32px; }
    .form-card { padding: 20px 16px; }
    .top-nav { flex-direction: column; align-items: flex-start; }
    .filter-q { width: 100%; }
}
