/* ===== 全局基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --text-1: #1f2937;
    --text-2: #4b5563;
    --text-3: #9ca3af;
    --border: #e5e7eb;
    --bg-1: #ffffff;
    --bg-2: #f9fafb;
    --bg-3: #f3f4f6;
    --sidebar-bg: #1e1e2d;
    --sidebar-hover: #27293d;
    --shadow: 0 1px 2px 0 rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-1);
    background: var(--bg-3);
    overflow: hidden;
}

/* ===== 布局容器 ===== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-3);
}

/* ===== 顶部导航栏 ===== */
.top-navbar {
    height: 56px;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    z-index: 100;
    box-shadow: var(--shadow);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 0 0 auto;
}

.navbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-2);
    color: var(--text-1);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-2);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.breadcrumb-item.active {
    color: var(--text-1);
    font-weight: 500;
}

.breadcrumb-sep {
    color: var(--text-3);
}

.notice-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 6px;
    font-size: 13px;
}

.notice-text {
    color: #d97706;
    font-weight: 500;
    transition: opacity 0.3s;
}

.notice-more {
    background: none;
    border: none;
    color: #d97706;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.notice-more:hover {
    background: rgba(217, 119, 6, 0.1);
}

.theme-toggle {
    width: 48px !important;
    padding: 4px;
}

.toggle-track {
    width: 40px;
    height: 20px;
    background: #d1d5db;
    border-radius: 10px;
    position: relative;
    transition: background 0.3s;
    cursor: pointer;
}

.toggle-thumb {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.theme-toggle:hover .toggle-track {
    background: #9ca3af;
}

.user-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.user-dropdown:hover {
    background: var(--bg-2);
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-1);
}

.dropdown-arrow {
    font-size: 10px;
    color: var(--text-3);
}

.dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    display: none;
    overflow: hidden;
    z-index: 200;
}

.user-dropdown:hover .dropdown-panel {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background: var(--bg-2);
    color: var(--text-1);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
}

.sidebar.collapsed {
    width: 64px;
}

.sidebar-logo {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-text {
    font-size: 24px;
    font-weight: 700;
    color: white;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.menu-item {
    display: block;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
    user-select: none;
}

.menu-item:hover {
    background: var(--sidebar-hover);
    color: white;
}

.menu-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.menu-item-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.menu-label {
    flex: 1;
}

.menu-arrow {
    font-size: 12px;
    transition: transform 0.3s;
}

.menu-item.expanded .menu-arrow {
    transform: rotate(90deg);
}

.submenu {
    display: none;
    background: rgba(0, 0, 0, 0.2);
}

.submenu.show {
    display: block;
}

.submenu-item {
    display: block;
    padding: 10px 20px 10px 52px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
    cursor: pointer;
}

.submenu-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.submenu-item.active {
    color: var(--primary);
    font-weight: 500;
}

/* ===== 标签页 ===== */
.tabs-bar {
    height: 40px;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
}

.tab-scroll-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tab-scroll-btn:hover {
    background: var(--bg-2);
    color: var(--text-1);
}

.tabs-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tab-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-2);
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    user-select: none;
}

.tab-item:hover {
    background: var(--bg-3);
}

.tab-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tab-close {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.2s;
}

.tab-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.tab-item.active .tab-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tab-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tab-action-btn:hover {
    background: var(--bg-2);
    color: var(--text-1);
}

/* ===== 内容卡片 ===== */
.content-card {
    background: var(--bg-1);
    border-radius: 8px;
    padding: 20px;
    margin: 20px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-1);
}

/* ===== 工具栏 ===== */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== 按钮 ===== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: #2563eb;
}

.btn-default {
    background: var(--bg-2);
    color: var(--text-2);
    border: 1px solid var(--border);
}

.btn-default:hover {
    background: var(--bg-3);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

/* ===== 表格 ===== */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.data-table thead {
    background: var(--bg-2);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-1);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
    background: var(--bg-2);
}

/* ===== 标签 ===== */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.tag-success { background: #d1fae5; color: #059669; }
.tag-warning { background: #fef3c7; color: #d97706; }
.tag-danger { background: #fee2e2; color: #dc2626; }
.tag-info { background: #dbeafe; color: #2563eb; }
.tag-default { background: var(--bg-2); color: var(--text-2); }

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-2);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== 卡片网格 ===== */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px;
}

.channel-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s;
}

.channel-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.channel-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-1);
}

.channel-info {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 8px;
}

.channel-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* ===== 模态框 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-dialog {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    border-radius: 4px;
    font-size: 20px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-2);
    color: var(--text-1);
}

.modal-body {
    padding: 20px;
    max-height: calc(90vh - 120px);
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===== 表单 ===== */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-item {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -240px;
        height: 100%;
        z-index: 99;
    }

    .sidebar.show {
        left: 0;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .channel-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== 账号列表（账号管理） ===== */
.account-list-card { padding: 16px; }

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px 16px;
    padding: 14px;
    background: var(--bg-2);
    border-radius: 6px;
    margin-bottom: 12px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-item label {
    flex: 0 0 64px;
    font-size: 13px;
    color: var(--text-2);
    text-align: right;
}

.filter-item .form-input,
.filter-item .form-select {
    flex: 1;
    height: 32px;
    padding: 4px 10px;
    font-size: 13px;
}

.filter-item.filter-actions {
    justify-content: flex-end;
    gap: 8px;
}

.filter-item.filter-actions .btn { padding: 6px 18px; }

.account-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 0;
    border-top: 1px dashed var(--border);
}

.toolbar-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
}

.account-table {
    font-size: 12px;
    min-width: 2400px;
}

.account-table th,
.account-table td {
    padding: 8px 10px;
    white-space: nowrap;
}

.account-table .col-check { width: 36px; }
.account-table .col-action { min-width: 220px; }

.account-table .cell-link {
    color: var(--info);
    cursor: pointer;
    text-decoration: underline;
}

.account-table .row-total td {
    background: #fffbeb;
    color: #d97706;
}

/* 自动开启开关 */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.switch::before {
    content: '';
    width: 30px;
    height: 16px;
    background: #d1d5db;
    border-radius: 9px;
    position: relative;
    transition: background 0.2s;
}

.switch.on::before { background: var(--success); }

.switch .switch-thumb {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    position: absolute;
    transform: translateX(2px);
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    margin-left: -28px;
}

.switch.on .switch-thumb { transform: translateX(16px); }

.switch .switch-text {
    font-size: 12px;
    color: var(--text-2);
}

.account-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
    padding: 12px 0 0;
}

@media (max-width: 1280px) {
    .filter-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 960px) {
    .filter-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 多用户列表 筛选条 */
.sub-user-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding: 14px;
    background: var(--bg-2);
    border-radius: 6px;
    margin-bottom: 12px;
}

.sub-user-filter .filter-item {
    flex: 0 0 auto;
    min-width: 240px;
}

.sub-user-filter .filter-item.filter-actions {
    margin-left: auto;
}

/* 添加/编辑用户表单 */
.su-form { padding: 8px 0; }

.su-form-item {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.su-form-item:last-child { margin-bottom: 0; }

.su-form-item .su-label {
    flex: 0 0 96px;
    text-align: right;
    font-size: 14px;
    color: var(--text-1);
    position: relative;
}

.su-form-item .su-required {
    color: var(--danger);
    margin-right: 4px;
}

.su-form-item .form-input,
.su-form-item .form-select {
    flex: 1;
    height: 38px;
    padding: 6px 12px;
    font-size: 14px;
}

/* ===== 订单列表 ===== */
.order-list-card { padding: 16px; }

.order-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 20px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-1);
}

.stat-card .stat-blue { color: var(--info); }

.order-filter {
    background: var(--bg-2);
    border-radius: 6px;
    padding: 14px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}

.of-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.of-item label {
    font-size: 13px;
    color: var(--text-2);
    white-space: nowrap;
}

.of-item .form-input,
.of-item .form-select {
    height: 32px;
    padding: 4px 10px;
    font-size: 13px;
    width: 160px;
}

.of-item.of-time .form-input { width: 180px; }
.of-item.of-time .of-sep { color: var(--text-3); font-size: 13px; }
.of-item.of-channel .form-select { width: 180px; }
.of-item.of-actions { margin-left: auto; gap: 8px; }
.of-item.of-actions .btn { padding: 6px 14px; }

.order-table-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px dashed var(--border);
}

.icon-btn-sm {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-2);
}

.icon-btn-sm:hover { color: var(--primary); border-color: var(--primary); }

@media (max-width: 1280px) {
    .order-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
