/* ==========================================================================
   联络小助 · 多小程序主控后台 样式
   浅色主题，无外部依赖
   ========================================================================== */

* { box-sizing: border-box; }

:root {
    --bg:        #f4f6fa;
    --panel:     #ffffff;
    --border:    #e3e8f0;
    --text:      #1f2733;
    --text-sub:  #6b7788;
    --primary:   #2f6bff;
    --primary-d: #1e53d8;
    --danger:    #e5453a;
    --warn:      #f0a020;
    --ok:        #17a673;
    --shadow:    0 1px 3px rgba(24, 39, 75, .07);
}

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

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

/* ---------------------------------------------------------------- 登录页 */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(140deg, #eef2fb 0%, #f7f9fd 55%, #eaf1ff 100%);
}

.login-card {
    width: 380px; max-width: calc(100vw - 32px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 34px 32px 26px;
    box-shadow: 0 12px 34px rgba(24, 39, 75, .10);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand h1 { margin: 0; font-size: 19px; letter-spacing: .5px; }
.login-brand p  { margin: 2px 0 0; font-size: 12.5px; color: var(--text-sub); }

.brand-dot {
    width: 34px; height: 34px; border-radius: 10px; flex: none;
    background: linear-gradient(135deg, #4c86ff, #2f6bff);
    box-shadow: 0 4px 12px rgba(47, 107, 255, .32);
}

.login-note {
    margin: 18px 0 0; font-size: 12px; color: var(--text-sub); text-align: center;
    line-height: 1.85;
}
.login-note code {
    background: #eef2fb; padding: 1px 6px; border-radius: 4px;
    font-size: 11.5px; color: #3c4a5e;
}

/* ---------------------------------------------------------------- 布局 */
.wrap { display: flex; min-height: 100vh; }

.sidebar {
    width: 218px; flex: none;
    background: #ffffff;
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--border);
}
.brand-text { font-size: 15.5px; font-weight: 600; letter-spacing: .4px; }

.nav { padding: 12px 10px; flex: 1; }
.nav-item {
    display: block; padding: 10px 14px; margin-bottom: 3px;
    border-radius: 8px; color: #46536a; font-size: 13.5px;
    transition: background .14s, color .14s;
}
.nav-item:hover { background: #f2f5fb; text-decoration: none; }
.nav-item.active { background: #eaf0ff; color: var(--primary); font-weight: 600; }

/* 侧边栏分组标题 */
.nav-group {
    font-size: 11px; color: #9aa7bd; letter-spacing: .08em;
    padding: 12px 14px 5px; user-select: none;
}

/* 手机管理端内嵌预览 */
.mobile-embed-card { padding-bottom: 0; }
.mobile-embed-wrap { display: flex; justify-content: center; padding: 8px 0 20px; }
.mobile-embed-frame {
    width: 420px; max-width: 100%;
    height: calc(100vh - 230px); min-height: 480px;
    border: 1px solid var(--border); border-radius: 18px; overflow: hidden;
    box-shadow: 0 8px 30px rgba(15, 35, 95, .12); background: #fff;
}
.mobile-embed-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

.sidebar-foot { padding: 14px 16px 18px; border-top: 1px solid var(--border); }
.mp-select-wrap label {
    display: block; font-size: 11.5px; color: var(--text-sub); margin-bottom: 5px;
}
.mp-select-wrap select {
    width: 100%; padding: 7px 8px; border: 1px solid var(--border);
    border-radius: 7px; font-size: 12.5px; background: #fff; color: var(--text);
}
.sidebar-note { margin-top: 7px; font-size: 11px; color: #97a1b0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 16px 24px;
    background: #fff; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar-left h1 { margin: 0; font-size: 17px; }
.topbar-sub { font-size: 12px; color: var(--text-sub); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right .user { font-size: 13px; color: #46536a; }

.tip-badge {
    font-size: 12px; color: #8a5a00; background: #fff7e6;
    border: 1px solid #ffe0a8; padding: 3px 10px; border-radius: 20px;
    max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.content { padding: 20px 24px 40px; }

/* ---------------------------------------------------------------- 卡片 */
.card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 11px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 14.5px; }
.card-head .sub { font-size: 12px; color: var(--text-sub); font-weight: 400; margin-left: 8px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------------------------------------------------------------- 统计块 */
.stat-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    margin-bottom: 18px;
}
.stat {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 11px; padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--text-sub); }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 6px; letter-spacing: .5px; }
.stat .value.small { font-size: 18px; }
.stat .foot { font-size: 11.5px; color: #97a1b0; margin-top: 4px; }
.stat.accent { border-left: 3px solid var(--primary); }
.stat.ok     { border-left: 3px solid var(--ok); }
.stat.warn   { border-left: 3px solid var(--warn); }
.stat.danger { border-left: 3px solid var(--danger); }

/* ---------------------------------------------------------------- 按钮 */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 14px; border-radius: 7px; font-size: 13px;
    border: 1px solid var(--border); background: #fff; color: var(--text);
    cursor: pointer; transition: all .14s; white-space: nowrap;
    font-family: inherit;
}
.btn:hover { border-color: #c9d4e5; background: #fafbfe; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
    background: var(--primary); border-color: var(--primary); color: #fff;
}
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f6cdc9; background: #fff5f4; }
.btn-danger:hover { background: #ffecea; border-color: #efb3ae; }
.btn-ok { color: var(--ok); border-color: #b9e6d6; background: #f2fbf8; }
.btn-ok:hover { background: #e6f7f1; border-color: #9ddcc6; }
.btn-ghost { color: var(--text-sub); }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; padding: 10px; font-size: 14px; }

/* ---------------------------------------------------------------- 表单 */
.field { margin-bottom: 14px; }
.field label {
    display: block; font-size: 12.5px; color: #46536a;
    margin-bottom: 5px; font-weight: 500;
}
.field label .req { color: var(--danger); margin-left: 3px; }
.field .hint { font-size: 11.5px; color: #97a1b0; margin-top: 4px; line-height: 1.5; }

input[type=text], input[type=password], input[type=number],
input[type=email], select, textarea {
    width: 100%; padding: 8px 11px;
    border: 1px solid var(--border); border-radius: 7px;
    font-size: 13px; color: var(--text); background: #fff;
    font-family: inherit; transition: border-color .14s, box-shadow .14s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 107, 255, .10);
}
textarea { resize: vertical; min-height: 74px; line-height: 1.65; }

.form-grid { display: grid; gap: 0 16px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }

.switch-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 11px 0; border-bottom: 1px dashed #edf1f7;
}
.switch-row:last-child { border-bottom: none; }
.switch-row .switch-text strong { display: block; font-size: 13px; font-weight: 500; }
.switch-row .switch-text span { font-size: 11.5px; color: var(--text-sub); }

.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider {
    position: absolute; inset: 0; cursor: pointer;
    background: #cfd8e5; border-radius: 24px; transition: background .18s;
}
.switch .slider::before {
    content: ''; position: absolute; width: 18px; height: 18px;
    left: 3px; top: 3px; background: #fff; border-radius: 50%;
    transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.8px; }
table.data th {
    text-align: left; padding: 11px 14px;
    background: #f8fafd; color: #56637a; font-weight: 600;
    border-bottom: 1px solid var(--border); white-space: nowrap;
    font-size: 12.2px;
}
table.data td {
    padding: 10px 14px; border-bottom: 1px solid #f0f3f8;
    vertical-align: middle; color: #313d4f;
}
table.data tbody tr:hover { background: #fafcff; }
table.data .mono {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 11.8px; color: #46536a;
}
table.data .nowrap { white-space: nowrap; }
table.data .empty {
    text-align: center; padding: 34px 10px; color: #97a1b0; font-size: 13px;
}

/* ---------------------------------------------------------------- 标签 */
.tag {
    display: inline-block; padding: 2px 8px; border-radius: 20px;
    font-size: 11.5px; line-height: 1.7; white-space: nowrap;
}
.tag.gray   { background: #f0f3f8; color: #6b7788; }
.tag.blue   { background: #eaf0ff; color: #2f6bff; }
.tag.green  { background: #e8f8f1; color: #13915f; }
.tag.red    { background: #fdeceb; color: #d0342a; }
.tag.orange { background: #fff5e5; color: #b4740a; }

/* ---------------------------------------------------------------- 工具条 */
.toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.toolbar .grow { flex: 1; }
.toolbar input[type=text], .toolbar select { width: auto; min-width: 148px; }

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask {
    position: fixed; inset: 0; background: rgba(20, 30, 48, .45);
    display: none; align-items: flex-start; justify-content: center;
    z-index: 200; overflow-y: auto; padding: 40px 16px;
}
.modal-mask.open { display: flex; }
.modal {
    background: #fff; border-radius: 13px; width: 720px; max-width: 100%;
    box-shadow: 0 20px 60px rgba(15, 25, 45, .28);
    animation: pop .18s ease-out;
}
@keyframes pop {
    from { transform: translateY(-10px); opacity: .6; }
    to   { transform: translateY(0); opacity: 1; }
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-close {
    border: none; background: none; font-size: 22px; line-height: 1;
    color: #97a1b0; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; max-height: calc(100vh - 230px); overflow-y: auto; }
.modal-foot {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 20px; border-top: 1px solid var(--border);
    background: #fafbfe; border-radius: 0 0 13px 13px;
}
.modal.wide { width: 860px; }

.section-title {
    font-size: 12.5px; font-weight: 600; color: #2f6bff;
    padding: 14px 0 8px; margin-top: 6px;
    border-top: 1px solid #eef2f8;
}
.section-title:first-child { border-top: none; padding-top: 0; margin-top: 0; }

/* ---------------------------------------------------------------- 提示 */
.alert {
    padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}
.alert-error { background: #fdeceb; color: #b32b21; border: 1px solid #f8cfcb; }
.alert-info  { background: #eaf0ff; color: #22509e; border: 1px solid #cddcff; }
.alert-warn  { background: #fff7e6; color: #8a5a00; border: 1px solid #ffe0a8; }
.alert-ok    { background: #e8f8f1; color: #0f7a51; border: 1px solid #b9e6d6; }

/* ---------------------------------------------------------------- 分页 */
.pager {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 10px; padding: 13px 18px; font-size: 12.8px; color: var(--text-sub);
}
.pager .btn { padding: 4px 11px; font-size: 12.5px; }

/* ---------------------------------------------------------------- 图表 */
.chart-box { padding: 18px; }
.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 190px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; position: relative; }
.bar-fill {
    width: 100%; max-width: 26px; background: linear-gradient(180deg, #6f9bff, #2f6bff);
    border-radius: 4px 4px 0 0; min-height: 2px; transition: opacity .14s;
}
.bar-col:hover .bar-fill { opacity: .78; }
.bar-col .bar-label {
    font-size: 10px; color: #97a1b0; white-space: nowrap;
    transform: rotate(-40deg); transform-origin: center; height: 26px;
}
.bar-col .bar-tip {
    position: absolute; bottom: 100%; margin-bottom: 8px;
    background: #1f2733; color: #fff; font-size: 11.5px;
    padding: 4px 9px; border-radius: 6px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity .14s; z-index: 5;
}
.bar-col:hover .bar-tip { opacity: 1; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-sub); margin-top: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ---------------------------------------------------------------- 空态 */
.empty-hint { padding: 40px 20px; text-align: center; color: #97a1b0; font-size: 13px; }

/* ---------------------------------------------------------------- 加载中 */
.loading { padding: 30px; text-align: center; color: #97a1b0; font-size: 13px; }

/* ---------------------------------------------------------------- Toast */
#toastBox {
    position: fixed; top: 22px; left: 50%; transform: translateX(-50%);
    z-index: 900; display: flex; flex-direction: column; gap: 9px;
    align-items: center; pointer-events: none;
}
.toast {
    padding: 10px 20px; border-radius: 9px; font-size: 13.2px; color: #fff;
    box-shadow: 0 8px 24px rgba(20, 30, 48, .22); animation: drop .2s ease-out;
    max-width: 460px;
}
.toast.ok    { background: #17a673; }
.toast.err   { background: #e5453a; }
.toast.info  { background: #3c4a5e; }
@keyframes drop {
    from { transform: translateY(-12px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 860px) {
    .sidebar { width: 60px; }
    .sidebar .brand-text, .sidebar .nav-item, .sidebar-foot, .sidebar .nav-group { display: none; }
    .sidebar .brand { justify-content: center; padding: 18px 0; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 16px 14px 32px; }
    .topbar { padding: 12px 16px; }
    .modal { width: 100%; }
}
