:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --heading: #0f172a;
    --text: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --sidebar-width: 250px;
    --header-height: 60px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏整体布局 */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
    gap: 10px;
}

/* 侧边栏头部图标容器及svg严格限制尺寸，防止撑开 */
.sidebar-header-icon {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    border-radius: 7px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
    flex-shrink: 0 !important;
    overflow: hidden;
}

.sidebar-header-icon svg,
.sidebar-header svg {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    max-width: 18px !important;
    max-height: 18px !important;
    color: #fff !important;
    display: block !important;
    flex-shrink: 0 !important;
}

.sidebar-section-title {
    padding: 14px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.8px;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 10px;
    flex-grow: 1;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* 侧边栏菜单图标严格限制尺寸 */
.sidebar-menu a svg {
    margin-right: 10px !important;
    width: 17px !important;
    height: 17px !important;
    min-width: 17px !important;
    min-height: 17px !important;
    max-width: 17px !important;
    max-height: 17px !important;
    flex-shrink: 0 !important;
    display: inline-block !important;
    transition: transform 0.2s;
}

.sidebar-menu a:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-menu a:hover svg {
    transform: scale(1.05);
}

.sidebar-menu a.active {
    color: #ffffff;
    background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    font-weight: 600;
}

.sidebar-menu a.active svg {
    color: #ffffff !important;
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.4);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    color: #f87171;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: background 0.2s;
}

.sidebar-footer a:hover {
    background: rgba(239, 68, 68, 0.12);
}

.sidebar-footer a svg {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
    margin-right: 9px !important;
    flex-shrink: 0 !important;
    display: inline-block !important;
}

/* 全局 SVG 防溢出约束 */
svg {
    max-width: 100%;
    vertical-align: middle;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.navbar {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text);
}

.mobile-menu-toggle svg {
    width: 22px !important;
    height: 22px !important;
}

.nav-time-box {
    display: flex;
    align-items: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    color: #334155;
    background: #f8fafc;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.nav-time-box svg {
    margin-right: 8px;
    width: 15px !important;
    height: 15px !important;
    flex-shrink: 0;
    color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    display: inline-block;
    padding: 3px 9px;
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.container-body {
    padding: 24px;
    flex-grow: 1;
}

.card {
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafcff;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--heading);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
}

.card-body {
    padding: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.stat-box {
    background: var(--bg-card);
    padding: 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 22px !important;
    height: 22px !important;
}

.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #ecfdf5; color: #16a34a; }
.stat-icon.orange { background: #fffbeb; color: #d97706; }
.stat-icon.red { background: #fef2f2; color: #dc2626; }

.stat-info h4 {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

.stat-info .num {
    font-size: 21px;
    font-weight: 700;
    color: var(--heading);
    margin-top: 3px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 15px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn svg {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0;
}

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-default { background: #f8fafc; color: #334155; border-color: #cbd5e1; }
.btn-default:hover { background: #f1f5f9; }

.form-group {
    margin-bottom: 15px;
}

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

.form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: #fff;
    color: var(--heading);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.data-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    padding: 11px 15px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.data-table tr:hover {
    background-color: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-secondary { background: #f1f5f9; color: #475569; }

.alert-warning-banner {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #b45309;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.alert-warning-banner svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
}

.flow-step-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 6px 0;
}

.flow-step-item {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 11px;
    font-size: 12px;
    font-weight: 500;
}

.flow-step-item svg {
    width: 13px !important;
    height: 13px !important;
    flex-shrink: 0;
}

.flow-step-item.active {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

.flow-step-item.completed {
    border-color: #16a34a;
    background: #f0fdf4;
    color: #15803d;
}

.flow-step-arrow {
    color: #94a3b8;
    font-weight: bold;
}

.step-builder-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.step-order-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-last-badge {
    background: #16a34a;
}

.modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-content {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 550px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--heading);
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
}

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

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0; bottom: 0; left: -250px;
    }
    .sidebar.open {
        left: 0;
    }
    .mobile-menu-toggle {
        display: block;
    }
    .container-body {
        padding: 14px;
    }
    .navbar {
        padding: 0 16px;
    }
    .nav-time-box {
        display: none;
    }
}
