* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #FF8C00;
    --primary-dark: #E67A00;
    --primary-light: #FFF0E0;
    --primary-bg: #FFF8F0;
    --danger: #DC3545;
    --success: #28A745;
    --info: #17A2B8;
    --text: #333;
    --text-light: #666;
    --text-lighter: #999;
    --border: #E8E8E8;
    --bg: #F5F5F5;
    --white: #FFF;
    --shadow: 0 2px 12px rgba(255, 140, 0, 0.1);
    --radius: 8px;
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: linear-gradient(180deg, #FF8C00 0%, #E67A00 100%);
    color: #fff;
    flex-shrink: 0;
    padding-top: 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s ease;
    z-index: 10;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-logo h1,
.sidebar.collapsed .sidebar-logo p,
.sidebar.collapsed .nav-item span:not(.icon) { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 14px 0; }
.sidebar.collapsed .nav-item .icon { margin: 0; }
.sidebar-toggle {
    display: flex;
    justify-content: flex-end;
    padding: 0 16px 12px;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.sidebar-toggle:hover { opacity: 1; }
.sidebar.collapsed .sidebar-toggle { justify-content: center; padding: 0 0 12px; }
.sidebar-logo { text-align: center; padding: 0 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.2); margin-bottom: 8px; }
.sidebar-logo h1 { font-size: 20px; font-weight: 700; white-space: nowrap; }
.sidebar-logo p { font-size: 12px; opacity: 0.8; margin-top: 4px; white-space: nowrap; }
.sidebar-nav { padding: 8px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 14px 24px; cursor: pointer; transition: all 0.2s; font-size: 15px; white-space: nowrap; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.15); }
.nav-item .icon { width: 20px; text-align: center; font-size: 18px; flex-shrink: 0; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.header { background: var(--white); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 9; }
.header-title { font-size: 18px; font-weight: 600; }
.header-user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-light); }
.header-user .header-user-info { display: flex; flex-direction: column; align-items: center; line-height: 1.3; }
.header-user .user-icon { font-size: 22px; }
.header-user .phone-display { font-size: 12px; font-weight: 600; color: var(--primary); }
.header-user .btn-sm { padding: 6px 16px; }
.content { flex: 1; padding: 24px; overflow-y: auto; }

/* ===== Auth Page ===== */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #FFF0E0 0%, #FFE4C4 100%); }
.auth-card { background: var(--white); border-radius: 16px; box-shadow: 0 8px 40px rgba(255,140,0,0.15); padding: 48px 40px; width: 420px; }
.auth-card h2 { text-align: center; color: var(--primary); font-size: 28px; margin-bottom: 8px; }
.auth-card .subtitle { text-align: center; color: var(--text-light); font-size: 14px; margin-bottom: 32px; }
.auth-tabs { display: flex; margin-bottom: 28px; border-bottom: 2px solid var(--border); }
.auth-tab { flex: 1; text-align: center; padding: 10px; cursor: pointer; font-size: 15px; color: var(--text-light); transition: all 0.2s; }
.auth-tab.active { color: var(--primary); border-bottom: 2px solid var(--primary); margin-bottom: -2px; font-weight: 600; }
.auth-form { display: none; }
.auth-form.active { display: block; }

/* ===== Form ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 14px; margin-bottom: 6px; color: var(--text); font-weight: 500; }
.form-control { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; transition: border 0.2s; outline: none; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,140,0,0.1); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ===== Button ===== */
.btn { padding: 10px 24px; border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #C82333; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-success { background: var(--success); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 32px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Toolbar ===== */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; position: sticky; top: 0; z-index: 8; background: var(--bg); padding: 12px 0; }
.toolbar .search-box { position: relative; flex: 1; max-width: 360px; }
.toolbar .search-box input { width: 100%; padding: 9px 14px 9px 38px; border: 1px solid var(--border); border-radius: 20px; font-size: 14px; outline: none; }
.toolbar .search-box input:focus { border-color: var(--primary); }
.toolbar .search-box .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-lighter); }
.toolbar .tag-filter select { padding: 9px 14px; border: 1px solid var(--border); border-radius: 20px; font-size: 14px; outline: none; cursor: pointer; }

/* ===== Card ===== */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== Table ===== */
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table th, table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table th { background: var(--primary-bg); color: var(--primary-dark); font-weight: 600; position: sticky; top: 0; z-index: 1; }
table tr:hover { background: #FFF8F0; }
table .actions { display: flex; gap: 6px; }
table .tag-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; color: #fff; margin: 1px 2px; }
table a.customer-name { color: var(--primary); text-decoration: none; font-weight: 500; cursor: pointer; }
table a.customer-name:hover { text-decoration: underline; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 20px; }
.pagination button { padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); cursor: pointer; font-size: 13px; }
.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination .page-info { font-size: 13px; color: var(--text-light); margin-left: 8px; }
.pagination .page-jump { font-size: 13px; color: var(--text-light); display: flex; align-items: center; gap: 4px; margin-left: 12px; }
.pagination .page-jump input { outline: none; }
.pagination .page-jump input:focus { border-color: var(--primary) !important; box-shadow: 0 0 0 2px rgba(255,140,0,0.1); }

/* ===== Modal ===== */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--white); border-radius: 12px; width: 90%; max-width: 800px; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-lg { max-width: 1000px; }
.modal-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-lighter); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Detail page ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-grid .full-width { grid-column: 1 / -1; }
.detail-item label { display: block; font-size: 13px; color: var(--text-light); margin-bottom: 4px; }
.detail-item .value { font-size: 15px; }
.tags-display { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); text-align: center; }
.stat-card .stat-num { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 14px; color: var(--text-light); margin-top: 4px; }

/* ===== Chart ===== */
.chart-container { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.chart-container h3 { margin-bottom: 16px; font-size: 16px; }
.chart-row { display: flex; gap: 16px; flex-wrap: wrap; }
.chart-bar-wrap { flex: 1; min-width: 300px; }
.bar-item { display: flex; align-items: center; margin-bottom: 10px; font-size: 13px; }
.bar-label { width: 120px; text-align: right; padding-right: 12px; color: var(--text-light); flex-shrink: 0; }
.bar-track { flex: 1; height: 24px; background: var(--bg); border-radius: 12px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #FFB347, #FF8C00); border-radius: 12px; transition: width 0.5s; }
.bar-count { width: 60px; text-align: right; padding-left: 8px; font-weight: 600; flex-shrink: 0; }

/* ===== Tag manager ===== */
.tag-list { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 20px; color: #fff; font-size: 13px; }
.tag-chip .tag-delete { cursor: pointer; opacity: 0.7; font-size: 16px; }
.tag-chip .tag-delete:hover { opacity: 1; }

/* ===== Follow-ups ===== */
.followup-list { max-height: 400px; overflow-y: auto; }
.followup-item { padding: 14px; border-bottom: 1px solid var(--border); }
.followup-item:last-child { border: none; }
.followup-time { font-size: 12px; color: var(--text-lighter); margin-bottom: 6px; }
.followup-content { font-size: 14px; line-height: 1.6; }
.followup-actions { margin-top: 8px; display: flex; gap: 8px; }

/* ===== Toast ===== */
.toast { position: fixed; top: 20px; right: 20px; z-index: 9999; padding: 12px 24px; border-radius: var(--radius); color: #fff; font-size: 14px; animation: slideIn 0.3s ease; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar-logo h1, .sidebar-logo p, .nav-item span:not(.icon) { display: none; }
    .nav-item { justify-content: center; padding: 14px 0; }
    .sidebar-toggle { display: none; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== Role badge ===== */
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.role-badge.role-admin { background: rgba(255,140,0,.15); color: var(--primary-dark); }
.role-badge.role-user { background: var(--bg); color: var(--text-light); }

/* ===== Auth hint ===== */
.auth-hint { font-size: 12px; color: var(--text-light); text-align: center; margin-top: 4px; line-height: 1.5; }

/* ===== Mini table (admin panels) ===== */
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th, .mini-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mini-table th { background: var(--primary-bg); color: var(--primary-dark); font-weight: 600; }
.mini-table tr:hover { background: var(--primary-bg); }
.mini-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== Whitelist list ===== */
.whitelist-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ===== 版本页脚 ===== */
.app-footer { text-align: center; padding: 14px 10px; font-size: 12px; color: var(--text-lighter); border-top: 1px solid var(--border); background: var(--white); }
.footer-icp { margin-left: 12px; }
.footer-icp a { color: var(--text-lighter); text-decoration: none; }
.footer-icp a:hover { color: var(--primary); text-decoration: underline; }

/* ===== 侧边栏二级菜单 ===== */
.nav-arrow { margin-left: auto; font-size: 11px; opacity: 0.8; transition: transform 0.2s; }
.nav-group.open .nav-arrow { transform: rotate(180deg); }
.nav-sub { display: none; }
.nav-group.open .nav-sub { display: block; }
.nav-sub-item { padding-left: 46px; font-size: 14px; }
.nav-sub-item.active { background: rgba(255,255,255,0.22); }
.sidebar.collapsed .nav-sub { display: none !important; }
.sidebar.collapsed .nav-arrow { display: none; }
@media (max-width: 768px) {
    .nav-sub { display: none !important; }
    .nav-arrow { display: none; }
}
