/* 禅先知 CXZ — 企微 SCRM 设计系统 v2 */
:root {
    --primary: #07c160;
    --primary-hover: #06ad56;
    --primary-light: #e8f8ef;
    --primary-soft: #f0faf4;
    --sidebar-bg: #fff;
    --sidebar-border: #eef0f3;
    --bg: #f4f6f9;
    --card: #fff;
    --border: #e8ebf0;
    --text: #1f2329;
    --text-secondary: #646a73;
    --muted: #8f959e;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 2px 8px rgba(0,0,0,.06);
    --radius: 10px;
    --radius-sm: 6px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border); display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content-area { padding: 20px 24px 32px; flex: 1; }

/* Brand */
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 16px; border-bottom: 1px solid var(--sidebar-border); }
.brand-logo { width: 40px; height: 40px; background: linear-gradient(135deg, #07c160, #05a650); color: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; box-shadow: 0 4px 12px rgba(7,193,96,.25); }
.brand-text strong { display: block; font-size: 16px; color: var(--text); letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: var(--muted); }
.sidebar-footer { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--sidebar-border); }
.version { font-size: 11px; color: var(--muted); }

/* Sidebar Nav */
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 16px; }
.nav-label { font-size: 11px; color: var(--muted); padding: 0 12px 6px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 0; border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; font-size: 14px; transition: all .15s; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-icon { width: 18px; text-align: center; font-size: 13px; opacity: .85; }

/* Topbar */
.topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; min-height: 64px; }
.page-title { margin: 0; font-size: 20px; font-weight: 600; color: var(--text); }
.page-desc { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; background: var(--bg); border-radius: 24px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.user-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 11px; color: var(--muted); }
.logout-form { margin: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 14px; text-decoration: none; color: var(--text); transition: all .15s; white-space: nowrap; }
.btn:hover { border-color: #d0d5dd; background: #fafbfc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-outline { background: #fff; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: var(--primary-light); color: #0d7a42; border: 1px solid #b7ebd0; }
.alert-error { background: #fff2f0; color: #cf1322; border: 1px solid #ffccc7; }

/* Dashboard */
.welcome-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: linear-gradient(135deg, #07c160 0%, #05a650 100%); color: #fff; border-radius: var(--radius); padding: 24px 28px; margin-bottom: 20px; box-shadow: 0 8px 24px rgba(7,193,96,.2); }
.welcome-banner h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.welcome-banner p { margin: 0; opacity: .9; font-size: 14px; }
.welcome-banner strong { font-weight: 700; }
.quick-actions { display: flex; gap: 8px; flex-shrink: 0; }
.welcome-banner .btn-primary { background: #fff; color: var(--primary); border-color: #fff; }
.welcome-banner .btn-primary:hover { background: #f0fff5; }
.welcome-banner .btn-outline { border-color: rgba(255,255,255,.6); color: #fff; background: transparent; }
.welcome-banner .btn-outline:hover { background: rgba(255,255,255,.15); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.metric-card { background: var(--card); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); transition: box-shadow .15s; }
.metric-card:hover { box-shadow: var(--shadow); }
.metric-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; flex-shrink: 0; }
.metric-green .metric-icon { background: #e8f8ef; color: #07c160; }
.metric-blue .metric-icon { background: #e8f3ff; color: #3370ff; }
.metric-orange .metric-icon { background: #fff3e8; color: #ff8800; }
.metric-purple .metric-icon { background: #f3eeff; color: #7b61ff; }
.metric-value { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--text); }
.metric-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* Panels */
.panel { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-body { padding: 16px 20px; }
.link-more { font-size: 13px; color: var(--primary); text-decoration: none; }
.link-more:hover { text-decoration: underline; }

/* Bar chart rows */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-label { width: 80px; font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: #f0f2f5; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #07c160, #34d399); border-radius: 4px; min-width: 2px; transition: width .3s; }
.bar-fill-orange { background: linear-gradient(90deg, #ff8800, #ffb84d); }
.bar-num { width: 36px; text-align: right; font-size: 13px; font-weight: 600; color: var(--text); flex-shrink: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 12px 20px; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--border); }
.data-table td { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.table-link { color: var(--text); text-decoration: none; font-weight: 500; }
.table-link:hover { color: var(--primary); }
.text-muted { color: var(--muted); }
.empty-cell, .empty-state { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 14px; }

/* Legacy table (inside content) */
table:not(.data-table):not(.info-table) { width: 100%; background: var(--card); border-collapse: collapse; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 16px; }
table:not(.data-table):not(.info-table) th { padding: 12px 16px; background: #fafbfc; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); }
table:not(.data-table):not(.info-table) td { padding: 14px 16px; border-bottom: 1px solid var(--border); }
table:not(.data-table):not(.info-table) tr:hover td { background: #fafbfc; }

/* Cards & forms */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.card h3 { margin: 0 0 16px; font-size: 15px; font-weight: 600; }
.form label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--text-secondary); }
.form input, .form textarea, .form select { display: block; width: 100%; margin-top: 6px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; transition: border-color .15s; background: #fff; }
.form input:focus, .form textarea:focus, .form select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(7,193,96,.12); }
.checkbox input { width: auto; display: inline-block; margin: 0; }

/* Toolbar & filters */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar { margin-bottom: 16px; }
.filter-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filter-form input, .filter-form select { margin-top: 0; }

/* Tags & badges */
.tag-pill { display: inline-block; background: var(--primary-light); color: #0d7a42; padding: 2px 10px; border-radius: 12px; font-size: 12px; margin: 2px 4px 2px 0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-ok { background: var(--primary-light); color: #0d7a42; }
.badge-lost { background: #f5f5f5; color: var(--muted); }

.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.status-sent::before, .status-done::before { background: #07c160; }
.status-sending::before, .status-pending::before, .status-scheduled::before { background: #3370ff; }
.status-failed::before { background: #f54a45; }

/* Customer */
.customer-cell { display: flex; gap: 10px; align-items: center; }
.customer-header { display: flex; gap: 16px; align-items: flex-start; }
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.avatar-lg { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; border: 1px solid var(--border); }
.info-table { width: 100%; box-shadow: none; margin: 0; border: none; }
.info-table th { width: 120px; background: transparent; font-weight: 500; color: var(--muted); border: none; padding: 10px 0; }
.info-table td { border: none; padding: 10px 0; border-bottom: 1px solid #f5f5f5; }
.tag-checkboxes { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.tag-checkboxes .checkbox { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline-form input { margin: 0; width: auto; }
.content-box { white-space: pre-wrap; background: #fafbfc; padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 14px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.muted, .text-muted { color: var(--muted); }
code { background: #f5f6f8; padding: 2px 8px; border-radius: 4px; font-size: 13px; color: #e83e8c; }

.tip-banner { background: #fffbe6; border: 1px solid #ffe58f; color: #ad6800; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; }

/* Mass message compose */
.mass-compose { max-width: 800px; }
.msg-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.msg-type-card { display: flex; align-items: center; justify-content: center; padding: 14px 12px; border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all .15s; background: #fff; }
.msg-type-card input { display: none; }
.msg-type-card.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.msg-type-name { font-size: 14px; }
.msg-panel.hidden { display: none; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 24px; font-size: 14px; }
.detail-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.attachment-preview { display: flex; gap: 14px; padding: 14px; background: #fafbfc; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.attachment-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }

/* Pagination */
nav[role="navigation"] { margin-top: 16px; }
nav[role="navigation"] svg { width: 16px; height: 16px; }

/* Install pages */
.install-body { background: linear-gradient(135deg, #1a2e1a, #07c160); min-height: 100vh; }
.install-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.install-card { background: #fff; border-radius: 16px; padding: 36px; width: 100%; max-width: 480px; box-shadow: 0 16px 48px rgba(0,0,0,.15); }
.install-card h1 { margin: 0 0 8px; font-size: 22px; }
.check-list { list-style: none; padding: 0; margin: 16px 0; }
.check-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.check-list .ok { color: #07c160; }
.check-list .fail { color: #f54a45; }

/* Responsive */
@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .welcome-banner { flex-direction: column; align-items: flex-start; }
    .metric-grid { grid-template-columns: 1fr; }
}
